public void PrintVariables(Jiffy.Essence essence) { PushIndent(essence.indent); WriteLine("/// <summary>"); WriteLine("/// Type: Monoscript"); WriteLine("/// <summary>"); WriteLine("protected SerializedProperty m_Script;"); essence.Foreach((FieldInfo info) => { #line default #line hidden #line 59 "C:\Users\Byron\Documents\jiffy-editor\proj.cs\JiffyEditor\Jiffy\Templates\Generators\SimpleEditor.t4" this.Write("/// <summary>\r\n/// Type: "); #line default #line hidden #line 61 "C:\Users\Byron\Documents\jiffy-editor\proj.cs\JiffyEditor\Jiffy\Templates\Generators\SimpleEditor.t4" this.Write(this.ToStringHelper.ToStringWithCulture(TemplateUtility.NiceTypeName(info.FieldType))); #line default #line hidden #line 61 "C:\Users\Byron\Documents\jiffy-editor\proj.cs\JiffyEditor\Jiffy\Templates\Generators\SimpleEditor.t4" this.Write("\r\n/// </summary>\r\nprotected SerializedProperty "); #line default #line hidden #line 63 "C:\Users\Byron\Documents\jiffy-editor\proj.cs\JiffyEditor\Jiffy\Templates\Generators\SimpleEditor.t4" this.Write(this.ToStringHelper.ToStringWithCulture(info.Name)); #line default #line hidden #line 63 "C:\Users\Byron\Documents\jiffy-editor\proj.cs\JiffyEditor\Jiffy\Templates\Generators\SimpleEditor.t4" this.Write(";\r\n"); #line default #line hidden #line 64 "C:\Users\Byron\Documents\jiffy-editor\proj.cs\JiffyEditor\Jiffy\Templates\Generators\SimpleEditor.t4" }); PopIndent(); }
public void PDPopulateSP(Jiffy.Essence essence) { PushIndent(essence.indent); WriteLine("/// <summary>"); WriteLine("/// Since PropertyDrawers are shared (they create one instance for many items) we can't"); WriteLine("/// store any local variables. This means that everytime we are setn a property we need"); WriteLine("/// to repopulate the SerializedProperties. This function does that."); WriteLine("/// </summary>"); WriteLine("public void PopulateProperties(SerializedProperty property)"); WriteLine("{"); PushIndent(essence.indent); essence.Foreach((FieldInfo info) => { #line default #line hidden #line 65 "C:\Users\Byron\Documents\jiffy-editor\proj.cs\JiffyEditor\Jiffy\Templates\Generators\SimplePropertyDrawer.t4" this.Write(this.ToStringHelper.ToStringWithCulture(info.Name)); #line default #line hidden #line 65 "C:\Users\Byron\Documents\jiffy-editor\proj.cs\JiffyEditor\Jiffy\Templates\Generators\SimplePropertyDrawer.t4" this.Write(" = property.FindPropertyRelative(\""); #line default #line hidden #line 65 "C:\Users\Byron\Documents\jiffy-editor\proj.cs\JiffyEditor\Jiffy\Templates\Generators\SimplePropertyDrawer.t4" this.Write(this.ToStringHelper.ToStringWithCulture(info.Name)); #line default #line hidden #line 65 "C:\Users\Byron\Documents\jiffy-editor\proj.cs\JiffyEditor\Jiffy\Templates\Generators\SimplePropertyDrawer.t4" this.Write("\"); \r\n"); #line default #line hidden #line 66 "C:\Users\Byron\Documents\jiffy-editor\proj.cs\JiffyEditor\Jiffy\Templates\Generators\SimplePropertyDrawer.t4" }); PopIndent(); WriteLine("}"); PopIndent(); }
public void PrintOnEnableFunction(Jiffy.Essence essence) { PushIndent(essence.indent); WriteLine("/// <summary>"); WriteLine("/// This function is called when the object is loaded."); WriteLine("/// We use it to init all our properties"); WriteLine("/// </summary>"); WriteLine("protected virtual void OnEnable()"); WriteLine("{"); PushIndent(essence.indent); WriteLine("m_Script = serializedObject.FindProperty(\"m_Script\");"); essence.Foreach((FieldInfo info) => { #line default #line hidden #line 83 "C:\Users\Byron\Documents\jiffy-editor\proj.cs\JiffyEditor\Jiffy\Templates\Generators\SimpleEditor.t4" this.Write(this.ToStringHelper.ToStringWithCulture(info.Name)); #line default #line hidden #line 83 "C:\Users\Byron\Documents\jiffy-editor\proj.cs\JiffyEditor\Jiffy\Templates\Generators\SimpleEditor.t4" this.Write(" = serializedObject.FindProperty(\""); #line default #line hidden #line 83 "C:\Users\Byron\Documents\jiffy-editor\proj.cs\JiffyEditor\Jiffy\Templates\Generators\SimpleEditor.t4" this.Write(this.ToStringHelper.ToStringWithCulture(info.Name)); #line default #line hidden #line 83 "C:\Users\Byron\Documents\jiffy-editor\proj.cs\JiffyEditor\Jiffy\Templates\Generators\SimpleEditor.t4" this.Write("\");\r\n"); #line default #line hidden #line 84 "C:\Users\Byron\Documents\jiffy-editor\proj.cs\JiffyEditor\Jiffy\Templates\Generators\SimpleEditor.t4" }); PopIndent(); WriteLine("}"); PopIndent(); }
public void CreateContent(Jiffy.Essence essence) { PushIndent(essence.indent); WriteLine("public GUIContent m_ScriptContent = new GUIContent(\"Script\")"); essence.Foreach((FieldInfo info) => { #line default #line hidden #line 42 "C:\Users\Byron\Documents\jiffy-editor\proj.cs\JiffyEditor\Jiffy\Templates\Generators\SimpleEditor.t4" this.Write("public GUIContent "); #line default #line hidden #line 43 "C:\Users\Byron\Documents\jiffy-editor\proj.cs\JiffyEditor\Jiffy\Templates\Generators\SimpleEditor.t4" this.Write(this.ToStringHelper.ToStringWithCulture(info.Name)); #line default #line hidden #line 43 "C:\Users\Byron\Documents\jiffy-editor\proj.cs\JiffyEditor\Jiffy\Templates\Generators\SimpleEditor.t4" this.Write("Content = new GUIContent(\""); #line default #line hidden #line 43 "C:\Users\Byron\Documents\jiffy-editor\proj.cs\JiffyEditor\Jiffy\Templates\Generators\SimpleEditor.t4" this.Write(this.ToStringHelper.ToStringWithCulture(info.Name)); #line default #line hidden #line 43 "C:\Users\Byron\Documents\jiffy-editor\proj.cs\JiffyEditor\Jiffy\Templates\Generators\SimpleEditor.t4" this.Write("\");\r\n"); #line default #line hidden #line 44 "C:\Users\Byron\Documents\jiffy-editor\proj.cs\JiffyEditor\Jiffy\Templates\Generators\SimpleEditor.t4" }); PopIndent(); }
public void PDPropertyHeight(Jiffy.Essence essence) { PushIndent(essence.indent); WriteLine("/// <summary>"); WriteLine("/// This property is used to set how much height space we are given to draw our inspector."); WriteLine("/// We use the helper function to get the height because other property drawers can change"); WriteLine("/// the required height"); WriteLine("/// </summary>"); WriteLine("public override float GetPropertyHeight(SerializedProperty property, GUIContent label)"); WriteLine("{"); PushIndent(essence.indent); WriteLine("PopulateProperties(property);"); WriteLine(string.Empty); WriteLine("float height = 0f;"); essence.Foreach((FieldInfo info) => { #line default #line hidden #line 104 "C:\Users\Byron\Documents\jiffy-editor\proj.cs\JiffyEditor\Jiffy\Templates\Generators\SimplePropertyDrawer.t4" this.Write("height += EditorGUI.GetPropertyHeight("); #line default #line hidden #line 105 "C:\Users\Byron\Documents\jiffy-editor\proj.cs\JiffyEditor\Jiffy\Templates\Generators\SimplePropertyDrawer.t4" this.Write(this.ToStringHelper.ToStringWithCulture(info.Name)); #line default #line hidden #line 105 "C:\Users\Byron\Documents\jiffy-editor\proj.cs\JiffyEditor\Jiffy\Templates\Generators\SimplePropertyDrawer.t4" this.Write("); \r\n"); #line default #line hidden #line 106 "C:\Users\Byron\Documents\jiffy-editor\proj.cs\JiffyEditor\Jiffy\Templates\Generators\SimplePropertyDrawer.t4" }); WriteLine("return height;"); PopIndent(); WriteLine("}"); PopIndent(); }
public void PDOnGUI(Jiffy.Essence essence) { PushIndent(essence.indent); WriteLine("/// <summary>"); WriteLine("/// Inside this function you can add your own custom GUI"); WriteLine("/// for the inspector of a specific object class."); WriteLine("/// </summary>"); WriteLine("public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)"); WriteLine("{"); PushIndent(essence.indent); WriteLine("PopulateProperties(property);"); WriteLine(string.Empty); WriteLine("position.height = EditorGUIUtility.singleLineHeight;"); WriteLine(string.Empty); essence.Foreach((FieldInfo info) => { #line default #line hidden #line 130 "C:\Users\Byron\Documents\jiffy-editor\proj.cs\JiffyEditor\Jiffy\Templates\Generators\SimplePropertyDrawer.t4" this.Write("EditorGUI.PropertyField( position:position, property:"); #line default #line hidden #line 131 "C:\Users\Byron\Documents\jiffy-editor\proj.cs\JiffyEditor\Jiffy\Templates\Generators\SimplePropertyDrawer.t4" this.Write(this.ToStringHelper.ToStringWithCulture(info.Name)); #line default #line hidden #line 131 "C:\Users\Byron\Documents\jiffy-editor\proj.cs\JiffyEditor\Jiffy\Templates\Generators\SimplePropertyDrawer.t4" if (essence.createContent) { #line default #line hidden #line 134 "C:\Users\Byron\Documents\jiffy-editor\proj.cs\JiffyEditor\Jiffy\Templates\Generators\SimplePropertyDrawer.t4" this.Write(", label:"); #line default #line hidden #line 134 "C:\Users\Byron\Documents\jiffy-editor\proj.cs\JiffyEditor\Jiffy\Templates\Generators\SimplePropertyDrawer.t4" this.Write(this.ToStringHelper.ToStringWithCulture(info.Name)); #line default #line hidden #line 134 "C:\Users\Byron\Documents\jiffy-editor\proj.cs\JiffyEditor\Jiffy\Templates\Generators\SimplePropertyDrawer.t4" this.Write("Content"); #line default #line hidden #line 134 "C:\Users\Byron\Documents\jiffy-editor\proj.cs\JiffyEditor\Jiffy\Templates\Generators\SimplePropertyDrawer.t4" } if (info.FieldType.IsArray || typeof(IList).IsAssignableFrom(info.FieldType)) { #line default #line hidden #line 138 "C:\Users\Byron\Documents\jiffy-editor\proj.cs\JiffyEditor\Jiffy\Templates\Generators\SimplePropertyDrawer.t4" this.Write(", includeChildren:true"); #line default #line hidden #line 138 "C:\Users\Byron\Documents\jiffy-editor\proj.cs\JiffyEditor\Jiffy\Templates\Generators\SimplePropertyDrawer.t4" } #line default #line hidden #line 140 "C:\Users\Byron\Documents\jiffy-editor\proj.cs\JiffyEditor\Jiffy\Templates\Generators\SimplePropertyDrawer.t4" this.Write(");\r\n"); #line default #line hidden #line 141 "C:\Users\Byron\Documents\jiffy-editor\proj.cs\JiffyEditor\Jiffy\Templates\Generators\SimplePropertyDrawer.t4" WriteLine("position.y += EditorGUIUtility.singleLineHeight;"); WriteLine(string.Empty); }); PopIndent(); WriteLine("}"); }
public void PrintGUIFunction(Jiffy.Essence essence) { PushIndent(essence.indent); WriteLine("/// <summary>"); WriteLine("/// Inside this function you can add your own custom GUI"); WriteLine("/// for the inspector of a specific object class."); WriteLine("/// </summary>"); WriteLine("public override void OnInspectorGUI()"); WriteLine("{"); PushIndent(essence.indent); WriteLine("EditorGUI.BeginChangeCheck();"); WriteLine("{"); PushIndent(essence.indent); if (essence.createContent) { WriteLine("EditorGUILayout.PropertyField(m_Script, m_ScriptContent);"); } else { WriteLine("EditorGUILayout.PropertyField(m_Script);"); } essence.Foreach((FieldInfo info) => { #line default #line hidden #line 114 "C:\Users\Byron\Documents\jiffy-editor\proj.cs\JiffyEditor\Jiffy\Templates\Generators\SimpleEditor.t4" this.Write("\r\nEditorGUILayout.PropertyField( property:"); #line default #line hidden #line 116 "C:\Users\Byron\Documents\jiffy-editor\proj.cs\JiffyEditor\Jiffy\Templates\Generators\SimpleEditor.t4" this.Write(this.ToStringHelper.ToStringWithCulture(info.Name)); #line default #line hidden #line 116 "C:\Users\Byron\Documents\jiffy-editor\proj.cs\JiffyEditor\Jiffy\Templates\Generators\SimpleEditor.t4" if (essence.createContent) { #line default #line hidden #line 119 "C:\Users\Byron\Documents\jiffy-editor\proj.cs\JiffyEditor\Jiffy\Templates\Generators\SimpleEditor.t4" this.Write(", label:"); #line default #line hidden #line 119 "C:\Users\Byron\Documents\jiffy-editor\proj.cs\JiffyEditor\Jiffy\Templates\Generators\SimpleEditor.t4" this.Write(this.ToStringHelper.ToStringWithCulture(info.Name)); #line default #line hidden #line 119 "C:\Users\Byron\Documents\jiffy-editor\proj.cs\JiffyEditor\Jiffy\Templates\Generators\SimpleEditor.t4" this.Write("Content"); #line default #line hidden #line 119 "C:\Users\Byron\Documents\jiffy-editor\proj.cs\JiffyEditor\Jiffy\Templates\Generators\SimpleEditor.t4" } if (info.FieldType.IsArray || typeof(IList).IsAssignableFrom(info.FieldType)) { #line default #line hidden #line 123 "C:\Users\Byron\Documents\jiffy-editor\proj.cs\JiffyEditor\Jiffy\Templates\Generators\SimpleEditor.t4" this.Write(", includeChildren:true"); #line default #line hidden #line 123 "C:\Users\Byron\Documents\jiffy-editor\proj.cs\JiffyEditor\Jiffy\Templates\Generators\SimpleEditor.t4" } #line default #line hidden #line 125 "C:\Users\Byron\Documents\jiffy-editor\proj.cs\JiffyEditor\Jiffy\Templates\Generators\SimpleEditor.t4" this.Write(");\r\n"); #line default #line hidden #line 126 "C:\Users\Byron\Documents\jiffy-editor\proj.cs\JiffyEditor\Jiffy\Templates\Generators\SimpleEditor.t4" }); PopIndent(); WriteLine("}"); WriteLine("if(EditorGUI.EndChangeCheck())"); WriteLine("{"); PushIndent(essence.indent); WriteLine("serializedObject.ApplyModifiedProperties();"); PopIndent(); WriteLine("}"); PopIndent(); WriteLine("}"); }