/// <summary> /// 重新绑定场景中的对象 /// </summary> public void RebindObject() { GameObject[] blues, yellows; GameObject ball; FindObjects(out blues, out yellows, out ball); blueObject = blues; yellowObject = yellows; ballObject = ball; ballComponent = ballObject.GetComponent <ControlBall>(); blueComponent = new ControlRobot[5] { blueObject[0].GetComponent <ControlRobot>(), blueObject[1].GetComponent <ControlRobot>(), blueObject[2].GetComponent <ControlRobot>(), blueObject[3].GetComponent <ControlRobot>(), blueObject[4].GetComponent <ControlRobot>(), }; yellowComponent = new ControlRobot[5] { yellowObject[0].GetComponent <ControlRobot>(), yellowObject[1].GetComponent <ControlRobot>(), yellowObject[2].GetComponent <ControlRobot>(), yellowObject[3].GetComponent <ControlRobot>(), yellowObject[4].GetComponent <ControlRobot>(), }; }
public static void RebindObject() { ballObject = GameObject.Find("Ball"); blueObject = new GameObject[5] { GameObject.Find("Blue0"), GameObject.Find("Blue1"), GameObject.Find("Blue2"), GameObject.Find("Blue3"), GameObject.Find("Blue4") }; yellowObject = new GameObject[5] { GameObject.Find("Yellow0"), GameObject.Find("Yellow1"), GameObject.Find("Yellow2"), GameObject.Find("Yellow3"), GameObject.Find("Yellow4"), }; ballComponent = ballObject.GetComponent <ControlBall>(); blueComponent = new ControlRobot[5] { blueObject[0].GetComponent <ControlRobot>(), blueObject[1].GetComponent <ControlRobot>(), blueObject[2].GetComponent <ControlRobot>(), blueObject[3].GetComponent <ControlRobot>(), blueObject[4].GetComponent <ControlRobot>(), }; yellowComponent = new ControlRobot[5] { yellowObject[0].GetComponent <ControlRobot>(), yellowObject[1].GetComponent <ControlRobot>(), yellowObject[2].GetComponent <ControlRobot>(), yellowObject[3].GetComponent <ControlRobot>(), yellowObject[4].GetComponent <ControlRobot>(), }; }
public void RebindObject(GameObject entity) { ballObject = entity.transform.Find("Ball").gameObject; blueObject = new GameObject[5] { entity.transform.Find("Robot/Blue/Blue0").gameObject, entity.transform.Find("Robot/Blue/Blue1").gameObject, entity.transform.Find("Robot/Blue/Blue2").gameObject, entity.transform.Find("Robot/Blue/Blue3").gameObject, entity.transform.Find("Robot/Blue/Blue4").gameObject }; yellowObject = new GameObject[5] { entity.transform.Find("Robot/Yellow/Yellow0").gameObject, entity.transform.Find("Robot/Yellow/Yellow1").gameObject, entity.transform.Find("Robot/Yellow/Yellow2").gameObject, entity.transform.Find("Robot/Yellow/Yellow3").gameObject, entity.transform.Find("Robot/Yellow/Yellow4").gameObject }; ballComponent = ballObject.GetComponent <ControlBall>(); blueComponent = new ControlRobot[5] { blueObject[0].GetComponent <ControlRobot>(), blueObject[1].GetComponent <ControlRobot>(), blueObject[2].GetComponent <ControlRobot>(), blueObject[3].GetComponent <ControlRobot>(), blueObject[4].GetComponent <ControlRobot>(), }; yellowComponent = new ControlRobot[5] { yellowObject[0].GetComponent <ControlRobot>(), yellowObject[1].GetComponent <ControlRobot>(), yellowObject[2].GetComponent <ControlRobot>(), yellowObject[3].GetComponent <ControlRobot>(), yellowObject[4].GetComponent <ControlRobot>(), }; }