Beispiel #1
0
        public override void OnInspectorGUI()
        {
            serializedObject.Update();

            if (InkCompiler.compiling)
            {
                Rect r = EditorGUILayout.BeginVertical();
                EditorGUI.ProgressBar(r, InkCompiler.GetEstimatedCompilationProgress(), "Compiling...");
                GUILayout.Space(EditorGUIUtility.singleLineHeight);
                EditorGUILayout.EndVertical();
                GUILayout.Space(EditorGUIUtility.standardVerticalSpacing);
            }
            else
            {
                var filesRequiringRecompile = InkLibrary.GetFilesRequiringRecompile();
                if (filesRequiringRecompile.Any())
                {
                    var files = string.Join("\n", filesRequiringRecompile.Select(x => x.filePath).ToArray());
                    EditorGUILayout.HelpBox("Some Ink files marked to compile automatically are not compiled! Check they don't have compile errors, or else try compiling now.\n" + files, MessageType.Warning);
                }
                else
                {
                    EditorGUILayout.HelpBox("All Ink files marked to compile automatically are compiled", MessageType.Info);
                }
            }
            EditorGUI.BeginDisabledGroup(InkCompiler.compiling);
            if (GUILayout.Button(new GUIContent("Rebuild Library", "Rebuilds the ink library. Do this if you're getting unusual errors")))
            {
                InkLibrary.Rebuild();
            }
            if (GUILayout.Button(new GUIContent("Recompile All", "Recompiles all files marked to compile automatically.")))
            {
                InkEditorUtils.RecompileAll();
            }
            EditorGUI.EndDisabledGroup();

            EditorGUI.BeginDisabledGroup(true);
            EditorGUILayout.PropertyField(serializedObject.FindProperty("inkLibrary"), true);
            EditorGUILayout.PropertyField(serializedObject.FindProperty("pendingCompilationStack"), true);
            EditorGUILayout.PropertyField(serializedObject.FindProperty("compilationStack"), true);
            EditorGUI.EndDisabledGroup();

            if (GUI.changed && target != null)
            {
                EditorUtility.SetDirty(target);
            }
            serializedObject.ApplyModifiedProperties();
        }
Beispiel #2
0
        public override void OnInspectorGUI()
        {
            serializedObject.Update();

            EditorGUI.BeginDisabledGroup(InkCompiler.compiling);
            if (GUILayout.Button(new GUIContent("Rebuild Library", "Rebuilds the ink library. Do this if you're getting unusual errors"), EditorStyles.miniButton))
            {
                InkLibrary.Rebuild();
            }
            EditorGUI.EndDisabledGroup();

            EditorGUILayout.Toggle("HasLockedUnityCompilation", InkCompiler.hasLockedUnityCompilation);
            if (GUILayout.Button("Unlock"))
            {
                EditorApplication.UnlockReloadAssemblies();
            }
                        #if UNITY_2019_4_OR_NEWER
            if (GUILayout.Button("AllowAutoRefresh"))
            {
                AssetDatabase.AllowAutoRefresh();
            }
                        #endif

            if (InkCompiler.compiling)
            {
                Rect r = EditorGUILayout.BeginVertical();
                EditorGUI.ProgressBar(r, InkCompiler.GetEstimatedCompilationProgress(), "Compiling...");
                GUILayout.Space(EditorGUIUtility.singleLineHeight);
                EditorGUILayout.EndVertical();
                GUILayout.Space(EditorGUIUtility.standardVerticalSpacing);
            }
            else
            {
                var filesRequiringRecompile = InkLibrary.GetFilesRequiringRecompile();
                if (filesRequiringRecompile.Any())
                {
                    var files = string.Join("\n", filesRequiringRecompile.Select(x => x.filePath).ToArray());
                    if (EditorApplication.isPlaying && InkSettings.Instance.delayInPlayMode)
                    {
                        EditorGUILayout.HelpBox("Some Ink files marked to compile on exiting play mode.\n" + files, MessageType.Info);
                    }
                    else
                    {
                        EditorGUILayout.HelpBox("Some Ink files marked to compile automatically are not compiled! Check they don't have compile errors, or else try compiling now.\n" + files, MessageType.Warning);
                    }
                }
                else
                {
                    EditorGUILayout.HelpBox("All Ink files marked to compile automatically are compiled", MessageType.Info);
                }
            }
            EditorGUI.BeginDisabledGroup(InkCompiler.compiling);
            if (GUILayout.Button(new GUIContent("Recompile All", "Recompiles all files marked to compile automatically.")))
            {
                InkEditorUtils.RecompileAll();
            }

            if (EditorApplication.isPlaying && InkSettings.Instance.delayInPlayMode)
            {
                var filesRequiringRecompile = InkLibrary.GetFilesRequiringRecompile();
                if (filesRequiringRecompile.Any())
                {
                    var files = string.Join("\n", filesRequiringRecompile.Select(x => x.filePath).ToArray());
                    if (GUILayout.Button(new GUIContent("Recompile Pending", "Recompiles all files marked to compile on exiting play mode.")))
                    {
                        InkEditorUtils.RecompileAll();
                    }
                }
            }

            EditorGUI.EndDisabledGroup();

            EditorGUI.BeginDisabledGroup(true);
            EditorGUILayout.PropertyField(serializedObject.FindProperty("inkLibrary"), true);
            EditorGUILayout.PropertyField(serializedObject.FindProperty("pendingCompilationStack"), true);
            EditorGUILayout.PropertyField(serializedObject.FindProperty("compilationStack"), true);
            EditorGUI.EndDisabledGroup();

            if (GUILayout.Button(new GUIContent("Clear Compilation Stacks")))
            {
                InkLibrary.ClearCompilationStacks();
            }
            if (GUI.changed && target != null)
            {
                EditorUtility.SetDirty(target);
            }
            serializedObject.ApplyModifiedProperties();
        }