static private InstantiateForAnimatorPreview ( Object original ) : |
||
original | Object | |
return |
internal static GameObject InstantiateForAnimatorPreview(Object original)
{
if (original == null)
{
throw new ArgumentException("The prefab you want to instantiate is null.");
}
GameObject go = InstantiateRemoveAllNonAnimationComponents(original, Vector3.zero, Quaternion.identity) as GameObject;
go.name = go.name + "AnimatorPreview";
go.tag = "Untagged";
InitInstantiatedPreviewRecursive(go);
Animator[] componentsInChildren = go.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 = go.AddComponent<Animator>();
animator2.enabled = false;
animator2.cullingMode = AnimatorCullingMode.AlwaysAnimate;
animator2.logWarnings = false;
animator2.fireEvents = false;
}
return go;
}
void SetupBounds(GameObject go) { m_IsValid = go != null && go != GetGenericAnimationFallback(); if (go != null) { m_PreviewInstance = EditorUtility.InstantiateForAnimatorPreview(go); previewUtility.AddSingleGO(m_PreviewInstance); m_Previewables = m_PreviewInstance.GetComponentsInChildren <IAnimationPreviewable>(); var bounds = GameObjectInspector.GetRenderableBounds(m_PreviewInstance); m_BoundingVolumeScale = Mathf.Max(bounds.size.x, Mathf.Max(bounds.size.y, bounds.size.z)); if (Animator && Animator.isHuman) { m_AvatarScale = m_ZoomFactor = Animator.humanScale; } else { m_AvatarScale = m_ZoomFactor = m_BoundingVolumeScale / 2; } } }