消息基类为System下的EventArgs,我们所有的消息体都要继承在EventArgs。我们在CommonMessageEvent下写了多个基本消息类,如下:BoolArgs,IntArgs,StringArgs,FloatArgs,Vector3Args,TransformArgs,GameObjectArgs,在发送此等消息时可直接使用已有的消息类。 在发送消息之前,先在EventIdPool中声明消息id,如下: public enum Even...
public IEnumerable<Enum> GetValueFromEnumInstance(Enum item) { Dictionary<string, Enum> values = new Dictionary<string, Enum>(); foreach (Enum value in Enum.GetValues(item.GetType())) { values.Add(value.ToString(), value); } List<string> itemNames = item.ToString().Split(',').ToList...
9 新建一个脚本“ResourcesTool”,在打开的“EnumResources”脚本上进行代码编辑,首先继承单例“Singleton”使资源工具单例化,然后设置一个公有的可泛型使用的资源加载函数,通过Switch和Enum来判断所加载的资源是哪个,最后返回加载的结果 ,具体代码及代码说明如下图 10 “ResourcesTool”脚本具体内容如下:usingSyst...
Vector2 screenSize=newVector2(Screen.width,Screen.height);float scaleFactor=0;switch(m_ScreenMatchMode){caseScreenMatchMode.MatchWidthOrHeight:{// We take the log of the relative width and height before taking the average.// Then we transform it back in the original space.// the reason to t...
在你开发游戏的时候,当你发现有一个业务需要你写许多if\switch\enum的值的时候,你需要的是把思维逆转...
/* in block. Used to protect objects reachable */ /* from reclaim notifiers. */ int (GC_CALLBACK *ok_disclaim_proc)(void * /*obj*/); /* The disclaim procedure is called before obj */ /* is reclaimed, but must also tolerate being */ ...
requiredstringname=3; } 2.协议解析类的生成,如下图所示,双击protoToCs.bat文件就可以把proto文件夹下的.proto协议生成c#文件并存储在generate目录下,proto和生成的cs目录更改在protoToCs文件里面 @echo off @rem 对该目录下每个*.prot文件做转换setcurdir=%cd%setprotoPath=%curdir%\proto\setgenerate=%curdir...
publicenumTransitionType//创建传送类型的枚举 {SameScene, DifferentScene } [Header("Transition Info")] publicstringsceneName;//以字符串形式记录 终点场景名public TransitionType transitionType;//传送类型枚举变量,需要在Unity窗口中设置public TransitionDestination.DestinationTag destinationTag;//设置传送终点名pri...
{ // Options for which axes to use //使用那个轴 public enum AxisOption { Both, // Use both OnlyHorizontal, // Only horizontal OnlyVertical // Only vertical } //控制方式 public enum ControlStyle { //绝对的,从图片的中心操作 Absolute, // operates from teh center of the image //相对的...
string[] toolbarStr = new string[] { "这", "是", "Toolbar" }; EnumTest enumTest; EnumTest enumTest2; int enumInt = 0; int selectedSize = 1; string[] names = { "网", "虫", "测", "试" }; int[] sizes = { 1, 2, 4 }; ...