private void OnGUI() { if (!m_Prefs) { DefaultAsset newRef = EditorGUILayout.ObjectField("Ink File", null, typeof(DefaultAsset), false) as DefaultAsset; if (newRef == null) { return; } m_Prefs = InkTodoPrefs.Load(newRef); EditorPrefs.SetString(kInkTodoFilePref, AssetDatabase.GetAssetPath(newRef)); } m_Prefs = EditorGUILayout.ObjectField("Ink Todo Prefs File", m_Prefs, typeof(InkTodoPrefs), false) as InkTodoPrefs; if (m_Prefs == null) { return; } SerializedObject so = new SerializedObject(m_Prefs); EditorGUILayout.PropertyField(so.FindProperty("m_InkFileAssets"), true); m_Prefs.OnGUI(); if (GUI.changed) { EditorUtility.SetDirty(m_Prefs); } so.ApplyModifiedProperties(); }
private void OnEnable() { if (!m_Prefs) { string path = EditorPrefs.GetString(kInkTodoFilePref, null); if (path != null) { DefaultAsset inkFile = AssetDatabase.LoadAssetAtPath <DefaultAsset>(path); m_Prefs = InkTodoPrefs.Load(inkFile); } } if (m_Prefs) { m_Prefs.Analyze(); } }
public static InkTodoPrefs Load(DefaultAsset inkFile) { string inkPath = AssetDatabase.GetAssetPath(inkFile); string directory = Path.GetDirectoryName(inkPath); string prefsName = Path.GetFileNameWithoutExtension(inkPath) + ".asset"; string prefsPath = Path.Combine(directory, prefsName); InkTodoPrefs prefs = AssetDatabase.LoadAssetAtPath <InkTodoPrefs>(prefsPath); if (!prefs) { prefs = CreateInstance <InkTodoPrefs>(); AssetDatabase.CreateAsset(prefs, prefsPath); InkFileInfo inkInfo = new InkFileInfo(inkFile); prefs.m_InkFileAssets = new List <DefaultAsset> { inkFile }; foreach (string includePath in inkInfo.Includes) { DefaultAsset includeAsset = AssetDatabase.LoadAssetAtPath <DefaultAsset>(includePath); if (includeAsset) { prefs.m_InkFileAssets.Add(includeAsset); } } prefs.m_Searches = new List <RegexTodoSearch> { new RegexTodoSearch() }; } prefs.Analyze(); return(prefs); }