コード例 #1
0
    // Must be called on object that has a Camera and PerspectiveProperties object
    public void enableCam(GameObject cam)
    {
        Debug.Log("EnableCam called");

        for (short i = 0; i < cameras.Count; i++)
        {
            bool camActive = cameras[i] == cam;
            if (cameras[i] != null)
            {
                cameras[i].SetActive(camActive);
            }

            if (camActive)
            {
                Debug.Log("Enabling cam " + i);
                activeCamIndex = i;
            }
        }


        // Set object data according to camera properties reference
        PerspectiveProperties camPropertiesRef = cam.GetComponent <PerspectiveProperties>();

        showUI              = camPropertiesRef.showUI;
        mouseIsLocked       = camPropertiesRef.mouseIsLocked;
        aircraftInputActive = camPropertiesRef.aircraftInputActive;


        // Use that data to complete the perspective change
        uiRef.GetComponent <hudControl>().setHudVisible(showUI);

        //aircraftPlayerInputRef.enabled = aircraftInputActive;
        setMouseLock(mouseIsLocked);
    }
コード例 #2
0
    //  SWITCH TO CAM PERSPECTIVE
    void enableCamIndex(short index)
    {
        if (cameras[index] != null) // only proceed if index is valid
        {
            // activate proper camera
            cameras[index].SetActive(true);

            // deactivate all cameras that aren't specified cam
            for (short i = 0; i < cameras.Count; i++)
            {
                if (i != index && cameras[i] != null)
                {
                    cameras[i].SetActive(false);
                }
            }

            // Set object data according to camera properties reference
            PerspectiveProperties camPropertiesRef = cameras[index].GetComponent <PerspectiveProperties>();
            showUI              = camPropertiesRef.showUI;
            mouseIsLocked       = camPropertiesRef.mouseIsLocked;
            aircraftInputActive = camPropertiesRef.aircraftInputActive;
        }
    }
コード例 #3
0
    // SOMEWHAT INEFFICIENT. SCRIPT LOOPS THROUGH NON-DESIRED CAMERAS TWICE
    //  Doesn't need to be called rapidly, so might not be a problem
    public void switchToType(PerspectiveProperties.CamType type)
    {
        bool camFound = false;

        // search for camera of desired type
        for (short i = 0; i < cameras.Count; i++)
        {
            if (cameras[i] != null)
            {
                PerspectiveProperties camProperties = cameras[i].GetComponent <PerspectiveProperties>();
                if (camProperties.camType == type) // if this camera is desired type
                {
                    enableCamIndex(i);             // switch to camera
                    camFound = true;
                }
            }
        }

        if (!camFound)
        {
            Debug.Log("Unable to find camera of type: " + type.ToString());
        }
    }