Ejemplo n.º 1
0
 private static void     ResetAssets()
 {
     if (HQ.settings == null)
     {
         NGEditorPrefs.DeleteKey(Constants.ConfigPathKeyPref, true);
         GUICallbackWindow.Open(() => HQ.LoadSharedNGSetting());
     }
 }
Ejemplo n.º 2
0
        public static void      Open(Action callback)
        {
            GUICallbackWindow w = EditorWindow.GetWindow <GUICallbackWindow>();

            w.maxSize          = new Vector2(1F, 1F);
            w.minSize          = new Vector2(1F, 1F);
            w.pendingCallback += callback;
        }
Ejemplo n.º 3
0
        protected virtual void  OnEnable()
        {
            if (this.once == false && NGSettings.Initialize != null)
            {
                this.once = true;

                GUICallbackWindow.Open(() => NGSettings.Initialize(this));
            }
        }
Ejemplo n.º 4
0
        private static void     CheckSettingsVersion()
        {
            if (HQ.settings != null && HQ.settings.version != NGSettings.Version)
            {
                EditorApplication.delayCall += () =>
                {
                    if (EditorUtility.DisplayDialog(Constants.PackageTitle, string.Format(LC.G("Preferences_AskResetSettings"), HQ.settings.version, NGSettings.Version), LC.G("Yes"), LC.G("No")) == true)
                    {
                        GUICallbackWindow.Open(() =>
                        {
                            SerializedObject obj   = new SerializedObject(HQ.settings);
                            NGSettings newSettings = ScriptableObject.CreateInstance <NGSettings>();

                            newSettings.hideFlags = HQ.settings.hideFlags;

                            if (NGSettings.sharedSettings == HQ.settings)
                            {
                                File.Delete(NGSettings.GetSharedSettingsPath());
                                NGSettings.sharedSettings = newSettings;
                            }

                            SerializedObject newObject = new SerializedObject(newSettings);
                            SerializedProperty it      = obj.GetIterator();

                            it.Next(true);

                            SerializedProperty end = it.GetEndProperty();

                            while (SerializedProperty.EqualContents(it, end) == false && it.Next(true) == true)
                            {
                                newObject.CopyFromSerializedProperty(it);
                            }

                            newObject.ApplyModifiedProperties();

                            string path = AssetDatabase.GetAssetPath(HQ.settings.GetInstanceID());

                            if (string.IsNullOrEmpty(path) == false)
                            {
                                AssetDatabase.CreateAsset(newSettings, path);
                            }

                            HQ.settings = newSettings;

                            if (HQ.SettingsChanged != null)
                            {
                                HQ.SettingsChanged();
                            }
                        });
                    }
                };
            }
        }