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); }
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); }