UnityEditor.PrefabInspector.AddComponentGUI C# (CSharp) Method

AddComponentGUI() private static method

private static AddComponentGUI ( Object prefab ) : void
prefab Object
return void
        private static void AddComponentGUI(Object prefab)
        {
            bool flag;
            SerializedObject obj2 = new SerializedObject(prefab);
            SerializedProperty x = obj2.FindProperty("m_Modification");
            SerializedProperty endProperty = x.GetEndProperty();
            do
            {
                flag = EditorGUILayout.PropertyField(x, new GUILayoutOption[0]);
            }
            while (x.NextVisible(flag) && !SerializedProperty.EqualContents(x, endProperty));
            obj2.ApplyModifiedProperties();
        }

Usage Example

Exemplo n.º 1
0
 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);
 }