private static void GetCloudScriptRevision() { // empty request object gets latest versions PlayFabEditorApi.GetCloudScriptRevision(new EditorModels.GetCloudScriptRevisionRequest(), (GetCloudScriptRevisionResult result) => { var csPath = PlayFabEditorHelper.CLOUDSCRIPT_PATH; var location = Path.GetDirectoryName(csPath); try { if (!Directory.Exists(location)) { Directory.CreateDirectory(location); } if (!File.Exists(csPath)) { using (var newfile = File.Create(csPath)) { } } File.WriteAllText(csPath, result.Files[0].FileContents); Debug.Log("CloudScript uploaded successfully!"); PlayFabEditorDataService.EnvDetails.localCloudScriptPath = csPath; PlayFabEditorDataService.SaveEnvDetails(); AssetDatabase.Refresh(); } catch (Exception ex) { Debug.LogException(ex); // PlayFabEditor.RaiseStateUpdate(PlayFabEditor.EdExStates.OnError, ex.Message); return; } }, PlayFabEditorHelper.SharedErrorCallback); }
private static void RemoveEdEx(bool clearPrefs = true, bool prompt = true) { if (prompt && !EditorUtility.DisplayDialog("Confirm Editor Extensions Removal", "This action will remove PlayFab Editor Extensions from the current project.", "Confirm", "Cancel")) { return; } try { window.Close(); var edExRoot = new DirectoryInfo(PlayFabEditorHelper.EDEX_ROOT); FileUtil.DeleteFileOrDirectory(edExRoot.Parent.FullName); if (clearPrefs) { PlayFabEditorDataService.RemoveEditorPrefs(); } AssetDatabase.Refresh(); } catch (Exception ex) { RaiseStateUpdate(EdExStates.OnError, ex.Message); } }
private static void OnRegisterClicked() { if (_userPass != _userPass2) { Debug.LogError("PlayFab developer account passwords must match."); return; } PlayFabEditorApi.RegisterAccouint(new RegisterAccountRequest() { DeveloperToolProductName = PlayFabEditorHelper.EDEX_NAME, DeveloperToolProductVersion = PlayFabEditorHelper.EDEX_VERSION, Email = _userEmail, Password = _userPass, StudioName = _studio }, (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); }
public static void DrawSdkPanel() { if (!isInitialized) { //SDK is installed. CheckSdkVersion(); isInitialized = true; GetLatestSdkVersion(); sdkFolder = FindSdkAsset(); if (sdkFolder != null) { PlayFabEditorDataService.EnvDetails.sdkPath = AssetDatabase.GetAssetPath(sdkFolder); PlayFabEditorDataService.SaveEnvDetails(); } } if (IsInstalled) { ShowSdkInstalledMenu(); } else { ShowSdkNotInstalledMenu(); } }
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(); }
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.GetApiVersion(ApiCategory.editorextensions), Email = _userEmail, Password = _userPass, StudioName = _studio }, (result) => { PlayFabEditorPrefsSO.Instance.DevAccountToken = result.DeveloperClientToken; PlayFabEditorPrefsSO.Instance.DevAccountEmail = _userEmail; PlayFabEditorDataService.RefreshStudiosList(); PlayFabEditor.RaiseStateUpdate(PlayFabEditor.EdExStates.OnLogin); 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); }
private static void OnLoginButtonClicked() { PlayFabEditorApi.Login(new LoginRequest() { DeveloperToolProductName = PlayFabEditorHelper.EDEX_NAME, DeveloperToolProductVersion = PlayFabEditorHelper.EDEX_VERSION, 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; }, (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); } }); }
static Startup() { PlayFabEditorDataService.LoadAllData(); if (PlayFabEditorDataService.EditorSettings.isEdExShown || !PlayFabEditorSDKTools.IsInstalled) { EditorCoroutine.Start(OpenPlayServices()); } }
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(); } }
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 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 }
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(); }); }
private static void SelectLocalFile() { var starterPath = File.Exists(PlayFabEditorDataService.EnvDetails.localCloudScriptPath) ? Application.dataPath : PlayFabEditorDataService.EnvDetails.localCloudScriptPath; var cloudScriptPath = string.Empty; cloudScriptPath = EditorUtility.OpenFilePanel("Select your Cloud Script file", starterPath, "js"); if (!string.IsNullOrEmpty(cloudScriptPath)) { PlayFabEditorDataService.EnvDetails.localCloudScriptPath = cloudScriptPath; PlayFabEditorDataService.SaveEnvDetails(); } }
public static void ImportLatestSDK() { PlayFabEditorHttp.MakeDownloadCall("https://aka.ms/PlayFabUnitySdk", (fileName) => { Debug.Log("PlayFab SDK Install: Complete"); AssetDatabase.ImportPackage(fileName, false); // attempts to re-import any changed assets (which ImportPackage doesn't implicitly do) AssetDatabase.Refresh(); PlayFabEditorPrefsSO.Instance.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; _uiStyle = null; try { if (PlayFabEditorDataService.EnvDetails != null && !string.IsNullOrEmpty(PlayFabEditorDataService.EnvDetails.edexPath)) { EDEX_ROOT = PlayFabEditorDataService.EnvDetails.edexPath; } rootFiles = Directory.GetDirectories(EDEX_ROOT); } 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(); } } } finally { if (relocatedEdEx && rootFiles.Length == 0) { Debug.Log("Found new EdEx root: " + EDEX_ROOT); } else if (rootFiles.Length == 0) { Debug.Log("Could not relocate the PlayFab Editor Extension"); EDEX_ROOT = string.Empty; } } } }
void OnEnable() { if (window == null) { window = this; window.minSize = new Vector2(320, 0); } if (!IsEventHandlerRegistered(StateUpdateHandler)) { EdExStateUpdate += StateUpdateHandler; } PlayFabEditorDataService.RefreshStudiosList(true); GetLatestEdExVersion(); }
public void RefreshInternalTitleData() { Action <PlayFab.PfEditor.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); }
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); }
void OnEnable() { if (window == null) { window = this; window.minSize = new Vector2(320, 0); } if (!IsEventHandlerRegistered(StateUpdateHandler)) { EdExStateUpdate += StateUpdateHandler; } RaiseStateUpdate(EdExStates.OnEnable); PlayFabEditorDataService.LoadAllData(); GetLatestEdExVersion(); }
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); }
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(); } }
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); }
public void RefreshTitleData() { Action <PlayFab.PfEditor.EditorModels.GetTitleDataResult> dataRequest = (result) => { items.Clear(); showSave = false; foreach (var kvp in result.Data) { items.Add(new KvpItem(kvp.Key, kvp.Value)); } PlayFabEditorPrefsSO.Instance.TitleDataCache.Clear(); foreach (var pair in result.Data) { PlayFabEditorPrefsSO.Instance.TitleDataCache.Add(pair.Key, pair.Value); } PlayFabEditorDataService.SaveEnvDetails(); }; PlayFabEditorApi.GetTitleData(dataRequest, PlayFabEditorHelper.SharedErrorCallback); }
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(); }
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(); }
private static void ShowSdkInstalledMenu() { isObjectFieldActive = sdkFolder == null; if (_previoussSdkFolderPath != sdkFolder) { // something changed, better save the result. _previoussSdkFolderPath = sdkFolder; PlayFabEditorDataService.EnvDetails.sdkPath = (AssetDatabase.GetAssetPath(sdkFolder)); PlayFabEditorDataService.SaveEnvDetails(); isObjectFieldActive = false; } var labelStyle = new GUIStyle(PlayFabEditorHelper.uiStyle.GetStyle("titleLabel")); using (new UnityVertical(PlayFabEditorHelper.uiStyle.GetStyle("gpStyleGray1"))) { EditorGUILayout.LabelField(string.Format("SDK {0} is installed", string.IsNullOrEmpty(installedSdkVersion) ? "Unknown" : installedSdkVersion), labelStyle, GUILayout.MinWidth(EditorGUIUtility.currentViewWidth)); if (!isObjectFieldActive) { GUI.enabled = false; } else { EditorGUILayout.LabelField( "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")); } using (new UnityHorizontal(PlayFabEditorHelper.uiStyle.GetStyle("gpStyleClear"))) { GUILayout.FlexibleSpace(); sdkFolder = EditorGUILayout.ObjectField(sdkFolder, typeof(UnityEngine.Object), false, GUILayout.MaxWidth(200)); GUILayout.FlexibleSpace(); } 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; } if (isSdkSupported && sdkFolder != null) { using (new UnityHorizontal(PlayFabEditorHelper.uiStyle.GetStyle("gpStyleClear"))) { GUILayout.FlexibleSpace(); if (GUILayout.Button("REMOVE SDK", PlayFabEditorHelper.uiStyle.GetStyle("textButton"), GUILayout.MinHeight(32), GUILayout.MinWidth(200))) { RemoveSdk(); } GUILayout.FlexibleSpace(); } } } if (sdkFolder != null) { using (new UnityVertical(PlayFabEditorHelper.uiStyle.GetStyle("gpStyleGray1"))) { isSdkSupported = false; string[] versionNumber = !string.IsNullOrEmpty(installedSdkVersion) ? installedSdkVersion.Split('.') : new string[0]; var 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 using (new UnityHorizontal(PlayFabEditorHelper.uiStyle.GetStyle("gpStyleClear"))) { EditorGUILayout.LabelField("Most of the Editor Extensions depend on SDK versions >2.0. Consider upgrading to the get most features.", PlayFabEditorHelper.uiStyle.GetStyle("orTxt")); } using (new UnityHorizontal(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(); } } else if (numerical >= 2) { isSdkSupported = true; } using (new UnityHorizontal(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(); EditorGUILayout.LabelField("You have the latest SDK!", labelStyle, GUILayout.MinHeight(32)); GUILayout.FlexibleSpace(); } } } } if (isSdkSupported && string.IsNullOrEmpty(PlayFabEditorDataService.SharedSettings.TitleId)) { using (new UnityVertical(PlayFabEditorHelper.uiStyle.GetStyle("gpStyleGray1"))) { EditorGUILayout.LabelField("Before making PlayFab API calls, the SDK must be configured to your PlayFab Title.", PlayFabEditorHelper.uiStyle.GetStyle("orTxt")); using (new UnityHorizontal()) { GUILayout.FlexibleSpace(); if (GUILayout.Button("SET MY TITLE", PlayFabEditorHelper.uiStyle.GetStyle("textButton"))) { PlayFabEditorMenu.OnSettingsClicked(); } GUILayout.FlexibleSpace(); } } } using (new UnityHorizontal(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(); } }
public static void DrawToolsPanel() { scrollPos = GUILayout.BeginScrollView(scrollPos, PlayFabEditorHelper.uiStyle.GetStyle("gpStyleGray1")); buttonWidth = EditorGUIUtility.currentViewWidth > 400 ? EditorGUIUtility.currentViewWidth / 2 : 200; using (new UnityHorizontal(PlayFabEditorHelper.uiStyle.GetStyle("gpStyleClear"))) { EditorGUILayout.LabelField("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); } } } 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('/')); using (new UnityHorizontal(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(); } using (new UnityHorizontal(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(); } } else { using (new UnityHorizontal(PlayFabEditorHelper.uiStyle.GetStyle("gpStyleClear"))) { GUILayout.FlexibleSpace(); EditorGUILayout.LabelField("No Cloud Script files added. Import your file to get started.", PlayFabEditorHelper.uiStyle.GetStyle("orTxt")); GUILayout.FlexibleSpace(); } } GUILayout.EndScrollView(); }
private static void DrawTitleSettingsSubPanel() { float labelWidth = 100; if (PlayFabEditorPrefsSO.Instance.StudioList != null && PlayFabEditorPrefsSO.Instance.StudioList.Count != StudioFoldOutStates.Count + 1) { StudioFoldOutStates.Clear(); foreach (var studio in PlayFabEditorPrefsSO.Instance.StudioList) { if (string.IsNullOrEmpty(studio.Id)) { continue; } if (!StudioFoldOutStates.ContainsKey(studio.Id)) { StudioFoldOutStates.Add(studio.Id, new StudioDisplaySet { Studio = studio }); } foreach (var title in studio.Titles) { if (!StudioFoldOutStates[studio.Id].titleFoldOutStates.ContainsKey(title.Id)) { StudioFoldOutStates[studio.Id].titleFoldOutStates.Add(title.Id, new TitleDisplaySet { Title = title }); } } } } _titleScrollPos = GUILayout.BeginScrollView(_titleScrollPos, PlayFabEditorHelper.uiStyle.GetStyle("gpStyleGray1")); using (new UnityHorizontal(PlayFabEditorHelper.uiStyle.GetStyle("gpStyleClear"))) { EditorGUILayout.LabelField("STUDIOS:", PlayFabEditorHelper.uiStyle.GetStyle("labelStyle"), GUILayout.Width(labelWidth)); GUILayout.FlexibleSpace(); if (GUILayout.Button("REFRESH", PlayFabEditorHelper.uiStyle.GetStyle("Button"))) { PlayFabEditorDataService.RefreshStudiosList(); } } foreach (var studio in StudioFoldOutStates) { var style = new GUIStyle(EditorStyles.foldout); if (studio.Value.isCollapsed) { style.fontStyle = FontStyle.Normal; } studio.Value.isCollapsed = EditorGUI.Foldout(EditorGUILayout.GetControlRect(), studio.Value.isCollapsed, string.Format("{0} ({1})", studio.Value.Studio.Name, studio.Value.Studio.Titles.Length), true, PlayFabEditorHelper.uiStyle.GetStyle("foldOut_std")); if (studio.Value.isCollapsed) { continue; } EditorGUI.indentLevel = 2; using (new UnityHorizontal(PlayFabEditorHelper.uiStyle.GetStyle("gpStyleClear"))) { EditorGUILayout.LabelField("TITLES:", PlayFabEditorHelper.uiStyle.GetStyle("labelStyle"), GUILayout.Width(labelWidth)); } GUILayout.Space(5); // draw title foldouts foreach (var title in studio.Value.titleFoldOutStates) { title.Value.isCollapsed = EditorGUI.Foldout(EditorGUILayout.GetControlRect(), title.Value.isCollapsed, string.Format("{0} [{1}]", title.Value.Title.Name, title.Value.Title.Id), true, PlayFabEditorHelper.uiStyle.GetStyle("foldOut_std")); if (title.Value.isCollapsed) { continue; } EditorGUI.indentLevel = 3; using (new UnityHorizontal(PlayFabEditorHelper.uiStyle.GetStyle("gpStyleClear"))) { EditorGUILayout.LabelField("SECRET KEY:", PlayFabEditorHelper.uiStyle.GetStyle("labelStyle"), GUILayout.Width(labelWidth)); EditorGUILayout.TextField("" + title.Value.Title.SecretKey); } using (new UnityHorizontal(PlayFabEditorHelper.uiStyle.GetStyle("gpStyleClear"))) { EditorGUILayout.LabelField("URL:", PlayFabEditorHelper.uiStyle.GetStyle("labelStyle"), GUILayout.Width(labelWidth)); GUILayout.FlexibleSpace(); if (GUILayout.Button("VIEW IN GAME MANAGER", PlayFabEditorHelper.uiStyle.GetStyle("textButton"))) { Application.OpenURL(title.Value.Title.GameManagerUrl); } GUILayout.FlexibleSpace(); } EditorGUI.indentLevel = 2; } EditorGUI.indentLevel = 0; } GUILayout.EndScrollView(); }