public override void Render() { if (rootProperty == null) { return; } EditorGUILayout.BeginVertical(); if (useFoldout) { shown = EditorGUILayout.Foldout(shown, FoldOutLabel); } else { shown = true; } if (shown) { EditorGUI.indentLevel++; for (int i = 0; i < listRoot.ChildCount; i++) { SerializedPropertyX child = listRoot.GetChildAt(i); RenderListItem(child, i); } CreateRollButton(); EditorGUI.indentLevel--; } EditorGUILayout.EndVertical(); }
//todo account for decorators eventually public static float GetHeight(SerializedPropertyX property, GUIContent label, bool includeChildren) { ExtendedPropertyDrawer drawer = Reflector.GetExtendedPropertyDrawerFor(property.type); if (drawer != null) { return drawer.GetPropertyHeight(property, label); } else if (!includeChildren || property.type.IsPrimitive || property.type.IsEnum || property.type == typeof(string) || Array.IndexOf(BuildInTypes, property.type) != -1) { return GetSinglePropertyHeight(property.type, label); } else if (property.type.IsArray) { if (property.isExpanded) { float height = 32f; for (int i = 0; i < property.ChildCount; i++) { SerializedPropertyX child = property.GetChildAt(i); height += GetHeight(child, child.label, child.isExpanded); } return height; } return 16f; } else { float height = 16f; for (int i = 0; i < property.ChildCount; i++) { SerializedPropertyX child = property.GetChildAt(i); height += GetHeight(child, child.label, child.isExpanded); } return height; } }
public void Update() { if (value == null) { children = new List <SerializedPropertyX>(); } else { Type fieldType = value.GetType(); if (IsArrayLike) { IList list = value as IList; for (int i = 0; i < children.Count; i++) { children[i].Value = list[i]; } } else { for (int i = 0; i < children.Count; i++) { SerializedPropertyX child = children[i]; child.Value = fieldType.GetField(child.name).GetValue(value); } } } }
public override void OnGUI(SerializedPropertyX source, GUIContent label) { Initialize(source); var displayList = new GUIContent[pointableMethods.Count + 1]; displayList[0] = new GUIContent("-- None --"); for (int i = 1; i < displayList.Length; i++) { displayList[i] = new GUIContent(pointableMethods[i - 1].signature); } SerializedPropertyX signature = source.FindProperty("signature"); if (signature.Value == null) { signature.Value = displayList[0].text; // } int idx = Array.FindIndex(displayList, content => { return(content.text == signature.Value as string); }); if (idx == -1) { idx = 0; } int newIdx = EditorGUILayout.Popup(label, idx, displayList); signature.Value = displayList[newIdx].text; }
private void Initialize(SerializedPropertyX source) { if (!initialized) { Type sourceType = source.type; if (sourceType.IsGenericType) { Type[] genericTypes = sourceType.GetGenericArguments(); Type[] args = new Type[genericTypes.Length - 1]; for (int i = 0; i < (genericTypes.Length - 1); i++) { args[i] = genericTypes[i]; } pointableMethods = Reflector.FindMethodPointersWithAttribute(typeof(Pointable), genericTypes[genericTypes.Length - 1], args); } else { pointableMethods = Reflector.FindMethodPointersWithAttribute(typeof(Pointable), typeof(void), Type.EmptyTypes); } if (source.Value == null) { source.Value = Activator.CreateInstance(source.type); } initialized = true; } }
public RenderData DefaultCreateDataInstance(SerializedPropertyX property, bool isNewTarget) { RenderData data = new RenderData(); data.isDisplayed = !isNewTarget; return(data); }
public void ApplyModifiedProperties(SerializedPropertyX parent) { Type fieldType = value == null ? type : value.GetType(); if (value == null) { value = CreateValue(type); } if (value == null) { return; } for (int i = 0; i < children.Count; i++) { SerializedPropertyX child = children[i]; child.ApplyModifiedProperties(this); if (IsArrayLike) { IList list = value as IList; list[i] = child.Value; } else { fieldType.GetField(child.name, BindFlags).SetValue(value, child.Value); } } }
private SerializedPropertyX(SerializedPropertyX parent, string name, Type type, object value = null, bool isDrawable = true) { // :this(name, type, value, isDrawable) { this.name = name; this.type = type; this.value = value ?? CreateValue(type); originalValue = value; changed = false; displayName = Util.SplitAndTitlize(name); children = new List <SerializedPropertyX>(); isExpanded = false; label = new GUIContent(displayName); IsDrawable = isDrawable; isRoot = true; isCircular = false; this.parent = parent; if (value != null && parent != null) { SerializedPropertyX ptr = parent; while (ptr != null) { if (ptr.Value == value) { isCircular = true; circularRef = ptr; break; } ptr = ptr.parent; } } BuildProperties(); isRoot = false; }
public void HasProperTypeWhenValueNotNullAndSubClass() { SerializedPropertyX property = new SerializedPropertyX("name", typeof(TestThingSubclass)); property.Value = new TestThingSubclass(); Assert.IsTrue(property.Type == typeof(TestThingSubclass)); }
public void CreatesInstanceIfInputNullAndEmptyConstructor() { SerializedPropertyX property = new SerializedPropertyX("name", typeof(TestThing)); Assert.IsNotNull(property.Value); Assert.IsInstanceOf <TestThing>(property.Value); }
public override void OnGUI(SerializedPropertyX property, GUIContent label) { Initialize(property); if ((bool)debugMode.Value) { EditorGUI.indentLevel++; for (int i = 0; i < property.ChildCount; i++) { SerializedPropertyX child = property.GetChildAt(i); child.isExpanded = true; if (skipRenderingFields.IndexOf(child.name) != -1) { continue; } EditorGUILayoutX.PropertyField(child, child.label, child.isExpanded); } EditorGUI.indentLevel--; CalculateButton(property); } else { EditorGUI.indentLevel++; EditorGUILayoutX.PropertyField(debugMode, debugMode.label, debugMode.isExpanded); EditorGUI.indentLevel--; } listRenderer.Render(); }
public void HasProperTypeWhenValueNull() { SerializedPropertyX property = new SerializedPropertyX("name", typeof(TestThing)); property.Value = null; Assert.IsTrue(property.Type == typeof(TestThing)); }
/// <summary> /// Gets the height of the property. /// </summary> /// <returns>The property height.</returns> /// <param name="property">Property.</param> /// <param name="label">Label.</param> public override float GetPropertyHeight(SerializedProperty property, GUIContent label) { // ensure property's decorator height is registered if (!decoratorHeights.ContainsKey(property.propertyPath)) { decoratorHeights.Add(property.propertyPath, 0f); } decoratorHeights[property.propertyPath] = 0f; if (DrawerToUse != null) { return(DrawerToUse.GetPropertyHeight(property, label)); } else { float result = EditorGUI.GetPropertyHeight(property, label, true); if (!property.IsArrayElement()) { foreach (PropertyAttribute attr in fieldInfo.GetCustomAttributes <PropertyAttribute>()) { GUIDrawer drawer = SerializedPropertyX.GetGUIDrawer(fieldInfo, attr); if (drawer is DecoratorDrawer) { float height = (drawer as DecoratorDrawer).GetHeight(); result -= height; decoratorHeights[property.propertyPath] += height; } } } return(result); } }
public override void Render() { if (rootProperty == null) { return; } SerializedPropertyX nameProp = rootProperty["id"]; GUILayout.BeginHorizontal(); GUILayout.BeginVertical(); GUILayout.Space(20f); EditorGUILayoutX.PropertyField(nameProp, new GUIContent("Evaluator Name"), true); GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); if (GUILayout.Button("Restore")) { targetItem.Restore(); GUIUtility.keyboardControl = 0; } if (GUILayout.Button("Delete")) { targetItem.QueueDelete(); } if (GUILayout.Button("Save")) { targetItem.Save(); } GUILayout.EndHorizontal(); GUILayout.EndVertical(); }
public override void Render() { if (rootProperty == null) { return; } SerializedPropertyX id = rootProperty.FindProperty("id"); SerializedPropertyX icon = rootProperty.FindProperty("icon"); GUILayout.BeginHorizontal(); EditorGUILayoutX.PropertyField(icon, GUIContent.none, false, GUILayout.Width(64f), GUILayout.Height(64f)); GUILayout.BeginVertical(); GUILayout.Space(20f); EditorGUILayoutX.PropertyField(id, new GUIContent("Character Name"), true); GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); if (GUILayout.Button("Restore")) { targetItem.Restore(); GUIUtility.keyboardControl = 0; } if (GUILayout.Button("Delete")) { targetItem.QueueDelete(); } if (GUILayout.Button("Save")) { targetItem.Save(); } GUILayout.EndHorizontal(); GUILayout.EndVertical(); }
protected override void RenderBody(SerializedPropertyX considerationProperty, RenderData _data, int index) { ConsiderationRenderData data = _data as ConsiderationRenderData; Consideration consideration = considerationProperty.GetValue <Consideration>(); //manually render description and curve to make sure they come first DrawerUtil.PushLabelWidth(125); DrawerUtil.PushIndentLevel(1); consideration.description = EditorGUILayout.TextField(new GUIContent("Description"), consideration.description); GUIContent content = new GUIContent(); content.text = Util.SplitAndTitlize(consideration.GetType().Name); EditorGUILayout.BeginHorizontal(); data.isInputDisplayed = EditorGUILayout.Foldout(data.isInputDisplayed, content); EditorGUILayout.EndHorizontal(); if (data.isInputDisplayed) { EditorGUI.indentLevel++; for (int i = 0; i < considerationProperty.ChildCount; i++) { SerializedPropertyX child = considerationProperty.GetChildAt(i); if (skipRenderingFields.IndexOf(child.name) != -1) { continue; } EditorGUILayoutX.PropertyField(child, child.label, child.isExpanded); } EditorGUI.indentLevel--; } RenderCurve(considerationProperty.FindProperty("curve"), data); DrawerUtil.PopLabelWidth(); DrawerUtil.PopIndentLevel(); }
public override void Render() { if (targetItem == null) { return; } SerializedPropertyX property = rootProperty.FindProperty("contextType"); Type contextType = property.GetValue <Type>(); if (contextType == null) { contextType = typeof(Context); } //shown = EditorGUILayout.Foldout(shown, "Context"); //action : context factory int idx = contextTypeList.IndexOf(contextType); if (idx == -1) { idx = 0; } int newIdx = EditorGUILayout.Popup("Context Type", idx, contextTypeNames); if (newIdx != idx) { //todo pop up revalidate dialog //todo remove components / requirements where T does not match context type selected property.Value = contextTypeList[newIdx]; } }
public override void OnGUI(Rect position, SerializedPropertyX source, GUIContent label) { Type sourceType = source.type; if (sourceType.IsGenericType) { Type[] genericTypes = sourceType.GetGenericArguments(); Type[] args = new Type[genericTypes.Length - 1]; for (int i = 0; i < args.Length; i++) { args[0] = genericTypes[i + 1]; } pointableMethods = Reflector.FindMethodPointersWithAttribute(typeof(Pointable), genericTypes[0], args); } else { pointableMethods = Reflector.FindMethodPointersWithAttribute(typeof(Pointable), typeof(void), Type.EmptyTypes); } if (source.Value == null) { source.Value = Activator.CreateInstance(source.type); } var displayList = new GUIContent[pointableMethods.Count + 1]; displayList[0] = new GUIContent("-- None --"); for (int i = 1; i < displayList.Length; i++) { displayList[i] = new GUIContent(pointableMethods[i - 1].signature); } SerializedPropertyX signature = source.FindProperty("signature"); if (signature.Value == null) signature.Value = displayList[0].text;// int idx = Array.FindIndex(displayList, content => { return content.text == signature.Value as string; }); if (idx == -1) idx = 0; int newIdx = EditorGUI.Popup(position, label, idx, displayList); signature.Value = displayList[newIdx].text; }
protected virtual RenderData CreateDataInstance(SerializedPropertyX property, bool isNewTarget) { RenderData data = new RenderData(); data.isDisplayed = !isNewTarget; return(data); }
public bool ApplyModifiedProperties() { if (!changed) { return(false); } changed = false; if (isCircular) { return(circularRef.ApplyModifiedProperties()); } Type fieldType = value == null ? type : value.GetType(); for (int i = 0; i < children.Count; i++) { SerializedPropertyX child = children[i]; child.ApplyModifiedProperties(); if (IsArrayLike) { IList list = value as IList; list[i] = child.Value; } else { fieldType.GetField(child.name, BindFlags).SetValue(value, child.Value); } } return(true); }
public void CreatesStructInstanceIfValueNull() { SerializedPropertyX property = new SerializedPropertyX("name", typeof(Vector3)); Assert.IsNotNull(property.Value); Assert.IsInstanceOf <Vector3>(property.Value); }
public override void OnGUI(SerializedPropertyX property, GUIContent label) { IntRange attr = property.GetValue <IntRange>(); label.text = property.displayName + " (" + attr.Value + ")"; property.isExpanded = EditorGUILayout.Foldout(property.isExpanded, label); if (property.isExpanded) { property["baseValue"].Value = EditorGUILayout.IntField(new GUIContent("Base Value"), property["baseValue"].GetValue <int>()); if (Mathf.Approximately(attr.BaseValue, 0)) { attr.BaseValue = 0; } attr.BaseValue = property["baseValue"].GetValue <int>(); property["currentValue"].Value = attr.Value; EditorGUI.indentLevel++; IntModifier[] modifiers = attr.GetReadOnlyModiferList(); for (int i = 0; i < modifiers.Length; i++) { IntModifier modifier = modifiers[i]; string valueStr = "Flat: " + modifier.flatBonus + " Percent: " + modifier.percentBonus; GUI.enabled = false; EditorGUILayout.TextField(new GUIContent(modifier.id), valueStr); GUI.enabled = true; } EditorGUILayoutX.PropertyField(property["min"]); EditorGUILayoutX.PropertyField(property["max"]); EditorGUI.indentLevel--; } }
public void CanResizeArrayToSmaller() { SerializedPropertyX property = new SerializedPropertyX("name", typeof(string[]), new string[] { "1", "2" }); property.ArraySize--; Assert.AreEqual(property.GetValue <string[]>().Length, 1); Assert.AreEqual(property.GetValue <string[]>()[0], "1"); }
public void CanCreateList() { SerializedPropertyX property = new SerializedPropertyX("name", typeof(List <string>)); Assert.IsNotNull(property.Value); Assert.IsInstanceOf <List <string> >(property.Value); Assert.AreEqual(property.ChildCount, 0); }
public void DoesNotCreateChildrenIfNonSerializedAttrIsPresent() { SerializedPropertyX property = new SerializedPropertyX("name", typeof(TestThingNonSerialized)); Assert.AreEqual(property.ChildCount, 2); Assert.IsNotNull(property["x"]); Assert.IsNotNull(property["z"]); }
public void DoesNotCreatePropertiesForPrivateOrProtectedChildren() { SerializedPropertyX property = new SerializedPropertyX("name", typeof(TestThing)); Assert.AreEqual(property.ChildCount, 1); Assert.IsNull(property["y"]); Assert.IsNull(property["z"]); }
public void FindTheSamePropertyDrawerOnSecondCall() { SerializedPropertyX property = new SerializedPropertyX("name", typeof(SomeType), new SomeType()); PropertyDrawerX drawer1 = Reflector.GetCustomPropertyDrawerFor(property); PropertyDrawerX drawer2 = Reflector.GetCustomPropertyDrawerFor(property); Assert.AreEqual(drawer1, drawer2); }
public void ChangeFlagIsNotSetWhenSameValueTypeValueAssigned() { SerializedPropertyX property = new SerializedPropertyX("name", typeof(float), 10); Assert.IsFalse(property.Changed); property.Value = 10; Assert.IsFalse(property.Changed); }
public void FindCustomPropertyDrawerForSubclass() { SerializedPropertyX property = new SerializedPropertyX("name", typeof(SomeType), new SomeType()); PropertyDrawerX drawerX = Reflector.GetCustomPropertyDrawerFor(property); Assert.IsNotNull(drawerX); Assert.IsInstanceOf <SomeDrawerX>(drawerX); }
public void ChangedIsSetWhenChildPropertyIsChanged() { TestThingSerialized thing = new TestThingSerialized(); SerializedPropertyX property = new SerializedPropertyX("name", typeof(TestThingSerialized), thing); property["x"].Value = 10; Assert.IsTrue(property.Changed); }
public int GetChildIndex(SerializedPropertyX child) { if (isCircular) { return(circularRef.GetChildIndex(child)); } return(children.IndexOf(child)); }
public static void DrawProperties(SerializedPropertyX root) { for (int i = 0; i < root.ChildCount; i++) { SerializedPropertyX property = root.GetChildAt(i); PropertyField(property, property.label, property.isExpanded); } }
public SerializedObjectX(object value) { root = value; if (value == null) throw new Exception("Target of a SerializedObjectX cannot be null or primitive"); Type type = value.GetType(); if (type.IsPrimitive || type.IsEnum || type == typeof(string)) { throw new Exception("Target of a SerializedObjectX cannot be null or primitive"); } rootProperty = new SerializedPropertyX(this, "__root__", value.GetType(), value); }
public static void PropertyField(Rect position, SerializedPropertyX property, GUIContent label, bool includeChildren = true) { var drawer = Reflector.GetExtendedPropertyDrawerFor(property.type); if (drawer != null) { drawer.OnGUI(position, property, label); } else { PropertyFieldExtendedValue(position, property, label); } }
public static void PropertyField(Rect position, SerializedPropertyX property) { PropertyField(position, property, property.label, true); }
private static void PropertyFieldExtendedValue(Rect position, SerializedPropertyX property, GUIContent label = null, GUIStyle style = null) { Type type = property.type; if (type.IsSubclassOf(typeof(UnityEngine.Object))) { property.Value = EditorGUI.ObjectField(position, label, (UnityEngine.Object)property.Value, type, true); } else if (type.IsArray) { if (property.Value == null) { property.Value = Array.CreateInstance(type.GetElementType(), 1); } //int ctrlId = GUIUtility.GetControlID(FocusType.Keyboard); property.isExpanded = EditorGUI.Foldout(position, property.isExpanded, label); if (property.isExpanded) { position.y += 16f; position.height -= 16f; EditorGUI.indentLevel++; Array array = (Array)property.Value; int length = array.Length; int newLength = 0; z = EditorGUI.IntField(position, new GUIContent("Size"), z); if (newLength < 0) newLength = 0; if (length != newLength) { var newArray = Array.CreateInstance(type.GetElementType(), newLength); for (int i = 0; i < newLength; i++) { if (i == array.Length) break; newArray.SetValue(array.GetValue(i), i); } array.CopyTo(newArray, 0); array = newArray; } position.y += 16f; position.height -= 16f; Type elementType = array.GetType().GetElementType(); for (int i = 0; i < array.Length; i++) { if (array.GetValue(i) == null) { array.SetValue(CreateInstance(elementType), i); } //array.SetValue(PropertyFieldExtendedValue(position, elementType, array.GetValue(i), new GUIContent("Element " + i), null), i); //position.y += 48f; //needs to be += getheight } EditorGUI.indentLevel--; } } else if (type.IsEnum) { if (style == null) style = EditorStyles.popup; //todo unity default is popup field property.Value = EditorGUI.EnumMaskField(position, label, (Enum)property.Value, style); } else if (type == typeof(Color)) { property.Value = EditorGUI.ColorField(position, label, (Color)property.Value); } else if (type == typeof(Bounds)) { Bounds b = (Bounds)property.Value; position = EditorGUI.PrefixLabel(position, label); position.x -= 48f; EditorGUI.LabelField(position, new GUIContent("Center:")); position.x += 53f; position.width -= 5f; b.center = EditorGUI.Vector3Field(position, GUIContent.none, b.center); position.y += 16f; position.x -= 53f; EditorGUI.LabelField(position, new GUIContent("Extents:")); position.x += 53f; b.extents = EditorGUI.Vector3Field(position, GUIContent.none, b.extents); property.Value = b; } else if (type == typeof(AnimationCurve)) { if (property.Value == null) property.Value = new AnimationCurve(); position.width = 200f; property.Value = EditorGUI.CurveField(position, label, (AnimationCurve)property.Value); } else if (type == typeof(double)) { if (style == null) style = EditorStyles.numberField; property.Value = EditorGUI.DoubleField(position, label, (double)property.Value, style); } else if (type == typeof(float)) { if (style == null) style = EditorStyles.numberField; property.Value = EditorGUI.FloatField(position, label, (float)property.Value, style); } else if (type == typeof(int)) { if (style == null) style = EditorStyles.numberField; property.Value = EditorGUI.IntField(position, label, (int)property.Value, style); } else if (type == typeof(long)) { if (style == null) style = EditorStyles.numberField; property.Value = EditorGUI.LongField(position, label, (long)property.Value, style); } else if (type == typeof(Rect)) { property.Value = EditorGUI.RectField(position, label, (Rect)property.Value); } else if (type == typeof(bool)) { if (style == null) style = EditorStyles.toggle; property.Value = EditorGUI.Toggle(position, label, (bool)property.Value, style); } else if (type == typeof(Vector2)) { property.Value = EditorGUI.Vector2Field(position, label, (Vector2)property.Value); } else if (type == typeof(Vector3)) { property.Value = EditorGUI.Vector3Field(position, label, (Vector3)property.Value); } else if (type == typeof(Vector4)) { property.Value = EditorGUI.Vector4Field(position, label.text, (Vector4)property.Value); } else if (type == typeof(string)) { if (style == null) style = EditorStyles.textField; property.Value = EditorGUI.TextField(position, label, (string)property.Value, style); } else { property.isExpanded = EditorGUI.Foldout(position, property.isExpanded, label); if (property.isExpanded) { EditorGUI.indentLevel++; position.y += 16f; position.height -= 16f; for (int i = 0; i < property.ChildCount; i++) { SerializedPropertyX child = property.GetChildAt(i); PropertyField(position, child); float propHeight = EditorGUIUtilityX.GetHeight(child, child.label, child.isExpanded); position.y += propHeight; position.height -= propHeight; } EditorGUI.indentLevel--; } } }
public abstract void OnGUI(Rect position, SerializedPropertyX property, GUIContent label);
public virtual float GetPropertyHeight(SerializedPropertyX property, GUIContent label) { return 16f; }
public static void PropertyField(SerializedPropertyX property, GUIContent label, bool includeChildren, params GUILayoutOption[] options) { Type type = property.type; ExtendedPropertyDrawer drawer = Reflector.GetExtendedPropertyDrawerFor(property.type); if (drawer != null) { drawer.OnGUI(GetControlRect(property), property, label); return; } if (type.IsSubclassOf(typeof(UnityEngine.Object))) { property.Value = EditorGUILayout.ObjectField(label, (UnityEngine.Object)property.Value, type, true, options); } else if (type.IsArray) { if (property.Value == null) { property.Value = Array.CreateInstance(type.GetElementType(), 1); } property.isExpanded = EditorGUILayout.Foldout(property.isExpanded, label.text); if (property.isExpanded) { EditorGUI.indentLevel++; property.ArraySize = EditorGUILayout.IntField(new GUIContent("Size"), property.ArraySize); for (int i = 0; i < property.ArraySize; i++) { SerializedPropertyX child = property.GetChildAt(i); PropertyField(child, child.label, child.isExpanded, options); } EditorGUI.indentLevel--; } } else if (type.IsEnum) { property.Value = EditorGUILayout.EnumMaskField(label, (Enum)property.Value, options); } else if (type == typeof(Color)) { property.Value = EditorGUILayout.ColorField(label, (Color)property.Value); } else if (type == typeof(Bounds)) { Bounds b = (Bounds)property.Value; property.Value = EditorGUILayout.BoundsField(label, b, options); } else if (type == typeof(AnimationCurve)) { if (property.Value == null) property.Value = new AnimationCurve(); property.Value = EditorGUILayout.CurveField(label, (AnimationCurve)property.Value, options); } else if (type == typeof(double)) { property.Value = EditorGUILayout.DoubleField(label, (double)property.Value); } else if (type == typeof(float)) { property.Value = EditorGUILayout.FloatField(label, (float)property.Value); } else if (type == typeof(int)) { property.Value = EditorGUILayout.IntField(label, (int)property.Value, options); } else if (type == typeof(long)) { property.Value = EditorGUILayout.LongField(label, (long)property.Value, options); } else if (type == typeof(Rect)) { property.Value = EditorGUILayout.RectField(label, (Rect)property.Value, options); } else if (type == typeof(bool)) { property.Value = EditorGUILayout.Toggle(label, (bool)property.Value, options); } else if (type == typeof(Vector2)) { property.Value = EditorGUILayout.Vector2Field(label, (Vector2)property.Value, options); } else if (type == typeof(Vector3)) { property.Value = EditorGUILayout.Vector3Field(label, (Vector3)property.Value, options); } else if (type == typeof(Vector4)) { property.Value = EditorGUILayout.Vector4Field(label.text, (Vector4)property.Value, options); } else if (type == typeof(string)) { property.Value = EditorGUILayout.TextField(label, (string)property.Value, options); } else { property.isExpanded = EditorGUILayout.Foldout(property.isExpanded, label); if (property.isExpanded) { EditorGUI.indentLevel++; for (int i = 0; i < property.ChildCount; i++) { SerializedPropertyX child = property.GetChildAt(i); PropertyField(child, child.label, child.isExpanded, options); } EditorGUI.indentLevel--; } } }
public static void PropertyField(SerializedPropertyX property, bool includeChildren, params GUILayoutOption[] options) { PropertyField(property, property.label, includeChildren, options); }
public static void PropertyField(SerializedPropertyX property, params GUILayoutOption[] options) { PropertyField(property, property.label, true, options); }
public static Rect GetControlRect(SerializedPropertyX property, GUIContent label = null) { label = label ?? property.label; return EditorGUILayout.GetControlRect(true, EditorGUIUtilityX.GetHeight(property, label, property.isExpanded)); }