private void ShowProp(ref Rect labelRect, ref Rect valueRect, ref Rect sourceRect, string label, string value, ILayoutElement source)
 {
   GUI.Label(labelRect, label, this.m_Styles.labelStyle);
   GUI.Label(valueRect, value, this.m_Styles.labelStyle);
   GUI.Label(sourceRect, source != null ? source.GetType().Name : "none", this.m_Styles.labelStyle);
   labelRect.y += EditorGUIUtility.singleLineHeight;
   valueRect.y += EditorGUIUtility.singleLineHeight;
   sourceRect.y += EditorGUIUtility.singleLineHeight;
 }
 private void ShowProp(ref Rect labelRect, ref Rect valueRect, ref Rect sourceRect, string label, string value, ILayoutElement source)
 {
     GUI.Label(labelRect, label, m_Styles.labelStyle);
     GUI.Label(valueRect, value, m_Styles.labelStyle);
     GUI.Label(sourceRect, source == null ? "none" : source.GetType().Name, m_Styles.labelStyle);
     labelRect.y  += EditorGUIUtility.singleLineHeight;
     valueRect.y  += EditorGUIUtility.singleLineHeight;
     sourceRect.y += EditorGUIUtility.singleLineHeight;
 }
示例#3
0
        private static ILayoutElement AddChildFields(ILayoutElement layoutElement, InitialiseElement initialiseElement = null)
        {
            var type = layoutElement.GetType();

            foreach (var field in type.GetFields())
            {
                if (!typeof(ILayoutElement).IsAssignableFrom(field.FieldType))
                {
                    continue;
                }
                var child = field.GetValue(layoutElement) as ILayoutElement;
                initialiseElement?.Invoke(child);
                ApplyAttributes(field.GetCustomAttributes(true), child);
                // Recurse to child, filling in it's children if it has any.
                AddChildFields(child, initialiseElement);
                layoutElement.Children.Add(child);
                child.Parent = layoutElement;
            }
            foreach (var property in type.GetProperties())
            {
                var attributes = property.GetCustomAttributes(true);
                if (!typeof(ILayoutElement).IsAssignableFrom(property.PropertyType) ||
                    !attributes.Any(x => x is ElementAttribute))
                {
                    continue;
                }
                var child = property.GetValue(layoutElement, new object[0]) as ILayoutElement;
                initialiseElement?.Invoke(child);
                // Recurse to child, filling in it's children if it has any.
                AddChildFields(child, initialiseElement);
                layoutElement.Children.Add(child);
                ApplyAttributes(attributes, child);
                child.Parent = layoutElement;
            }
            return(layoutElement);
        }