private static void SetupSearchPatch(ref object datas, ref string search, ref Action <object, AssetBundleController, CustomDataListLoader> ___action) { int num = searchValue.LastIndexOf("/"); var text = searchValue.Substring(0, num); if (!Directory.Exists(GlobalData.assetBundlePath + "/list/" + text)) { return; } foreach (var text3 in Directory.GetFiles(GlobalData.assetBundlePath + "/list/" + text, search + "_Mlist.txt")) { Logger.LogInfo("Load Mlist:" + text3); StreamReader streamReader = new StreamReader(new FileStream(text3, FileMode.Open)); string assetBundleName = streamReader.ReadLine(); string contents = streamReader.ReadToEnd(); string tempFileName = Path.GetTempFileName(); File.WriteAllText(tempFileName, contents); CustomDataListLoader customDataListLoader = new CustomDataListLoader(); customDataListLoader.Load(tempFileName); File.Delete(tempFileName); AssetBundleController assetBundleController2 = new AssetBundleController(); assetBundleController2.OpenFromFile(GlobalData.assetBundlePath, assetBundleName); ___action(datas, assetBundleController2, customDataListLoader); assetBundleController2.Close(false); } }
public static AssetBundleController New_OpenFromFile(string directory, string assetBundleName) { AssetBundleController controller = new AssetBundleController(); if (controller.OpenFromFile(directory, assetBundleName)) { return(controller); } return(null); }
private static void LoadMods(Dictionary <int, object> datas, ref string search, Action <Dictionary <int, object>, AssetBundleController, CustomDataListLoader> ___action) { var dir = ""; var filter = ""; var lastSlash = search.LastIndexOf("/", StringComparison.Ordinal); if (lastSlash != -1) { dir = search.Substring(0, lastSlash); filter = search.Remove(0, lastSlash + 1); } foreach (var folder in modFolders) { var abdataDir = Path.Combine(folder, "abdata"); var listDir = BepInEx.Utility.CombinePaths(abdataDir, "list", dir); if (Directory.Exists(listDir)) { foreach (var listPath in Directory.GetFiles(listDir, filter + "_Mlist.txt")) { using (var fileStream = new FileStream(listPath, FileMode.Open)) using (var streamReader = new StreamReader(fileStream)) { var assetBundleName = streamReader.ReadLine(); var listLoader = new CustomDataListLoader(); Traverse.Create(listLoader).Method("Load", new[] { typeof(TextReader) }).GetValue(streamReader); var abc = new AssetBundleController(); abc.OpenFromFile(Path.Combine(folder, "abdata"), assetBundleName); var count = datas.Count; ___action(datas, abc, listLoader); for (int i = count; i < datas.Count; i++) { var prefabData = (ItemDataBase)datas.Values.ElementAt(i); prefabData.assetbundleDir = abdataDir; } abc.Close(); } } } } }
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(); }
private static bool SetupSearchPrefix(object __instance, ref object datas, ref string search) { string text = string.Empty; int num = search.LastIndexOf("/"); if (num != -1) { text = search.Substring(0, num); search = search.Remove(0, num + 1); } string[] files = Directory.GetFiles(GlobalData.assetBundlePath + "/" + text, search, SearchOption.TopDirectoryOnly); Array.Sort(files); foreach (string path in files) { if (Path.GetExtension(path).Length == 0) { string text2 = Path.GetFileNameWithoutExtension(path); if (text.Length > 0) { text2 = text + "/" + text2; } AssetBundleController assetBundleController = new AssetBundleController(); assetBundleController.OpenFromFile(GlobalData.assetBundlePath, text2); var args = new Type[] { datas.GetType(), typeof(AssetBundleController) }; Traverse.Create(__instance).Method("Setup", args).GetValue(datas, assetBundleController); assetBundleController.Close(false); } } if (Directory.Exists(MoreSlotID.ModFolder)) { foreach (var modDir in Directory.GetDirectories(MoreSlotID.ModFolder, "*", SearchOption.TopDirectoryOnly)) { var abdataDir = Path.Combine(modDir, "abdata"); var listDir = BepInEx.Utility.CombinePaths(abdataDir, "list", text); if (Directory.Exists(listDir)) { foreach (string list in Directory.GetFiles(listDir, search + "_Mlist.txt")) { Console.WriteLine("Load Mlist: " + list); StreamReader streamReader = new StreamReader(new FileStream(list, FileMode.Open)); string assetBundleName = streamReader.ReadLine(); MoreSlotID.AssetList[assetBundleName] = abdataDir; string contents = streamReader.ReadToEnd(); string tempFileName = Path.GetTempFileName(); File.WriteAllText(tempFileName, contents); CustomDataListLoader customDataListLoader = new CustomDataListLoader(); customDataListLoader.Load(tempFileName); File.Delete(tempFileName); foreach (var data in Traverse.Create(customDataListLoader).Field("datas").GetValue <List <string[]> >()) { MoreSlotID.ThumbList[data[data.Length - 1]] = abdataDir; } AssetBundleController assetBundleController2 = new AssetBundleController(); assetBundleController2.OpenFromFile(abdataDir, assetBundleName); var args = new Type[] { datas.GetType(), typeof(AssetBundleController), typeof(CustomDataListLoader) }; Traverse.Create(__instance).Field("action").Method("Invoke", args).GetValue(datas, assetBundleController2, customDataListLoader); assetBundleController2.Close(false); } } } } return(false); }
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); } }