Forge/Editor/DataInspector.cs
/// <summary>
/// Helper method to edit the given field on the specified data instance.
/// </summary>
/// <param name="data">The data instance to edit.</param>
/// <param name="property">The property on the instance to modify.</param>
Helper method to edit the given field on the specified data instance.
Helper method to edit the given field on the specified data instance .
private void EditProperty(Data.IData data, PropertyMetadata property) {
            TooltipAttribute tooltip = (TooltipAttribute)Attribute.GetCustomAttribute(property.MemberInfo, typeof(TooltipAttribute));
            CommentAttribute comment = (CommentAttribute)Attribute.GetCustomAttribute(property.MemberInfo, typeof(CommentAttribute));
            GUIContent label = new GUIContent(property.Name, tooltip != null ? tooltip.Tooltip : "");
            if (comment != null) {
                EditorGUILayout.HelpBox(comment.Comment, MessageType.Info);
            }
            IPropertyEditor propertyEditor = PropertyEditor.Get(property.StorageType, property.MemberInfo);
            object currentValue = property.Read(data);
            Rect rect = EditorGUILayout.GetControlRect(true, propertyEditor.GetElementHeight(label, currentValue));
            object updatedValue = propertyEditor.Edit(rect, label, currentValue);
            property.Write(data, updatedValue);
        }
private void EditProperty ( Data . IData data , PropertyMetadata property ) { TooltipAttribute tooltip = ( TooltipAttribute ) Attribute . GetCustomAttribute ( property . MemberInfo , typeof ( TooltipAttribute ) ) ; CommentAttribute comment = ( CommentAttribute ) Attribute . GetCustomAttribute ( property . MemberInfo , typeof ( CommentAttribute ) ) ; GUIContent label = new GUIContent ( property . Name , tooltip != null ? tooltip . Tooltip : " " ) ; if ( comment != null ) { EditorGUILayout . HelpBox ( comment . Comment , MessageType . Info ) ; } IPropertyEditor propertyEditor = PropertyEditor . Get ( property . StorageType , property . MemberInfo ) ; object currentValue = property . Read ( data ) ; Rect rect = EditorGUILayout . GetControlRect ( true , propertyEditor . GetElementHeight ( label , currentValue ) ) ; object updatedValue = propertyEditor . Edit ( rect , label , currentValue ) ; property . Write ( data , updatedValue ) ; }
Helper method to edit the given field on the specified data instance.
Helper method to edit the given field on the specified data instance .
// edit the field
data
Data.IData
The data instance to edit.
The data instance to edit .
property
PropertyMetadata
The property on the instance to modify.
The property on the instance to modify .