UnityEditor.EditorUtility.GetPrefabType C# (CSharp) Method

GetPrefabType() private method

private GetPrefabType ( Object target ) : PrefabType
target Object
return PrefabType
        public static PrefabType GetPrefabType(Object target)
        {
            return PrefabUtility.GetPrefabType(target);
        }

Usage Example

示例#1
0
        /// <summary>
        /// Connect copied objects to prefabs if original object is connected, and sets helper reference back to new prefab reference
        /// Also recursively calls itself in all children
        /// </summary>
        /// <param name="toMine">Whether we are copying theirs to mine (true) or mie to theirs (false)</param>
        void ConnectPrefabsAfterCopy(bool toMine)
        {
            var original = toMine ? theirs : mine;
            var copy     = toMine ? mine : theirs;

            if (Util.IsPrefabParent(original) && PrefabUtility.GetPrefabType(original) == PrefabType.PrefabInstance)
            {
                copy      = PrefabUtility.ConnectGameObjectToPrefab(copy, (GameObject)PrefabUtility.GetPrefabParent(original));
                copy.name = original.name;                 // ConnectPrefab will rename to prefab name

                // ConnectPrefab will override transform
                var copyTransform     = copy.transform;
                var originalTransform = original.transform;
                copyTransform.localPosition = originalTransform.localPosition;
                copyTransform.localRotation = originalTransform.localRotation;
                copyTransform.localScale    = originalTransform.localScale;
            }

            if (toMine)
            {
                mine = copy;
            }
            else
            {
                theirs = copy;
            }

            if (children != null)
            {
                foreach (var child in children)
                {
                    child.ConnectPrefabsAfterCopy(toMine);
                }
            }
        }
All Usage Examples Of UnityEditor.EditorUtility::GetPrefabType
EditorUtility