/// <summary> /// Draws the property. /// </summary> protected override void DrawPropertyLayout(IPropertyValueEntry <T> entry, GUIContent label) { FieldInfo fieldInfo; SerializedProperty unityProperty = entry.Property.Tree.GetUnityPropertyForPath(entry.Property.Path, out fieldInfo); if (unityProperty == null) { SirenixEditorGUI.ErrorMessageBox("Could not get a Unity SerializedProperty for the property '" + entry.Property.NiceName + "' of type '" + entry.TypeOfValue.GetNiceName() + "' at path '" + entry.Property.Path + "'."); return; } if (unityProperty.serializedObject.targetObject is EmittedScriptableObject <T> ) { var targetObjects = unityProperty.serializedObject.targetObjects; for (int i = 0; i < targetObjects.Length; i++) { EmittedScriptableObject <T> target = (EmittedScriptableObject <T>)targetObjects[i]; target.SetValue(entry.Values[i]); } unityProperty.serializedObject.Update(); unityProperty = unityProperty.serializedObject.FindProperty(unityProperty.propertyPath); } if (label == null) { label = GUIHelper.TempContent(""); } EditorGUILayout.PropertyField(unityProperty, label, true); if (unityProperty.serializedObject.targetObject is EmittedScriptableObject <T> ) { unityProperty.serializedObject.ApplyModifiedPropertiesWithoutUndo(); var targetObjects = unityProperty.serializedObject.targetObjects; for (int i = 0; i < targetObjects.Length; i++) { EmittedScriptableObject <T> target = (EmittedScriptableObject <T>)targetObjects[i]; entry.Values[i] = target.GetValue(); } } }
//private static readonly bool IsAtomic = AtomHandlerLocator.IsMarkedAtomic(typeof(T)); /// <summary> /// Draws the property. /// </summary> protected override void DrawPropertyLayout(GUIContent label) { var entry = this.ValueEntry; FieldInfo fieldInfo; SerializedProperty unityProperty = entry.Property.Tree.GetUnityPropertyForPath(entry.Property.Path, out fieldInfo); if (unityProperty == null) { SirenixEditorGUI.ErrorMessageBox("Could not get a Unity SerializedProperty for the property '" + entry.Property.NiceName + "' of type '" + entry.TypeOfValue.GetNiceName() + "' at path '" + entry.Property.Path + "'."); return; } bool isEmittedProperty = unityProperty.serializedObject.targetObject is EmittedScriptableObject <T>; if (isEmittedProperty) { var targetObjects = unityProperty.serializedObject.targetObjects; for (int i = 0; i < targetObjects.Length; i++) { EmittedScriptableObject <T> target = (EmittedScriptableObject <T>)targetObjects[i]; target.SetValue(entry.Values[i]); } unityProperty.serializedObject.Update(); unityProperty = unityProperty.serializedObject.FindProperty(unityProperty.propertyPath); } if (label == null) { label = GUIContent.none; } if (!isEmittedProperty) { EditorGUI.BeginChangeCheck(); } EditorGUILayout.PropertyField(unityProperty, label, true); if (!isEmittedProperty && EditorGUI.EndChangeCheck()) { entry.Values.ForceMarkDirty(); } //else if (!isEmittedProperty && IsAtomic) //{ // for (int i = 0; i < entry.ValueCount; i++) // { // entry.Values[i] = entry.Values[i]; // } //} if (isEmittedProperty) { unityProperty.serializedObject.ApplyModifiedPropertiesWithoutUndo(); var targetObjects = unityProperty.serializedObject.targetObjects; for (int i = 0; i < targetObjects.Length; i++) { EmittedScriptableObject <T> target = (EmittedScriptableObject <T>)targetObjects[i]; entry.Values[i] = target.GetValue(); } } }