void OnEnable()
        {
            if (window == null)
            {
                window         = this;
                window.minSize = new Vector2(320, 0);
            }

            if (!IsEventHandlerRegistered(StateUpdateHandler))
            {
                EdExStateUpdate += StateUpdateHandler;
            }

            PlayFabEditorPrefsSO.Instance.PanelIsShown = true;
            PlayFabEditorDataService.RefreshStudiosList(true);
            GetLatestEdExVersion();

            root = rootVisualElement;
            root.Clear();

            root.AddChildrenOf(new Header());
            root.Add(new IMGUIContainer().AssignTo(out var progressBar));
            progressBar.onGUIHandler = ProgressBar.Draw;
            root.Add(new Menu().AssignTo(out menu));
            root.Add(new IMGUIContainer().Set(name: "mainIMGUI", flexGrow: 1).AssignTo(out mainIMGUI));
            rootVisualElement.styleSheets.Add(AssetDatabase.LoadAssetAtPath <StyleSheet>(Path.Combine(Strings.PATH_UI, "styles.uss")));
            //var template = AssetDatabase.LoadAssetAtPath<VisualTreeAsset>(Path.Combine(Strings.PATH_UI, "mainView.uxml"));
            //StylePropertyReader tree = new TemplateContainer();
            //template.CloneTree(root);


            Update();
        }
Example #2
0
 public SubMenuComponent()
 {
     if (!PlayFabEditor.IsEventHandlerRegistered(StateUpdateHandler))
     {
         PlayFabEditor.EdExStateUpdate += StateUpdateHandler;
     }
 }
Example #3
0
        private static void OnWwwSuccess <TResultType>(string api, Action <TResultType> resultCallback, Action <PlayFab.PfEditor.EditorModels.PlayFabError> errorCallback, string response) where TResultType : class
        {
            var httpResult = JsonWrapper.DeserializeObject <HttpResponseObject>(response, PlayFabEditorUtil.ApiSerializerStrategy);

            if (httpResult.code != 200)
            {
                OnWwwError(errorCallback, response);
                return;
            }

            PlayFabEditor.RaiseStateUpdate(PlayFabEditor.EdExStates.OnHttpRes, api);
            if (resultCallback == null)
            {
                return;
            }

            TResultType result         = null;
            var         resultAssigned = false;

            var dataJson = JsonWrapper.SerializeObject(httpResult.data, PlayFabEditorUtil.ApiSerializerStrategy);

            result         = JsonWrapper.DeserializeObject <TResultType>(dataJson, PlayFabEditorUtil.ApiSerializerStrategy);
            resultAssigned = true;

            if (resultAssigned)
            {
                resultCallback(result);
            }
        }
Example #4
0
        private static void WriteResultFile(string url, Action <string> resultCallback, byte[] response)
        {
            PlayFabEditor.RaiseStateUpdate(PlayFabEditor.EdExStates.OnHttpRes, url);

            string fileName;

            if (url.IndexOf("unity-edex") > -1)
            {
                fileName = PlayFabEditorHelper.EDEX_UPGRADE_PATH;
            }
            else if (url.IndexOf("unity-via-edex") > -1)
            {
                fileName = PlayFabEditorHelper.SDK_DOWNLOAD_PATH;
            }
            else
            {
                fileName = PlayFabEditorHelper.EDEX_PACKAGES_PATH;
            }

            var fileSaveLocation  = PlayFabEditorHelper.EDEX_ROOT + fileName;
            var fileSaveDirectory = Path.GetDirectoryName(fileSaveLocation);

            Debug.Log("Saving " + response.Length + " bytes to: " + fileSaveLocation);
            if (!Directory.Exists(fileSaveDirectory))
            {
                Directory.CreateDirectory(fileSaveDirectory);
            }
            File.WriteAllBytes(fileSaveLocation, response);
            resultCallback(fileSaveLocation);
        }
Example #5
0
 public void OnDestroy()
 {
     if (PlayFabEditor.IsEventHandlerRegistered(StateUpdateHandler))
     {
         PlayFabEditor.EdExStateUpdate -= StateUpdateHandler;
     }
 }
Example #6
0
        internal static void MakeApiCall <TRequestType, TResultType>(string api, string apiEndpoint, TRequestType request, Action <TResultType> resultCallback, Action <EditorModels.PlayFabError> errorCallback) where TResultType : class
        {
            var url = apiEndpoint + api;
            var req = JsonWrapper.SerializeObject(request, PlayFabEditorUtil.ApiSerializerStrategy);
            //Set headers
            var headers = new Dictionary <string, string>
            {
                { "Content-Type", "application/json" },
                { "X-ReportErrorAsSuccess", "true" },
                { "X-PlayFabSDK", PlayFabEditorHelper.EDEX_NAME + "_" + PlayFabEditorHelper.EDEX_VERSION }
            };

            if (api.Contains("/Server/") || api.Contains("/Admin/"))
            {
                if (PlayFabEditorDataService.ActiveTitle == null || string.IsNullOrEmpty(PlayFabEditorDataService.ActiveTitle.SecretKey))
                {
                    PlayFabEditor.RaiseStateUpdate(PlayFabEditor.EdExStates.OnError, "Must have PlayFabSettings.DeveloperSecretKey set to call this method");
                    return;
                }

                headers.Add("X-SecretKey", PlayFabEditorDataService.ActiveTitle.SecretKey);
            }

            //Encode Payload
            var payload = System.Text.Encoding.UTF8.GetBytes(req.Trim());
            var www     = new WWW(url, payload, headers);

            PlayFabEditor.RaiseStateUpdate(PlayFabEditor.EdExStates.OnHttpReq, api, PlayFabEditorHelper.MSG_SPIN_BLOCK);

            EditorCoroutine.Start(Post(www, (response) => { OnWwwSuccess(api, resultCallback, errorCallback, response); }, (error) => { OnWwwError(errorCallback, error); }), www);
        }
Example #7
0
 static PlayFabEditorDataMenu()
 {
     if (!PlayFabEditor.IsEventHandlerRegistered(StateUpdateHandler))
     {
         PlayFabEditor.EdExStateUpdate += StateUpdateHandler;
     }
 }
Example #8
0
        internal static void MakeDownloadCall(string url, Action <string> resultCallback)
        {
            var www = new WWW(url);

            PlayFabEditor.RaiseStateUpdate(PlayFabEditor.EdExStates.OnHttpReq, url, PlayFabEditorHelper.MSG_SPIN_BLOCK);
            EditorCoroutine.Start(PostDownload(www, (response) => { WriteResultFile(url, resultCallback, response); }, PlayFabEditorHelper.SharedErrorCallback), www);
        }
Example #9
0
 private static void OnLoginButtonClicked()
 {
     PlayFabEditorApi.Login(new LoginRequest()
     {
         DeveloperToolProductName    = PlayFabEditorHelper.EDEX_NAME,
         DeveloperToolProductVersion = PlayFabEditorHelper.EDEX_VERSION,
         Email    = _userEmail,
         Password = _userPass
     }, (result) =>
     {
         PlayFabEditorPrefsSO.Instance.DevAccountToken = result.DeveloperClientToken;
         PlayFabEditorPrefsSO.Instance.DevAccountEmail = _userEmail;
         PlayFabEditorDataService.RefreshStudiosList();
         PlayFabEditor.RaiseStateUpdate(PlayFabEditor.EdExStates.OnLogin);
         PlayFabEditorPrefsSO.Save();
         PlayFabEditorMenu._menuState = PlayFabEditorMenu.MenuStates.Sdks;
     }, (error) =>
     {
         if ((int)error.Error == 1246 || error.ErrorMessage.Contains("TwoFactor"))
         {
             // pop 2FA dialog
             PlayFabEditor.RaiseStateUpdate(PlayFabEditor.EdExStates.OnWarning, "This account requires 2-Factor Authentication.");
             activeState = PanelDisplayStates.TwoFactorPrompt;
         }
         else
         {
             PlayFabEditorHelper.SharedErrorCallback(error);
         }
     });
 }
Example #10
0
        private static void OnRegisterClicked()
        {
            if (_userPass != _userPass2)
            {
                Debug.LogError("PlayFab developer account passwords must match.");
                return;
            }

            PlayFabEditorApi.RegisterAccount(new RegisterAccountRequest()
            {
                DeveloperToolProductName    = PlayFabEditorHelper.EDEX_NAME,
                DeveloperToolProductVersion = PlayFabEditorHelper.EDEX_VERSION,
                Email      = _userEmail,
                Password   = _userPass,
                StudioName = _studio
            }, (result) =>
            {
                PlayFabEditorPrefsSO.Instance.DevAccountToken = result.DeveloperClientToken;
                PlayFabEditorPrefsSO.Instance.DevAccountEmail = _userEmail;

                PlayFabEditorDataService.RefreshStudiosList();

                PlayFabEditor.RaiseStateUpdate(PlayFabEditor.EdExStates.OnLogin);
                PlayFabEditorMenu._menuState = PlayFabEditorMenu.MenuStates.Sdks;
                PlayFabEditorPrefsSO.Save();
            }, PlayFabEditorHelper.SharedErrorCallback);
        }
        private static void BeginCloudScriptUpload()
        {
            var filePath = File.Exists(PlayFabEditorDataService.EnvDetails.localCloudScriptPath) ? PlayFabEditorDataService.EnvDetails.localCloudScriptPath : PlayFabEditorHelper.CLOUDSCRIPT_PATH;

            if (!File.Exists(PlayFabEditorDataService.EnvDetails.localCloudScriptPath) && !File.Exists(PlayFabEditorHelper.CLOUDSCRIPT_PATH))
            {
                PlayFabEditor.RaiseStateUpdate(PlayFabEditor.EdExStates.OnError, "Cloud Script Upload Failed: null or corrupt file at path(" + filePath + ").");
                return;
            }

            var s        = File.OpenText(filePath);
            var contents = s.ReadToEnd();

            s.Close();

            var request = new UpdateCloudScriptRequest();

            request.Publish = EditorUtility.DisplayDialog("Deployment Options", "Do you want to make this Cloud Script live after uploading?", "Yes", "No");
            request.Files   = new List <CloudScriptFile>()
            {
                new CloudScriptFile()
                {
                    Filename     = PlayFabEditorHelper.CLOUDSCRIPT_FILENAME,
                    FileContents = contents
                }
            };

            PlayFabEditorApi.UpdateCloudScript(request, (UpdateCloudScriptResult result) =>
            {
                PlayFabEditorDataService.EnvDetails.localCloudScriptPath = filePath;
                PlayFabEditorDataService.SaveEnvDetails();

                Debug.Log("CloudScript uploaded successfully!");
            }, PlayFabEditorHelper.SharedErrorCallback);
        }
Example #12
0
        internal static void MakeApiCall <TRequestType, TResultType>(string api, string apiEndpoint, TRequestType request, Action <TResultType> resultCallback, Action <EditorModels.PlayFabError> errorCallback) where TResultType : class
        {
            var url = apiEndpoint + api;
            var req = JsonWrapper.SerializeObject(request, PlayFabEditorUtil.ApiSerializerStrategy);
            //Set headers
            var headers = new Dictionary <string, string>
            {
                { "Content-Type", "application/json" },
                { "X-ReportErrorAsSuccess", "true" },
                { "X-PlayFabSDK", PlayFabEditorHelper.EDEX_NAME + "_" + PlayFabEditorHelper.EDEX_VERSION }
            };

            if (api.Contains("/Server/") || api.Contains("/Admin/"))
            {
                if (PlayFabEditorDataService.ActiveTitle == null || string.IsNullOrEmpty(PlayFabEditorDataService.ActiveTitle.SecretKey))
                {
                    PlayFabEditorDataService.RefreshStudiosList();
                    return;
                }

                headers.Add("X-SecretKey", PlayFabEditorDataService.ActiveTitle.SecretKey);
            }

            //Encode Payload
            var payload = System.Text.Encoding.UTF8.GetBytes(req.Trim());

#if UNITY_2018_2_OR_NEWER
            ////------------------------- K code
            //using (var www = new UnityWebRequest(url))
            //{
            var www = new UnityWebRequest(url)
            {
                uploadHandler   = new UploadHandlerRaw(payload),
                downloadHandler = new DownloadHandlerBuffer(),
                method          = "POST"
            };

            foreach (var header in headers)
            {
                if (!string.IsNullOrEmpty(header.Key) && !string.IsNullOrEmpty(header.Value))
                {
                    www.SetRequestHeader(header.Key, header.Value);
                }
                else
                {
                    UnityEngine.Debug.LogWarning("Null header");
                }
            }


            PlayFabEditor.RaiseStateUpdate(PlayFabEditor.EdExStates.OnHttpReq, api, PlayFabEditorHelper.MSG_SPIN_BLOCK);
            EditorCoroutine.Start(Post(www, (response) => { OnWwwSuccess(api, resultCallback, errorCallback, response); }, (error) => { OnWwwError(errorCallback, error); }), www);
    #else
            var www = new WWW(url, payload, headers);
            PlayFabEditor.RaiseStateUpdate(PlayFabEditor.EdExStates.OnHttpReq, api, PlayFabEditorHelper.MSG_SPIN_BLOCK);
            EditorCoroutine.Start(Post(www, (response) => { OnWwwSuccess(api, resultCallback, errorCallback, response); }, (error) => { OnWwwError(errorCallback, error); }), www);
    #endif
            //www.Dispose();
            //}
        }
Example #13
0
        public Menu()
        {
            this.Set(flexDirection: FlexDirection.Row, justifyContent: Justify.SpaceAround, height: 25f, _class: "darkBackground");

            stateWithButton.Add(MenuStates.Sdk, new Button());
            stateWithButton.Add(MenuStates.Settings, new Button());
            stateWithButton.Add(MenuStates.Data, new Button());
            stateWithButton.Add(MenuStates.Tools, new Button());
            stateWithButton.Add(MenuStates.Packages, new Button());
            stateWithButton.Add(MenuStates.Help, new Button());
            stateWithButton.Add(MenuStates.Logout, new Button());

            foreach (var sWB in stateWithButton)
            {
                var btn   = sWB.Value;
                var state = sWB.Key;

                btn.clickable.clicked += () => OnMenuButton(state);
                btn.text = state.ToString().ToUpperInvariant();

                Add(btn);
            }
            var savedState = (MenuStates)PlayFabEditorPrefsSO.Instance.curMainMenuIdx;

            OnMenuButton(savedState);

            PlayFabEditor.EdExStateUpdate += PlayFabEditor_EdExStateUpdate;

            void OnMenuButton(MenuStates state)
            {
                foreach (var sWB in stateWithButton)
                {
                    var curBtn = sWB.Value;
                    curBtn.RemoveFromClassList("blueColor");
                }
                stateWithButton[state].AddToClassList("blueColor");
                PlayFabEditor.RaiseStateUpdate(PlayFabEditor.EdExStates.OnMenuItemClicked, state.ToString());

                PlayFabEditorPrefsSO.Instance.curMainMenuIdx = (int)state;

                if (state == MenuStates.Logout)
                {
                    PlayFabEditorAuthenticate.Logout();
                }
            }

            void PlayFabEditor_EdExStateUpdate(PlayFabEditor.EdExStates state, string status, string misc)
            {
                if (state == PlayFabEditor.EdExStates.OnLogin)
                {
                    OnMenuButton(MenuStates.Sdk);
                }

                if (state == PlayFabEditor.EdExStates.GoToSettings)
                {
                    OnMenuButton(MenuStates.Settings);
                }
            }
        }
Example #14
0
        public static void OnLogoutClicked()
        {
            _menuState = MenuStates.Logout;
            PlayFabEditor.RaiseStateUpdate(PlayFabEditor.EdExStates.OnMenuItemClicked, MenuStates.Logout.ToString());
            PlayFabEditorAuthenticate.Logout();

            _menuState = MenuStates.Sdks;
            PlayFabEditorDataService.EditorView.currentMainMenu = (int)_menuState;
        }
        public static void OnLogoutClicked()
        {
            _menuState = MenuStates.Logout;
            PlayFabEditor.RaiseStateUpdate(PlayFabEditor.EdExStates.OnMenuItemClicked, MenuStates.Logout.ToString());
            PlayFabEditorAuthenticate.Logout();

            _menuState = MenuStates.Sdks;
            PlayFabEditorPrefsSO.Instance.curMainMenuIdx = (int)_menuState;
        }
Example #16
0
 private static void OnWwwError(Action <PlayFab.PfEditor.EditorModels.PlayFabError> errorCallback, string error)
 {
     if (errorCallback != null)
     {
         errorCallback(PlayFabEditorHelper.GeneratePlayFabError(error));
     }
     else
     {
         PlayFabEditor.RaiseStateUpdate(PlayFabEditor.EdExStates.OnError, "OnWwwError" + error);
     }
 }
Example #17
0
        internal static void MakeDownloadCall(string url, Action <string> resultCallback)
        {
#if UNITY_2018_2_OR_NEWER
            UnityWebRequest www = UnityWebRequest.Get(url);
            PlayFabEditor.RaiseStateUpdate(PlayFabEditor.EdExStates.OnHttpReq, url, PlayFabEditorHelper.MSG_SPIN_BLOCK);
            EditorCoroutine.Start(PostDownload(www, (response) => { WriteResultFile(url, resultCallback, response); }, PlayFabEditorHelper.SharedErrorCallback), www);
#else
            var www = new WWW(url);
            PlayFabEditor.RaiseStateUpdate(PlayFabEditor.EdExStates.OnHttpReq, url, PlayFabEditorHelper.MSG_SPIN_BLOCK);
            EditorCoroutine.Start(PostDownload(www, (response) => { WriteResultFile(url, resultCallback, response); }, PlayFabEditorHelper.SharedErrorCallback), www);
#endif
        }
 private static void SaveToEditorPrefs(object obj, string key)
 {
     try
     {
         var json = JsonWrapper.SerializeObject(obj);
         EditorPrefs.SetString(KeyPrefix + key, json);
     }
     catch (Exception ex)
     {
         PlayFabEditor.RaiseStateUpdate(PlayFabEditor.EdExStates.OnError, ex.Message);
     }
 }
Example #19
0
        static void PlayFabServices()
        {
            var editorAsm   = typeof(UnityEditor.Editor).Assembly;
            var inspWndType = editorAsm.GetType("UnityEditor.SceneHierarchyWindow");

            if (inspWndType == null)
            {
                inspWndType = editorAsm.GetType("UnityEditor.InspectorWindow");
            }

            window = GetWindow <PlayFabEditor>(inspWndType);
            window.titleContent = new GUIContent("PlayFab EdEx");
            PlayFabEditorPrefsSO.Instance.PanelIsShown = true;
        }
        public static void LoadAllData()
        {
            if (IsDataLoaded)
            {
                return;
            }

            AccountDetails = LoadFromEditorPrefs <PlayFab_DeveloperAccountDetails>(PlayFab_DeveloperAccountDetails.Name);
            EnvDetails     = LoadFromEditorPrefs <PlayFab_DeveloperEnvironmentDetails>(PlayFab_DeveloperEnvironmentDetails.Name);
            EditorSettings = LoadFromEditorPrefs <PlayFab_EditorSettings>(PlayFab_EditorSettings.Name);
            EditorView     = LoadFromEditorPrefs <PlayFab_EditorView>(PlayFab_EditorView.Name);

            _IsDataLoaded = true;
            PlayFabEditor.RaiseStateUpdate(PlayFabEditor.EdExStates.OnDataLoaded, "Complete");
        }
Example #21
0
        private static void RemoveSdk(bool prompt = true)
        {
            if (prompt && !EditorUtility.DisplayDialog("Confirm SDK Removal", "This action will remove the current PlayFab SDK. Related plug-ins will need to be manually removed.", "Confirm", "Cancel"))
            {
                return;
            }

            //try to clean-up the plugin dirs
            if (Directory.Exists(Application.dataPath + "/Plugins"))
            {
                var folders = Directory.GetDirectories(Application.dataPath + "/Plugins", "PlayFabShared", SearchOption.AllDirectories);
                foreach (var folder in folders)
                {
                    FileUtil.DeleteFileOrDirectory(folder);
                }

                //try to clean-up the plugin files (if anything is left)
                var files = Directory.GetFiles(Application.dataPath + "/Plugins", "PlayFabErrors.cs", SearchOption.AllDirectories);
                foreach (var file in files)
                {
                    FileUtil.DeleteFileOrDirectory(file);
                }
            }

            var request = Client.Remove(Strings.Package.BuildName(ApiCategory.sdk));

            EditorApplication.update += Progress;

            void Progress()
            {
                if (request.IsCompleted)
                {
                    if (request.Status == StatusCode.Success)
                    {
                        PlayFabEditor.RaiseStateUpdate(PlayFabEditor.EdExStates.OnSuccess, "PlayFab SDK Removed!");
                        installedSdkVersion = null;
                        isInstalled         = false;
                    }
                    else if (request.Status >= StatusCode.Failure)
                    {
                        PlayFabEditor.RaiseStateUpdate(PlayFabEditor.EdExStates.OnError,
                                                       "An unknown error occured and the PlayFab SDK could not be removed.");
                    }

                    EditorApplication.update -= Progress;
                }
            }
        }
Example #22
0
        void OnEnable()
        {
            if (window == null)
            {
                window         = this;
                window.minSize = new Vector2(320, 0);
            }

            if (!IsEventHandlerRegistered(StateUpdateHandler))
            {
                EdExStateUpdate += StateUpdateHandler;
            }

            PlayFabEditorDataService.RefreshStudiosList(true);
            GetLatestEdExVersion();
        }
Example #23
0
        void OnEnable()
        {
            if (window == null)
            {
                window         = this;
                window.minSize = new Vector2(320, 0);
            }

            if (!IsEventHandlerRegistered(StateUpdateHandler))
            {
                EdExStateUpdate += StateUpdateHandler;
            }

            RaiseStateUpdate(EdExStates.OnEnable);
            PlayFabEditorDataService.LoadAllData();
            GetLatestEdExVersion();
        }
Example #24
0
        private static void OnTitleIdChange(string newTitleId)
        {
            var studio = GetStudioForTitleId(newTitleId);

            PlayFabEditorPrefsSO.Instance.SelectedStudio    = studio.Name;
            PlayFabEditorDataService.SharedSettings.TitleId = newTitleId;
#if ENABLE_PLAYFABADMIN_API || ENABLE_PLAYFABSERVER_API || UNITY_EDITOR
            PlayFabEditorDataService.SharedSettings.DeveloperSecretKey = studio.GetTitleSecretKey(newTitleId);
#endif
            PlayFabEditorPrefsSO.Instance.TitleDataCache.Clear();
            if (PlayFabEditorDataMenu.tdViewer != null)
            {
                PlayFabEditorDataMenu.tdViewer.items.Clear();
            }
            PlayFabEditorDataService.SaveEnvDetails();
            PlayFabEditor.RaiseStateUpdate(PlayFabEditor.EdExStates.OnSuccess);
        }
 private static void OnContinueButtonClicked()
 {
     PlayFabEditorApi.Login(new LoginRequest()
     {
         DeveloperToolProductName    = PlayFabEditorHelper.EDEX_NAME,
         DeveloperToolProductVersion = PlayFabEditorHelper.GetApiVersion(ApiCategory.editorextensions),
         TwoFactorAuth = _2FaCode,
         Email         = _userEmail,
         Password      = _userPass
     }, (result) =>
     {
         PlayFabEditorPrefsSO.Instance.DevAccountToken = result.DeveloperClientToken;
         PlayFabEditorPrefsSO.Instance.DevAccountEmail = _userEmail;
         PlayFabEditorDataService.RefreshStudiosList();
         PlayFabEditor.RaiseStateUpdate(PlayFabEditor.EdExStates.OnLogin);
         PlayFabEditorPrefsSO.Save();
     }, PlayFabEditorHelper.SharedErrorCallback);
 }
 private static void OnContinueButtonClicked()
 {
     PlayFabEditorApi.Login(new LoginRequest()
     {
         DeveloperToolProductName    = PlayFabEditorHelper.EDEX_NAME,
         DeveloperToolProductVersion = PlayFabEditorHelper.EDEX_VERSION,
         TwoFactorAuth = _2FaCode,
         Email         = _userEmail,
         Password      = _userPass
     }, (result) =>
     {
         PlayFabEditorDataService.AccountDetails.devToken = result.DeveloperClientToken;
         PlayFabEditorDataService.AccountDetails.email    = _userEmail;
         PlayFabEditorDataService.RefreshStudiosList();
         PlayFabEditor.RaiseStateUpdate(PlayFabEditor.EdExStates.OnLogin);
         PlayFabEditorDataService.SaveAccountDetails();
         PlayFabEditorMenu._menuState = PlayFabEditorMenu.MenuStates.Sdks;
     }, PlayFabEditorHelper.SharedErrorCallback);
 }
Example #27
0
 private static void GetCloudScriptRevision()
 {
     // empty request object gets latest versions
     PlayFabEditorApi.GetCloudScriptRevision(new EditorModels.GetCloudScriptRevisionRequest(), (GetCloudScriptRevisionResult result) =>
     {
         var csPath = PlayFabEditorHelper.CLOUDSCRIPT_PATH;
         try
         {
             File.WriteAllText(csPath, result.Files[0].FileContents);
             Debug.Log("CloudScript uploaded successfully!");
             PlayFabEditorDataService.EnvDetails.localCloudScriptPath = csPath;
             PlayFabEditorDataService.SaveEnvDetails();
         }
         catch (Exception ex)
         {
             PlayFabEditor.RaiseStateUpdate(PlayFabEditor.EdExStates.OnError, ex.Message);
             return;
         }
     }, PlayFabEditorHelper.SharedErrorCallback);
 }
        private static void SelectLocalFile()
        {
            var starterPath     = File.Exists(PlayFabEditorDataService.EnvDetails.localCloudScriptPath) ? Application.dataPath : PlayFabEditorDataService.EnvDetails.localCloudScriptPath;
            var cloudScriptPath = string.Empty;

            try
            {
                cloudScriptPath = EditorUtility.OpenFilePanel("Select your Cloud Script file", starterPath, "js");
            }
            catch (Exception ex)
            {
                PlayFabEditor.RaiseStateUpdate(PlayFabEditor.EdExStates.OnError, ex.Message);
            }

            if (!string.IsNullOrEmpty(cloudScriptPath))
            {
                PlayFabEditorDataService.EnvDetails.localCloudScriptPath = cloudScriptPath;
                PlayFabEditorDataService.SaveEnvDetails();
            }
        }
        public static void Logout()
        {
            PlayFabEditor.RaiseStateUpdate(PlayFabEditor.EdExStates.OnLogout);

            PlayFabEditorApi.Logout(new LogoutRequest
            {
                DeveloperClientToken = PlayFabEditorDataService.AccountDetails.devToken
            }, null, PlayFabEditorHelper.SharedErrorCallback);

            _userPass  = string.Empty;
            _userPass2 = string.Empty;

            activeState = PanelDisplayStates.Login;

            PlayFabEditorDataService.AccountDetails.studios  = null;
            PlayFabEditorDataService.AccountDetails.devToken = string.Empty;
            PlayFabEditorDataService.SaveAccountDetails();

            PlayFabEditorDataService.EnvDetails.titleData.Clear();
            PlayFabEditorDataService.SaveEnvDetails();
        }
Example #30
0
        public static void Logout()
        {
            PlayFabEditor.RaiseStateUpdate(PlayFabEditor.EdExStates.OnLogout);

            PlayFabEditorApi.Logout(new LogoutRequest
            {
                DeveloperClientToken = PlayFabEditorPrefsSO.Instance.DevAccountToken
            }, null, PlayFabEditorHelper.SharedErrorCallback);

            _userPass  = string.Empty;
            _userPass2 = string.Empty;

            activeState = PanelDisplayStates.Login;

            PlayFabEditorPrefsSO.Instance.StudioList      = null;
            PlayFabEditorPrefsSO.Instance.DevAccountToken = string.Empty;
            PlayFabEditorPrefsSO.Save();

            PlayFabEditorPrefsSO.Instance.TitleDataCache.Clear();
            PlayFabEditorDataService.SaveEnvDetails();
        }