随笔分类 -  Unity3D

摘要://Author:smilelance//From:http://blog.csdn.net/smilelance//转换C#代码:using System.Runtime.InteropServices;//结构体转换成字节流public static byte[] StructToBytes<T>(T obj) {int size = Marshal.SizeOf(typeof(T)); IntPtr bufferPtr = Marshal.AllocHGlobal(size);try { Marshal.StructureToPtr(obj, bufferPtr, false 阅读全文
posted @ 2012-08-23 18:54 MXi4oyu 阅读(322) 评论(0) 推荐(0)
摘要://Author:smilelance//From:http://blog.csdn.net/smilelance1、动画的循环animation.wrapMode = WrapMode.Loop; //设置所有动画的循环模式animation["death"].wrapMode = WrapMode.Once;//设置单个动画的循环模式2、动画层次animation["death"].layer = 1;layer默认是0,值越大显示优先级越高3、动画的切换animation.CrossFade("idle");animation. 阅读全文
posted @ 2012-08-22 16:07 MXi4oyu 阅读(397) 评论(0) 推荐(0)
摘要:Debug.Log("Version of the runtime: " + Application.unityVersion);注:这行代码必须写在主线程里,也就是继承自MonoBehaviour的脚本里 阅读全文
posted @ 2012-08-21 09:57 MXi4oyu 阅读(939) 评论(0) 推荐(0)
摘要:我们有一个继承自MonoBehaviour的类是用来做对象交互动作的,想做成单例的,写成通用的方法报错。private static Communication instance; public static Communication GetInstance() { if(instance==null){ instance=new Communication(); } return instance; }提示:You are trying to create a MonoBehaviour using the 'new' keyword. This is ... 阅读全文
posted @ 2012-08-07 16:48 MXi4oyu 阅读(414) 评论(0) 推荐(0)