Exemplo n.º 1
0
    void Awake()
    {
        // Setup self instance
        if (Instance != null)
        {
            throw new UnityException("CameraManager Instance already exist !");
        }
        else
        {
            Instance = this;
        }

        // Get the camera tracker and keep reference
        cameraTracker = this.transform;

        if (cameraTracker == null)
        {
            string errorMessage = "No cameraTracker founded. Add one under that GameObject !";
            Debug.LogError(errorMessage);
            throw new UnityException(errorMessage);
        }

        // Setup normal camera reference
        behindCamRef = ScriptableObject.CreateInstance <BehindCameraControllerImpl> ();
        behindCamRef.setCamera(Camera.main);
        behindCamRef.setTracker(cameraTracker);
        behindCamRef.InitCam();

        // Setup inside camera reference
        insideCamRef = ScriptableObject.CreateInstance <InsideCameraControllerImpl> ();
        insideCamRef.setCamera(Camera.main);
        insideCamRef.setTracker(cameraTracker);
        insideCamRef.InitCam();

        // Setup orbital camera reference
        orbitalCamRef = ScriptableObject.CreateInstance <OrbitalCameraControllerImpl> ();
        orbitalCamRef.setCamera(Camera.main);
        orbitalCamRef.setTracker(cameraTracker);
        orbitalCamRef.InitCam();
    }
    public void SetCameraManagementOnGameObject(GameObject go)
    {
        // Get the camera tracker transform and keep reference
        cameraTracker = go.transform;

        if (cameraTracker == null) {
            string errorMessage = "No cameraTracker founded. Add one under that GameObject !";
            Debug.LogError (errorMessage);
            throw new UnityException (errorMessage);
        }

        // Setup orbital camera reference
        orbitalCamRef = ScriptableObject.CreateInstance<OrbitalCameraControllerImpl> ();
        orbitalCamRef.setCamera (Camera.main.GetComponent<Camera>());
        orbitalCamRef.setTracker (cameraTracker);
        orbitalCamRef.InitCam ();

        // Setup normal camera reference (Not used currently in that project)
        autoOrbitalCamRef = ScriptableObject.CreateInstance<AutoOrbitalCameraControllerImpl> ();
        autoOrbitalCamRef.setCamera (Camera.main.GetComponent<Camera>());
        autoOrbitalCamRef.setTracker (cameraTracker);
        autoOrbitalCamRef.InitCam ();
    }
Exemplo n.º 3
0
    public void SetCameraManagementOnGameObject(GameObject go)
    {
        // Get the camera tracker transform and keep reference
        cameraTracker = go.transform;

        if (cameraTracker == null)
        {
            string errorMessage = "No cameraTracker founded. Add one under that GameObject !";
            Debug.LogError(errorMessage);
            throw new UnityException(errorMessage);
        }

        // Setup orbital camera reference
        orbitalCamRef = ScriptableObject.CreateInstance <OrbitalCameraControllerImpl> ();
        orbitalCamRef.setCamera(Camera.main.GetComponent <Camera>());
        orbitalCamRef.setTracker(cameraTracker);
        orbitalCamRef.InitCam();

        // Setup normal camera reference (Not used currently in that project)
        autoOrbitalCamRef = ScriptableObject.CreateInstance <AutoOrbitalCameraControllerImpl> ();
        autoOrbitalCamRef.setCamera(Camera.main.GetComponent <Camera>());
        autoOrbitalCamRef.setTracker(cameraTracker);
        autoOrbitalCamRef.InitCam();
    }