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.Clear(); PlayFabEditorDataService.accountDetails.devToken = string.Empty; PlayFabEditorDataService.SaveAccountDetails(); PlayFabEditorDataService.envDetails.titleData.Clear(); PlayFabEditorDataService.SaveEnvDetails(); }
public static void BeginCloudScriptUpload() { string 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; } StreamReader s = File.OpenText(filePath); string contents = s.ReadToEnd(); s.Close(); UpdateCloudScriptRequest 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); }
public static void After() { if (PlayFabEditorDataService.envDetails.isAdminApiEnabled && !buildTargets.Contains(PlayFabEditorHelper.ADMIN_API)) { var str = AddToBuildTarget(buildTargets, PlayFabEditorHelper.ADMIN_API); PlayerSettings.SetScriptingDefineSymbolsForGroup(EditorUserBuildSettings.selectedBuildTargetGroup, str); PlayFabEditorDataService.SaveEnvDetails(); } else if (!PlayFabEditorDataService.envDetails.isAdminApiEnabled && buildTargets.Contains(PlayFabEditorHelper.ADMIN_API)) { var str = RemoveToBuildTarget(buildTargets, PlayFabEditorHelper.ADMIN_API); PlayerSettings.SetScriptingDefineSymbolsForGroup(EditorUserBuildSettings.selectedBuildTargetGroup, str); PlayFabEditorDataService.SaveEnvDetails(); } if (PlayFabEditorDataService.envDetails.isServerApiEnabled && !buildTargets.Contains(PlayFabEditorHelper.SERVER_API)) { var str = AddToBuildTarget(buildTargets, PlayFabEditorHelper.SERVER_API); PlayerSettings.SetScriptingDefineSymbolsForGroup(EditorUserBuildSettings.selectedBuildTargetGroup, str); PlayFabEditorDataService.SaveEnvDetails(); } else if (!PlayFabEditorDataService.envDetails.isServerApiEnabled && buildTargets.Contains(PlayFabEditorHelper.SERVER_API)) { var str = RemoveToBuildTarget(buildTargets, PlayFabEditorHelper.SERVER_API); PlayerSettings.SetScriptingDefineSymbolsForGroup(EditorUserBuildSettings.selectedBuildTargetGroup, str); PlayFabEditorDataService.SaveEnvDetails(); } if (PlayFabEditorDataService.envDetails.isDebugRequestTimesEnabled && !buildTargets.Contains(PlayFabEditorHelper.DEBUG_REQUEST_TIMING)) { var str = AddToBuildTarget(buildTargets, PlayFabEditorHelper.DEBUG_REQUEST_TIMING); PlayerSettings.SetScriptingDefineSymbolsForGroup(EditorUserBuildSettings.selectedBuildTargetGroup, str); PlayFabEditorDataService.SaveEnvDetails(); } else if (!PlayFabEditorDataService.envDetails.isDebugRequestTimesEnabled && buildTargets.Contains(PlayFabEditorHelper.DEBUG_REQUEST_TIMING)) { var str = RemoveToBuildTarget(buildTargets, PlayFabEditorHelper.DEBUG_REQUEST_TIMING); PlayerSettings.SetScriptingDefineSymbolsForGroup(EditorUserBuildSettings.selectedBuildTargetGroup, str); PlayFabEditorDataService.SaveEnvDetails(); } if (!PlayFabEditorDataService.envDetails.isClientApiEnabled && !buildTargets.Contains(PlayFabEditorHelper.CLIENT_API)) { Debug.Log(PlayFabEditorHelper.CLIENT_API + ":" + buildTargets.Contains(PlayFabEditorHelper.CLIENT_API)); var str = AddToBuildTarget(buildTargets, PlayFabEditorHelper.CLIENT_API); PlayerSettings.SetScriptingDefineSymbolsForGroup(EditorUserBuildSettings.selectedBuildTargetGroup, str); PlayFabEditorDataService.SaveEnvDetails(); } else if (PlayFabEditorDataService.envDetails.isClientApiEnabled && buildTargets.Contains(PlayFabEditorHelper.CLIENT_API)) { Debug.Log(PlayFabEditorHelper.CLIENT_API + "- Removed"); var str = RemoveToBuildTarget(buildTargets, PlayFabEditorHelper.CLIENT_API); PlayerSettings.SetScriptingDefineSymbolsForGroup(EditorUserBuildSettings.selectedBuildTargetGroup, str); PlayFabEditorDataService.SaveEnvDetails(); } }
private static void OnSaveSettings() { // make assessments on the override at studio positon 0 if (PlayFabEditorSDKTools.IsInstalled && PlayFabEditorSDKTools.isSdkSupported) { if (_foundUnknownTitleId || _selectedStudioIndex == 0) { if (PlayFabEditorDataService.envDetails.selectedTitleId != _TitleId) { PlayFabEditorDataService.envDetails.titleData.Clear(); if (PlayFabEditorDataMenu.tdViewer != null) { PlayFabEditorDataMenu.tdViewer.items.Clear(); } } PlayFabEditorDataService.envDetails.selectedTitleId = _TitleId; } else { // if we switched titles clear titledata if (PlayFabEditorDataService.envDetails.selectedTitleId != GetSelectedTitleIdFromOptions()) { PlayFabEditorDataService.envDetails.titleData.Clear(); if (PlayFabEditorDataMenu.tdViewer != null) { PlayFabEditorDataMenu.tdViewer.items.Clear(); } } PlayFabEditorDataService.envDetails.selectedTitleId = GetSelectedTitleIdFromOptions(); } PlayFabEditorDataService.envDetails.selectedStudio = studioOptions[_selectedStudioIndex]; #if ENABLE_PLAYFABADMIN_API || ENABLE_PLAYFABSERVER_API PlayFabEditorDataService.envDetails.developerSecretKey = _DeveloperSecretKey; #endif PlayFabEditorDataService.envDetails.compressApiData = _CompressApiData; PlayFabEditorDataService.envDetails.keepAlive = _KeepAlive; PlayFabEditorDataService.envDetails.webRequestType = _RequestType; PlayFabEditorDataService.envDetails.timeOut = _RequestTimeOut; PlayFabEditorDataService.SaveEnvDetails(); PlayFabEditor.RaiseStateUpdate(PlayFabEditor.EdExStates.OnSuccess); } else { PlayFabEditor.RaiseStateUpdate(PlayFabEditor.EdExStates.OnError, "SDK is unsupported or not installed"); } }
public static void ImportLatestSDK() { PlayFabEditorHttp.MakeDownloadCall("https://api.playfab.com/sdks/download/unity-via-edex", (fileName) => { Debug.Log("PlayFab SDK Install: Complete"); AssetDatabase.ImportPackage(fileName, false); PlayFabEditorDataService.envDetails.sdkPath = PlayFabEditorHelper.DEFAULT_SDK_LOCATION; PlayFabEditorDataService.SaveEnvDetails(); }); }
static PlayFabEditorHelper() { // scan for changes to the editor folder / structure. if (uiStyle == null) { string[] rootFiles = new string[0]; bool relocatedEdEx = false; try { EDEX_ROOT = PlayFabEditorDataService.envDetails.edexPath ?? EDEX_ROOT; rootFiles = Directory.GetDirectories(EDEX_ROOT); uiStyle = GetUiStyle(); } catch { if (rootFiles.Length == 0) { // this probably means the editor folder was moved. //see if we can locate the moved root // and reload the assets var movedRootFiles = Directory.GetFiles(Application.dataPath, PLAYFAB_EDEX_MAINFILE, SearchOption.AllDirectories); if (movedRootFiles.Length > 0) { relocatedEdEx = true; EDEX_ROOT = movedRootFiles[0].Substring(0, movedRootFiles[0].IndexOf(PLAYFAB_EDEX_MAINFILE) - 1); PlayFabEditorDataService.envDetails.edexPath = EDEX_ROOT; PlayFabEditorDataService.SaveEnvDetails(); uiStyle = GetUiStyle(); } } } finally { if (relocatedEdEx && rootFiles.Length == 0) { Debug.Log(string.Format("Found new EdEx root: {0}", EDEX_ROOT)); } else if (rootFiles.Length == 0) { Debug.Log("Could not relocate the PlayFab Editor Extension"); EDEX_ROOT = string.Empty; } } } }
public void RefreshRecords() { Action <PlayFab.Editor.EditorModels.GetTitleDataResult> cb = (result) => { items.Clear(); showSave = false; foreach (var kvp in result.Data) { items.Add(new KvpItem(kvp.Key, kvp.Value)); } PlayFabEditorDataService.envDetails.titleInternalData = result.Data; PlayFabEditorDataService.SaveEnvDetails(); }; PlayFabEditorApi.GetTitleInternalData(cb, PlayFabEditorHelper.SharedErrorCallback); }
public void RefreshRecords() { //BaseUiAnimationController.StartAlphaFade(1, 0, listDisplay); Action <PlayFab.Editor.EditorModels.GetTitleDataResult> cb = (result) => { items.Clear(); showSave = false; foreach (var kvp in result.Data) { items.Add(new KvpItem(kvp.Key, kvp.Value)); } PlayFabEditorDataService.envDetails.titleData = result.Data; PlayFabEditorDataService.SaveEnvDetails(); }; PlayFabEditorApi.GetTitleData(cb, PlayFabEditorHelper.SharedErrorCallback); }
public static void SelectLocalFile() { string starterPath = File.Exists(PlayFabEditorDataService.envDetails.localCloudScriptPath) ? Application.dataPath : PlayFabEditorDataService.envDetails.localCloudScriptPath; string 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 GetCloudScriptRevision() { // empty request object gets latest versions PlayFabEditorApi.GetCloudScriptRevision(new EditorModels.GetCloudScriptRevisionRequest(), (GetCloudScriptRevisionResult result) => { var csPath = PlayFabEditorHelper.CLOUDSCRIPT_PATH; try { System.IO.File.WriteAllText(csPath, result.Files.First().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); }
public static void DrawSdkPanel() { if (!isInitialized) { //SDK is installed. isInstalled = IsInstalled; CheckSdkVersion(); isInitialized = true; GetLatestSdkVersion(); sdkFolder = FindSdkAsset(); if (sdkFolder != null) { PlayFabEditorDataService.envDetails.sdkPath = AssetDatabase.GetAssetPath(sdkFolder); PlayFabEditorDataService.SaveEnvDetails(); } } if (isInstalled) { // cant find the sdk, but we suspect its in the project (either in-full or in-part) isObjectFieldActive = sdkFolder == null ? true : false; if (_previoussSdkFolderPath != sdkFolder) { // something changed, better save the result. _previoussSdkFolderPath = sdkFolder; PlayFabEditorDataService.envDetails.sdkPath = (AssetDatabase.GetAssetPath(sdkFolder)); PlayFabEditorDataService.SaveEnvDetails(); isObjectFieldActive = false; } GUIStyle labelStyle = new GUIStyle(PlayFabEditorHelper.uiStyle.GetStyle("titleLabel")); GUILayout.BeginVertical(PlayFabEditorHelper.uiStyle.GetStyle("gpStyleGray1")); GUILayout.Label(string.Format("SDK {0} is installed", string.IsNullOrEmpty(installedSdkVersion) ? "Unknown" : installedSdkVersion), labelStyle, GUILayout.MinWidth(EditorGUIUtility.currentViewWidth)); if (!isObjectFieldActive) { GUI.enabled = false; } else { GUILayout.Label("An SDK was detected, but we were unable to find the directory. Drag-and-drop the top-level PlayFab SDK folder below.", PlayFabEditorHelper.uiStyle.GetStyle("orTxt")); } GUILayout.BeginHorizontal(PlayFabEditorHelper.uiStyle.GetStyle("gpStyleClear")); GUILayout.FlexibleSpace(); sdkFolder = EditorGUILayout.ObjectField(sdkFolder, typeof(UnityEngine.Object), false, GUILayout.MaxWidth(200)); GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); if (!isObjectFieldActive) { // this is a hack to prevent our "block while loading technique" from breaking up at this point. GUI.enabled = EditorApplication.isCompiling || PlayFabEditor.blockingRequests.Count > 0 ? false : true; } if (isSdkSupported == true && sdkFolder != null) { GUILayout.BeginHorizontal(PlayFabEditorHelper.uiStyle.GetStyle("gpStyleClear")); GUILayout.FlexibleSpace(); if (GUILayout.Button("REMOVE SDK", PlayFabEditorHelper.uiStyle.GetStyle("textButton"), GUILayout.MinHeight(32), GUILayout.MinWidth(200))) { RemoveSDK(); } GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); } GUILayout.EndVertical(); if (sdkFolder != null) { //TODO START BACK HERE... GUILayout.BeginVertical(PlayFabEditorHelper.uiStyle.GetStyle("gpStyleGray1")); isSdkSupported = false; string[] versionNumber = !string.IsNullOrEmpty(installedSdkVersion) ? installedSdkVersion.Split('.') : new string[0]; int numerical = 0; if (string.IsNullOrEmpty(installedSdkVersion) || versionNumber == null || versionNumber.Length == 0 || (versionNumber.Length > 0 && int.TryParse(versionNumber[0], out numerical) && numerical < 2)) { //older version of the SDK GUILayout.BeginHorizontal(PlayFabEditorHelper.uiStyle.GetStyle("gpStyleClear")); GUILayout.Label("Most of the Editor Extensions depend on SDK versions >2.0. Consider upgrading to the get most features.", PlayFabEditorHelper.uiStyle.GetStyle("orTxt")); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(PlayFabEditorHelper.uiStyle.GetStyle("gpStyleClear")); GUILayout.FlexibleSpace(); if (GUILayout.Button("READ THE UPGRADE GUIDE", PlayFabEditorHelper.uiStyle.GetStyle("textButton"), GUILayout.MinHeight(32))) { Application.OpenURL("https://github.com/PlayFab/UnitySDK/blob/master/UPGRADE.md"); } GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); } else if (numerical >= 2) { isSdkSupported = true; } GUILayout.BeginHorizontal(PlayFabEditorHelper.uiStyle.GetStyle("gpStyleClear")); if (ShowSDKUpgrade() && isSdkSupported) { GUILayout.FlexibleSpace(); if (GUILayout.Button("Upgrade to " + latestSdkVersion, PlayFabEditorHelper.uiStyle.GetStyle("Button"), GUILayout.MinHeight(32))) { UpgradeSdk(); } GUILayout.FlexibleSpace(); } else if (isSdkSupported) { GUILayout.FlexibleSpace(); GUILayout.Label("You have the latest SDK!", labelStyle, GUILayout.MinHeight(32)); GUILayout.FlexibleSpace(); } GUILayout.EndHorizontal(); GUILayout.EndVertical(); } if (isSdkSupported && string.IsNullOrEmpty(PlayFabEditorDataService.envDetails.selectedTitleId)) { GUILayout.BeginVertical(PlayFabEditorHelper.uiStyle.GetStyle("gpStyleGray1")); GUILayout.Label("Before making PlayFab API calls, the SDK must be configured to your PlayFab Title.", PlayFabEditorHelper.uiStyle.GetStyle("orTxt")); GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); if (GUILayout.Button("SET MY TITLE", PlayFabEditorHelper.uiStyle.GetStyle("textButton"))) { PlayFabEditorMenu.OnSettingsClicked(); } GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); GUILayout.EndVertical(); } GUILayout.BeginHorizontal(PlayFabEditorHelper.uiStyle.GetStyle("gpStyleGray1")); GUILayout.FlexibleSpace(); if (GUILayout.Button("VIEW RELEASE NOTES", PlayFabEditorHelper.uiStyle.GetStyle("textButton"), GUILayout.MinHeight(32), GUILayout.MinWidth(200))) { Application.OpenURL("https://api.playfab.com/releaseNotes/"); } GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); } else { //NO SDK Is Installed.. GUILayout.BeginVertical(PlayFabEditorHelper.uiStyle.GetStyle("gpStyleGray1")); GUIStyle labelStyle = new GUIStyle(PlayFabEditorHelper.uiStyle.GetStyle("titleLabel")); GUILayout.Label("No SDK is installed.", labelStyle, GUILayout.MinWidth(EditorGUIUtility.currentViewWidth)); GUILayout.Space(20); GUILayout.BeginHorizontal(PlayFabEditorHelper.uiStyle.GetStyle("gpStyleGray1")); var buttonWidth = 150; GUILayout.FlexibleSpace(); if (GUILayout.Button("Install PlayFab SDK", PlayFabEditorHelper.uiStyle.GetStyle("Button"), GUILayout.MaxWidth(buttonWidth), GUILayout.MinHeight(32))) { ImportLatestSDK(); } GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); GUILayout.EndVertical(); } }
public static void DrawToolsPanel() { scrollPos = GUILayout.BeginScrollView(scrollPos, PlayFabEditorHelper.uiStyle.GetStyle("gpStyleGray1")); buttonWidth = EditorGUIUtility.currentViewWidth > 400 ? EditorGUIUtility.currentViewWidth / 2 : 200; GUILayout.BeginHorizontal(PlayFabEditorHelper.uiStyle.GetStyle("gpStyleClear")); GUILayout.Label("CLOUD SCRIPT:", PlayFabEditorHelper.uiStyle.GetStyle("labelStyle")); GUILayout.Space(10); if (GUILayout.Button("IMPORT", PlayFabEditorHelper.uiStyle.GetStyle("textButton"), GUILayout.MinHeight(30))) { ImportCloudScript(); } GUILayout.Space(10); if (File.Exists(PlayFabEditorDataService.envDetails.localCloudScriptPath)) { if (GUILayout.Button("REMOVE", PlayFabEditorHelper.uiStyle.GetStyle("textButton"), GUILayout.MinHeight(30))) { PlayFabEditorDataService.envDetails.localCloudScriptPath = string.Empty; PlayFabEditorDataService.SaveEnvDetails(); } GUILayout.Space(10); if (GUILayout.Button("EDIT", PlayFabEditorHelper.uiStyle.GetStyle("textButton"), GUILayout.MinHeight(30))) { EditorUtility.OpenWithDefaultApp(PlayFabEditorDataService.envDetails.localCloudScriptPath); } } GUILayout.EndHorizontal(); if (File.Exists(PlayFabEditorDataService.envDetails.localCloudScriptPath)) { var path = File.Exists(PlayFabEditorDataService.envDetails.localCloudScriptPath) ? PlayFabEditorDataService.envDetails.localCloudScriptPath : PlayFabEditorHelper.CLOUDSCRIPT_PATH; var shortPath = "..." + path.Substring(path.LastIndexOf('/')); GUILayout.BeginHorizontal(PlayFabEditorHelper.uiStyle.GetStyle("gpStyleClear")); GUILayout.FlexibleSpace(); if (GUILayout.Button(shortPath, PlayFabEditorHelper.uiStyle.GetStyle("textButton"), GUILayout.MinWidth(110), GUILayout.MinHeight(20))) { EditorUtility.RevealInFinder(path); } // GUILayout.Space(10); // if (GUILayout.Button("EDIT LOCALLY", PlayFabEditorHelper.uiStyle.GetStyle("textButton"), GUILayout.MinWidth(90), GUILayout.MinHeight(20))) // { // EditorUtility.OpenWithDefaultApp(path); // } GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(PlayFabEditorHelper.uiStyle.GetStyle("gpStyleClear")); GUILayout.FlexibleSpace(); if (GUILayout.Button("SAVE TO PLAYFAB", PlayFabEditorHelper.uiStyle.GetStyle("Button"), GUILayout.MinHeight(32), GUILayout.Width(buttonWidth))) { if (EditorUtility.DisplayDialog("Deployment Confirmation", "This action will upload your local Cloud Script changes to PlayFab?", "Continue", "Cancel")) { BeginCloudScriptUpload(); } } GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); } else { GUILayout.BeginHorizontal(PlayFabEditorHelper.uiStyle.GetStyle("gpStyleClear")); GUILayout.FlexibleSpace(); GUILayout.Label("No Cloud Script files added. Import your file to get started.", PlayFabEditorHelper.uiStyle.GetStyle("orTxt")); GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); } GUILayout.EndScrollView(); }