随笔分类 -  Unity3d

c# 获取变量名称
摘要:示例: public class Test { public int tInt; public bool tBool; } var t = new Test(); Console.WriteLine(t.tInt) ///打印 tInt public static string GetFieldNa 阅读全文

posted @ 2024-07-16 10:52 yungs 阅读(180) 评论(0) 推荐(0)

Unity Editor下运行DoTween动画
摘要:DOTweenEditorPreview.PrepareTweenForPreview(tar.GetTween()); DOTweenEditorPreview.Start(); 以Test脚本为例: public class UTest : MonoBehaviour { public Twee 阅读全文

posted @ 2024-05-10 11:36 yungs 阅读(297) 评论(0) 推荐(0)

修改Unity创建时的脚本抬头
摘要:VS2015:C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\ItemTemplatesCache\CSharp\CSharp MonoBehaviour.zipvs2019 C:\Program Files (x86) 阅读全文

posted @ 2021-01-12 15:39 yungs 阅读(153) 评论(0) 推荐(0)

Unity Slider 实现多段颜色
摘要:1 public Slider slider; 2 public Image bg; 3 const int W = 256; 4 const int H = 256; 5 void Start () { 6 var hueTex = new Texture2D(256, 256); 7 var color = Color.red; 8 ... 阅读全文

posted @ 2019-07-17 17:16 yungs 阅读(1271) 评论(0) 推荐(0)

Unity tolua调用C#中的自定义对象的方法
摘要:Unity: 定义一个类 wrap方法: Mono: lua 脚本 OK 阅读全文

posted @ 2019-07-09 23:00 yungs 阅读(2175) 评论(0) 推荐(0)

Unity tolua 把传递自定义对象参数
摘要:首先创建一个类,用于当作一个对象。 接着创建第二个类 对LuaTestA进行Lua绑定。 对LuaTestB进行Lua绑定。 Mono脚本 lua脚本:文件名为test.lua,放到streamingassets文件夹下 阅读全文

posted @ 2019-07-09 22:02 yungs 阅读(1373) 评论(0) 推荐(0)

Unity自带JsonUtility
摘要:每一个类要加上 [System.Serializable] 阅读全文

posted @ 2019-05-10 16:42 yungs 阅读(345) 评论(0) 推荐(0)

Unity屏幕坐标转UI坐标
摘要:var t = Vector2.zero; RectTransformUtility.ScreenPointToLocalPointInRectangle(mCanvas.transform as RectTransform,Input.mousePosition, mCanvas.worldCamera,out t); 阅读全文

posted @ 2018-11-21 16:54 yungs 阅读(4720) 评论(0) 推荐(1)

Unity加载第三方C# DLL时,解析不能删除的问题。
摘要:把DLL加载到内存可解决问题。 阅读全文

posted @ 2018-01-05 16:15 yungs 阅读(1018) 评论(0) 推荐(0)

Unity 编辑器 Inspector
摘要:1 using UnityEngine; 2 using System.Collections.Generic; 3 using System; 4 public class TestA : MonoBehaviour 5 { 6 public int T_int = 1; 7 public int[] TA_int = new int[] { 1, 2 }; 8... 阅读全文

posted @ 2017-09-29 14:53 yungs 阅读(405) 评论(0) 推荐(0)

Unity保存序列化数据
摘要:public class NewEditModeTest :Editor { [MenuItem("CreateData/CreateTestData")] static void TestCreateData() { var create = ScriptableObject.CreateInstance (); int index = 1; var path = Appli... 阅读全文

posted @ 2017-09-28 14:48 yungs 阅读(919) 评论(0) 推荐(0)

Unity单例写法,一劳永逸。
摘要:/// /// Singleton class /// /// Type of the singleton public abstract class Singleton : MonoBehaviour where T : Singleton { private static T s_instance; /// /// The static reference to... 阅读全文

posted @ 2017-03-13 16:38 yungs 阅读(216) 评论(0) 推荐(0)

Unity3d组合键
摘要:创建一个脚本:CombinationKey.cs 1 using UnityEngine; 2 using System.Collections; 3 4 public class CombinationKey 5 { 6 public CombinationKey (KeyCode p,... 阅读全文

posted @ 2015-04-09 13:06 yungs 阅读(1275) 评论(0) 推荐(0)

Unity3d动态载入文件
摘要:载入FBXGameObject mFbx = Instantiate( Resources.Load("fileName")) as GameObject 2.图片Texture mT = Resources.Load(fileName) as Texture;mFbx.transform.re... 阅读全文

posted @ 2015-04-09 12:40 yungs 阅读(217) 评论(0) 推荐(0)