InstantiateRemoveAllNonAnimationComponents() статический приватный Метод

static private InstantiateRemoveAllNonAnimationComponents ( Object original, Vector3 position, Quaternion rotation ) : Object
original Object
position Vector3
rotation UnityEngine.Quaternion
Результат Object
Пример #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);
        }
Пример #2
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;

            EditorUtility.InitInstantiatedPreviewRecursive(gameObject);
            Animator component = gameObject.GetComponent <Animator>();

            if (component)
            {
                component.enabled     = false;
                component.cullingMode = AnimatorCullingMode.AlwaysAnimate;
                component.logWarnings = false;
                component.fireEvents  = false;
            }
            return(gameObject);
        }