Пример #1
0
        private static InkSettings FindSettings()
        {
            if (EditorPrefs.HasKey(pathPlayerPrefsKey))
            {
                InkSettings settings = AssetDatabase.LoadAssetAtPath <InkSettings>(EditorPrefs.GetString(pathPlayerPrefsKey));
                if (settings != null)
                {
                    return(settings);
                }
                else
                {
                    EditorPrefs.DeleteKey(pathPlayerPrefsKey);
                }
            }

            string[] GUIDs = AssetDatabase.FindAssets("t:" + typeof(InkSettings).Name);
            if (GUIDs.Length > 0)
            {
                if (GUIDs.Length > 1)
                {
                    for (int i = 1; i < GUIDs.Length; i++)
                    {
                        AssetDatabase.DeleteAsset(AssetDatabase.GUIDToAssetPath(GUIDs[i]));
                    }
                    Debug.LogWarning("More than one InkSettings was found. Deleted excess asset instances.");
                }
                string path = AssetDatabase.GUIDToAssetPath(GUIDs[0]);
                EditorPrefs.SetString(pathPlayerPrefsKey, path);
                return(AssetDatabase.LoadAssetAtPath <InkSettings>(path));
            }
            return(null);
        }
        static void DrawSettings(InkSettings settings)
        {
            EditorGUI.indentLevel++;
            DrawVersions();
            EditorGUILayout.Separator();

            var cachedLabelWidth = EditorGUIUtility.labelWidth;

            EditorGUIUtility.labelWidth = 260;

            EditorGUILayout.LabelField(new GUIContent("Settings"), EditorStyles.boldLabel);
            if (settings.templateFile == null)
            {
                DrawTemplateMissingWarning();
            }
            settings.templateFile = (DefaultAsset)EditorGUILayout.ObjectField(new GUIContent("Ink Template", "Optional. The default content of files created via Assets > Create > Ink."), settings.templateFile, typeof(DefaultAsset));

            settings.defaultJsonAssetPath         = (DefaultAsset)EditorGUILayout.ObjectField(new GUIContent("New JSON Path", "By default, story JSON files are placed next to the ink. Drag a folder here to place new JSON files there instead."), settings.defaultJsonAssetPath, typeof(DefaultAsset));
            settings.compileAllFilesAutomatically = EditorGUILayout.Toggle(new GUIContent("Compile All Ink Automatically", "When disabled, automatic compilation can be enabled on a per-story basis via the inspector for a master story file. This can be helpful when you have several stories in a single project."), settings.compileAllFilesAutomatically);
            settings.delayInPlayMode = EditorGUILayout.Toggle(new GUIContent("Delay compilation if in Play Mode", "When enabled, ink compilation is delayed if in play mode. Files will be compiled on re-entering edit mode."), settings.delayInPlayMode);
            settings.printInkLogsInConsoleOnCompile = EditorGUILayout.Toggle(new GUIContent("Print ink TODOs in console on compile", "When enabled, ink lines starting with TODO are printed in the console."), settings.printInkLogsInConsoleOnCompile);
            settings.handleJSONFilesAutomatically   = EditorGUILayout.Toggle(new GUIContent("Handle JSON Automatically", "Whether JSON files are moved, renamed and deleted along with their ink files."), settings.handleJSONFilesAutomatically);
            settings.compileTimeout = EditorGUILayout.IntField(new GUIContent("Compile Timeout", "The max time the compiler will attempt to compile for in case of unhanded errors. You may need to increase this for very large ink projects."), settings.compileTimeout);

            EditorGUIUtility.labelWidth = cachedLabelWidth;

            EditorGUI.indentLevel--;
        }
Пример #3
0
        private static InkSettings FindOrCreateSettings()
        {
            InkSettings tmpSettings = FindSettings();

            // If we couldn't find the asset in the project, create a new one.
            if (tmpSettings == null)
            {
                tmpSettings = CreateInkSettings();
                Debug.Log("Created a new InkSettings file at " + defaultPath + " because one was not found.");
            }
            return(tmpSettings);
        }
 // Deletes the persistent version of this asset that we used to use prior to 0.9.71
 void OnEnable()
 {
     if (!Application.isPlaying && EditorUtility.IsPersistent(this))
     {
         var path = AssetDatabase.GetAssetPath(this);
         if (!string.IsNullOrEmpty(path))
         {
             if (_Instance == this)
             {
                 _Instance = null;
             }
             AssetDatabase.DeleteAsset(AssetDatabase.GetAssetPath(this));
             AssetDatabase.Refresh();
             return;
         }
     }
 }
        public static SettingsProvider CreateInkSettingsProvider()
        {
            // First parameter is the path in the Settings window.
            // Second parameter is the scope of this setting: it only appears in the Project Settings window.
            var provider = new SettingsProvider("Project/Ink", SettingsScope.Project)
            {
                // By default the last token of the path is used as display name if no label is provided.
                label = "Ink",
                // Create the SettingsProvider and initialize its drawing (IMGUI) function in place:
                guiHandler = (searchContext) => {
                    var settings = InkSettings.GetSerializedSettings();
                    DrawSettings(settings);
                },

                // Populate the search keywords to enable smart search filtering and label highlighting:
                // keywords = new HashSet<string>(new[] { "Number", "Some String" })
            };

            return(provider);
        }
Пример #6
0
 void OnEnable()
 {
     // Validate the includeFilesToCompileAsMasterFiles list.
     for (int i = includeFilesToCompileAsMasterFiles.Count - 1; i >= 0; i--)
     {
         if (includeFilesToCompileAsMasterFiles[i] == null)
         {
             includeFilesToCompileAsMasterFiles.RemoveAt(i);
             Debug.LogError("REMOVE " + includeFilesToCompileAsMasterFiles.Count);
         }
     }
     // Validate the filesToCompileAutomatically list.
     for (int i = filesToCompileAutomatically.Count - 1; i >= 0; i--)
     {
         if (filesToCompileAutomatically[i] == null)
         {
             filesToCompileAutomatically.RemoveAt(i);
         }
     }
     // Deletes the persistent version of this asset that we used to use prior to 0.9.71
     if (!Application.isPlaying && EditorUtility.IsPersistent(this))
     {
         var path = AssetDatabase.GetAssetPath(this);
         if (!string.IsNullOrEmpty(path))
         {
                                 #if !UNITY_2020_1_OR_NEWER
             if (_instance == this)
             {
                 _instance = null;
             }
                                 #endif
             AssetDatabase.DeleteAsset(AssetDatabase.GetAssetPath(this));
             AssetDatabase.Refresh();
             return;
         }
     }
 }
Пример #7
0
 public void OnEnable()
 {
     data = (InkSettings)target;
 }
Пример #8
0
 static string[] OnWillSaveAssets(string[] paths)
 {
     InkSettings.SaveToFile();
     return(paths);
 }
Пример #9
0
 private void OnEnable()
 {
     _Instance = this;
 }