SetPropertyModifications() private method

private SetPropertyModifications ( Object targetPrefab, PropertyModification modifications ) : void
targetPrefab Object
modifications PropertyModification
return void
 public static void OnOverridenPrefabsInspector(GameObject gameObject)
 {
     GUI.enabled = true;
     UnityEngine.Object prefabObject = PrefabUtility.GetPrefabObject(gameObject);
     if (prefabObject == null)
     {
         return;
     }
     EditorGUIUtility.labelWidth = 200f;
     if (PrefabUtility.GetPrefabType(gameObject) == PrefabType.PrefabInstance)
     {
         PropertyModification[] propertyModifications = PrefabUtility.GetPropertyModifications(gameObject);
         if (propertyModifications != null && propertyModifications.Length != 0)
         {
             GUI.changed = false;
             for (int i = 0; i < propertyModifications.Length; i++)
             {
                 propertyModifications[i].value = EditorGUILayout.TextField(propertyModifications[i].propertyPath, propertyModifications[i].value, new GUILayoutOption[0]);
             }
             if (GUI.changed)
             {
                 PrefabUtility.SetPropertyModifications(gameObject, propertyModifications);
             }
         }
     }
     PrefabInspector.AddComponentGUI(prefabObject);
 }
示例#2
0
        public static void OnOverridenPrefabsInspector(GameObject gameObject)
        {
            GUI.enabled = true;

            var prefab = PrefabUtility.GetPrefabObject(gameObject);

            if (prefab == null)
            {
                return;
            }

            EditorGUIUtility.labelWidth = 200;

            if (PrefabUtility.GetPrefabType(gameObject) == PrefabType.PrefabInstance)
            {
                PropertyModification[] modifications = PrefabUtility.GetPropertyModifications(gameObject);
                if (modifications != null && modifications.Length != 0)
                {
                    GUI.changed = false;
                    for (int i = 0; i < modifications.Length; i++)
                    {
                        modifications[i].value = EditorGUILayout.TextField(modifications[i].propertyPath, modifications[i].value);
                    }

                    if (GUI.changed)
                    {
                        PrefabUtility.SetPropertyModifications(gameObject, modifications);
                    }
                }
            }

            AddComponentGUI(prefab);
        }