UnityEditor.EditorUtility.InstantiateRemoveAllNonAnimationComponents C# (CSharp) Method

InstantiateRemoveAllNonAnimationComponents() static private method

static private InstantiateRemoveAllNonAnimationComponents ( Object original, Vector3 position, Quaternion rotation ) : Object
original Object
position Vector3
rotation UnityEngine.Quaternion
return Object
        internal static Object InstantiateRemoveAllNonAnimationComponents(Object original, Vector3 position, Quaternion rotation)
        {
            if (original == null)
            {
                throw new ArgumentException("The prefab you want to instantiate is null.");
            }
            return Internal_InstantiateRemoveAllNonAnimationComponentsSingle(original, position, rotation);
        }

Usage Example

示例#1
0
        internal static GameObject InstantiateForAnimatorPreview(UnityEngine.Object original)
        {
            if (original == null)
            {
                throw new ArgumentException("The prefab you want to instantiate is null.");
            }
            GameObject gameObject = EditorUtility.InstantiateRemoveAllNonAnimationComponents(original, Vector3.zero, Quaternion.identity) as GameObject;

            gameObject.name += "AnimatorPreview";
            gameObject.tag   = "Untagged";
            EditorUtility.InitInstantiatedPreviewRecursive(gameObject);
            Animator[] componentsInChildren = gameObject.GetComponentsInChildren <Animator>();
            for (int i = 0; i < componentsInChildren.Length; i++)
            {
                Animator animator = componentsInChildren[i];
                animator.enabled     = false;
                animator.cullingMode = AnimatorCullingMode.AlwaysAnimate;
                animator.logWarnings = false;
                animator.fireEvents  = false;
            }
            if (componentsInChildren.Length == 0)
            {
                Animator animator2 = gameObject.AddComponent <Animator>();
                animator2.enabled     = false;
                animator2.cullingMode = AnimatorCullingMode.AlwaysAnimate;
                animator2.logWarnings = false;
                animator2.fireEvents  = false;
            }
            return(gameObject);
        }
All Usage Examples Of UnityEditor.EditorUtility::InstantiateRemoveAllNonAnimationComponents
EditorUtility