FindRootGameObjectWithSameParentPrefab() private method

private FindRootGameObjectWithSameParentPrefab ( GameObject target ) : GameObject
target UnityEngine.GameObject
return UnityEngine.GameObject
コード例 #1
0
        internal static void RevertPrefabInstanceWithUndo(GameObject target)
        {
            string     text       = "Revert Prefab Instance";
            PrefabType prefabType = PrefabUtility.GetPrefabType(target);
            bool       flag       = prefabType == PrefabType.DisconnectedModelPrefabInstance || prefabType == PrefabType.DisconnectedPrefabInstance;
            GameObject gameObject;

            if (flag)
            {
                gameObject = PrefabUtility.FindRootGameObjectWithSameParentPrefab(target);
            }
            else
            {
                gameObject = PrefabUtility.FindValidUploadPrefabInstanceRoot(target);
            }
            List <UnityEngine.Object> hierarchy = new List <UnityEngine.Object>();

            PrefabUtility.GetObjectListFromHierarchy(hierarchy, gameObject);
            Undo.RegisterFullObjectHierarchyUndo(gameObject, text);
            if (flag)
            {
                PrefabUtility.ReconnectToLastPrefab(gameObject);
                Undo.RegisterCreatedObjectUndo(PrefabUtility.GetPrefabObject(gameObject), text);
            }
            PrefabUtility.RevertPrefabInstance(gameObject);
            List <UnityEngine.Object> list = new List <UnityEngine.Object>();

            PrefabUtility.GetObjectListFromHierarchy(list, PrefabUtility.FindPrefabRoot(gameObject));
            PrefabUtility.RegisterNewObjects(list, hierarchy, text);
        }