Beispiel #1
0
    static void AssetCopy()
    {
        s_controller.OpenFromFile(Application.streamingAssetsPath, "pose");
        RuntimeAnimatorController rac     = s_controller.LoadAsset <RuntimeAnimatorController>("AC_Edit_F");
        AnimationClip             amiclip = rac.animationClips[1];
        //anime.runtimeAnimatorController = s_controller.LoadAsset<RuntimeAnimatorController>("AC_Edit_F");
        //Runt
        //anime.runtimeAnimatorController.animationClips
        //ami.clip = anime.runtimeAnimatorController.animationClips[1];
        string tempExportedClip = "Assets/tempClip.anim";
        string exportPath       = "Assets/Clone.anim";
        var    copyClip         = Object.Instantiate(amiclip);

        AssetDatabase.CreateAsset(copyClip, tempExportedClip);
        File.Copy(tempExportedClip, exportPath, true);
        File.Delete(tempExportedClip);

        // AssetDatabaseリフレッシュ
        AssetDatabase.Refresh();
    }
Beispiel #2
0
        private static Texture2D LoadAsset(AssetBundleController abc, string assetName)
        {
            if (abc.assetBundleName.Contains("thumnbnail/thumbnail_") || abc.assetBundleName.Contains("thumnbnail/thumnbs_"))
            {
                if (MoreSlotID.ThumbList.TryGetValue(assetName, out string abdataDir))
                {
                    string text = BepInEx.Utility.CombinePaths(abdataDir, "thumnbnail_R", assetName + ".png");
                    if (File.Exists(text))
                    {
                        Console.WriteLine("Load thumb: " + text);
                        return(LoadPNG(text));
                    }
                    else
                    {
                        Console.WriteLine($"Thumbnail '{text}' does not exist");
                    }
                }
            }

            return(abc.LoadAsset <Texture2D>(assetName));
        }
Beispiel #3
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);
        }
    }