Пример #1
0
 void OnGUI()
 {
     if (GUI.Button(new Rect(0, 0, 100, 100), "ExportFBX"))
     {
         MyExport myExport = new MyExport();
         //myExport.Init ();
         myExport.CreateDocument();
         myExport.Clear();
     }
 }
Пример #2
0
    private void OnGUI()
    {
        if (GUI.Button(new Rect(10, 10, 150, 50), "动画加载"))
        {
            controller.OpenFromFile(Application.streamingAssetsPath, "pose");
            anime.runtimeAnimatorController = controller.LoadAsset <RuntimeAnimatorController>("AC_Edit_F");
            anime.Stop();

            List <FMeshBoneInfo> SkeletonInfo = new List <FMeshBoneInfo>();
            UnityBoneTransform.CatchSkeleton(gameObject.transform, ref SkeletonInfo);
            orginSkeletonInfo = SkeletonInfo;
            StatisticsGenerateDataBegin(SkeletonInfo);
        }

        if (GUI.Button(new Rect(170, 10, 150, 50), "动画导出"))
        {
            controller.OpenFromFile(Application.streamingAssetsPath, "pose");
            anime.runtimeAnimatorController = controller.LoadAsset <RuntimeAnimatorController>("AC_Edit_F");
            anime.Stop();
            //anime.Play("tachi_pose_12");
            AnimatorClipInfo [] acinfo = anime.GetCurrentAnimatorClipInfo(0);
            foreach (var v in acinfo)
            {
                Debug.Log(v.clip.name);
            }

            List <AnimationClip> aniList = new List <AnimationClip>();
            foreach (var v in anime.runtimeAnimatorController.animationClips)
            {
                aniList.Add(v);
                Debug.Log(v + " " + v.length + " " + v.frameRate);
            }

            AnimSequence         anim         = UnityBoneTransform.CatchAnimationClip(aniList[8], gameObject.transform);
            List <FMeshBoneInfo> SkeletonInfo = new List <FMeshBoneInfo>();
            UnityBoneTransform.CatchSkeleton(gameObject.transform, ref SkeletonInfo);
            MyExport aMyExport = new MyExport();
            aMyExport.CreateDocument();
            aMyExport.ExportAnimSequence(anim, SkeletonInfo);
            aMyExport.WriteToFile("E:/1.fbx");
        }

        if (GUI.Button(new Rect(350, 10, 150, 50), "动画采样"))
        {
            List <AnimationClip> aniList = new List <AnimationClip>();
            foreach (var v in anime.runtimeAnimatorController.animationClips)
            {
                aniList.Add(v);
                Debug.Log(v + " " + v.length + " " + v.frameRate);
            }

            aniList[0].SampleAnimation(gameObject, fSampleTime);

            List <FMeshBoneInfo> SkeletonInfo = new List <FMeshBoneInfo>();
            UnityBoneTransform.CatchSkeleton(gameObject.transform, ref SkeletonInfo);
            StatisticsGenerateDataBegin(SkeletonInfo);

            Debug.Log(GameObject.Find("cf_J_Hips").transform.localRotation.eulerAngles);
            bSampleAniamtion = true;
        }


        if (GUI.Button(new Rect(620, 10, 150, 50), "重置T-Pose"))
        {
            UpdateTransformFromMeshBoneList(orginSkeletonInfo);
        }
    }