Example #1
0
        public static void MenuOpenSettings()
        {
            // Open EM_Settings in Inspector window.
            EM_Settings instance = EM_Settings.LoadSettingsAsset();

            if (instance == null)
            {
                instance = EM_BuiltinObjectCreator.CreateEMSettingsAsset();
            }

            Selection.activeObject = instance;

            // Focus on Inspector window if needed.
            if (EditorWindow.focusedWindow == null || EditorWindow.focusedWindow.GetType().Name != InspectorWindowType)
            {
                var allWindows = Resources.FindObjectsOfTypeAll <EditorWindow>();
                if (allWindows != null)
                {
                    foreach (var a in allWindows)
                    {
                        string windowType = a.GetType().Name;
                        if (windowType == InspectorWindowType)
                        {
                            a.Focus();
                            break;
                        }
                    }
                }
            }
        }
        public static void MenuOpenSettings()
        {
            EM_Settings instance = EM_Settings.LoadSettingsAsset();

            if (instance == null)
            {
                instance = CreateSettingsAsset();
            }

            Selection.activeObject = instance;
        }
Example #3
0
        public static void MenuOpenSettings()
        {
            // Load settings object or create a new one if it doesn't exist.
            EM_Settings instance = EM_Settings.LoadSettingsAsset();

            if (instance == null)
            {
                instance = EM_BuiltinObjectCreator.CreateEMSettingsAsset();
            }

            EM_SettingsWindow.ShowWindow();
        }
        private static EM_Settings CreateSettingsAsset()
        {
            // Stop if the asset is already created.
            EM_Settings instance = EM_Settings.LoadSettingsAsset();

            if (instance != null)
            {
                return(instance);
            }

            // Create Resources folder if it doesn't exist.
            FileIO.EnsureFolderExists(EM_Constants.ResourcesFolder);

            // Now create the asset inside the Resources folder.
            instance = EM_Settings.Instance; // this will create a new instance of the EMSettings scriptable.
            AssetDatabase.CreateAsset(instance, EM_Constants.SettingsAssetPath);
            AssetDatabase.SaveAssets();
            AssetDatabase.Refresh();

            Debug.Log("EM_Settings.asset is created at " + EM_Constants.SettingsAssetPath);

            return(instance);
        }