MemberExposerFunctions Class Reference

This class contains functions that can be used to extract the ExposedMembers of a given object, and functions to draw each, or all of the ExposedMembers found, in a custom editor/property-drawer

Classes

class  ExposeDelegatesForType
 Each instance of this class stores three delegates that are used to draw the property(both, an auto layout and Rect-specified, versions), or get it's hight.
The user may choose to create and register one's own instance of this class, specifying custom draw and height functions, for a custom type.
 

Public Member Functions

delegate bool ExposeMemberDelegate (Rect drawRect, ExposedMember field, GUIStyle guiStyle, object undoObject=null, GUIContent overrideLabel=null)
 Defines the signature of a function used to draw the auto-layout version of a specific type's control. It is the duty of this function to draw the control using the appropriate EditorGUI functions.
Note that there are, generally, two versions of EditorGUI functions, one that takes a GUIStyle as a parameter, and another that does not. It is the duty of this function to check if the optional "guiStyle" parameter is null or not, and call the appropriate EditorGUI function. (This is necessary because passing a null GUIStyle into any EditorGUI functions that take it, will generate a unity-runtime error) It must also check to see if the value is changed by the user and return true, if so. It's duties also include recording the undoObject via MemberExposerFunctions.recordUndo(undoObject, field). This should only be done if a change is made and the MemberExposerFunctions.recordUndoOnChange override value is true, but BEFORE the change is applied.
 
delegate float ExposeMemberHeightDelegate (ExposedMember field)
 Defines the signature of a function used to determine the height of a control that is NOT using the auto-layout.
 
delegate bool ExposeMemberLayoutDelegate (ExposedMember field, GUILayoutOption[] guiOptions, object undoObject=null, GUIContent overrideLabel=null)
 Defines the signature of a function used to draw the auto-layout version of a specific type's control. It is the duty of this function to draw the control using the appropriate EditorGUILayout functions. It must also check to see if the value is changed by the user and return true, if so. It's duties also include recording the undoObject via MemberExposerFunctions.recordUndo(undoObject, field). This should only be done if a change is made and the MemberExposerFunctions.recordUndoOnChange override value is true, but BEFORE the change is applied.
 

Static Public Member Functions

static void ExposeAllProperties (Rect drawRect, ExposedObjectMembers exposedObjectMembers, GUIStyle guiStyle, object undoObject=null)
 Used to draw all the exposed properties in the list, starting at the drawRect location. The list is actually a dictionary, which contains multiple sub-lists of ExposedProperties, each with their own group name.
 
static float ExposeAllPropertiesHeight (ExposedObjectMembers exposedObjectMembers)
 Used to compute the height of a set of grouped exposed properties
 
static void ExposeAllPropertiesLayout (ExposedObjectMembers exposedObjectMembers, object undoObject=null)
 Used to draw all the exposed properties in the list, using unity's auto-layout. The list is actually a dictionary, which contains multiple sub-lists of ExposedProperties, each with their own group name.
 
static bool ExposeProperty (Rect drawRect, ExposedMember field, GUIStyle guiStyle, object undoObject=null, GUIContent overrideLabel=null, bool useGroups=true)
 Uses the appropriate EditorGUI fFunction to draw the specified property, and if a change is detected, store the new value. Passing an object to the undoObject parameter, will allow the system to record an undo-copy of the object, when a change is detected (just before the change is applied to the object). If the type of the ExposedProperty does not have a registered ExposeDelegatesForType, this function will attempt to create a CustomTypeExposer for it, dynamically. if the field is read-only, and the MemberExposerFunctions.disableGUIForReadOnlyAccessors value is true, the control will be drawn disabled, and not respond to the user.
 
static float ExposePropertyHeight (ExposedMember field, bool useGroups=true)
 Determines the drawn height of the exposed property. If the property is not visible because it's group is folded up, will return 0.
 
static bool ExposePropertyLayout (ExposedMember field, GUILayoutOption[] guiOptions, object undoObject=null, GUIContent overrideLabel=null, bool useGroups=true)
 Uses the appropriate EditorGUILayout function to draw the specified property, and if a change is detected, store the new value. Passing an object to the undoObject parameter, will allow the system to record an undo-copy of the object, when a change is detected (just before the change is applied to the object). If the field is read-only, and the MemberExposerFunctions.disableGUIForReadOnlyAccessors value is true, the control will be drawn disabled, and not respond to the user.
 
static ExposedMember FindExposedMemberByName (IEnumerable allProperties, string name)
 Searches the provided array of ExposedMember's for any with the specified name.
Returns the first ExposedMember found with that name, or if none are found, returns null. Rather than searching the nicified ExposedMember.Name, it searches for the identifier, in code, of the exposed-accessor. (via- System.Reflection.PropertyInfo.Name)
 
static ExposedMember[] GetAllExposedPropertiesInObject (System.Object obj, string prependPath=null)
 Uses reflection to find all the [ExposeProperty] attributes assigned to the specified object. All the fields found are returned as an array of ExposedMember objects that store various information about the accessor.
 
static ExposeDelegatesForType GetDelegatesForType (System.Type typeDelegatesExpose, bool includeBaseClasses=false)
 Gets the registered exposer delegate for the specified type. If no delegate is found, will conditionally search for an exposer of an ancestor class
 
static bool HasDelegatesRegistered (System.Type typeDelegatesExpose, bool includeBaseClasses=false)
 public function that allows user to check if a Type already has Expose delegates registered.
 
static bool InternalExposeProperty (bool useLayout, Rect drawRect, ExposedMember field, GUIStyle guiStyle, object undoObject=null, GUIContent overrideLabel=null, bool useGroups=true, GUILayoutOption[] guiOptions=null)
 Uses the appropriate EditorGUI fFunction to draw the specified property, and if a change is detected, store the new value. Passing an object to the undoObject parameter, will allow the system to record an undo-copy of the object, when a change is detected (just before the change is applied to the object). If the type of the ExposedProperty does not have a registered ExposeDelegatesForType, this function will attempt to create a CustomTypeExposer for it, dynamically. if the field is read-only, and the MemberExposerFunctions.disableGUIForReadOnlyAccessors value is true, the control will be drawn disabled, and not respond to the user.
 
static void recordUndo (object undoObject, ExposedMember field)
 Check that the undoObject is not null, and if so, records it via undo
 
static void RegisterDelegates (System.Type typeDelegateExposes, ExposeDelegatesForType toRegister)
 Allows the User to Optionally specify drawer delegates for additional exposed-property types, that are not already included in the built-in types.
 

Static Public Attributes

static bool disableGUIForReadOnlyAccessors
 When true (default), exposed read-only accessors and fields will have GUI.enabled set to false, when drawn to screen, preventing user changes, and gray-out display.
 
static bool recordUndoOnChange
 Undo recording override control. Set to false to prohibit recording of undo.