随笔分类 -  Unity / Unity-Editor

摘要:public class EditorClipDemoWnd : EditorWindow { [MenuItem("Demos/EditorClipDemoWnd")] static void ShowWindow() { var window = GetWindow<EditorClipDemo 阅读全文
posted @ 2024-11-09 00:02 yanghui01 阅读(25) 评论(0) 推荐(1) 编辑
摘要:曲线在unity下如何绘制? 类似绘制圆,是用一段一段的线段拼接来模拟的,这边也是类似,可以用一段一段的线段来模拟曲线。 既然要模拟,那我们也得知道贝塞尔曲线的公式才行。 一般用的比较多的就是3次贝塞尔曲线,该曲线由起点p1,p1的控制点c1,终点p2,p2的控制点c2组成。 公式为:p = p1* 阅读全文
posted @ 2024-07-28 23:46 yanghui01 阅读(88) 评论(0) 推荐(0) 编辑
摘要:这个仅仅是修改fnt,不负责从fnt生成unity字体文件。 fnt生成字体文件看这边:ugui位图字体使用 - fnt生成fontsettings工具 效果 工具代码 public class FntEditTool : EditorWindow { [MenuItem("MyTools/Fnt 阅读全文
posted @ 2024-04-30 00:07 yanghui01 阅读(346) 评论(0) 推荐(0) 编辑
摘要:fnt文件生成unity字体的原理其实就是渲染图集Atlas上的Sprite,这边直接利用Unity自带的图集工具生成fnt文件 注意:这里生成的fnt文件还没法直接用,因为没有关联字符,这个工具只是第1步,第2步要用Fnt编辑工具关联字符:Fnt文件编辑工具 效果 public class Spr 阅读全文
posted @ 2024-04-29 22:17 yanghui01 阅读(128) 评论(0) 推荐(0) 编辑
摘要:public class SpriteAtlasExportTool : EditorWindow { const string MenuItemPath_ExportSelectSpriteAtlas = "MyTools/Export Select SpriteAtlas"; [MenuItem 阅读全文
posted @ 2024-04-28 22:53 yanghui01 阅读(55) 评论(0) 推荐(0) 编辑
摘要:效果 枚举 public enum MyFontStyleMask { Bold = 1, Italic = 1 << 1, Outline = 1 << 2, } 标签类 using UnityEngine; public class MyEnumMaskAttribute : PropertyA 阅读全文
posted @ 2024-04-12 22:15 yanghui01 阅读(99) 评论(0) 推荐(0) 编辑
摘要:效果 枚举 public enum MyFontStyle { Bold, Italic, Outline, } public enum MyFontStyleMask { Bold = 1, Italic = 1 << 1, Outline = 1 << 2, } 标签类 using UnityE 阅读全文
posted @ 2024-04-12 22:06 yanghui01 阅读(43) 评论(0) 推荐(0) 编辑
摘要:效果 多边形表示 //#define X_ROTATE_90 using System; using System.Collections.Generic; using UnityEngine; public class MyPolygon : MonoBehaviour { [SerializeF 阅读全文
posted @ 2023-10-31 23:41 yanghui01 阅读(30) 评论(0) 推荐(0) 编辑
摘要:IMGUI中每个可点击(交互)的控件都会有一个controlID, 一般在mouseDown的时候设置, mouseUp的时候清除。 #if UNITY_EDITOR using UnityEditor; using UnityEngine; public class TestHotControlI 阅读全文
posted @ 2023-10-19 23:45 yanghui01 阅读(74) 评论(0) 推荐(0) 编辑
摘要:效果 #if UNITY_EDITOR using UnityEditor; using UnityEngine; public class TestSceneGUIWindow : EditorWindow { [MenuItem("MyTools/TestSceneGUIWindow")] pu 阅读全文
posted @ 2023-10-19 23:29 yanghui01 阅读(36) 评论(0) 推荐(0) 编辑
摘要:扩展Scene视图的几种方式 1) 注册SceneView.duringSceneGui委托(Unity2018及之前版本是SceneView.onSceneGUIDelegate) #if UNITY_EDITOR using UnityEditor; public class TestScene 阅读全文
posted @ 2023-10-19 23:05 yanghui01 阅读(231) 评论(0) 推荐(0) 编辑
摘要:var ray = Camera.ScreenPointToRay(screenPos); 1) screenPos需要是左下角为(0, 0), 单位为像素的屏幕坐标。 2) 得到的射线的开始为屏幕坐标在相机near平面上的点, 指向屏幕坐标在far平面上的点 在游戏代码中使用 using Unit 阅读全文
posted @ 2023-10-19 00:35 yanghui01 阅读(259) 评论(0) 推荐(0) 编辑
摘要:原理: 用相机拍摄预制体,生成一张预览图 需要注意: 1) GameObject.Instantiate实例化预制体后,要等待几帧才能获取到正确的Transform参数,刚创建就获取可能是不对的。 2) 预制体预览有两种实现方式,一种是继承Editor然后重写OnPreviewGUI;另一种是继承O 阅读全文
posted @ 2023-10-09 23:35 yanghui01 阅读(237) 评论(0) 推荐(0) 编辑
摘要:EditorApplication.RepaintAnimationWindow(); //刷新Animation窗口 EditorApplication.RepaintProjectWindow(); //刷新Project窗口 EditorApplication.RepaintHierarchy 阅读全文
posted @ 2023-10-09 22:57 yanghui01 阅读(303) 评论(0) 推荐(0) 编辑
摘要:ContextMenuItem 用于给成员变量增加右键菜单 加在成员变量上,在成员变量上右键弹出右键菜单,对应的菜单函数只能是成员函数,不能是static函数 public class TestContextMenu : MonoBehaviour { [ContextMenuItem("Reset 阅读全文
posted @ 2023-07-30 23:13 yanghui01 阅读(99) 评论(0) 推荐(0) 编辑
摘要:效果 using System.IO; using UnityEditor; using UnityEngine; public static class AssetDepsTool { private const string Default_Copy_Folder = "D:/UnityAsse 阅读全文
posted @ 2023-07-30 00:02 yanghui01 阅读(7) 评论(0) 推荐(0) 编辑
摘要:#if UNITY_EDITOR using System; using System.IO; using UnityEditor; using UnityEngine; public static class SpriteTool { // OpenDirAfterExport const str 阅读全文
posted @ 2023-07-01 01:26 yanghui01 阅读(40) 评论(0) 推荐(0) 编辑
摘要:最终效果 1) fnt文件上右击,执行命令 2) 空白位置右击,打开工具窗口生成fontsettings文件。 或者从菜单 -> Assets -> BMFont -> open BMFontTool打开 字体渲染中的几个术语 1) baseline, ascent, descent, Charac 阅读全文
posted @ 2023-06-29 00:51 yanghui01 阅读(651) 评论(0) 推荐(0) 编辑
摘要:#if UNITY_EDITOR using System; using System.IO; using UnityEditor; using UnityEngine; public class TextureAlphaExport : MonoBehaviour { [MenuItem("MyT 阅读全文
posted @ 2023-03-17 23:57 yanghui01 阅读(97) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示