private void OnDrawElement(Rect rect, int index, bool isActive, bool isFocused) { SerializedProperty foldoutProperty = GetPropertyFromIndexAndName(index, "IsFoldOut"); SerializedProperty depthProperty = GetPropertyFromIndexAndName(index, "TriggerAtDepth"); SerializedProperty delayProperty = GetPropertyFromIndexAndName(index, "TriggerDelayTime"); SerializedProperty typeProperty = GetPropertyFromIndexAndName(index, "EventType"); float[] widths = new float[] { rect.width / 4.0f, rect.width / 4.0f, rect.width / 2.0f }; float[] offsets = new float[] { 0.0f, rect.width / 4.0f, rect.width / 2.0f }; SerializedProperty[] properties = new SerializedProperty[] { depthProperty, delayProperty, typeProperty }; for (int i = 0; i < 3; ++i) { Rect r = new Rect(rect.x + offsets[i] + (i != 0 ? LINE_SPACING / 2 : 0.0f), rect.y, widths[i] - (i == 0 || i == 2 ? LINE_SPACING / 2 : LINE_SPACING), LINE_HEIGHT); EditorGUI.PropertyField(r, properties[i], GUIContent.none); } //Rect depthRect = new Rect(rect.x, rect.y, EditorGUIUtility.labelWidth - 4.0f, LINE_HEIGHT); //Rect typeRect = new Rect(rect.x + EditorGUIUtility.labelWidth, rect.y, rect.width - EditorGUIUtility.labelWidth, LINE_HEIGHT); //EditorGUI.PropertyField(depthRect, depthProperty, GUIContent.none); //EditorGUI.PropertyField(typeRect, typeProperty, GUIContent.none); GameEventCore.EGameEventType type = (GameEventCore.EGameEventType)typeProperty.enumValueIndex; Rect propertyRect = new Rect(rect.x, rect.y + LINE_HEIGHT + LINE_SPACING, rect.width, LINE_HEIGHT); Rect tempRect = propertyRect; DrawProperty(ref propertyRect, index, "Name", false); foldoutProperty.isExpanded = foldoutProperty.boolValue = EditorGUI.Foldout(tempRect, foldoutProperty.boolValue, GUIContent.none); if (foldoutProperty.isExpanded) { propertyRect.x += LINE_HEIGHT + LINE_SPACING; propertyRect.width -= LINE_HEIGHT + LINE_SPACING; string[] gameEventProperties = GameEventCore.GameEventActions[(int)type].OnGetProperties(); for (int i = 0; i < gameEventProperties.Length; ++i) { DrawProperty(ref propertyRect, index, gameEventProperties[i]); } } }
private float OnElementHeight(int index) { float height = 0.0f; SerializedProperty foldoutProperty = GetPropertyFromIndexAndName(index, "IsFoldOut"); if (foldoutProperty.isExpanded) { GameEventCore.EGameEventType type = (GameEventCore.EGameEventType)GetPropertyFromIndexAndName(index, "EventType").enumValueIndex; string[] gameEventProperties = GameEventCore.GameEventActions[(int)type].OnGetProperties(); for (int i = 0; i < gameEventProperties.Length; ++i) { SerializedProperty property = GetPropertyFromIndexAndName(index, gameEventProperties[i]); if (property != null) { height += GetPropertyHeight(property) + LINE_SPACING; } else { height += LINE_HEIGHT + LINE_SPACING; } } } return(ELEMENT_SPACING + LINE_HEIGHT + LINE_SPACING + height); }