Beispiel #1
0
        void Start()
        {
            DebugUIBuilder.instance.AddLabel("OVROverlay Sample");
            DebugUIBuilder.instance.AddDivider();
            DebugUIBuilder.instance.AddLabel("Level Loading Example");
            DebugUIBuilder.instance.AddButton("Simulate Level Load", TriggerLoad);
            DebugUIBuilder.instance.AddButton("Destroy Cubes", TriggerUnload);
            DebugUIBuilder.instance.AddDivider();
            DebugUIBuilder.instance.AddLabel("OVROverlay vs. Application Render Comparison");
            overlayRadioButton     = DebugUIBuilder.instance.AddRadio("OVROverlay", "group", delegate(Toggle t) { RadioPressed(ovrOverlayID, "group", t); }).GetComponentInChildren <Toggle>();
            applicationRadioButton = DebugUIBuilder.instance.AddRadio("Application", "group", delegate(Toggle t) { RadioPressed(applicationID, "group", t); }).GetComponentInChildren <Toggle>();
            noneRadioButton        = DebugUIBuilder.instance.AddRadio("None", "group", delegate(Toggle t) { RadioPressed(noneID, "group", t); }).GetComponentInChildren <Toggle>();

            DebugUIBuilder.instance.Show();

            // Start with Overlay Quad
            desiredUiType = EUiDisplayType.EUDT_OverlayQuad;
            CameraAndRenderTargetSetup();
            cameraRenderOverlay.enabled             = true;
            cameraRenderOverlay.currentOverlayShape = OVROverlay.OverlayShape.Quad;
            spawnedCubes.Capacity = numObjectsPerLevel * numLevels;
        }
Beispiel #2
0
    void OverlaySwitch()
    {
        float cylinderRadius = transform.localScale.z;
        bool  isMenuActive   = OVRInspector.instance.IsMenuActive();
        bool  triggerDisplay = wasMenuActive && !isMenuActive;

        wasMenuActive = OVRInspector.instance.IsMenuActive();

        // Hide the cursor by set the size to 0, we don't want to disable it since it will cause overlay layers reordering
        // Want to keep it topmost.
        cursor.transform.localScale = isMenuActive ? new Vector3(0, 0, 0) : new Vector3(0.3f, 0.3f, 0.3f);

        if (isMenuActive)
        {
            worldGeoProxy_Quad.SetActive(false);
            worldGeoProxy_Cylinder.SetActive(false);
            overOverlay.enabled = false;
            return;
        }

        // Switch between World Geo, Plane Overlay and Cylinder Overlay
        if (triggerDisplay ||
            OVRInput.GetDown(OVRInput.Button.One) ||
            OVRInput.GetDown(OVRInput.Button.PrimaryIndexTrigger)
#if !UNITY_ANDROID || UNITY_EDITOR
            || Input.GetMouseButtonDown(0) ||
            Input.GetMouseButtonDown(1)
#endif
            )
        {
#if !UNITY_ANDROID || UNITY_EDITOR
            if (desiredUiType == EUiDisplayType.EUDT_WorldGeoQuad)
            {
                // Switch to EUDT_OverlayQuad
                desiredUiType = EUiDisplayType.EUDT_OverlayQuad;
                informationText.GetComponent <TextMesh>().text = "Overlay Layer Quad, Press any key to World Geo Quad";
                overOverlay.enabled             = true;
                overOverlay.currentOverlayShape = OVROverlay.OverlayShape.Quad;
                worldGeoProxy_Quad.SetActive(false);
                worldGeoProxy_Cylinder.SetActive(false);
            }
            else if (desiredUiType == EUiDisplayType.EUDT_OverlayQuad)
            {
                // Switch to EUDT_WorldGeoQuad
                desiredUiType = EUiDisplayType.EUDT_WorldGeoQuad;
                informationText.GetComponent <TextMesh>().text = "World Geo Quad, Press any key to Overlay Layer Quad";
                overOverlay.enabled             = false;
                overOverlay.currentOverlayShape = OVROverlay.OverlayShape.Quad;
                worldGeoProxy_Quad.SetActive(true);
                worldGeoProxy_Cylinder.SetActive(false);
            }
#else
            if (desiredUiType == EUiDisplayType.EUDT_WorldGeoQuad)
            {
                // Switch to EUDT_OverlayQuad
                desiredUiType = EUiDisplayType.EUDT_OverlayQuad;
                informationText.GetComponent <TextMesh>().text = "Overlay Layer Quad, Press any key to World Geo Cylinder";

                overOverlay.enabled             = true;
                overOverlay.currentOverlayShape = OVROverlay.OverlayShape.Quad;
                worldGeoProxy_Quad.SetActive(false);
                worldGeoProxy_Cylinder.SetActive(false);
            }
            else if (desiredUiType == EUiDisplayType.EUDT_OverlayQuad)
            {
                // Switch to EUDT_WorldGeoCylinder
                desiredUiType = EUiDisplayType.EUDT_WorldGeoCylinder;
                informationText.GetComponent <TextMesh>().text = "World Geo Cylinder, Press any key to Overlay Layer Cylinder";

                // Resize renderTarget
                CameraAndRenderTargetSetup();
                overOverlay.enabled             = false;
                overOverlay.currentOverlayShape = OVROverlay.OverlayShape.Cylinder;
                worldGeoProxy_Quad.SetActive(false);
                worldGeoProxy_Cylinder.SetActive(true);
            }
            else if (desiredUiType == EUiDisplayType.EUDT_WorldGeoCylinder)
            {
                // Switch to EUDT_OverlayCylinder
                desiredUiType = EUiDisplayType.EUDT_OverlayCylinder;
                informationText.GetComponent <TextMesh>().text = "Overlay Layer Cylinder, Press any key to World Geo Quad";

                overOverlay.enabled             = true;
                overOverlay.currentOverlayShape = OVROverlay.OverlayShape.Cylinder;
                worldGeoProxy_Quad.SetActive(false);
                worldGeoProxy_Cylinder.SetActive(false);
            }
            else if (desiredUiType == EUiDisplayType.EUDT_OverlayCylinder)
            {
                // Switch to EUDT_WorldGeoQuad
                desiredUiType = EUiDisplayType.EUDT_WorldGeoQuad;
                informationText.GetComponent <TextMesh>().text = "World Geo Quad, Press any key to Overlay Layer Quad";

                // Resize renderTarget
                CameraAndRenderTargetSetup();

                overOverlay.enabled             = false;
                overOverlay.currentOverlayShape = OVROverlay.OverlayShape.Quad;
                worldGeoProxy_Quad.SetActive(true);
                worldGeoProxy_Cylinder.SetActive(false);
            }
#endif
        }

        // Cylinder's original is at cylinder center, Quad overlay is at Quad center
        // So offset cylinder with cylinderRadius for making cylinder inscribing the Quad
        if (desiredUiType == EUiDisplayType.EUDT_WorldGeoCylinder || desiredUiType == EUiDisplayType.EUDT_OverlayCylinder)
        {
            transform.position = startPos - Vector3.forward * (cylinderRadius);
        }
        else
        {
            transform.position = startPos;
        }
    }