DisplayProgressBar() private method

private DisplayProgressBar ( string title, string info, float progress ) : void
title string
info string
progress float
return void
        internal static bool GenerateMetadataEntityScripts()
        {
            var result   = false;
            var settings = MetadataAssetSettings.Load();

            MetadataAssetSettings.CreateEntityScriptsStoreFolder(settings);

            if (string.IsNullOrEmpty(settings.ExcelWorkbookFilesFolderPath))
            {
                if (UnityEditorUtility.DisplayDialog("Error", "'Excel Workbook Files Folder Path' is not valid path!", "OK"))
                {
                    UnityEditorUtility.ClearProgressBar();
                }
            }
            else
            {
                ForEachExcelFile(settings.ExcelWorkbookFilesFolderPath, (table, fileName, index, length) =>
                {
                    if (table == null)
                    {
                        return;
                    }

                    var info     = $"Generating Metadata Entity Script: {fileName}.cs... {index + 1}/{length}";
                    var progress = (float)(index + 1) / length;
                    UnityEditorUtility.DisplayProgressBar("Hold on...", info, progress);
                    var rawInfoList = CreateMetadataEntityRawInfoList(settings, table);
                    result          = GenerateMetadataEntityScript(settings, fileName, rawInfoList);
                });
            }

            UnityEditorUtility.ClearProgressBar();
            return(result);
        }
        private static void BuildAssets()
        {
            EditorUtility.ClearConsole();

            if (UnityEditorUtility.scriptCompilationFailed)
            {
                return;
            }

            try
            {
                var result = MetadataAssetUtility.GenerateMetadataEntityScripts();
                EditorPrefs.SetBool(ScriptsGeneratedPrefKey, result);

                if (result)
                {
                    UnityEditorUtility.DisplayProgressBar("Hold on...", "Compiling metadata entity scripts...", 0f);
                }
                else
                {
                    if (UnityEditorUtility.DisplayDialog("Error", "Failed to generate metadata entity scripts!", "OK"))
                    {
                        UnityEditorUtility.ClearProgressBar();
                    }
                }
            }
            catch (System.Exception e)
            {
                Debug.LogException(e);
            }
        }
        internal static bool CreateMetadataDatabaseFiles()
        {
            var result   = false;
            var settings = MetadataAssetSettings.Load();

            MetadataAssetSettings.CreateMetadataPersistentStoreFolder(settings);
            DeleteTempDbFiles();

            var dbFolderPath = EditorPath.ConvertToAbsolutePath(settings.MetadataPersistentStorePath);

            ForEachExcelFile(settings.ExcelWorkbookFilesFolderPath, (table, fileName, index, length) =>
            {
                if (table == null)
                {
                    return;
                }

                var entityClassName = fileName.ToTitleCase();
                var info            = $"Creating Database File for Entity {entityClassName}... {index + 1}/{length}";
                var progress        = (float)(index + 1) / length;
                UnityEditorUtility.DisplayProgressBar("Hold on...", info, progress);

                var rawInfoList     = CreateMetadataEntityRawInfoList(settings, table);
                var entityClassType = GetEntityClassType(settings, entityClassName);

                if (entityClassType != null)
                {
                    var entityDataList = CreateEntityDataList(settings, table, entityClassType, rawInfoList);
                    typeof(MetadataAssetUtility).InvokeGenericStaticMethod("InsertEntityData", new[] { entityClassType }, new object[] { dbFolderPath, entityClassName, rawInfoList, entityDataList, index });
                    result = true;
                }
                else
                {
                    UnityDebug.LogErrorFormat(null, "Can not find the entity class: {0}.cs!", entityClassName);
                    result = false;
                }
            });

            // Copy MetadataEntityDBConfig database file.
            if (result)
            {
                CopyDatabaseFile(dbFolderPath, MetadataEntityDBConfig.DatabaseLocalAddress);
            }

            UnityEditorUtility.ClearProgressBar();
            return(result);
        }
Ejemplo n.º 4
0
        private void DrawSetupPhoton()
        {
            DrawInputWithLabel("Photon Cloud Setup", () =>
            {
                GUILayout.BeginVertical();
                GUILayout.Space(5);
                GUILayout.Label(BoltWizardText.PHOTON, textLabel);
                GUILayout.EndVertical();

                GUILayout.BeginHorizontal();
                GUILayout.Label(BoltWizardText.PHOTON_DASH, textLabel);
                if (GUILayout.Button("Visit Dashboard", minimalButton))
                {
                    OpenURL("https://dashboard.photonengine.com/")();
                }

                GUILayout.EndHorizontal();
            }, false);
            GUILayout.Space(15);

            BoltRuntimeSettings settings = BoltRuntimeSettings.instance;

            DrawInputWithLabel("Photon Bolt App ID or Email", () =>
            {
                GUILayout.BeginVertical();

                AppIdOrEmail = EditorGUILayout.TextField(AppIdOrEmail, centerInputText);

                GUILayout.EndVertical();
            }, false, true, 300);

            DrawInputWithLabel("Region",
                               () =>
            {
                settings.photonCloudRegionIndex = EditorGUILayout.Popup(settings.photonCloudRegionIndex,
                                                                        BoltRuntimeSettings.photonCloudRegions);
            }, true, true);

            DrawInputWithLabel("NAT Punchthrough Enabled",
                               () => { settings.photonUsePunch = Toggle(settings.photonUsePunch); }, true, true);

            // Action

            if (beforeNextCallback == null)
            {
                beforeNextCallback = () =>
                {
                    if (requestingAppId)
                    {
                        BoltLog.Info("Please, wait until your request for a new AppID finishes.");
                        return(false);
                    }

                    if (AccountService.IsValidEmail(AppIdOrEmail))
                    {
                        try
                        {
                            EditorUtility.DisplayProgressBar(BoltWizardText.CONNECTION_TITLE,
                                                             BoltWizardText.CONNECTION_INFO, 0.5f);
                            BoltLog.Info("Starting request");

                            requestingAppId = new AccountService().RegisterByEmail(
                                AppIdOrEmail,
                                new List <ServiceTypes>()
                            {
                                ServiceTypes.Bolt
                            },
                                (response) =>
                            {
                                if (response.ReturnCode == AccountServiceReturnCodes.Success)
                                {
                                    var appKey = response.ApplicationIds[((int)ServiceTypes.Bolt).ToString()];

                                    settings.photonAppId = appKey;
                                    AppIdOrEmail         = appKey;

                                    BoltLog.Info("You new App ID: {0}", AppIdOrEmail);
                                }
                                else
                                {
                                    BoltLog.Warn(
                                        "It was not possible to process your request, please go to the Photon Cloud Dashboard.");
                                    BoltLog.Warn("Return Code: {0}",
                                                 AccountServiceReturnCodes.ReturnCodes[response.ReturnCode]);
                                }

                                requestingAppId = false;
                                EditorUtility.ClearProgressBar();
                            }, (err) =>
                            {
                                BoltLog.Error(err);

                                requestingAppId = false;
                                EditorUtility.ClearProgressBar();
                            });

                            if (requestingAppId)
                            {
                                BoltLog.Info("Requesting your new App ID");
                            }
                            else
                            {
                                BoltLog.Warn(
                                    "It was not possible to process your request, please go to the Photon Cloud Dashboard.");
                                EditorUtility.ClearProgressBar();
                            }
                        }
                        catch (Exception ex)
                        {
                            EditorUtility.DisplayDialog("Error", ex.Message, "ok");
                        }
                    }
                    else if (IsAppId(AppIdOrEmail))
                    {
                        settings.photonAppId = AppIdOrEmail;
                        return(true);
                    }
                    else
                    {
                        ShowNotification(new GUIContent("Please specify a valid Photon Bolt App ID or Email."));
                    }

                    return(false);
                };
            }
        }
Ejemplo n.º 5
0
        private void DrawSetupPhoton()
        {
            this.DrawInputWithLabel("Photon Cloud Setup", () =>
            {
                GUILayout.BeginVertical();
                GUILayout.Space(5);
                GUILayout.Label(WizardText.PHOTON, this.textLabelStyle);
                GUILayout.EndVertical();

                GUILayout.Space(5);
                GUILayout.BeginHorizontal();
                GUILayout.Label(WizardText.PHOTON_DASH, this.textLabelStyle);
                if (GUILayout.Button("Visit Dashboard", this.minimalButtonStyle))
                {
                    string mail = (this.inputState == InputState.Email) ? appIdOrEmail : string.Empty;
                    this.OpenURL(EditorIntegration.UrlCloudDashboard + mail)();
                }

                GUILayout.EndHorizontal();
            }, false);
            GUILayout.Space(15);

            this.DrawInputWithLabel("Photon AppID or Email", () =>
            {
                GUILayout.BeginVertical();

                appIdOrEmail = EditorGUILayout.TextField(appIdOrEmail, this.centerInputTextStyle).Trim();   // trimming all input in/of this field

                GUILayout.EndVertical();
            }, false, true, 300);


            // input state check to show dependent info / buttons
            if (AccountService.IsValidEmail(appIdOrEmail))
            {
                this.inputState = InputState.Email;
            }
            else
            {
                this.inputState = AppSettings.IsAppId(appIdOrEmail) ? InputState.Appid : InputState.NotFinished;
            }

            // button to skip setup
            GUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();
            if (GUILayout.Button("Skip", GUILayout.Width(100)))
            {
                this.requestHighlighSettings = true;
                this.setupState = SetupState.Skip;
            }

            // SETUP button
            EditorGUI.BeginDisabledGroup(this.inputState == InputState.NotFinished || requestingAppId);
            if (GUILayout.Button("Setup", GUILayout.Width(100)))
            {
                this.requestHighlighSettings = true;
                GUIUtility.keyboardControl   = 0;
                if (this.inputState == InputState.Email && !requestingAppId)
                {
                    requestingAppId = new AccountService().RegisterByEmail(appIdOrEmail, new List <ServiceTypes>()
                    {
                        ServiceTypes.Realtime
                    }, SuccessCallback, ErrorCallback, this.originAssetVersion);
                    if (requestingAppId)
                    {
                        EditorUtility.DisplayProgressBar(WizardText.CONNECTION_TITLE, WizardText.CONNECTION_INFO, 0.5f);
                        this.setupState = SetupState.SendingEmail;
                    }
                }
                else if (this.inputState == InputState.Appid)
                {
                    this.setupState = SetupState.AppIdApplied;

                    // Save App ID
                    AppSettingsInstance.AppIdRealtime = appIdOrEmail;
                }
            }
            EditorGUI.EndDisabledGroup();
            GUILayout.FlexibleSpace();
            GUILayout.EndHorizontal();

            GUILayout.Space(10);

            switch (this.setupState)
            {
            case SetupState.RegisteredSuccessful:
                GUILayout.Label(WizardText.RegisteredNewAccountInfo, this.textLabelStyle);
                GUILayout.Label(WizardText.SetupCompleteInfo, this.textLabelStyle);
                this.HighlightSettings();
                break;

            case SetupState.AppIdApplied:
                GUILayout.Label(WizardText.AppliedToSettingsInfo, this.textLabelStyle);
                GUILayout.Label(WizardText.SetupCompleteInfo, this.textLabelStyle);
                this.HighlightSettings();
                break;

            case SetupState.AlreadyRegistered:
                GUILayout.Label(WizardText.AlreadyRegisteredInfo, this.textLabelStyle);
                this.HighlightSettings();
                break;

            case SetupState.RegistrationError:
                GUILayout.Label(WizardText.RegistrationError, this.textLabelStyle);
                this.HighlightSettings();
                break;

            case SetupState.Skip:
                GUILayout.Label(WizardText.SkipRegistrationInfo, this.textLabelStyle);
                this.HighlightSettings();
                break;
            }
        }
Ejemplo n.º 6
0
 public static void DisplayAOTProgressBar(int totalFiles, int filesFinished)
 {
     EditorUtility.DisplayProgressBar("Building Player", string.Format("AOT cross compile ({0}/{1})", (object)(filesFinished + 1).ToString(), (object)totalFiles.ToString()), 0.95f);
 }
Ejemplo n.º 7
0
 public void DisplayProgressBar(string title, string content, float progress)
 {
     EditorUtility.DisplayProgressBar(title, content, progress);
 }
Ejemplo n.º 8
0
 private void DoApply(SerializedObject so)
 {
     if (this.multipleSprites)
     {
         List <string>      list  = new List <string>();
         List <string>      list2 = new List <string>();
         SerializedProperty serializedProperty = so.FindProperty("m_SpriteSheet.m_Sprites");
         for (int i = 0; i < this.m_RectsCache.Count; i++)
         {
             SpriteRect spriteRect = this.m_RectsCache.RectAt(i);
             if (string.IsNullOrEmpty(spriteRect.name))
             {
                 spriteRect.name = "Empty";
             }
             if (!string.IsNullOrEmpty(spriteRect.originalName))
             {
                 list.Add(spriteRect.originalName);
                 list2.Add(spriteRect.name);
             }
             if (serializedProperty.arraySize < this.m_RectsCache.Count)
             {
                 serializedProperty.InsertArrayElementAtIndex(serializedProperty.arraySize);
             }
             SerializedProperty arrayElementAtIndex = serializedProperty.GetArrayElementAtIndex(i);
             spriteRect.ApplyToSerializedProperty(arrayElementAtIndex);
             EditorUtility.DisplayProgressBar(SpriteEditorWindow.SpriteEditorWindowStyles.saveProgressTitle.text, string.Format(SpriteEditorWindow.SpriteEditorWindowStyles.saveContentText.text, i, this.m_RectsCache.Count), (float)i / (float)this.m_RectsCache.Count);
         }
         while (this.m_RectsCache.Count < serializedProperty.arraySize)
         {
             serializedProperty.DeleteArrayElementAtIndex(this.m_RectsCache.Count);
         }
         if (list.Count > 0)
         {
             PatchImportSettingRecycleID.PatchMultiple(so, 213, list.ToArray(), list2.ToArray());
         }
     }
     else if (this.m_RectsCache.Count > 0)
     {
         SpriteRect spriteRect2 = this.m_RectsCache.RectAt(0);
         so.FindProperty("m_Alignment").intValue                  = (int)spriteRect2.alignment;
         so.FindProperty("m_SpriteBorder").vector4Value           = spriteRect2.border;
         so.FindProperty("m_SpritePivot").vector2Value            = spriteRect2.pivot;
         so.FindProperty("m_SpriteTessellationDetail").floatValue = spriteRect2.tessellationDetail;
         SerializedProperty serializedProperty2 = so.FindProperty("m_SpriteSheet.m_Outline");
         if (spriteRect2.outline != null)
         {
             SpriteRect.ApplyOutlineChanges(serializedProperty2, spriteRect2.outline);
         }
         else
         {
             serializedProperty2.ClearArray();
         }
         SerializedProperty serializedProperty3 = so.FindProperty("m_SpriteSheet.m_PhysicsShape");
         if (spriteRect2.physicsShape != null)
         {
             SpriteRect.ApplyOutlineChanges(serializedProperty3, spriteRect2.physicsShape);
         }
         else
         {
             serializedProperty3.ClearArray();
         }
     }
     EditorUtility.ClearProgressBar();
 }