private void DrawPropertyChildrenRecursive(SerializedProperty property, SerializedProperty propertyReference) { SerializedProperty endProperty = property.GetEndProperty(); SerializedProperty endReferenceProperty = (propertyReference != null) ? propertyReference.GetEndProperty() : null; // go into the children of the property property.NextVisible(enterChildren: true); if (propertyReference != null) { propertyReference.NextVisible(enterChildren: true); } EditorGUI.indentLevel++; do { bool changed = this.ArePropertyValuesChanged(property, propertyReference); EditorGUIUtil.SetBoldDefaultFont(changed); EditorGUILayout.PropertyField(property); if (property.hasVisibleChildren && property.isExpanded) { this.DrawPropertyChildrenRecursive(property.Copy(), (propertyReference != null) ? propertyReference.Copy() : null); } } while (this.EnterNextVisibleForProperties(property, ref propertyReference, endReferenceProperty, enterChildren: false) && !SerializedProperty.EqualContents(property, endProperty)); EditorGUI.indentLevel--; }
protected virtual void ObjectOnGUI(TEntity entity, SerializedProperty serializedObj, SerializedProperty serializedObjReference, Rect objRect) { // Icon + Title Texture2D iconTexture = null; string title = "Default"; EditorDisplayComponent displayComponent = entity.GetComponent <EditorDisplayComponent>(); if (displayComponent != null) { iconTexture = displayComponent.iconTexture; if (!displayComponent.title.IsNullOrEmpty()) { title = Regex.Replace(displayComponent.title, @"\s+", ""); } } iconTexture = iconTexture ?? Texture2DUtil.CreateTextureWithColor(Color.blue, kIconEdgeSize, kIconEdgeSize); GUIStyle titleStyle = new GUIStyle(this._skin.customStyles[0]); EditorGUILayout.LabelField(new GUIContent(title, iconTexture), titleStyle, GUILayout.Width(kIconEdgeSize), GUILayout.Height(kIconEdgeSize + 10.0f)); // Fields float oldFieldWidth = EditorGUIUtility.fieldWidth; EditorGUIUtility.fieldWidth = kFieldWidth; EditorGUIUtility.labelWidth = kLabelWidth; SerializedProperty property = serializedObj; SerializedProperty propertyReference = serializedObjReference; this.DrawPropertyChildrenRecursive(property, propertyReference); EditorGUIUtil.SetBoldDefaultFont(false); property.Reset(); EditorGUIUtility.fieldWidth = oldFieldWidth; EditorGUIUtility.labelWidth = 0; }