unity3d调用另一个脚本组件的方法

来源:互联网 发布:软件测试工程师招聘 编辑:程序博客网 时间:2024/05/22 12:46

首先获取脚本组件,然后就可以调用它的方法了。

void Start ()     {        anim = GetComponent<Animator> ();        gunAim = GetComponentInParent<GunAim>();    }    void Update ()     {        if (Input.GetButtonDown("Fire1") && Time.time > nextFire && !gunAim.GetIsOutOfBounds())         {            anim.SetTrigger ("Fire");            ...        }    }
阅读全文
1 0