Пример #1
0
 public string ReadLogTail(int n = 1)
 {
     return(ImportExportHelper.ReadFileTail(ImportExportHelper.PersistentPath(logFile), n));
 }
        public override void OnInspectorGUI()
        {
            EditorGUI.BeginChangeCheck();
            serializedObject.Update();

            EditorUtils.BrandField();

            using (new EditorGUI.DisabledScope(true))
                EditorGUILayout.PropertyField(serializedObject.FindProperty("m_Script"));

            EditorGUILayout.PropertyField(this.settingsProperty);

            EditorGUI.indentLevel++;

            if (this.settingsProperty.objectReferenceValue == null)
            {
                this.editor = null;
            }

            if (this.editor == null && this.settingsProperty.objectReferenceValue != null)
            {
                Editor.CreateCachedEditor(this.settingsProperty.objectReferenceValue, null, ref this.editor);
            }

            if (this.editor != null)
            {
                this.editor.DrawDefaultInspector();
                this.editor.serializedObject.ApplyModifiedProperties();
            }

            EditorGUI.indentLevel--;

            EditorGUILayout.PropertyField(this.overwriteLocalFilesProperty);
            EditorGUILayout.PropertyField(this.enableInEditorProperty);

            if (this.enableInEditorProperty.boolValue)
            {
                EditorGUILayout.HelpBox("Its recommended to disable this component in the editor to reduce loading time.", MessageType.Warning);
            }

            EditorGUILayout.LabelField("Add ScriptableObject you want to import and export and the GameObject that holds a reference to it. Awake will be called on all GameObjects after a successful import.", EditorStyles.wordWrappedMiniLabel);

            this.entriesList.DoLayoutList();

            if (this.entriesList.index != -1)
            {
                SerializedProperty element          = this.entriesList.serializedProperty.GetArrayElementAtIndex(this.entriesList.index);
                ScriptableObject   scriptableObject = (ScriptableObject)element.FindPropertyRelative("scriptableObject").objectReferenceValue;

                EditorGUILayout.BeginHorizontal();

                GUILayout.FlexibleSpace();

                this.importAsset = (TextAsset)EditorGUILayout.ObjectField(this.importAsset, typeof(TextAsset), false);

                if (GUILayout.Button("Import"))
                {
                    this.me.ImportManually(scriptableObject, Application.dataPath + "/" + AssetDatabase.GetAssetPath(this.importAsset));
                    ReserializeEntries(this.me);
                }

                if (GUILayout.Button("Open"))
                {
                    EditorUtility.RevealInFinder(ImportExportHelper.ExistingPersistentPath(scriptableObject.name + ".json"));
                }

                EditorGUILayout.EndHorizontal();
            }

            string tail = this.me.ReadLogTail(3);

            if (tail != null)
            {
                EditorGUILayout.LabelField(tail, EditorStyles.helpBox);

                EditorGUILayout.BeginHorizontal();

                GUILayout.FlexibleSpace();

                if (GUILayout.Button("Clear Log"))
                {
                    this.me.ClearLogFile();
                }

                EditorGUILayout.EndHorizontal();
            }

            serializedObject.ApplyModifiedProperties();
            EditorGUI.EndChangeCheck();
        }
Пример #3
0
 public void ClearLogFile()
 {
     ImportExportHelper.DeleteFile(ImportExportHelper.PersistentPath(logFile));
 }