public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { EditorGUI.BeginProperty(position, label, property); GrassPostProcess element = GetElement(property); property.isExpanded = EditorGUI.Foldout(new Rect(position.x, position.y, EditorGUIUtility.labelWidth, EditorGUIUtility.singleLineHeight), property.isExpanded, new GUIContent(NameAttribute.GetNameFromClassType(element.GetType()), NameAttribute.GetDescriptionFromClassType(element.GetType())), true); if (GUI.changed) { property.serializedObject.ApplyModifiedProperties(); } if (property.objectReferenceValue == null) { EditorGUIUtility.ExitGUI(); } if (property.isExpanded) { const float witdthOffset = 25f; var newRect = new Rect(position.x, position.y, position.width - position.x - witdthOffset, position.height); DrawAllChildrensGUI(newRect, property); } property.serializedObject.ApplyModifiedProperties(); EditorGUI.EndProperty(); }
private void OnAddDropdownCallback(Rect button, ReorderableList list) { GenericMenu menu = new GenericMenu(); #if UNITY_2018_2_OR_NEWER menu.allowDuplicateNames = true; #endif List <Type> types = AssetsManager.GetListOfType(typeof(GrassPostProcess)); foreach (Type type in types) { menu.AddItem(new GUIContent(NameAttribute.GetNameFromClassType(type), NameAttribute.GetDescriptionFromClassType(type)), false, AddPostProcessHandler, type.Name); } menu.ShowAsContext(); }