public BoatController() { to_from = 1; from_positions = new Vector3[] { new Vector3(4.5f, 1.5f, 0), new Vector3(5.5f, 1.5f, 0) }; to_positions = new Vector3[] { new Vector3(-5.5f, 1.5f, 0), new Vector3(-4.5f, 1.5f, 0) }; // 载入预制 boat = Object.Instantiate(Resources.Load("Perfabs/Boat", typeof(GameObject)), from_pos, Quaternion.identity, null) as GameObject; boat.name = "boat"; // 挂载脚本 movingScript = boat.AddComponent(typeof(Moving)) as Moving; boat.AddComponent(typeof(ClickGUI)); }
public MyCharacterController(string which_character) { // 载入预制 if (which_character == "priest") { character = Object.Instantiate(Resources.Load("Perfabs/Priest", typeof(GameObject)), Vector3.zero, Quaternion.identity, null) as GameObject; characterType = 0; } else { character = Object.Instantiate(Resources.Load("Perfabs/Devil", typeof(GameObject)), Vector3.zero, Quaternion.identity, null) as GameObject; characterType = 1; } // 为人物挂载脚本 movingScript = character.AddComponent(typeof(Moving)) as Moving; // 添加点击事件 clickGUI = character.AddComponent(typeof(ClickGUI)) as ClickGUI; clickGUI.setController(this); }