Example #1
0
    static IEnumerable <Object> GetRemovedObjects(Object go, PEPrefabScript prefabInstance)
    {
        foreach (var liif in prefabInstance.Modifications.RemovedObjects)
        {
            var instanceObj = prefabInstance.GetDiffWith().Links[liif];
            if (instanceObj == null)
            {
                continue;
            }

            var removedGO        = instanceObj.InstanceTarget as GameObject;
            var removedComponent = instanceObj.InstanceTarget as Component;

            if (removedComponent is PEPrefabScript)
            {
                continue;
            }

            var remoteParent = (removedGO != null) ? (removedGO.transform.parent == null ? removedGO.transform.gameObject : removedGO.transform.parent.gameObject) : (removedComponent != null ? removedComponent.gameObject : null);

            var localLink = prefabInstance.Links[prefabInstance.GetDiffWith().Links[remoteParent]];
            if (localLink == null)
            {
                continue;
            }

            var localParent = localLink.InstanceTarget;

            if (localParent == go)
            {
                yield return(instanceObj.InstanceTarget);
            }
        }
    }
Example #2
0
    static internal void DrawView(PEPrefabScript script)
    {
        GUILayout.Space(3);
        var icon = EditorGUIUtility.ObjectContent(null, typeof(GameObject));

        GUILayout.BeginHorizontal();

        if (!string.IsNullOrEmpty(script.ParentPrefabGUID))
        {
            var c = GUI.backgroundColor;

            if (!script.ParentPrefab)
            {
                GUI.backgroundColor = Color.red;
            }

            var content = new GUIContent(script.ParentPrefab ? script.ParentPrefab.name : "Missing:" + script.ParentPrefabGUID, icon.image);

            GUILayout.Label("Parent:", GUILayout.Width(50));

            if (GUILayout.Button(content, EditorStyles.miniButton, GUILayout.Height(16), GUILayout.MinWidth(0)))
            {
                EditorGUIUtility.PingObject(script.ParentPrefab);
            }

            GUI.backgroundColor = c;
        }
        if (!string.IsNullOrEmpty(script.PrefabGUID))
        {
            var c = GUI.backgroundColor;

            if (!script.Prefab)
            {
                GUI.backgroundColor = Color.red;
            }

            var content = new GUIContent(script.Prefab ? script.Prefab.name : "Missing:" + script.PrefabGUID, icon.image);

            GUILayout.Label("Prefab:", GUILayout.Width(50));

            if (GUILayout.Button(content, EditorStyles.miniButton, GUILayout.Height(16), GUILayout.MinWidth(0)))
            {
                EditorGUIUtility.PingObject(script.Prefab);
            }

            GUI.backgroundColor = c;
        }
        GUILayout.EndHorizontal();
        GUILayout.Space(1);
        DrawCommands(script);

        EditorGUIUtility.labelWidth = 150;
    }
Example #3
0
    static void DrawCommands(PEPrefabScript prefabScript)
    {
        var e = GUI.enabled;

        GUI.enabled = true;
        if (GUILayout.Button("Menu", EditorStyles.miniButton))
        {
            var menu = new GenericMenu();
            PEUtils.BuildMenu(menu, prefabScript, PrefabUtility.GetPrefabParent(prefabScript.gameObject) == prefabScript.Prefab);
            menu.ShowAsContext();
        }
        GUI.enabled = e;
    }