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 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 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; }
public SerializedPropertyX FindProperty(string propertyName) { if (isCircular) { return(circularRef.FindProperty(propertyName)); } return(children.Find((child) => child.name == propertyName)); }
public override void Render() { if (targetItem == null) { return; } SerializedPropertyX castMode = rootProperty.FindProperty("castMode"); SerializedPropertyX ignoreGCD = rootProperty.FindProperty("IgnoreGCD"); SerializedPropertyX castTime = rootProperty.FindProperty("castTime").FindProperty("baseValue"); SerializedPropertyX channelTime = rootProperty.FindProperty("channelTime").FindProperty("baseValue"); SerializedPropertyX channelTicks = rootProperty.FindProperty("channelTicks").FindProperty("baseValue"); SerializedPropertyX charges = rootProperty.FindProperty("charges"); GUILayout.BeginHorizontal(); EditorGUILayoutX.PropertyField(castMode, false); ignoreGCD.Value = EditorGUILayout.ToggleLeft("Ignore GCD", (bool)ignoreGCD.Value); GUILayout.EndHorizontal(); int castVal = (int)castMode.Value; if (castVal != (int)CastMode.Instant) { if (castVal != (int)CastMode.Channel) { castTime.Value = EditorGUILayout.FloatField(new GUIContent("Cast Time"), (float)castTime.Value); } if (castVal != (int)CastMode.Cast) { channelTime.Value = EditorGUILayout.FloatField(new GUIContent("Channel Time"), (float)channelTime.Value); channelTicks.Value = EditorGUILayout.IntField(new GUIContent("Channel Ticks"), (int)channelTicks.Value); } } EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Charges (" + charges.ArraySize + ")"); if (GUILayout.Button("+", GUILayout.Width(25f))) { charges.ArraySize++; } EditorGUILayout.EndHorizontal(); EditorGUI.indentLevel++; for (int i = 0; i < charges.ArraySize; i++) { EditorGUILayout.BeginHorizontal(); SerializedPropertyX chargeProp = charges.GetChildAt(i); SerializedPropertyX cooldown = chargeProp.FindProperty("cooldown").FindProperty("baseValue"); cooldown.Value = EditorGUILayout.FloatField(new GUIContent("Cooldown"), (float)cooldown.Value); GUI.enabled = charges.ArraySize > 1; if (GUILayout.Button("-", GUILayout.Width(25f), GUILayout.Height(15f))) { charges.DeleteArrayElementAt(i); } GUI.enabled = true; EditorGUILayout.EndHorizontal(); } EditorGUI.indentLevel--; }
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; }
private void Initialize(SerializedPropertyX source) { if (!initialized) { var tmp = source.GetParent; while (tmp != null) { rootProperty = tmp; tmp = rootProperty.GetParent; } listRoot = source["modifiers"]; listRenderer = new ListRenderer(); listRenderer.Initialize(); listRenderer.SetTargetProperty(rootProperty, listRoot); listRenderer.SetSearchBox(CreateSearchBox); skipRenderingFields = new List <string>(); skipRenderingFields.Add("modifiers"); skipRenderingFields.Add("contextType"); debugMode = source.FindProperty("debugMode"); initialized = true; } }
public SerializedPropertyX FindProperty(string name) { return(rootProperty.FindProperty(name)); }