[Unity3d]脚本相互调用以及控制
2013-11-08 17:54
369 查看
在unity中,我们时常碰到要调用另外一个脚本中的方法,或者通过代码来控制该脚本是否启动执行,下面就贴上这段脚本。
using UnityEngine; using System.Collections; public class scriptChange : MonoBehaviour { int i = 0; // Use this for initialization void Start () { } // Update is called once per frame void Update () { //鼠标右击 if (Input.GetMouseButtonDown(1)) { print("mousedown"); MouseLook obj = (MouseLook)gameObject.GetComponent("MouseLook"); //C#调用另外一个脚本的方法 //if (obj == null) //{ // print("null"); //} ////print(obj); //else //{ // print("OK"); // print(obj); // obj.active = true; // obj.test(); //} //鼠标右击开始和关闭 if (i == 0) { //开启脚本 transform.GetComponent<MouseLook>().enabled = true; } else { transform.GetComponent<MouseLook>().enabled = false; } i++; i = i % 2; } } }
相关文章推荐
- [Unity3d]脚本相互调用以及控制
- unity3d中,脚本的相互调用。
- Unity3d移动代码(脚本)向前向后以及转弯,速度转向控制
- unity3d中,脚本的相互调用。
- unity3d easytouch计算摇杆旋转角度以及摇杆八方向控制角色
- Unity3D之Mecanim动画系统学习笔记(六):使用脚本控制动画
- Unity3D中js与C#之间相互调用的解决办法
- 在Java中执行脚本命令以及调用外部程序说明
- shell脚本里相互调用的方法
- 【Unity3D】Unity3D工具、Mono工具、内部脚本工作原理以及跨平台特性
- scrapy一些非常实用资料整理,与其他mongdb、django、redis、solr、tor结合使用以及用Python脚本调用等等方法
- unity3d中脚本Awake()和GetInstance()的调用关系
- Unity3D Player角色移动控制脚本
- Unity3D UGUI之DoTweenAnimation脚本控制动画方法
- Unity3D中的第三人称镜头的脚本控制
- 对象间相互调用时互相控制的几种方法
- Unity3d 与IOS 相互调用
- Linux(centos 6.5) 调用java脚本以及定时执行的脚本实例及配置文件详解
- shell脚本里相互调用的方法
- Unity3D GUI C#脚本实例1——slider 控制环境光