BDFramework.Core 学习
x哥(懂的都懂)的框架, 拿点代码过来做注释. 想了解详情可以去他的github
https://github.com/yimengfan/BDFramework.Core
# Object files # Libraries # Shared objects (inc. Windows DLLs) *.so.* *.dylib # Executables *.exe *.out *.app *.i* *.x86_64 *.hex /TestProject/Library /TestProject/obj /TestProject/Temp /TestProject/UnityPackageManager /TestProject/Assembly-CSharp.csproj /TestProject/Assembly-CSharp-Editor.csproj /TestProject/Assembly-CSharp-Editor-firstpass.csproj /TestProject/TestProject.sln /TestProject/.idea/.idea.TestProject/.idea/contentModel.xml /TestProject/.idea/.idea.TestProject/.idea/indexLayout.xml /TestProject/.idea/.idea.TestProject/.idea/modules.xml /TestProject/.idea/.idea.TestProject/.idea/workspace.xml /TestProject/.idea/.idea.TestProject/riderModule.iml /TestProject/TestProject.sln.DotSettings.user /TestProject/UpgradeLog.htm /TestProject/Assets/Resource/.svn /TestProject/Assets/Code/.svn /TestProject/.sonarqube /TestProject/TestProject.Editor.Plugins.csproj /TestProject/TestProject.Editor.csproj /TestProject/TestProject.csproj /TestProject/.idea/.idea.TestProject/.idea/encodings.xml /TestProject/.idea/.idea.TestProject/.idea/sonarIssues.xml /TestProject/.idea/.idea.TestProject/.idea/vcs.xml /TestProject/.vs/TestProject/v15/.suo /TestProject/.vs/TestProject/v15/Server/sqlite3/db.lock /TestProject/.vs/TestProject/v15/Server/sqlite3/storage.ide /TestProject/.vs /TestProject/.idea /TestProject/.idea /TestProject/.vs /TestProject/UnityDLL /TestProject/*.err /TestProject/*.tmp /TestProject/*.cmdline /TestProject/Unity.PackageManagerUI.Editor.csproj /TestProject/Unity.TextMeshPro.Editor.csproj /TestProject/Unity.TextMeshPro.csproj /TestProject/UnityEditor.StandardEvents.csproj /TestProject/Assets/Plugins/Editor/JetBrains/JetBrains.Rider.Unity.Editor.Plugin.Repacked.dll /TestProject/Assets/Plugins/Editor/JetBrains TestProject/Assets/Code/Game/Editor.meta TestProject/Assets/Code/Game/Editor/AnimtionImport.meta TestProject/Assets/Code/Game/Editor/Data.meta TestProject/Assets/Code/Game/Editor/HeroEdit.meta TestProject/Assets/Code/Game/Editor/RouteTool.meta TestProject/Assets/Code/Game/Editor/AnimtionImport/Editor.meta TestProject/Assets/Code/Game/Editor/HeroEdit/Editor.meta TestProject/Assets/Code/Game/Editor/HeroEdit/Table.meta TestProject/Assets/Code/Game/Editor/HeroEdit/TableAttributes.meta TestProject/Assets/Code/Game/Editor/RouteTool/Editor.meta TestProject/Assets/Plugins/iOS.meta /TestProject/Assets/StreamingAssets/Windows/Art /TestProject/Assets/StreamingAssets/iOS/Art /TestProject/rotorz.dotnet-exception-utils.csproj /TestProject/rotorz.dotnet-type-utils.csproj /TestProject/rotorz.unity3d-editor-menu.editor.csproj /TestProject/rotorz.unity3d-package-utils.editor.csproj /TestProject/rotorz.unity3d-reorderable-list.csproj /TestProject/rotorz.unity3d-reorderable-list.editor.csproj /TestProject/rotorz.unity3d-utils.csproj /TestProject/rotorz.unity3d-utils.editor.csproj /TestProject/Assembly-CSharp-firstpass.csproj /TestProject/ProjectSettings/ProjectVersion.txt /TestProject/Logs /TestProject/Assets/Code/BDFramework/Tools/ILRBuild/build.sln.meta /TestProject/Assets/Code/BDFramework/Tools/ILRBuild/build.sln /TestProject/Assets/Plugins/Editor/JetBrains.meta /TestProject/Assets/Code/BDFramework/Tools/ILRBuild/build.exe.meta /TestProject/Assets/Plugins/Sirenix/Odin Inspector/Config/Resources.meta /TestProject/Assets/Plugins/Sirenix/Odin Inspector/Config/Resources/Sirenix.meta /TestProject/Assets/3rdPlugins/.svn /TestProject/Assets/DebugUILine.cs /TestProject/Assets/DebugUILine.cs.meta /TestProject/Assets/DebugUILine.cs /TestProject/Assets/StreamingAssets/Windows/hotfix/Assembly-CSharp.dll.mdb.meta /TestProject/Assets/StreamingAssets/Windows/hotfix/Assembly-CSharp.dll.mdb /TestProject/Assets/Resource/Effect/.svn /TestProject/Assets/StreamingAssets/.svn /TestProject/Assets/3rdPlugins/com.unity.textmeshpro@1.3.0/Tests.meta /TestProject/Assets/3rdPlugins/com.unity.textmeshpro@1.3.0/Tests
参考 ignore
PosPlus 教程 https://www.bilibili.com/video/av23948137
资源目录(大致)
Resource(不是Resources) 资源目录
Effect 特效目录
Font 字体目录
handlers 协议目录
Img 图片目录
Model 模型目录
Resources 打进本地包
Runtime 运行时
Scene 场景目录
Shaders Shader目录
Table Excel表目录
TableEditor JSON表目录
导入流程
原始文件
sunwukong@ani.txt(UTF-8)
Ctrl+D 复制动画信息
打开 Animation 窗口
删除 动画 Position 信息
创建 Animator Controller
将动画拖进 Animator Controller
添加脚本
#region FPS计算 float fps; float deltaTime = 0.0f; float msec; Rect rect; GUIStyle style = new GUIStyle(); void Start() { int w = Screen.width, h = Screen.height; rect = , , , h * / ); style.alignment = TextAnchor.UpperLeft; style.fontSize = h * / ; style.normal.textColor = new Color(1.0f, 0.0f, 0f, 1.0f); } void Update() { deltaTime += (Time.deltaTime - deltaTime) * 0.1f; } void OnGUI() { msec = deltaTime * 1000.0f; fps = 1.0f / deltaTime; GUI.Label(rect, string.Format("{0:0.0} ms ({1:0.} fps)", msec, fps), style); } #endregion
FPS计算
[UnityEditor.MenuItem()] static public void DeleteModelUnuseData() { var path = Application.dataPath + "/Resource/Runtime/Char"; var fs = Directory.GetFiles(path, "*.prefab", SearchOption.AllDirectories); ; foreach (var f in fs) { i++; EditorUtility.DisplayProgressBar("处理模型", Path.GetFileName(f), i / fs.Length); // var absPath = "Assets" + f.Replace(Application.dataPath, ""); var o = AssetDatabase.LoadMainAssetAtPath(absPath) as GameObject; //添加特殊点 var p1 = o.transform.Find("EffectPoint"); if (p1 == null) { // var op1= new GameObject("EffectPoint"); // op1.transform.SetParent(o.transform,false); Debug.LogError("缺少节点 EffectPoint:" + absPath); } var p2 = o.transform.Find("AtkPoint"); if (p2 == null) { p2 = o.transform.Find("Bip001/AtkPoint"); // var op2= new GameObject("AtkPoint"); // op2.transform.SetParent(o.transform,false); if (p2 == null) Debug.LogError("缺少节点 AtkPoint:" + absPath); } var p3 = o.transform.Find("BehurtPoint"); if (p3 == null) { // var op3= new GameObject("BehurtPoint"); // op3.transform.SetParent(o.transform,false); Debug.LogError("缺少节点 BehurtPoint:" + absPath); } //添加特殊点 var p4 = o.transform.Find("StaticPoint"); if (p4 == null) { // var op1= new GameObject("EffectPoint"); // op1.transform.SetParent(o.transform,false); Debug.LogError("缺少节点 StaticPoint:" + absPath); } var p5 = o.transform.Find("HeadPoint"); if (p5 == null) { // var op1= new GameObject("EffectPoint"); // op1.transform.SetParent(o.transform,false); Debug.LogError("缺少节点 HeadPoint:" + absPath); } else { p5.position = ,); } //删除镜头 var cams = o.GetComponentsInChildren<Camera>(); foreach (var c in cams) { GameObject.DestroyImmediate(c, true); } //删除animator var ani = o.GetComponent<Animator>(); if (ani != null) { GameObject.DestroyImmediate(ani, true); } } EditorUtility.ClearProgressBar(); AssetDatabase.SaveAssets(); // AssetDatabase.Refresh(); }
模型资源检测
[MenuItem("Assets/自动创建角色", true)] static public bool CreateCharValidation() { string path = AssetDatabase.GetAssetPath(Selection.activeObject).ToLower(); return path.EndsWith(".fbx"); } [MenuItem("Assets/自动创建角色")] static public void CreateChar() { string path = AssetDatabase.GetAssetPath(Selection.activeObject); Object[] objs = AssetDatabase.LoadAllAssetsAtPath(path); string directory = Path.GetDirectoryName(path) + "/"; Dictionary<string, AnimationClip> clipDict = CreateAnimClips(directory, objs); AnimatorController ac = CreateAnimController(directory, clipDict); Dictionary<string, Material> matDict = CreateMaterials(directory, objs); CreatePrefab(path, matDict, ac, clipDict); } private static Dictionary<string, AnimationClip> CreateAnimClips(string directory, Object[] objs) { Dictionary<string, AnimationClip> clipDict = new Dictionary<string, AnimationClip>(); AnimationClip srcClip; //源AnimationClip AnimationClip newClip; //新AnimationClip string animationPath = ""; foreach (Object o in objs) { if (o.GetType() == typeof(AnimationClip)) { srcClip = o as AnimationClip; if (srcClip.name.Equals("__preview__Take 001")) continue; EditorUtility.DisplayProgressBar("复制动画文件", srcClip.name, 0.1f); newClip = new AnimationClip(); newClip.name = srcClip.name; //防止动画命名出错 if (newClip.name == "hit") { newClip.name = "behurt"; } animationPath = directory + srcClip.name + ".anim"; if (File.Exists(animationPath)) { File.Delete(animationPath); } var setting = AnimationUtility.GetAnimationClipSettings(srcClip); if (srcClip.name == "idle") { setting.loopTime = true; } AnimationUtility.SetAnimationClipSettings(newClip, setting); //设置新clip的AnimationClipSettings newClip.frameRate = srcClip.frameRate; //设置新clip的帧率 EditorCurveBinding[] curveBindings = AnimationUtility.GetCurveBindings(srcClip); //获取clip的curveBinds ; i < curveBindings.Length; i++) { AnimationUtility.SetEditorCurve(newClip, curveBindings[i], AnimationUtility.GetEditorCurve(srcClip, curveBindings[i])); //设置新clip的curve } EditorUtility.DisplayProgressBar("复制动画文件", srcClip.name, 0.7f); AssetDatabase.CreateAsset(newClip, animationPath); //AssetDatabase中的路径都是相对Asset的 如果指定路径已存在asset则会被删除,然后创建新的asset EditorUtility.DisplayProgressBar("复制动画文件", srcClip.name, 0.9f); clipDict.Add(newClip.name, newClip); } } EditorUtility.ClearProgressBar(); AssetDatabase.SaveAssets(); //保存修改 AssetDatabase.Refresh(); return clipDict; } private static AnimatorController CreateAnimController(string directory, Dictionary<string, AnimationClip> clipDict) { //创建animationController文件,保存在Assets路径下 AnimatorController animatorController = AnimatorController.CreateAnimatorControllerAtPath(directory + "New Animation Controller.controller"); //得到它的Layer, 默认layer为base 你可以去拓展 AnimatorControllerLayer layer = animatorController.layers[]; AnimatorStateMachine sm = layer.stateMachine; foreach (KeyValuePair<string, AnimationClip> kv in clipDict) { //取出动画名子 添加到state里面 AnimatorState state = sm.AddState(kv.Key); state.motion = kv.Value; //把state添加在layer里面 sm.AddAnyStateTransition(state); } return animatorController; } private static Dictionary<string, Material> CreateMaterials(string directory, Object[] objs) { Dictionary<string, Material> dict = new Dictionary<string, Material>(); string matPath = directory + "/Materials"; if (Directory.Exists(matPath)) { Directory.Delete(matPath, true); AssetDatabase.Refresh(); } Directory.CreateDirectory(matPath); foreach (Object o in objs) { if (o.GetType() == typeof(Material)) { var srcMat = o as Material; EditorUtility.DisplayProgressBar("复制材质球", srcMat.name, 0.1f); var newMat = new Material(srcMat); newMat.name = srcMat.name; EditorUtility.DisplayProgressBar("复制材质球", srcMat.name, 0.7f); string newPath = matPath + "/" + newMat.name + ".mat"; AssetDatabase.CreateAsset(newMat, newPath); EditorUtility.DisplayProgressBar("复制材质球", srcMat.name, 0.9f); dict.Add(newMat.name, newMat); } } EditorUtility.ClearProgressBar(); AssetDatabase.SaveAssets(); //保存修改 AssetDatabase.Refresh(); return dict; } private static void CreatePrefab(string path, Dictionary<string, Material> matDict, AnimatorController ac, Dictionary<string, AnimationClip> clipDict) { var charPath = Application.dataPath + "/Resource/Runtime/Char/"; int count = Directory.GetFiles(charPath, "*.prefab", SearchOption.TopDirectoryOnly).Length; count++; var o = AssetDatabase.LoadMainAssetAtPath(path) as GameObject; GameObject go = GameObject.Instantiate(o); //1.设置prefab的name go.name = count > ? count + " + count; //2,设置特殊点 GameObject point = new GameObject("EffectPoint"); point.transform.SetParent(go.transform, false); point = new GameObject("BehurtPoint"); point.transform.SetParent(go.transform, false); point = new GameObject("StaticPoint"); point.transform.SetParent(go.transform, false); point = new GameObject("AtkPoint"); point.transform.SetParent(go.transform, false); point = new GameObject("HeadPoint"); point.transform.position = ,); point.transform.SetParent(go.transform, false); //3.设置材质球 Renderer[] renders = go.GetComponentsInChildren<Renderer>(); foreach (var render in renders) { int cnt = render.sharedMaterials.Length; Material[] matArr = new Material[cnt]; ; i < cnt; i++) { Material oldMat = render.sharedMaterials[i]; Material newMatPath; if (matDict.TryGetValue(oldMat.name, out newMatPath)) { matArr[i] = newMatPath; } else { //一般不会走进来 matArr[i] = null; } } render.sharedMaterials = matArr; } //4.animator controller 操作 Animator animator = go.GetComponent<Animator>(); if (animator == null) { animator = go.AddComponent<Animator>(); } RuntimeAnimatorController runAnim = AssetDatabase.LoadAssetAtPath<RuntimeAnimatorController>(AssetDatabase.GetAssetPath(ac)); animator.runtimeAnimatorController = runAnim; AniPlayer aniPlayer = go.gameObject.AddComponent<FB.PosePlus.AniPlayer>(); animator.enabled = false; aniPlayer.Clips = null; foreach (var c in clipDict.Values) { CloneAni(animator, c, c.frameRate); } //5.创建 skill相关 SkillPlayer_TBS skilltbs = go.GetComponent<SkillPlayer_TBS>(); if (skilltbs == null) { skilltbs = go.AddComponent<SkillPlayer_TBS>(); } G_Skill _s = new G_Skill(); string directory = System.IO.Path.GetDirectoryName(path); string outpath = directory + "/" + skilltbs.name + ".Skills.txt"; File.WriteAllText(outpath, JsonMapper.ToJson(_s)); AssetDatabase.Refresh(); var src = AssetDatabase.LoadAssetAtPath<TextAsset>(outpath); skilltbs.SkillText = src; AssetDatabase.SaveAssets(); PrefabUtility.SaveAsPrefabAsset(go, "Assets/Resource/Runtime/Char/"+go.name+".prefab"); GameObject.DestroyImmediate(go); } static void CloneAni(Animator target, AnimationClip clip, float fps) { var ani = target; //创建CleanData.Ani FB.PosePlus.AniClip _clip = ScriptableObject.CreateInstance<FB.PosePlus.AniClip>(); _clip.boneinfo = new List<string>(); //也增加了每个动画中的boneinfo信息. //这里重新检查动画曲线,找出动画中涉及的Transform部分,更精确 List<Transform> cdpath = new List<Transform>(); AnimationClipCurveData[] curveDatas = AnimationUtility.GetAllCurves(clip, true); foreach (var dd in curveDatas) { Transform tran = ani.transform.Find(dd.path); if (cdpath.Contains(tran) == false) { _clip.boneinfo.Add(dd.path); cdpath.Add(tran); } } Debug.LogWarning("curve got path =" + cdpath.Count); string path = System.IO.Path.GetDirectoryName(AssetDatabase.GetAssetPath(clip.GetInstanceID())); _clip.name = clip.name; _clip.frames = new List<FB.PosePlus.Frame>(); _clip.loop = clip.isLooping; float flen = (clip.length * fps); int framecount = (int) flen; if (flen - framecount > 0.0001) framecount++; //if (framecount < 1) framecount = 1; framecount += ; FB.PosePlus.Frame last = null; //ani.StartPlayback(); //逐帧复制 //ani.Play(_clip.name, 0, 0); ; i < framecount; i++) { ani.Play(_clip.name, , (i * 1.0f / fps) / clip.length); ani.Update(); last = new FB.PosePlus.Frame(last, i, cdpath); _clip.frames.Add(last); } if (_clip.loop) { _clip.frames[].LinkLoop(last); } Debug.Log("FrameCount." + framecount); FB.PosePlus.AniPlayer con = ani.GetComponent<FB.PosePlus.AniPlayer>(); List<FB.PosePlus.AniClip> clips = null; if (con.Clips != null) { clips = new List<FB.PosePlus.AniClip>(con.Clips); } else { clips = new List<FB.PosePlus.AniClip>(); } foreach (var c in clips) { if (c.name == _clip.name + ".FBAni") { clips.Remove(c); break; } } //ani.StopPlayback(); string outpath = path + "/" + clip.name + ".FBAni.asset"; AssetDatabase.CreateAsset(_clip, outpath); var src = AssetDatabase.LoadAssetAtPath(outpath, typeof(FB.PosePlus.AniClip)) as FB.PosePlus.AniClip; //设置clip //FB.CleanData.AniController con = ani.GetComponent<FB.CleanData.AniController>(); clips.Add(src); con.Clips = clips; }
自动创建角色
https://github.com/blueberryzzz/ReferenceFinder
BDFramework.Core 学习的更多相关文章
- EntityFramework Core 学习系列(一)Creating Model
EntityFramework Core 学习系列(一)Creating Model Getting Started 使用Command Line 来添加 Package dotnet add pa ...
- ASP.NET Core学习系列
.NET Core ASP.NET Core ASP.NET Core学习之一 入门简介 ASP.NET Core学习之二 菜鸟踩坑 ASP.NET Core学习之三 NLog日志 ASP.NET C ...
- Nancy in .Net Core学习笔记 - 初识Nancy
前言 去年11月份参加了青岛MVP线下活动,会上老MVP衣明志介绍了Nancy, 一直没有系统的学习一下,最近正好有空,就结合.NET Core学习总结了一下. 注: 本文中大部分内容都是对官网文档的 ...
- .NET CORE学习笔记系列(2)——依赖注入[7]: .NET Core DI框架[服务注册]
原文https://www.cnblogs.com/artech/p/net-core-di-07.html 包含服务注册信息的IServiceCollection对象最终被用来创建作为DI容器的IS ...
- .NET CORE学习笔记系列(2)——依赖注入[6]: .NET Core DI框架[编程体验]
原文https://www.cnblogs.com/artech/p/net-core-di-06.html 毫不夸张地说,整个ASP.NET Core框架是建立在一个依赖注入框架之上的,它在应用启动 ...
- .NET CORE学习笔记系列(2)——依赖注入[5]: 创建一个简易版的DI框架[下篇]
为了让读者朋友们能够对.NET Core DI框架的实现原理具有一个深刻而认识,我们采用与之类似的设计构架了一个名为Cat的DI框架.在上篇中我们介绍了Cat的基本编程模式,接下来我们就来聊聊Cat的 ...
- .NET CORE学习笔记系列(2)——依赖注入[4]: 创建一个简易版的DI框架[上篇]
原文https://www.cnblogs.com/artech/p/net-core-di-04.html 本系列文章旨在剖析.NET Core的依赖注入框架的实现原理,到目前为止我们通过三篇文章从 ...
- .NET CORE学习笔记系列(2)——依赖注入【3】依赖注入模式
原文:https://www.cnblogs.com/artech/p/net-core-di-03.html IoC主要体现了这样一种设计思想:通过将一组通用流程的控制权从应用转移到框架中以实现对流 ...
- .NET CORE学习笔记系列(2)——依赖注入【2】基于IoC的设计模式
原文:https://www.cnblogs.com/artech/p/net-core-di-02.html 正如我们在<控制反转>提到过的,很多人将IoC理解为一种“面向对象的设计模式 ...
随机推荐
- git必知必会
1. Git 配置 --system #系统级别--global #用户全局--local #单独一个项目 git config --global user.name "xxxx" ...
- 前端框架Easyui学习积累
前端框架Easyui学习积累 1.easyui textbox 赋值:$("#id").textbox("setValue","xx"); ...
- pymongo和mongoengine安装和使用教程 包含常用命令行和代码示例 | pymongo and mongoengine tutorial on ubuntu 16.04
本文首发于个人博客https://kezunlin.me/post/e88f04e5/,欢迎阅读最新内容! pymongo and mongoengine tutorial on ubuntu 16. ...
- Android应用图标尺寸以及drawable(ldpi、mdpi、hdpi、xhdpi、xxhdpi)
应用图标: L DPI ( Low Density Screen,120 DPI ),其图标大小为 36 x 36 px M DPI ( Medium Density Screen, 160 DPI ...
- SQL server已经设置为单用户模式,还是无法做分离、属性设置等操作
https://www.cnblogs.com/xingyunqiu/p/10336938.html SQL server已经设置为单用户模式,Sql server还原失败数据库正在使用,无法获得对数 ...
- MySQL学习——操作视图
MySQL学习——操作视图 摘要:本文主要学习了使用DDL语句操作视图的方法. 了解视图 是什么 视图是从一个.多个表或者视图中导出的表,包含一系列带有名称的数据列和若干条数据行. 特点 视图不是数据 ...
- C#操作SQLite数据库增、删、改、查 欢迎转载
C#操作SQLite数据库增.删.改.查 欢迎转载 转载记得留下链接地址哦!!! 最近项目上要使用SQLite数据库,不怕大伙笑话毕业四年多了,一直使用Oracle或者MySQL或者SQLServer ...
- Python中使用requests和parsel爬取喜马拉雅电台音频
场景 喜马拉雅电台: https://www.ximalaya.com/ 找到一步小说音频,这里以下面为例 https://www.ximalaya.com/youshengshu/16411402/ ...
- 大数据分析的下一代架构--IOTA架构设计实践[下]
大数据分析的下一代架构--IOTA架构设计实践[下] 原创置顶 代立冬 发布于2018-12-31 20:59:53 阅读数 2151 收藏 展开 IOTA架构提出背景 大数据3.0时代以前,Lam ...
- 2018年最新Java面试题及答案整理
基础篇 基本功 面向对象特征 封装,继承,多态和抽象 封装封装给对象提供了隐藏内部特性和行为的能力.对象提供一些能被其他对象访问的方法来改变它内部的数据.在 Java 当中,有 3 种修饰符: pub ...