文档

支持

Get started

This section explains how to start using Unity Cloud Python SDK.
阅读时间1 分钟最后更新于 10 个月前

Before you begin, verify you meet the prerequisites.

Install the Python SDK package

To install Python SDK, follow these steps:
  • Run the following command:
    pip install --index-url https://unity3ddist.jfrog.io/artifactory/api/pypi/am-pypi-prod-local/simple unity-cloud
  • If it's not the first time you're installing the Python SDK, add the
    --force-reinstall
    argument in the command as follows:
    pip install --index-url https://unity3ddist.jfrog.io/artifactory/api/pypi/am-pypi-prod-local/simple unity-cloud --force-reinstall
    .
注意
Some IDEs use virtual environments by default. The recommended best practice is to run the command inside your IDE in your project to ensure that your project has the latest version.

Use the Python SDK

To use the SDK, first call
initialize()
. Here is an example of the typical initialize process:
def initialize():unity_cloud.initialize()unity_cloud.identity.user_login.use()# Check whether the user is signed inauth_state = unity_cloud.identity.user_login.get_authentication_state()if auth_state != unity_cloud.identity.user_login.Authentication_State.LOGGED_IN: unity_cloud.identity.user_login.login()
注意
You need to initialize only once.
However, if you need to run an initialization again, you must uninitialize before that. Here is an example of the typical uninitialize process:
def uninitialize():unity_cloud.uninitialize()
Read more about the Identity module and managing authentication.