示例#1
0
        public override void OnInspectorGUI()
        {
            editor.Repaint();
            serializedObject.Update();
            if (inkFile == null)
            {
                EditorGUILayout.HelpBox("Ink File is not in library.", MessageType.Warning);
                if (GUILayout.Button("Rebuild Library"))
                {
                    InkLibrary.Rebuild();
                    Rebuild();
                }
                return;
            }

            if (InkCompiler.IsInkFileOnCompilationStack(inkFile))
            {
                EditorGUILayout.HelpBox("File is compiling...", MessageType.Info);
                return;
            }

            if (!inkFile.isMaster)
            {
                EditorGUI.BeginChangeCheck();
                var newCompileAsIfMaster = EditorGUILayout.Toggle(new GUIContent("Compile As If Master File", "This file is included by another ink file. Typically, these files don't want to be compiled, but this option enables them to be for special purposes."), InkSettings.instance.includeFilesToCompileAsMasterFiles.Contains(inkFile.inkAsset));
                if (EditorGUI.EndChangeCheck())
                {
                    if (newCompileAsIfMaster)
                    {
                        InkSettings.instance.includeFilesToCompileAsMasterFiles.Add(inkFile.inkAsset);
                        EditorUtility.SetDirty(InkSettings.instance);
                    }
                    else
                    {
                        InkSettings.instance.includeFilesToCompileAsMasterFiles.Remove(inkFile.inkAsset);
                        EditorUtility.SetDirty(InkSettings.instance);
                    }
                }
                EditorApplication.RepaintProjectWindow();
            }

            if (inkFile.compileAsMasterFile)
            {
                DrawMasterFileHeader();
                DrawEditAndCompileDates(inkFile);
                if (inkFile.hasUnhandledCompileErrors)
                {
                    EditorGUILayout.HelpBox("Last compiled failed", MessageType.Error);
                }
                if (inkFile.hasErrors)
                {
                    EditorGUILayout.HelpBox("Last compiled had errors", MessageType.Error);
                }
                else if (inkFile.hasWarnings)
                {
                    EditorGUILayout.HelpBox("Last compile had warnings", MessageType.Warning);
                }
                else if (inkFile.jsonAsset == null)
                {
                    EditorGUILayout.HelpBox("Ink file has not been compiled", MessageType.Warning);
                }
                if (inkFile.requiresCompile && GUILayout.Button("Compile"))
                {
                    InkCompiler.CompileInk(inkFile);
                }

                DrawCompileErrors();
                DrawErrors();
                DrawWarnings();
                DrawTODOList();
            }
            else
            {
                EditorGUILayout.LabelField("Include File", EditorStyles.boldLabel);
            }

            DrawListOfMasterFiles();
            DrawIncludedFiles();
            DrawFileContents();


            serializedObject.ApplyModifiedProperties();
        }