1,U3D同一GameObject中脚本之间的通讯:《JS》
var other : JSB;
关键代码 : ①this。GameObject。getComponent(“JSB”);
②this。GameObject。getComponent。<JSB>();
③this。GameObject。getComponent(JSB);
function Start(){
other = ①/②/③;
}
2,U3D不同GameObject之间脚本通讯
关键代码 : ① :var $com : Transform ;
将 游戏物体(GameObject)复制到 变量 $com当中
② :var $js : JSB
将游戏物体(GameObject)-> JSB 复制到 $js 当中 ,因为 GameObject中 挂有 JSB
③ : 利用 : GameObject。find() 方案 :
var $gameObject : GameObject;
function Start(){
$gameObject = GameObject.find("Sphere");
}
这个方案 , 不需要 在 属性面板 赋值 。
④ : 利用 : GameObject。FindGameObjectWithTag
添加 Tag
定义 变量 : var $gameObject : GameObject;