Esempio n. 1
0
        private static GameObject CalculatePreviewGameObject(UnityEngine.Animator selectedAnimator, Motion motion, ModelImporterAnimationType animationType)
        {
            AnimationClip firstAnimationClipFromMotion = GetFirstAnimationClipFromMotion(motion);
            GameObject    preview = AvatarPreviewSelection.GetPreview(animationType);

            if (IsValidPreviewGameObject(preview, ModelImporterAnimationType.None))
            {
                return(preview);
            }
            if ((selectedAnimator != null) && IsValidPreviewGameObject(selectedAnimator.gameObject, animationType))
            {
                return(selectedAnimator.gameObject);
            }
            preview = FindBestFittingRenderableGameObjectFromModelAsset(firstAnimationClipFromMotion, animationType);
            if (preview != null)
            {
                return(preview);
            }
            if (animationType == ModelImporterAnimationType.Human)
            {
                return(GetHumanoidFallback());
            }
            if (animationType == ModelImporterAnimationType.Generic)
            {
                return(GetGenericAnimationFallback());
            }
            return(null);
        }
Esempio n. 2
0
        static GameObject CalculatePreviewGameObject(Animator selectedAnimator, Motion motion, ModelImporterAnimationType animationType)
        {
            AnimationClip sourceClip = GetFirstAnimationClipFromMotion(motion);

            // Use selected preview
            GameObject selected = AvatarPreviewSelection.GetPreview(animationType);

            if (IsValidPreviewGameObject(selected, ModelImporterAnimationType.None))
            {
                return(selected);
            }

            if (selectedAnimator != null && IsValidPreviewGameObject(selectedAnimator.gameObject, animationType))
            {
                return(selectedAnimator.gameObject);
            }

            // Find the best fitting preview game object for the asset we are viewing (Handles @ convention, will pick base path for you)
            selected = FindBestFittingRenderableGameObjectFromModelAsset(sourceClip, animationType);
            if (selected != null)
            {
                return(selected);
            }

            if (animationType == ModelImporterAnimationType.Human)
            {
                return(GetHumanoidFallback());
            }
            else if (animationType == ModelImporterAnimationType.Generic)
            {
                return(GetGenericAnimationFallback());
            }

            return(null);
        }
Esempio n. 3
0
        private static GameObject CalculatePreviewGameObject(Animator selectedAnimator, Motion motion, ModelImporterAnimationType animationType)
        {
            AnimationClip firstAnimationClipFromMotion = AvatarPreview.GetFirstAnimationClipFromMotion(motion);
            GameObject    gameObject = AvatarPreviewSelection.GetPreview(animationType);

            if (AvatarPreview.IsValidPreviewGameObject(gameObject, ModelImporterAnimationType.None))
            {
                return(gameObject);
            }
            if (selectedAnimator != null && AvatarPreview.IsValidPreviewGameObject(selectedAnimator.gameObject, animationType))
            {
                return(selectedAnimator.gameObject);
            }
            gameObject = AvatarPreview.FindBestFittingRenderableGameObjectFromModelAsset(firstAnimationClipFromMotion, animationType);
            if (gameObject != null)
            {
                return(gameObject);
            }
            if (animationType == ModelImporterAnimationType.Human)
            {
                return(AvatarPreview.GetHumanoidFallback());
            }
            if (animationType == ModelImporterAnimationType.Generic)
            {
                return(AvatarPreview.GetGenericAnimationFallback());
            }
            return(null);
        }