/// <summary> /// Finds the serialized property starting from the root object (the Monobehaviour or the ScriptableObject) and /// going down through every composed fields (custom serializable class and struct). /// </summary> private void FindSerializedProperty() { serializedProperty = FieldInfoHelper.GetSerializedPropertyFromPath(entityInfo.propertyPath, serializedObject, out directParentSerializedObject); if (serializedProperty == null) { string path = FieldInfoHelper.GetFieldInfoPath(entityInfo.fieldInfo, serializedObject.targetObject.GetType()); if (!string.IsNullOrEmpty(path)) { string[] pathTable = path.Split('.'); if (pathTable.Length > 0) { serializedProperty = serializedObject.FindProperty(pathTable [0]); for (int i = 1; i < pathTable.Length; i++) { serializedProperty = serializedProperty.FindPropertyRelative(pathTable [i]); } } } else { Debug.LogWarning("The field info " + entityInfo.fieldInfo.Name + " you initialized this renderer with cannot be found in the children properties of the target."); } } }
void RenderObjectClass(Action preRender = null) { EditorGUILayout.PropertyField(FieldInfoHelper.GetSerializedPropertyFromPath(entityInfo.propertyPath, serializedObject)); if (subtarget != null) { CreateSerializedObject(); subSerializedObject.Update(); EditorGUI.indentLevel += 2 * Settings.indentation; foldout = EditorGUILayout.Foldout(foldout, ""); if (foldout) { GUILayout.Space(15 * Settings.indentation); EditorGUILayout.BeginHorizontal(InspectorStyle.DefaultStyle.inlineFoldableBackgroundStyle); base.Render(preRender); EditorGUILayout.EndHorizontal(); } EditorGUI.indentLevel -= 2 * Settings.indentation; subSerializedObject.ApplyModifiedProperties(); } CheckIfTargetNotNull(); }
public override void InitializeFromEntityInfo(EntityInfo entityInfo) { base.InitializeFromEntityInfo(entityInfo); isReadOnly = (AttributeHelper.GetAttribute <ReadOnlyAttribute>(entityInfo.fieldInfo) != null); isSelectable = (AttributeHelper.GetAttribute <SelectableAttribute>(entityInfo.fieldInfo) != null); list = FieldInfoHelper.GetSerializedPropertyFromPath(entityInfo.propertyPath, entityInfo.serializedObject); listControl = new ReorderableListControl(); listControl.ItemInserted += ListControl_OnItemInsertedHandler; listControl.ItemRemoving += ListControl_OnItemRemovingHandler; listControl.ItemMoved += ListControl_OnItemMovedHandler; if (isReadOnly) { listControl.Flags = ReorderableListFlags.DisableReordering | ReorderableListFlags.DisableContextMenu | ReorderableListFlags.HideAddButton | ReorderableListFlags.HideRemoveButtons; } listAdaptor = new EESerializedPropertyAdaptor(serializedProperty, isReadOnly); listAdaptor.OnItemSelected += ListAdaptor_HandleOnItemSelected; listAdaptor.OnItemInserted += ListAdaptor_HandleOnItemInserted; listAdaptor.OnDrawItem += ListAdaptor_HandleOnDrawItem; listAdaptor.OnDrawItemBackground += ListAdaptor_HandleOnDrawItemBackground; }