예제 #1
0
    public static T FindChild <T>(GameObject parent, string childName)
    {
        GameObject uiGO = UnityTool.FindOneOfAllChild(parent, childName);

        if (uiGO == null)
        {
            Debug.LogError("在游戏物体" + parent + "下面查找不到" + childName);
            return(default(T));
        }
        return(uiGO.GetComponent <T>());
    }
예제 #2
0
 public override GameObject Fire()
 {
     GameObject.transform.position = mFireSpot.position; //发射子弹的初始位置和角度
     GameObject.transform.rotation = mFireSpot.rotation;
     mRigidbody          = GameObject.GetComponent <Rigidbody>();
     mRigidbody.velocity = GameObject.transform.forward * mBullet.Speed; // 设置子弹发射出的初速度
     mTrails             = UnityTool.FindOneOfAllChild(GameObject, "Trails");
     mTrails.SetActive(false);
     MSC.SetState(new LaunchState(MSC, this));
     mIsFire = true;
     return(GameObject);
 }