Beispiel #1
0
    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);
        }
    }
Beispiel #2
0
    public void Submit()
    {
        RobotCreated robot = new RobotCreated();

        if (robot_create == null)
        {
            robot_create = GameObject.Find("Robot");
        }
        for (int i = 0; i < robot_create.transform.childCount; i++)
        {
            GameObject            child = robot_create.transform.GetChild(i).gameObject;
            RobotCreatedComponent comp  = new RobotCreatedComponent();
            comp.prefabName = child.name.Replace("(Clone)", "");
            comp.pos        = child.transform.localPosition;
            comp.rot        = child.transform.localRotation.eulerAngles;
            comp.scale      = child.transform.localScale;
            robot.RobotComponents.Add(comp);
        }
        RobotCreateTool.Instance.SaveJsonRobotCreated(robot);
        ShowSuccessSubmitTip();
    }