public void Cancel() { Destroy(this.gameObject); RobotsCreated robots = RobotCreateTool.Instance.GetRobotsCreated(); Debug.Log("Robots数量:" + robots.RobotCreated.Count); for (int i = 0; i < robots.RobotCreated.Count; i++) { GameObject root = Instantiate(new GameObject()); root.name = "RobotCreate_" + i; root.AddComponent <Rigidbody>(); RobotCreated robot = robots.RobotCreated[i]; for (int j = 0; j < robot.RobotComponents.Count; j++) { RobotCreatedComponent comp = robot.RobotComponents[j]; GameObject obj = Instantiate(Resources.Load <GameObject>("RobotComponents/" + comp.prefabName), root.transform); obj.transform.localPosition = comp.pos; obj.transform.localRotation = Quaternion.Euler(comp.rot); obj.transform.localScale = comp.scale; //root = CopyCollider(obj, root); } root.transform.position = new Vector3(0, 3, 0); root.transform.rotation = Quaternion.Euler(Vector3.zero); } }
public RobotsCreated GetRobotsCreated() { if (RobotsCreated != null) { return(RobotsCreated); } RobotsCreated = LoadJsonRobotCreated(); if (RobotsCreated != null) { return(RobotsCreated); } return(new RobotsCreated()); }
public void SaveJsonRobotCreated(RobotCreated robot) { if (RobotsCreated == null) { RobotsCreated = LoadJsonRobotCreated(); } if (RobotsCreated == null) { RobotsCreated = new RobotsCreated(); } RobotsCreated.RobotCreated.Add(robot); string json = JsonUtility.ToJson(RobotsCreated); //StreamWriter sw = new StreamWriter() File.WriteAllText(RobotsCreatedJsonFilePath, json, Encoding.UTF8); }