Exemplo n.º 1
0
        /// <summary>
        /// Update override method called by Unity editor. The update cycle looks
        /// for any action events that were generated in the OnGUI method by the
        /// user and takes action on those events.
        /// </summary>
        void Update()
        {
            if (registryDataDirty)
            {
                LoggingController.Log("plugin data marked dirty - refreshing...");
                registryDataDirty = false;
                RegistryManagerController.RefreshRegistryCache();
                EditorUtility.SetDirty(this);
            }

            while (installRegistry.Count > 0)
            {
                var regUriStr = installRegistry.Pop();
                try {
                    ResponseCode rc = RegistryManagerController.AddRegistry(new Uri(regUriStr));
                    if (ResponseCode.REGISTRY_ADDED == rc)
                    {
                        registryDataDirty = true;
                    }
                    else if (ResponseCode.REGISTRY_ALREADY_PRESENT == rc)
                    {
                        EditorUtility.DisplayDialog("Registry Already Present",
                                                    "The registry was NOT added since it" +
                                                    "is already known.",
                                                    "Ok");
                    }
                    else
                    {
                        EditorUtility.DisplayDialog("Registry Location Not Valid",
                                                    string.Format(
                                                        "The registry cannot be added. An " +
                                                        "error has occured using the provided " +
                                                        "location.\n\n{0}", rc),
                                                    "Ok");
                    }
                } catch (Exception e) {
                    // failure - bad data
                    EditorUtility.DisplayDialog("Registry Location Processing Error",
                                                string.Format("A processing exception was " +
                                                              "generated while trying to add {0}." +
                                                              "\n\n{1}", regUriStr, e),
                                                "Ok");
                }
            }

            while (uninstallRegistry.Count > 0)
            {
                var regUriStr = uninstallRegistry.Pop();
                if (EditorUtility.DisplayDialog("Confirm Delete Registry",
                                                "Are you sure you want to delete the registry?",
                                                "Yes Delete It!",
                                                "Cancel"))
                {
                    ResponseCode rc = RegistryManagerController
                                      .RemoveRegistry(new Uri(regUriStr));
                    registryDataDirty = true;
                    if (ResponseCode.REGISTRY_NOT_FOUND == rc)
                    {
                        EditorUtility.DisplayDialog("Registry Not Found!",
                                                    "There was a problem while trying to " +
                                                    "remove the registry. It was not " +
                                                    "found when we tried to remove it."
                                                    , "Ok");
                    }
                }
            }
        }