コード例 #1
0
    public void GamebaseInitialize()
    {
        Gamebase.Initialize((launchingInfo, error) =>
        {
            if (Gamebase.IsSuccess(error) == true)
            {
                Debug.Log("Initialization succeeded.");

                var serverInfo = launchingInfo.launching.app.accessInfo.serverAddress;
                if (serverInfo != null)
                {
                    var serverData = serverInfo.Split(':');
                    GamebaseInfo.Instance.GameServerIp   = serverData[0];
                    GamebaseInfo.Instance.GameServerPort = serverData[1];

                    GamebaseInfo.Instance.SetGamebaseInfo(string.Format("GameServerIP:{0}, GameServerPort:{1}", GamebaseInfo.Instance.GameServerIp, GamebaseInfo.Instance.GameServerPort));
                }

                GamebaseLogin();

                //Following notices are registered in the Gamebase Console
                var notice = launchingInfo.launching.notice;
                if (notice != null)
                {
                    if (string.IsNullOrEmpty(notice.message) == false)
                    {
                        Debug.Log(string.Format("title:{0}", notice.title));
                        Debug.Log(string.Format("message:{0}", notice.message));
                        Debug.Log(string.Format("url:{0}", notice.url));
                    }
                }

                //Status information of game app version set in the Gamebase Unity SDK initialization.
                var status = launchingInfo.launching.status;

                // Game status code (e.g. Under maintenance, Update is required, Service has been terminated)
                // refer to GamebaseLaunchingStatus
                if (status.code == GamebaseLaunchingStatus.IN_SERVICE)
                {
                    // Service is now normally provided.
                }
                else
                {
                    switch (status.code)
                    {
                    case GamebaseLaunchingStatus.RECOMMEND_UPDATE:
                        {
                            // Update is recommended.
                            break;
                        }

                    // ...
                    case GamebaseLaunchingStatus.INTERNAL_SERVER_ERROR:
                        {
                            // Error in internal server.
                            break;
                        }
                    }
                }
            }
            else
            {
                // Check the error code and handle the error appropriately.
                Debug.Log(string.Format("Initialization failed. error is {0}", error));
            }
        });
    }