Beispiel #1
0
    /// <summary>
    /// Add a new camera to the robot using the default position and rotation
    /// </summary>
    /// <returns></returns>
    public GameObject AddCamera(Robot robot, Transform anchor)
    {
        GameObject newCamera = new GameObject("RobotCamera_" + robotCameraList.Count);

        newCamera.AddComponent <Camera>();

        newCamera.transform.parent        = anchor;
        newCamera.transform.localPosition = new Vector3(0f, 0.5f, 0f);
        newCamera.transform.localRotation = Quaternion.identity;

        RobotCamera configuration = newCamera.AddComponent <RobotCamera>();

        configuration.UpdateConfiguration();
        configuration.SetParentRobot(robot);

        newCamera.SetActive(false);
        if (robotCameraList.Count == 0)
        {
            CurrentCamera = newCamera;
        }

        robotCameraList.Add(newCamera);
        if (robotCameraList.Count == 0)
        {
            CurrentCamera = newCamera;
        }
        return(newCamera);
    }
Beispiel #2
0
    /// <summary>
    /// Add a new camera to the robot
    /// </summary>
    /// <param name="anchor"></param> The robot node to which the camera attaches
    /// <param name="positionOffset"></param>
    /// <param name="rotationOffset"></param>
    /// <returns></returns>
    public GameObject AddCamera(Robot robot, Transform anchor, Vector3 positionOffset, Vector3 rotationOffset)
    {
        GameObject newCamera = new GameObject("RobotCamera_" + robotCameraList.Count);

        newCamera.AddComponent <Camera>();

        newCamera.transform.parent        = anchor;
        newCamera.transform.localPosition = positionOffset;
        newCamera.transform.localRotation = Quaternion.Euler(rotationOffset);

        RobotCamera configuration = newCamera.AddComponent <RobotCamera>();

        configuration.UpdateConfiguration();
        configuration.SetParentRobot(robot);

        newCamera.SetActive(false);
        if (robotCameraList.Count == 0)
        {
            CurrentCamera = newCamera;
        }

        robotCameraList.Add(newCamera);

        return(newCamera);
    }
    /// <summary>
    /// Add a new camera to the robot using the default position (0, 0.5, 0) and rotation
    /// </summary>
    /// <returns></returns>
    public GameObject AddCamera(Robot robot, Transform anchor)
    {
        GameObject newCamera = new GameObject("RobotCamera_" + robotCameraList.Count);

        newCamera.AddComponent <Camera>();

        newCamera.transform.parent        = anchor;
        newCamera.transform.localPosition = new Vector3(0f, 0.5f, 0f);
        newCamera.transform.localRotation = Quaternion.identity;

        RobotCamera configuration = newCamera.AddComponent <RobotCamera>();

        configuration.UpdateConfiguration();
        //Set the camera parent robot, which is necessary when changing robot and restoring the configuration
        configuration.SetParentRobot(robot);

        newCamera.SetActive(false);
        //Make sure current camera is the first one on the list
        if (robotCameraList.Count == 0)
        {
            CurrentCamera = newCamera;
        }

        robotCameraList.Add(newCamera);

        return(newCamera);
    }