Esempio n. 1
0
        public InspectableProperty GetEndProperty(bool includeInVisible = false)
        {
            InspectableProperty property = Copy();

            if (includeInVisible)
            {
                property.Next(false);
                return(property);
            }
            property.NextVisible(false);
            return(property);
        }
Esempio n. 2
0
        public static void SetPrefabOverride(object userData)
        {
            InspectableProperty inspectableProperty = userData as InspectableProperty;

            if (inspectableProperty != null && inspectableProperty.Type != NullableStr)
            {
#if UNITY_2018_2_OR_NEWER
                Object prefab = PrefabUtility.GetCorrespondingObjectFromSource(inspectableProperty.InspectableObject.SerializedObject.targetObject);
#else
                Object prefab = PrefabUtility.GetPrefabParent(inspectableProperty.InspectableObject.SerializedObject.targetObject);
#endif
                SerializedObject   serializedObject   = new SerializedObject(prefab);
                SerializedProperty serializedProperty = serializedObject.FindProperty(inspectableProperty.InspectableObject.Path);
                InspectableObject  inspectableObject  = InspectableObject.CreateInstance(serializedProperty);
                inspectableProperty.Value = inspectableObject.FindProperty(inspectableProperty.PropertyPath).Value;
                inspectableProperty.InspectableObject.ApplyModifiedProperties();
            }
            else
            {
                InspectableObject inspectableObject = inspectableProperty == null ? userData as InspectableObject : inspectableProperty.InspectableObject;
                if (inspectableObject != null)
                {
                    InspectableProperty prop = inspectableObject.GetIterator();
                    while (prop.Next(true))
                    {
                        SetPrefabOverride(prop);
                    }
                }
                else
                {
                    SerializedProperty serializedProperty = userData as SerializedProperty;
                    if (serializedProperty != null && serializedProperty.IsInspectableObjectDataArrayOrList())
                    {
                        for (int i = 0; i < serializedProperty.arraySize; i++)
                        {
                            SerializedProperty prop = serializedProperty.GetArrayElementAtIndex(i);
                            if (prop.IsInspectableObjectData())
                            {
                                SetPrefabOverride(InspectableObject.CreateInstance(prop));
                            }
                        }
                    }
                }
            }
        }