DisplayDialog() private method

private DisplayDialog ( string title, string message, string ok ) : bool
title string
message string
ok string
return bool
示例#1
0
        private void DrawSupport()
        {
            DrawInputWithLabel("Bolt Support", () =>
            {
                GUILayout.BeginVertical();
                GUILayout.Space(5);
                GUILayout.Label(BoltWizardText.SUPPORT, textLabel);
                GUILayout.EndVertical();
            }, false);
            GUILayout.Space(15);

            DrawStepOption(discordIcon, discordHeader, discordText,
                           callback: OpenURL("https://discord.gg/0ya6ZpOvnShSCtbb"));
            DrawStepOption(bugtrackerIcon, bugtrackerHeader, bugtrackerText,
                           callback: OpenURL("https://github.com/BoltEngine/Bolt-Tracker"));
            DrawStepOption(documentationIcon, documentationHeader, documentationText,
                           callback: OpenURL("https://doc.photonengine.com/en-us/bolt/current/setup/overview"));
            DrawStepOption(reviewIcon, reviewHeader, reviewText,
                           callback: OpenURL("https://assetstore.unity.com/packages/tools/network/photon-bolt-free-127156"));

            // Action

            if (beforeNextCallback == null)
            {
                beforeNextCallback = () =>
                {
                    RunCompiler = EditorUtility.DisplayDialog(BoltWizardText.FINISH_TITLE, BoltWizardText.FINISH_QUESTION,
                                                              "Yes", "No");
                    return(true);
                };
            }
        }
        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);
            }
        }
示例#3
0
        void Install(BoltPackage package)
        {
            string       packageName = package.name;
            PackageFlags flags       = package.packageFlags;

            if ((flags & PackageFlags.WarnForProjectOverwrite) == PackageFlags.WarnForProjectOverwrite)
            {
                if (ProjectExists())
                {
                    if (EditorUtility.DisplayDialog("Warning",
                                                    "Importing this package will overwrite the existing bolt project file that contains all your states, events, etc. Are you sure?",
                                                    "Yes", "No") == false)
                    {
                        return;
                    }
                }
            }

            if ((flags & PackageFlags.RunInitialSetup) == PackageFlags.RunInitialSetup)
            {
                InitialSetup();
            }

            AssetDatabase.ImportPackage(PackagePath(packageName), false);

            currentStage = BoltSetupStage.Bolt;
        }
        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);
        }
示例#5
0
        private void DrawSupport()
        {
            this.DrawInputWithLabel("Support", () =>
            {
                GUILayout.BeginVertical();
                GUILayout.Space(5);
                GUILayout.Label(WizardText.SUPPORT, this.textLabelStyle);
                GUILayout.EndVertical();
            }, false);

            GUILayout.Space(15);

            this.DrawStepOption(this.discordIcon, WizardText.DISCORD_HEADER, WizardText.DISCORD_TEXT, callback: this.OpenURL(EditorIntegration.UrlDiscordGeneral));
            this.DrawStepOption(this.documentationIcon, WizardText.DOCUMENTATION_HEADER, WizardText.DOCUMENTATION_TEXT, callback: this.OpenURL(EditorIntegration.UrlRealtimeDocsOnline));

            // Action

            if (this.beforeNextCallback == null)
            {
                this.beforeNextCallback = () =>
                {
                    return(EditorUtility.DisplayDialog(WizardText.FINISH_TITLE, WizardText.FINISH_QUESTION, "Yes", "No"));
                };
            }
        }
示例#6
0
            /// <summary>
            /// Display Dialog to remove a scene from build settings (or just disable it)
            /// </summary>
            static public void RemoveBuildScene(BuildScene buildScene, bool force = false)
            {
                bool onlyDisable = false;

                if (force == false)
                {
                    int selection = -1;

                    string title   = "Remove Scene From Build";
                    string details = string.Format("You are about to remove the following scene from build settings:\n    {0}\n    buildIndex: {1}\n\n{2}",
                                                   buildScene.assetPath, buildScene.buildIndex,
                                                   "This will modify build settings, but the scene asset will remain untouched.");
                    string confirm = "Remove From Build";
                    string alt     = "Just Disable";
                    string cancel  = "Cancel (do nothing)";

                    if (buildScene.scene.enabled)
                    {
                        details  += "\n\nIf you want, you can also just disable it instead.";
                        selection = EditorUtility.DisplayDialogComplex(title, details, confirm, alt, cancel);
                    }
                    else
                    {
                        selection = EditorUtility.DisplayDialog(title, details, confirm, cancel) ? 0 : 2;
                    }

                    switch (selection)
                    {
                    case 0:                     // remove
                        break;

                    case 1:                     // disable
                        onlyDisable = true;
                        break;

                    default:
                    case 2:                     // cancel
                        return;
                    }
                }

                // User chose to not remove, only disable the scene
                if (onlyDisable)
                {
                    SetBuildSceneState(buildScene, false);
                }
                // User chose to fully remove the scene from build settings
                else
                {
                    List <EditorBuildSettingsScene> tempScenes = EditorBuildSettings.scenes.ToList();
                    tempScenes.RemoveAll(scene => scene.guid.Equals(buildScene.assetGUID));
                    EditorBuildSettings.scenes = tempScenes.ToArray();
                }
            }
示例#7
0
        private void OnDestroy()
        {
            if (EditorPrefs.GetBool(FirstStartupKey, false) == false)
            {
                if (!EditorUtility.DisplayDialog(WizardText.CLOSE_MSG_TITLE, WizardText.CLOSE_MSG_QUESTION, "Yes", "Back"))
                {
                    EditorApplication.update += ReOpen;
                }
            }

            ready = false;
        }
示例#8
0
        public static void Create(ConektonUtilityConstant.PlatformType type)
        {
            (string folderName, string linkFolderName) = GetFolderNames(type);

            if (Directory.Exists(folderName))
            {
                return;
            }

            if (!Directory.Exists(linkFolderName))
            {
                UEditorUtility.DisplayDialog("Target SDK folder is not found", "Please it locate under this project folder (not under the Assets folder).", "OK", "");
                Debug.LogWarning("This editor script will make a symbolic link of the target SDK folder under the Assets folder. Please put the target SDK folder under this project folder directly.");
                return;
            }

            switch (type)
            {
            case ConektonUtilityConstant.PlatformType.Nreal:
                RemoveSDKFolder(ConektonUtilityConstant.PlatformType.Oculus);
                break;

            case ConektonUtilityConstant.PlatformType.Oculus:
                RemoveSDKFolder(ConektonUtilityConstant.PlatformType.Nreal);
                break;
            }

            Process proc = new Process();

#if UNITY_EDITOR_WIN
            proc.StartInfo.FileName  = System.Environment.GetEnvironmentVariable("ComSpec");
            proc.StartInfo.Arguments = $"/c mklink /D \"{folderName}\" \"{linkFolderName}\"";
            proc.StartInfo.Verb      = "RunAs";
            proc.Start();
#else
            proc.StartInfo.FileName               = System.Environment.GetEnvironmentVariable("SHELL");
            proc.StartInfo.UseShellExecute        = false;
            proc.StartInfo.RedirectStandardInput  = true;
            proc.StartInfo.RedirectStandardOutput = true;
            proc.StartInfo.Verb = "RunAs";
            proc.Start();
            proc.StandardInput.WriteLine($"ln -s \"{linkFolderName}\" \"{folderName}\"");
            proc.StandardInput.WriteLine("exit");
            proc.StandardInput.Flush();
#endif
            proc.WaitForExit();
            proc.Close();

            AssetDatabase.Refresh();
        }
        private static void OnScriptsReloaded()
        {
            var scriptsGenerated = EditorPrefs.GetBool(ScriptsGeneratedPrefKey);

            if (!scriptsGenerated)
            {
                return;
            }

            UnityEditorUtility.ClearProgressBar();
            EditorPrefs.SetBool(ScriptsGeneratedPrefKey, false);

            if (!UnityEditorUtility.scriptCompilationFailed)
            {
                try
                {
                    var result = MetadataAssetUtility.CreateMetadataDatabaseFiles();

                    if (result)
                    {
                        if (UnityEditorUtility.DisplayDialog("Success", "Build success!", "OK"))
                        {
                            UnityEditorUtility.ClearProgressBar();
                        }
                    }
                    else
                    {
                        if (UnityEditorUtility.DisplayDialog("Error", "Failed to create metadata database files!", "OK"))
                        {
                            UnityEditorUtility.ClearProgressBar();
                        }
                    }
                }
                catch (System.Exception e)
                {
                    Debug.LogException(e);
                }
            }
            else
            {
                if (UnityEditorUtility.DisplayDialog("Error", "Failed to compile metadata entity scripts!", "OK"))
                {
                    UnityEditorUtility.ClearProgressBar();
                }
            }
        }
示例#10
0
        static void CacheServerVersion1GUI(bool allowCacheServerChanges, string overrideAddress)
        {
            GUILayout.Label(Properties.assetPipelineVersion1, EditorStyles.boldLabel);

            GUILayout.Space(5);

            if (!allowCacheServerChanges)
            {
                EditorGUILayout.HelpBox("Cache Server preferences cannot be modified because a remote address was specified via command line argument. To modify Cache Server preferences, restart Unity without the " + kIpAddressKeyArgs + " command line argument.", MessageType.Info, true);
            }

            using (new EditorGUI.DisabledScope(!allowCacheServerChanges))
            {
                var displayMode = !allowCacheServerChanges ? CacheServerMode.Remote : s_CacheServerMode;
                s_CacheServerMode = (CacheServerMode)EditorGUILayout.EnumPopup("Cache Server Mode", displayMode);
            }

            if (s_CacheServerMode == CacheServerMode.Remote)
            {
                using (new EditorGUI.DisabledScope(!allowCacheServerChanges))
                {
                    var displayAddress = overrideAddress != null ? overrideAddress : s_CacheServerIPAddress;
                    s_CacheServerIPAddress = EditorGUILayout.TextField("IP Address", displayAddress);

                    if (GUI.changed)
                    {
                        s_ConnectionState = ConnectionState.Unknown;
                    }
                }

                GUILayout.Space(5);

                using (new EditorGUI.DisabledScope(AssetDatabase.IsV2Enabled()))
                {
                    if (GUILayout.Button("Check Connection", GUILayout.Width(150)))
                    {
                        if (InternalEditorUtility.CanConnectToCacheServer())
                        {
                            s_ConnectionState = ConnectionState.Success;
                        }
                        else
                        {
                            s_ConnectionState = ConnectionState.Failure;
                        }
                    }
                }

                GUILayout.Space(-25);

                var s = AssetDatabase.IsV1Enabled() ? s_ConnectionState : ConnectionState.Unknown;

                switch (s)
                {
                case ConnectionState.Success:
                    EditorGUILayout.HelpBox("Connection successful.", MessageType.Info, false);
                    break;

                case ConnectionState.Failure:
                    EditorGUILayout.HelpBox("Connection failed.", MessageType.Warning, false);
                    break;

                case ConnectionState.Unknown:
                    GUILayout.Space(44);
                    break;
                }
            }
            else if (s_CacheServerMode == CacheServerMode.Local)
            {
                const int kMinSizeInGigabytes = 1;
                const int kMaxSizeInGigabytes = 200;

                // Write size in GigaBytes.
                s_LocalCacheServerSize = EditorGUILayout.IntSlider(Properties.maxCacheSize, s_LocalCacheServerSize, kMinSizeInGigabytes, kMaxSizeInGigabytes);

                s_EnableCustomPath = EditorGUILayout.Toggle(Properties.customCacheLocation, s_EnableCustomPath);
                // browse for cache folder if not per project
                if (s_EnableCustomPath)
                {
                    GUIStyle style = EditorStyles.miniButton;
                    GUILayout.BeginHorizontal();
                    EditorGUILayout.PrefixLabel(Properties.cacheFolderLocation, style);
                    Rect       r       = GUILayoutUtility.GetRect(GUIContent.none, style);
                    GUIContent guiText = string.IsNullOrEmpty(s_CachePath) ? Properties.browse : new GUIContent(s_CachePath);
                    if (EditorGUI.DropdownButton(r, guiText, FocusType.Passive, style))
                    {
                        string pathToOpen = s_CachePath;
                        string path       = EditorUtility.OpenFolderPanel(Properties.browseCacheLocation.text, pathToOpen, "");
                        if (!string.IsNullOrEmpty(path))
                        {
                            if (LocalCacheServer.CheckValidCacheLocation(path))
                            {
                                s_CachePath = path;
                                WritePreferences();
                            }
                            else
                            {
                                EditorUtility.DisplayDialog("Invalid Cache Location", string.Format("The directory {0} contains some files which don't look like Unity Cache server files. Please delete the directory contents or choose another directory.", path), "OK");
                            }
                            EditorGUIUtility.ExitGUI();
                        }
                    }
                    GUILayout.EndHorizontal();
                }
                else
                {
                    s_CachePath = "";
                }

                bool locationExists = LocalCacheServer.CheckCacheLocationExists();
                if (locationExists == true)
                {
                    GUIContent cacheSizeIs = EditorGUIUtility.TrTextContent("Cache size is unknown");
                    if (s_LocalCacheServerUsedSize != -1)
                    {
                        cacheSizeIs = EditorGUIUtility.TextContent("Cache size is " + EditorUtility.FormatBytes(s_LocalCacheServerUsedSize));
                    }

                    GUILayout.BeginHorizontal();
                    GUIStyle style = EditorStyles.miniButton;
                    EditorGUILayout.PrefixLabel(cacheSizeIs, style);
                    Rect r = GUILayoutUtility.GetRect(GUIContent.none, style);
                    if (EditorGUI.Button(r, Properties.enumerateCache, style))
                    {
                        s_LocalCacheServerUsedSize = LocalCacheServer.CheckCacheLocationExists() ? FileUtil.GetDirectorySize(LocalCacheServer.GetCacheLocation()) : 0;
                    }
                    GUILayout.EndHorizontal();

                    GUILayout.BeginHorizontal();
                    GUIContent spacerContent = EditorGUIUtility.blankContent;
                    EditorGUILayout.PrefixLabel(spacerContent, style);
                    Rect r2 = GUILayoutUtility.GetRect(GUIContent.none, style);
                    if (EditorGUI.Button(r2, Properties.cleanCache, style))
                    {
                        LocalCacheServer.Clear();
                        s_LocalCacheServerUsedSize = 0;
                    }
                    GUILayout.EndHorizontal();
                }
                else
                {
                    EditorGUILayout.HelpBox("Local cache directory does not exist - please check that you can access the cache folder and are able to write to it", MessageType.Warning, false);
                    //If the cache server was on an external HDD or on a temporarily unavailable network drive, set the size to unknown so that the user re-queries it when they've reconnected
                    s_LocalCacheServerUsedSize = -1;
                }

                GUILayout.Label(Properties.cacheFolderLocation.text + ":");
                GUILayout.Label(LocalCacheServer.GetCacheLocation(), Styles.cacheFolderLocation);
            }
        }
示例#11
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);
                };
            }
        }
示例#12
0
        // Deletes the assets of the instance IDs, with an optional user confirmation dialog.
        // Returns true if the delete operation was successfully performed on all assets.
        // Note: Zero input assets always returns true.
        // Also note that the operation cannot be undone even if some operations failed.
        internal static bool DeleteAssets(List <int> instanceIDs, bool askIfSure)
        {
            if (instanceIDs.Count == 0)
            {
                return(true);
            }

            bool foundAssetsFolder = instanceIDs.IndexOf(AssetDatabase.GetMainAssetOrInProgressProxyInstanceID("Assets")) >= 0;

            if (foundAssetsFolder)
            {
                string title = "Cannot Delete";
                EditorUtility.DisplayDialog(title, "Deleting the 'Assets' folder is not allowed", "Ok");
                return(false);
            }

            var paths = GetMainPathsOfAssets(instanceIDs).ToList();

            if (paths.Count == 0)
            {
                return(false);
            }

            if (askIfSure)
            {
                string title = "Delete selected asset";
                if (paths.Count > 1)
                {
                    title = title + "s";
                }
                title = title + "?";

                int    maxCount = 3;
                string infotext = "";
                for (int i = 0; i < paths.Count && i < maxCount; ++i)
                {
                    infotext += "   " + paths[i] + "\n";
                }
                if (paths.Count > maxCount)
                {
                    infotext += "   ...\n";
                }
                infotext += "\nYou cannot undo this action.";
                if (!EditorUtility.DisplayDialog(title, infotext, "Delete", "Cancel"))
                {
                    return(false);
                }
            }

            bool success = true;

            AssetDatabase.StartAssetEditing();
            foreach (string path in paths)
            {
                if (!AssetDatabase.MoveAssetToTrash(path))
                {
                    success = false;
                }
            }
            AssetDatabase.StopAssetEditing();

            return(success);
        }
示例#13
0
        /**
         * Initiate a purchase of the selected package from the asset store.
         * The package will be the one that contains the currently selected asset.
         *
         * Since not all users may have allowed for single click purchases this can result
         * in two scenarios:
         * 1. single click allowed and a native purchase acknowledgement dialog appears to
         *    finalize the purchase.
         * 2. single click is not allowed and the package is put to an asset store basket.
         *    Then the asset store window is displayed with the basket open.
         */
        void InitiateBuySelected(bool firstAttempt)
        {
            //Debug.Log("payavail " + paymentAvailability.ToString());
            // Ask the asset store if the use has allowed single click payments
            AssetStoreAsset asset = AssetStoreAssetSelection.GetFirstAsset();

            if (asset == null)
            {
                EditorUtility.DisplayDialog("No asset selected", "Please select asset before buying a package", "ok");
            }
            else if (paymentAvailability == PaymentAvailability.AnonymousUser)
            {
                // Maybe the asset store window did a login already and we have a session key
                // then we just need to fetch the new info
                if (AssetStoreClient.LoggedIn())
                {
                    AssetStoreAssetSelection.RefreshFromServer(delegate() {
                        InitiateBuySelected(false);
                    });
                }
                else if (firstAttempt)
                {
                    LoginAndInitiateBuySelected();
                }
            }
            else if (paymentAvailability == PaymentAvailability.ServiceDisabled)
            {
                // Use the asset store window to complete the purchase since single click is not possible
                if (asset.previewInfo == null)
                {
                    return;
                }
                AssetStore.Open(string.Format("content/{0}/directpurchase", asset.packageID));
            }
            else if (paymentAvailability == PaymentAvailability.BasketNotEmpty)
            {
                // Use the asset store window to complete the purchase since there is already \
                // something in the users basket
                if (asset.previewInfo == null)
                {
                    return;
                }

                // Maybe the basket has been emptied and this is a retry by the user
                if (firstAttempt)
                {
                    AssetStoreAssetSelection.RefreshFromServer(delegate() {
                        InitiateBuySelected(false);
                    });
                }
                else
                {
                    AssetStore.Open(string.Format("content/{0}/basketpurchase", asset.packageID));
                }
            }
            else
            {
                // Show single click window
                AssetStoreInstaBuyWindow.ShowAssetStoreInstaBuyWindow(asset,
                                                                      AssetStoreAssetInspector.s_PurchaseMessage,
                                                                      AssetStoreAssetInspector.s_PaymentMethodCard,
                                                                      AssetStoreAssetInspector.s_PaymentMethodExpire,
                                                                      AssetStoreAssetInspector.s_PriceText
                                                                      );
            }
        }
        static public void LaunchOnTargets(BuildTargetGroup targetGroup, BuildTarget buildTarget, Build.Reporting.BuildReport buildReport, List <DeploymentTargetId> launchTargets)
        {
            try
            {
                // Early out so as not to show/update progressbars unnecessarily
                if (buildReport == null)
                {
                    throw new System.NotSupportedException();
                }

                ProgressHandler progressHandler = new ProgressHandler("Deploying Player",
                                                                      delegate(string title, string message, float globalProgress)
                {
                    if (EditorUtility.DisplayCancelableProgressBar(title, message, globalProgress))
                    {
                        throw new DeploymentOperationAbortedException();
                    }
                }, 0.1f);         // BuildPlayer.cpp starts off at 0.1f for some reason

                var taskManager = new ProgressTaskManager(progressHandler);

                // Launch on all selected targets
                taskManager.AddTask(() =>
                {
                    int successfulLaunches = 0;
                    var exceptions         = new List <DeploymentOperationFailedException>();
                    foreach (var target in launchTargets)
                    {
                        try
                        {
                            var manager         = DeploymentTargetManager.CreateInstance(targetGroup, buildReport.summary.platform);
                            var buildProperties = BuildProperties.GetFromBuildReport(buildReport);
                            manager.LaunchBuildOnTarget(buildProperties, target, taskManager.SpawnProgressHandlerFromCurrentTask());
                            successfulLaunches++;
                        }
                        catch (DeploymentOperationFailedException e)
                        {
                            exceptions.Add(e);
                        }
                    }

                    foreach (var e in exceptions)
                    {
                        UnityEngine.Debug.LogException(e);
                    }

                    if (successfulLaunches == 0)
                    {
                        // TODO: Maybe more specifically no compatible targets?
                        throw new NoTargetsFoundException("Could not launch build");
                    }
                });

                taskManager.Run();
            }
            catch (DeploymentOperationFailedException e)
            {
                UnityEngine.Debug.LogException(e);
                EditorUtility.DisplayDialog(e.title, e.Message, "Ok");
            }
            catch (DeploymentOperationAbortedException)
            {
                System.Console.WriteLine("Deployment aborted");
            }
            catch (NoTargetsFoundException)
            {
                throw new UnityException(string.Format("Could not find any valid targets to launch on for {0}", buildTarget));
            }
        }
        protected override DragAndDropVisualMode HandleDragAndDrop(DragAndDropArgs args)
        {
            // Check if we can handle the current drag data (could be dragged in from other areas/windows in the editor)
            var draggedRows = DragAndDrop.GetGenericData(k_DragId) as List <int>;

            if (draggedRows == null || args.dragAndDropPosition != DragAndDropPosition.BetweenItems)
            {
                return(DragAndDropVisualMode.None);
            }

            if (args.performDrop)
            {
                if (m_Positions.hasMultipleDifferentValues)
                {
                    if (!EditorUtility.DisplayDialog(L10n.Tr("Moving an array element will copy the complete array to all other selected objects."),
                                                     L10n.Tr("Unique values in the different selected objects will be lost"),
                                                     L10n.Tr("OK"),
                                                     L10n.Tr("Cancel")))
                    {
                        return(DragAndDropVisualMode.Rejected);
                    }
                }

                int arraySize = GetArraySize();
                var newList   = new List <Vector3>(arraySize);
                draggedRows.Sort();

                int nextDragItem = 0;
                for (int i = 0; i < arraySize; ++i)
                {
                    if (i == args.insertAtIndex)
                    {
                        // Insert the items here
                        foreach (var viewItem in draggedRows)
                        {
                            newList.Add(m_Positions.GetArrayElementAtIndex(viewItem).vector3Value);
                        }
                    }

                    if (i == draggedRows[nextDragItem])
                    {
                        // Ignore this item, it is being moved
                        nextDragItem++;
                        if (nextDragItem >= draggedRows.Count)
                        {
                            nextDragItem = 0;
                        }
                    }
                    else
                    {
                        newList.Add(m_Positions.GetArrayElementAtIndex(i).vector3Value);
                    }
                }

                // Add to the end?
                if (args.insertAtIndex == arraySize)
                {
                    foreach (var viewItem in draggedRows)
                    {
                        newList.Add(m_Positions.GetArrayElementAtIndex(viewItem).vector3Value);
                    }
                }

                // Copy the list back
                for (int i = 0; i < arraySize; ++i)
                {
                    m_Positions.GetArrayElementAtIndex(i).vector3Value = newList[i];
                }

                SetSelection(Enumerable.Range(args.insertAtIndex - draggedRows.Count(o => o < args.insertAtIndex), draggedRows.Count).ToList());
            }
            return(DragAndDropVisualMode.Move);
        }
        public override void OnInspectorGUI()
        {
            if (m_EditorUserSettings != null && !m_EditorUserSettings.targetObject)
            {
                LoadEditorUserSettings();
            }

            serializedObject.Update();

            // GUI.enabled hack because we don't want some controls to be disabled if the EditorSettings.asset is locked
            // since some of the controls are not dependent on the Editor Settings asset. Unfortunately, this assumes
            // that the editor will only be disabled because of version control locking which may change in the future.
            var editorEnabled = GUI.enabled;

            ShowUnityRemoteGUI(editorEnabled);

            GUILayout.Space(10);
            bool collabEnabled = Collab.instance.IsCollabEnabledForCurrentProject();
            using (new EditorGUI.DisabledScope(!collabEnabled))
            {
                GUI.enabled = !collabEnabled;
                GUILayout.Label(Content.versionControl, EditorStyles.boldLabel);

                ExternalVersionControl selvc = EditorSettings.externalVersionControl;
                CreatePopupMenuVersionControl(Content.mode.text, vcPopupList, selvc, SetVersionControlSystem);
                GUI.enabled = editorEnabled && !collabEnabled;
            }
            if (collabEnabled)
            {
                EditorGUILayout.HelpBox("Version Control not available when using Collaboration feature.", MessageType.Warning);
            }

            if (VersionControlSystemHasGUI())
            {
                GUI.enabled = true;
                bool hasRequiredFields = false;

                if (EditorSettings.externalVersionControl == ExternalVersionControl.Generic ||
                    EditorSettings.externalVersionControl == ExternalVersionControl.Disabled)
                {
                    // no specific UI for these VCS types
                }
                else
                {
                    ConfigField[] configFields = Provider.GetActiveConfigFields();

                    hasRequiredFields = true;

                    foreach (ConfigField field in configFields)
                    {
                        string newVal;
                        string oldVal = EditorUserSettings.GetConfigValue(field.name);
                        if (field.isPassword)
                        {
                            newVal = EditorGUILayout.PasswordField(field.label, oldVal);
                            if (newVal != oldVal)
                                EditorUserSettings.SetPrivateConfigValue(field.name, newVal);
                        }
                        else
                        {
                            newVal = EditorGUILayout.TextField(field.label, oldVal);
                            if (newVal != oldVal)
                                EditorUserSettings.SetConfigValue(field.name, newVal);
                        }

                        if (field.isRequired && string.IsNullOrEmpty(newVal))
                            hasRequiredFields = false;
                    }
                }

                // Log level popup
                string logLevel = EditorUserSettings.GetConfigValue("vcSharedLogLevel");
                int idx = System.Array.FindIndex(logLevelPopupList, (item) => item.ToLower() == logLevel);
                if (idx == -1)
                {
                    logLevel = "notice";
                    idx = System.Array.FindIndex(logLevelPopupList, (item) => item.ToLower() == logLevel);
                    if (idx == -1)
                    {
                        idx = 0;
                    }
                    logLevel = logLevelPopupList[idx];
                    EditorUserSettings.SetConfigValue("vcSharedLogLevel", logLevel);
                }
                int newIdx = EditorGUILayout.Popup(Content.logLevel, idx, logLevelPopupList);
                if (newIdx != idx)
                {
                    EditorUserSettings.SetConfigValue("vcSharedLogLevel", logLevelPopupList[newIdx].ToLower());
                }

                GUI.enabled = editorEnabled;

                string osState = "Connected";
                if (Provider.onlineState == OnlineState.Updating)
                    osState = "Connecting...";
                else if (Provider.onlineState == OnlineState.Offline)
                    osState = "Disconnected";
                else if (EditorUserSettings.WorkOffline)
                    osState = "Work Offline";

                EditorGUILayout.LabelField(Content.status.text, osState);

                if (Provider.onlineState != OnlineState.Online && !string.IsNullOrEmpty(Provider.offlineReason))
                {
                    GUI.enabled = false;
                    GUILayout.TextArea(Provider.offlineReason);
                    GUI.enabled = editorEnabled;
                }

                GUILayout.BeginHorizontal();
                GUILayout.FlexibleSpace();
                GUI.enabled = hasRequiredFields && Provider.onlineState != OnlineState.Updating;
                if (GUILayout.Button("Connect", EditorStyles.miniButton))
                    Provider.UpdateSettings();
                GUILayout.EndHorizontal();

                EditorUserSettings.AutomaticAdd = EditorGUILayout.Toggle(Content.automaticAdd, EditorUserSettings.AutomaticAdd);

                if (Provider.requiresNetwork)
                {
                    bool workOfflineNew = EditorGUILayout.Toggle(Content.workOffline, EditorUserSettings.WorkOffline); // Enabled has a slightly different behaviour
                    if (workOfflineNew != EditorUserSettings.WorkOffline)
                    {
                        // On toggling on show a warning
                        if (workOfflineNew && !EditorUtility.DisplayDialog("Confirm working offline", "Working offline and making changes to your assets means that you will have to manually integrate changes back into version control using your standard version control client before you stop working offline in Unity. Make sure you know what you are doing.", "Work offline", "Cancel"))
                        {
                            workOfflineNew = false; // User cancelled working offline
                        }
                        EditorUserSettings.WorkOffline = workOfflineNew;
                        EditorApplication.RequestRepaintAllViews();
                    }

                    EditorUserSettings.allowAsyncStatusUpdate = EditorGUILayout.Toggle(Content.allowAsyncUpdate, EditorUserSettings.allowAsyncStatusUpdate);
                }

                if (Provider.hasCheckoutSupport)
                {
                    EditorUserSettings.showFailedCheckout = EditorGUILayout.Toggle(Content.showFailedCheckouts, EditorUserSettings.showFailedCheckout);
                    EditorUserSettings.overwriteFailedCheckoutAssets = EditorGUILayout.Toggle(Content.overwriteFailedCheckoutAssets, EditorUserSettings.overwriteFailedCheckoutAssets);
                }

                var newOverlayIcons = EditorGUILayout.Toggle(Content.overlayIcons, EditorUserSettings.overlayIcons);
                if (newOverlayIcons != EditorUserSettings.overlayIcons)
                {
                    EditorUserSettings.overlayIcons = newOverlayIcons;
                    EditorApplication.RequestRepaintAllViews();
                }

                GUI.enabled = editorEnabled;

                // Semantic merge popup
                EditorUserSettings.semanticMergeMode = (SemanticMergeMode)EditorGUILayout.Popup(Content.smartMerge, (int)EditorUserSettings.semanticMergeMode, semanticMergePopupList);

                DrawOverlayDescriptions();
            }

            GUILayout.Space(10);

            int index = (int)EditorSettings.serializationMode;
            using (new EditorGUI.DisabledScope(!collabEnabled))
            {
                GUI.enabled = !collabEnabled;
                GUILayout.Label(Content.assetSerialization, EditorStyles.boldLabel);
                GUI.enabled = editorEnabled && !collabEnabled;


                CreatePopupMenu("Mode", serializationPopupList, index, SetAssetSerializationMode);
            }
            if (collabEnabled)
            {
                EditorGUILayout.HelpBox("Asset Serialization is forced to Text when using Collaboration feature.", MessageType.Warning);
            }

            GUILayout.Space(10);

            GUI.enabled = true;
            GUILayout.Label(Content.defaultBehaviorMode, EditorStyles.boldLabel);
            GUI.enabled = editorEnabled;

            index = Mathf.Clamp((int)EditorSettings.defaultBehaviorMode, 0, behaviorPopupList.Length - 1);
            CreatePopupMenu(Content.mode.text, behaviorPopupList, index, SetDefaultBehaviorMode);

            {
                var wasEnabled = GUI.enabled;
                GUI.enabled = true;

                DoAssetPipelineSettings();

                if (m_AssetPipelineMode.intValue == (int)AssetPipelineMode.Version2)
                    DoCacheServerSettings();

                GUI.enabled = wasEnabled;
            }
            GUILayout.Space(10);

            GUI.enabled = true;
            GUILayout.Label("Prefab Editing Environments", EditorStyles.boldLabel);
            GUI.enabled = editorEnabled;

            {
                EditorGUI.BeginChangeCheck();
                SceneAsset scene = EditorSettings.prefabRegularEnvironment;
                scene = (SceneAsset)EditorGUILayout.ObjectField("Regular Environment", scene, typeof(SceneAsset), false);
                if (EditorGUI.EndChangeCheck())
                    EditorSettings.prefabRegularEnvironment = scene;
            }
            {
                EditorGUI.BeginChangeCheck();
                SceneAsset scene = EditorSettings.prefabUIEnvironment;
                scene = (SceneAsset)EditorGUILayout.ObjectField("UI Environment", scene, typeof(SceneAsset), false);
                if (EditorGUI.EndChangeCheck())
                    EditorSettings.prefabUIEnvironment = scene;
            }

            GUILayout.Space(10);

            GUI.enabled = true;
            GUILayout.Label(Content.graphics, EditorStyles.boldLabel);
            GUI.enabled = editorEnabled;

            EditorGUI.BeginChangeCheck();
            bool showRes = LightmapVisualization.showResolution;
            showRes = EditorGUILayout.Toggle(Content.showLightmapResolutionOverlay, showRes);
            if (EditorGUI.EndChangeCheck())
                LightmapVisualization.showResolution = showRes;

            GUILayout.Space(10);

            GUI.enabled = true;
            GUILayout.Label(Content.spritePacker, EditorStyles.boldLabel);
            GUI.enabled = editorEnabled;

            index = Mathf.Clamp((int)EditorSettings.spritePackerMode, 0, spritePackerPopupList.Length - 1);
            CreatePopupMenu(Content.mode.text, spritePackerPopupList, index, SetSpritePackerMode);

            if (EditorSettings.spritePackerMode == SpritePackerMode.AlwaysOn
                || EditorSettings.spritePackerMode == SpritePackerMode.BuildTimeOnly)
            {
                index = Mathf.Clamp((int)(EditorSettings.spritePackerPaddingPower - 1), 0, 2);
                CreatePopupMenu("Padding Power (Legacy Sprite Packer)", spritePackerPaddingPowerPopupList, index, SetSpritePackerPaddingPower);
            }

            DoProjectGenerationSettings();
            DoEtcTextureCompressionSettings();
            DoLineEndingsSettings();
            DoStreamingSettings();
            DoShaderCompilationSettings();
            DoEnterPlayModeSettings();

            serializedObject.ApplyModifiedProperties();
            m_EditorUserSettings.ApplyModifiedProperties();
        }
示例#17
0
        private void DrawSetting()                     // Setting
        {
            m_Tools.BiaoTi_B("说明");
            MyCreate.Box_Hei(() =>
            {
                m_Tools.TextText_WL("ES3.Save<T>(string key ,T value)", "调用下面设置", 140);
                m_Tools.TextText_WL("ES3.Save<T>(string key ,T value ," + "ES3Settings".AddGreen() + ")", "使用新设置", 140);
            });

            AddSpace();

            m_Tools.BiaoTi_O("默认运行时的" + "设置".AddYellow());
            MyCreate.Box(() =>
            {
                settings.location = (ES3.Location)m_Tools.TextEnum_B("位置" + "(location)".AddWhite(), settings.location, ref isLocation,
                                                                     () =>
                {
                    MyCreate.Box_Hei(() =>
                    {
                        m_Tools.Text_L("数据应存储和加载的位置");
                        m_Tools.Text_L("Resources 只允许加载,当然不能存储" + "(所以 Resources 作用不大)".AddGreen());
                        m_Tools.Text_G("感觉这个就默认 File 文件即可");
                    });
                });

                if (settings.location == ES3.Location.File)
                {
                    settings.directory = (ES3.Directory)m_Tools.TextEnum_B("文件保存目录" + "(directory)".AddWhite(), settings.directory);
                }


                settings.path = m_Tools.TextString_B("文件名" + "(path)".AddWhite(), settings.path);

                MyCreate.AddSpace(5);

                settings.encryptionType = (ES3.EncryptionType)m_Tools.TextEnum_B("加密类型" + "(encryptionType)".AddWhite(), settings.encryptionType, ref isencryptionType,
                                                                                 () =>
                {
                    MyCreate.Box_Hei(() =>
                    {
                        m_Tools.Text_L("目前支持易保存AES 加密利用 128 位密钥 ");
                        m_Tools.Text_L("不需要加密就 None");
                    });
                });

                if (settings.encryptionType == ES3.EncryptionType.AES)
                {
                    settings.encryptionPassword = m_Tools.TextString("加密密码" + "(encryptionPassword)".AddWhite(), settings.encryptionPassword);
                }

                settings.format     = (ES3.Format)m_Tools.TextEnum_B("文件格式" + "(format)".AddWhite(), settings.format);
                settings.bufferSize = m_Tools.TextInt_B("缓存长度" + "(bufferSize)".AddWhite(), settings.bufferSize, ref isbufferSize, () =>
                {
                    MyCreate.Box_Hei(() =>
                    {
                        m_Tools.Text_L("任何流缓冲区都将设置为此长度(以字节为单位)");
                        m_Tools.Text_L("    通常使用更大的缓冲区会提高性能但也会增加内存使用量,");
                        m_Tools.Text_L("    但有些系统会执行优化,这会使性能下降得不那么明显");
                        m_Tools.Text_G("如果不确定,请将其保留为默认值 2048");
                    });
                });
            });

            AddSpace();
            m_Tools.BiaoTi_O("Editor" + "设置".AddYellow());
            MyCreate.Box(() =>
            {
                editorSettings.addMgrToSceneAutomatically = m_Tools.TextBool_H("自动将 Manager 添加到场景", editorSettings.addMgrToSceneAutomatically);
                editorSettings.autoUpdateReferences       = m_Tools.TextBool_H("自动更新 References", editorSettings.autoUpdateReferences);


                // Show Assembly names array.
                SerializedObject so = new SerializedObject(editorSettings);
                SerializedProperty settingsProperty      = so.FindProperty("settings");
                SerializedProperty assemblyNamesProperty = settingsProperty.FindPropertyRelative("assemblyNames");
                EditorGUILayout.PropertyField(assemblyNamesProperty, new GUIContent("包含ES3Types的程序集", "我们要从中加载ES3Types的程序集的名称"), true); // True means show children
                so.ApplyModifiedProperties();
            });


            AddSpace();
            m_Tools.BiaoTi_Y("工具");
            MyCreate.Box(() =>
            {
                MyCreate.Heng(() =>
                {
                    m_Tools.Text_B("Open persistentDataPath 文件夹");
                    MyCreate.AddSpace();
                    MyCreate.Button("  打开  ", () =>
                    {
                        Application.OpenURL(Application.persistentDataPath);
                    });
                });


                MyCreate.Heng(() =>
                {
                    m_Tools.Text_B("Clear persistentDataPath" + "(删除文件夹下所有)".AddGreen());
                    MyCreate.AddSpace();
                    MyCreate.Button("  清理  ", () =>
                    {
                        if (EditorUtility.DisplayDialog("清理 persistentDataPath", "确定全部删除?\n 操作不可销毁.", "删除", "取消"))
                        {
                            System.IO.DirectoryInfo di = new DirectoryInfo(Application.persistentDataPath);
                            foreach (FileInfo file in di.GetFiles())
                            {
                                file.Delete();
                            }
                            foreach (DirectoryInfo dir in di.GetDirectories())
                            {
                                dir.Delete(true);
                            }
                        }
                    });
                });


                MyCreate.Heng(() =>
                {
                    m_Tools.Text_B("Clear PlayerPrefs");
                    MyCreate.AddSpace();
                    MyCreate.Button("  清理  ", () =>
                    {
                        if (EditorUtility.DisplayDialog("清理 PlayerPrefs", "确定全部清理?", "清理", "取消"))
                        {
                            PlayerPrefs.DeleteAll();
                        }
                    });
                });
            });
        }
        // Deletes the assets of the instance IDs, with an optional user confirmation dialog.
        // Returns true if the delete operation was successfully performed on all assets.
        // Note: Zero input assets always returns true.
        // Also note that the operation cannot be undone even if some operations failed.
        internal static bool DeleteAssets(List <int> instanceIDs, bool askIfSure)
        {
            if (instanceIDs.Count == 0)
            {
                return(true);
            }

            bool foundAssetsFolder = instanceIDs.IndexOf(AssetDatabase.GetMainAssetOrInProgressProxyInstanceID("Assets")) >= 0;

            if (foundAssetsFolder)
            {
                EditorUtility.DisplayDialog(L10n.Tr("Cannot Delete"), L10n.Tr("Deleting the 'Assets' folder is not allowed"), L10n.Tr("Ok"));
                return(false);
            }

            var paths = GetMainPathsOfAssets(instanceIDs).ToList();

            if (paths.Count == 0)
            {
                return(false);
            }

            if (askIfSure)
            {
                string title;
                if (paths.Count > 1)
                {
                    title = L10n.Tr("Delete selected assets?");
                }
                else
                {
                    title = L10n.Tr("Delete selected asset?");
                }

                int maxCount = 3;
                var infotext = new StringBuilder();
                for (int i = 0; i < paths.Count && i < maxCount; ++i)
                {
                    infotext.AppendLine("   " + paths[i]);
                }
                if (paths.Count > maxCount)
                {
                    infotext.AppendLine("   ...");
                }
                infotext.AppendLine(L10n.Tr("You cannot undo this action."));
                if (!EditorUtility.DisplayDialog(title, infotext.ToString(), L10n.Tr("Delete"), L10n.Tr("Cancel")))
                {
                    return(false);
                }
            }

            bool success = true;

            AssetDatabase.StartAssetEditing();
            foreach (string path in paths)
            {
                if (!AssetDatabase.MoveAssetToTrash(path))
                {
                    success = false;
                }
            }
            AssetDatabase.StopAssetEditing();
            if (!success)
            {
                string message = (Provider.enabled && Provider.onlineState == OnlineState.Offline) ?
                                 L10n.Tr("Some assets could not be deleted.\nMake sure you are connected to your Version Control server or \"Work Offline\" is enabled.") :
                                 L10n.Tr("Some assets could not be deleted.\nMake sure nothing is keeping a hook on them, like a loaded DLL for example.");

                EditorUtility.DisplayDialog(L10n.Tr("Cannot Delete"), message, L10n.Tr("Ok"));
            }
            return(success);
        }