public override void OnGUI(Rect pos, SerializedProperty property, GUIContent label) { Widget.Input target = DrawerHelper.GetParent(property) as Widget.Input; if (target == null) { return; } if (target.Owner == null) { target.Owner = property.serializedObject.targetObject as Widget; } //EditorGUIUtility.LookLikeControls(); bool expanded_state = sm_ExpandedStates[property.propertyPath]; bool expanded = EditorGUI.Foldout(m_Expanded ? new Rect(pos.x, pos.y, pos.width / 2, pos.height / m_Rows) : pos, expanded_state, label); if (expanded_state) { EditorGUI.indentLevel += 1; EditorGUI.LabelField(new Rect(pos.x, pos.y += pos.height / m_Rows, pos.width, pos.height / m_Rows), "Input Name: " + target.FullInputName); EditorGUI.LabelField(new Rect(pos.x, pos.y += pos.height / m_Rows, pos.width, pos.height / m_Rows), "Data Type: " + target.DataTypeName); EditorGUI.indentLevel -= 1; } sm_ExpandedStates[property.propertyPath] = expanded; }
public override void OnGUI(Rect pos, SerializedProperty properties, GUIContent label) { SerializedDelegate target = DrawerHelper.GetParent(properties) as SerializedDelegate; if (target == null) { return; } SerializedProperty targetProperty = properties.FindPropertyRelative("m_Target"); SerializedProperty methodProperty = properties.FindPropertyRelative("m_Method"); SerializedProperty componentProperty = properties.FindPropertyRelative("m_Component"); // pass through label EditorGUIUtility.LookLikeControls(); EditorGUI.LabelField( new Rect(pos.x, pos.y, pos.width / 2, pos.height / rows), label ); // target + method section EditorGUI.indentLevel++; // select target if (EditorGUI.PropertyField(new Rect(pos.x, pos.y += pos.height / rows, pos.width, pos.height / rows), targetProperty)) { Log.Debug("SerializedDelegate", "PropertyField()"); } List <string> components = GetComponents(targetProperty); if (components != null) { int selected = components.IndexOf(componentProperty.stringValue); int select = EditorGUI.Popup(new Rect(pos.x, pos.y += pos.height / rows, pos.width, pos.height / rows), "Component", selected, components.ToArray()); if (select != selected) { componentProperty.stringValue = components[select]; } List <string> methods = GetComponentMethods(target.DelegateType, targetProperty, componentProperty); if (methods != null) { selected = methods.IndexOf(methodProperty.stringValue); select = EditorGUI.Popup(new Rect(pos.x, pos.y += pos.height / rows, pos.width, pos.height / rows), "Method", selected, methods.ToArray()); if (select != selected) { methodProperty.stringValue = methods[select]; } } } EditorGUI.indentLevel--; }