Пример #1
0
 public void OnIsInviteLoadingButtonClicked()
 {
     Debug.Log(string.Format("Is invite loading: {0}", PartyKit.IsInviteLoading()));
 }
Пример #2
0
        void Start()
        {
            if (!TrailConfig.InitializeSDKAtStartup && alwaysInitializeSDKAtStartup)
            {
                Debug.LogWarning("[TrailSDK] - Automatic Initialization is <color=red>disabled</color>, will manually call SDK.Init();");
                SDK.Init();
            }

            SDK.OnInitialized += (Trail.Result result) =>
            {
                if (result != Trail.Result.Ok)
                {
                    Debug.LogErrorFormat("Trail SDK init failed: {0}", result.ToString());
                    return;
                }

                Debug.LogFormat("Trail SDK init succeeded");
                if (!TrailConfig.InitializeSDKAtStartup)
                {
                    var finishGameLoadTaskResult = SDK.FinishGameLoadTask();
                    if (finishGameLoadTaskResult != Trail.Result.Ok)
                    {
                        Debug.LogErrorFormat("Failed to finish game load task: {0}", finishGameLoadTaskResult);
                    }
                }

                this.GameUserID.text = string.Format("Game user ID: {0}", AuthKit.GetGameUserID());
                this.PlayToken.text  = string.Format("Play token: {0}", AuthKit.GetPlayToken());
                SDK.OnFocusChanged  += (this.OnGameActiveStatusChanged);
                this.OnGameActiveStatusChanged(SDK.IsGameFocused);

                PerformanceKit.OnDisplayResolutionChanged += OnBrowserResolutionChanged;
                OnBrowserResolutionChanged(Trail.Resolution.Zero);

                Debug.Log(string.Format("Is loading invite: {0}", PartyKit.IsInviteLoading()));
                var partyData = PartyKit.GetPartyData();
                for (int i = 0; i < partyData.Count; i++)
                {
                    var field = partyData[i];
                    Debug.Log(string.Format("Party data: {0}  -  Key: {1} - Value: {2}", i, field.Key, field.Value));
                }

                PartyKit.OnPartyDataUpdated += OnPartyDataUpdated;

                SDK.StartupArg[] args;
                SDK.GetStartupArgs(out args);

                for (int i = 0; i < args.Length; ++i)
                {
                    var arg = args[i];
                    Debug.Log(string.Format("Startup Arg #{0}: Name: \"{1}\", Length {2}",
                                            i, arg.Name, arg.Value.Length));
                }

                string cloudStoragePath;
                FileKit.GetCloudStoragePath(out cloudStoragePath);
                Debug.Log("Cloud storage path: " + cloudStoragePath);

                AuthKit.GetFingerprint((res, fingerprint) => {
                    if (res.IsOk())
                    {
                        Debug.Log("Fingerprint: " + fingerprint);
                    }
                    else
                    {
                        Debug.LogErrorFormat("Failed to get fingerprint: {0}",
                                             res.ToString());
                    }
                });

#if !UNITY_EDITOR && UNITY_WEBGL
                var path = FileKit.GetCloudStoragePathFormatted("example.txt");
                if (System.IO.File.Exists(path))
                {
                    inputField.text = System.IO.File.ReadAllText(path);
                }
#endif
            };

            UnityEngine.Object.DontDestroyOnLoad(this.gameObject);
        }