예제 #1
0
        /// <summary>
        /// Called when sign in finishes.
        /// </summary>
        /// <param name="wasInteractive">If true, this was the interactive (browser-based) sign-in flow.</param>
        /// <param name="status">The result of the sign in process.</param>
        private void OnSignInFinished(bool wasInteractive, PolyStatus status)
        {
            if (status.ok)
            {
                string tok = PolyApi.AccessToken;
                PtDebug.LogFormat("ABM: Sign in success. Access token: {0}",
                                  (tok != null && tok.Length > 6) ? tok.Substring(0, 6) + "..." : "INVALID");
                PtAnalytics.SendEvent(PtAnalytics.Action.ACCOUNT_SIGN_IN_SUCCESS);
            }
            else if (wasInteractive)
            {
                Debug.LogErrorFormat("Failed to sign in. Please try again: " + status);
                PtAnalytics.SendEvent(PtAnalytics.Action.ACCOUNT_SIGN_IN_FAILURE, status.ToString());
            }
            if (null != refreshCallback)
            {
                refreshCallback();
            }

            // If we had a deferred request that was waiting for auth, send it now.
            if (requestToSendAfterAuth != null)
            {
                PtDebug.Log("Sending deferred request that was waiting for auth.");
                PolyRequest request = requestToSendAfterAuth;
                requestToSendAfterAuth = null;
                StartRequest(request);
            }
        }
예제 #2
0
    /// <summary>
    /// Called when thumbnail is fetched
    /// </summary>
    /// <param name="asset">the asset of which thumbnail fetch was requested</param>
    /// <param name="status">status of the fetch request</param>
    private void FetchThumbnailCallback(PolyAsset asset, PolyStatus status)
    {
        if (!status.ok)
        {
            Toaster.showToast("Error fetching thumbnail : " + status.ToString(), 2);
            return;
        }

        Texture2D  texture         = asset.thumbnailTexture;                                                                                            // store thumbnail texture
        GameObject thumbnailObject = new GameObject("thumbnail");                                                                                       // instantiate gameobject to store thumbnail

        thumbnailObject.transform.SetParent(assetsPanel);                                                                                               // make the gameobject children to assetpanel
        thumbnailObject.AddComponent <Image>().sprite            = Sprite.Create(texture, new Rect(0, 0, texture.width, texture.height), Vector2.zero); // add texture as sprite
        thumbnailObject.GetComponent <RectTransform>().sizeDelta = new Vector2(texture.width, texture.height);                                          // resize the object
        thumbnailObject.AddComponent <Button>().onClick.AddListener(() => OnAssetThumbnailClicked(asset));                                              // add button to the object and add listener
    }