SetActive 调用此方法,传入bool参数(true/false)可以使当前物体显示或者隐藏 AddComponent 为游戏对象添加组件,脚本 CompareTag 调用此方法,传入字符串参数(“TagName”)当前游戏对象的tag值是否为参数TagName,名字一样返回True,反之False。 GetComponent 获取游戏对象的组件,脚本 GetComponentInChildren 返回此游戏对象或者它的...
int a = Int32("12");//打印结果为12 //精度比括号强转好,会四舍五入 a = Int32(1.45815f);//打印结果为2 //bool也可以转成数值类型 1对应true 0对应false a = C.ToInt32(true);//打印结果为1 a = Int32(false);//打印结果为0 a = Int32('A');//打印结果为65 //每一个类型都存在...
int.Parse()是一种类容转换,表示将数字内容的字符串转为int类型。 Convert.ToInt32()是一种类容转换,与 int.Parse 较为类似,它不限于将字符串转为int类型,还可以是其它类型的参数; int.TryParse (String s,out int num.)与 int.Parse(string s)又较为类似,但它不会产生异常,最后一个参数为输出值,如果...
//声明变量的规则应该与MonoBehavior的public变量规则相同 public bool a; public float b; public GameObject c; public Material d; } 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 通过这种方式,我们能在Inspector窗口中看到变化,其中数据的关联信息是通过脚本文件unity配置的meta文件进行记录的,之后我...
int LayerBitMask = 1 << LayerMask.NameToLayer("Pawn"); RaycastHit Hit; bool bHit = Physics.Raycast(Start, Direction, out Hit, Distance, LayerBitMask); if (bHit) { return Hit.collider.gameObject; } return null; }Copy full snippet
int: bool:bool和trigger看似类似,但bool需要人为切换true or false,trigger打开后会自动关上 trigger:trigger通常用于切换过去时需要判断,回来时不需要判断的情况。bool适用于去和回都要进行判断的情况 此外:这个条件是需要同时满足才能切换状态 使用注意事项: ...
1privatestaticvoidWriteValue(object obj,JsonWriter writer,2bool writer_is_private,3int depth)4{5if(depth>max_nesting_depth)6thrownewJsonException(7String.Format("Max allowed object depth reached while "+8"trying to export from type {0}",9obj.GetType()));1011if(obj==null)12{13writer.Write...
SetInteger、SetFloat、SetBool、SetTrigger分别对应Paramters中的Int、Float、Bool、Trigger类型。 SetInteger有两个重载: public void SetInteger(string name, int value); public void SetInteger(int id, int value); 对于第一个重载,第一个参数类型是string,对应的是parameter中的参数名称。第二个参数是要设置的值...
bool isEqual(float a, float b) { if(a >= b - Mathf.Epsilon && a <= b + Mathf.Epsilon) return true; else return false; } } 17、Mathf.Exp指数 static function Exp (power : float) : float 返回e 的 power 次方的值。 18、Mathf.FloorToInt最大整数 ...
原始数据类型(int、float、double、bool、string等) 枚举类型 某些Unity 内置类型:Vector2、Vector3、Vector4、Rect、Quaternion、Matrix4x4、Color、Color32、LayerMask、AnimationCurve、Gradient、RectOffset、GUIStyle 可序列化的容器字段类型 可序列化的简单字段类型的数组 ...