private static void CreateInheritedPropertyDrawer() { var path = AssetDatabase.GetAssetPath(Selection.activeObject); if (path.Length > 0 && path.Split('/').Contains("Editor")) { List <string> typeNames = new List <string>(); List <string> displayNames = new List <string>(); GetNoneUnityObjectInAssemblies(typeNames, displayNames); List <string> classText = new List <string>(); classText.Add("using UnityEditor;"); classText.Add("using UnityEngine;"); classText.Add("using HephaestusForge.EditorFieldOnly;"); classText.Add(""); classText.Add("[CustomPropertyDrawer(typeof({0}))]"); classText.Add("public sealed class {0}PropertyDrawer : BaseEditorFieldOnlyPropertyDrawer"); classText.Add("{"); classText.Add(" protected override void Init()"); classText.Add(" {"); classText.Add(" }"); classText.Add(""); classText.Add(" protected override int GetPropertyHeight(SerializedProperty[] children)"); classText.Add(" {"); classText.Add(" return 0;"); classText.Add(" }"); classText.Add(""); classText.Add(" protected override void OnGUI(Rect position, SerializedProperty[] children)"); classText.Add(" {"); classText.Add(" }"); classText.Add("}"); if (Directory.Exists(path)) { FileCreationWindow.ShowWindow(path, typeNames.ToArray(), displayNames.ToArray(), classText.ToArray(), "PropertyDrawer"); return; } var pathSplit = path.Split('/').ToList(); pathSplit.RemoveAt(pathSplit.Count - 1); path = string.Join("/", pathSplit); if (Directory.Exists(path)) { FileCreationWindow.ShowWindow(path, typeNames.ToArray(), displayNames.ToArray(), classText.ToArray(), "PropertyDrawer"); return; } } else { #if UNITY_EDITOR || DEVELOPMENT_BUILD Debug.LogError("An Inherited inspector needs to be inside an Editor folder."); #endif } }
private static void CreateInheritedInspector() { var path = AssetDatabase.GetAssetPath(Selection.activeObject); if (path.Length > 0 && path.Split('/').Contains("Editor")) { List <string> typeNames = new List <string>(); List <string> displayNames = new List <string>(); GetUnityObjectInAssemblies(typeNames, displayNames); List <string> classText = new List <string>(); classText.Add("using UnityEditor;"); classText.Add("using HephaestusForge.EditorFieldOnly;"); classText.Add(""); classText.Add("[CustomEditor(typeof({0}))]"); classText.Add("public sealed class {0}Inspector : BaseEditorFieldOnlyInspector"); classText.Add("{"); classText.Add(" protected override void CustomDraw(SerializedProperty serializedProperty)"); classText.Add(" {"); classText.Add(" throw new System.NotImplementedException();"); classText.Add(" }"); classText.Add(""); classText.Add(" protected override void Enabled(out bool didRequestEditorField)"); classText.Add(" {"); classText.Add(" didRequestEditorField = true;"); classText.Add(" }"); classText.Add("}"); if (Directory.Exists(path)) { FileCreationWindow.ShowWindow(path, typeNames.ToArray(), displayNames.ToArray(), classText.ToArray(), "Inspector"); return; } var pathSplit = path.Split('/').ToList(); pathSplit.RemoveAt(pathSplit.Count - 1); path = string.Join("/", pathSplit); if (Directory.Exists(path)) { FileCreationWindow.ShowWindow(path, typeNames.ToArray(), displayNames.ToArray(), classText.ToArray(), "Inspector"); return; } } else { #if UNITY_EDITOR || DEVELOPMENT_BUILD Debug.LogError("An Inherited inspector needs to be inside an Editor folder."); #endif } }