Inheritance: MonoBehaviour, ICardboardPointer
Ejemplo n.º 1
0
    private void AddReticleSupport(GameObject gameObject)
    {
        // User wants a reticle?
        if (addReticle)
        {
            // Retrieve the reticle asset.
            Object asset = UnityEditor.AssetDatabase.LoadAssetAtPath(
                "Assets/Cardboard/Prefabs/UI/CardboardReticle.prefab",
                typeof(GameObject));
            if (asset == null)
            {
                // Show there was an error.
                EditorUtility.DisplayDialog("Failed to create Reticle",
                                            "CardboardReticle.prefab not found. Did you move the Cardboard " +
                                            "assets directory? Expected location: \"Assets/Cardboard/Prefabs" +
                                            "/UI/CardboardReticle.prefab\"", "Maybe?..");
                return;
            }

            // Find head. Reticle should be child of head.
            CardboardHead head = gameObject.GetComponentInChildren <CardboardHead>();

            if (head)
            {
                // Found head! Refer its GameObject.
                GameObject headObject = head.gameObject;

                // Reticle object.
                GameObject reticleObject;

                // Find existing reticle.
                CardboardReticle cardboardReticle = headObject.GetComponentInChildren <CardboardReticle>();
                if (cardboardReticle != null)
                {
                    reticleObject = cardboardReticle.gameObject;
                }
                else
                {
                    // Instantiate reticle.
                    GameObject instance = Object.Instantiate(asset) as GameObject;
                    instance.name = asset.name; // removes the (clone) from the name.
                    // Set as child of CardboardHead object.
                    instance.transform.SetParent(headObject.transform, false);

                    reticleObject = instance;
                }

                if (uGUISupport)
                {
                    // Add modules to support uGUI.
                    AddGazeInputModule();
                    AddPhysicsRaycasterToCamera(gameObject);
                }
                else
                {
                    AddCardboardGaze(gameObject, reticleObject);
                }
            }
        }
    }
Ejemplo n.º 2
0
    void Awake()
    {
        player = GameObject.Find("CardboardMain");
        GameObject reticleObject = GameObject.Find("Cardboard Reticle");
        reticle = reticleObject.GetComponent<CardboardReticle>();

        walls = GameObject.FindGameObjectsWithTag("Walls");
    }
Ejemplo n.º 3
0
    void Awake()
    {
        player = GameObject.Find("CardboardMain");
        GameObject reticleObject = GameObject.Find("Cardboard Reticle");

        reticle = reticleObject.GetComponent <CardboardReticle>();

        walls = GameObject.FindGameObjectsWithTag("Walls");
    }
Ejemplo n.º 4
0
    public void Start()
    {
        // Save a flag in the local player preferences to initialize VR mode
        // This way when the app is restarted, it is in the mode that was last used.
        int doVR = PlayerPrefs.GetInt("VREnabled");

        Cardboard.SDK.VRModeEnabled = doVR == 1;
        CardboardHead head = cardboardMain.GetComponentInChildren <CardboardHead>();

        head.enabled     = Cardboard.SDK.VRModeEnabled;
        cardboardReticle = cardboardMain.GetComponentInChildren <CardboardReticle>();
        cardboardReticle.gameObject.SetActive(Cardboard.SDK.VRModeEnabled);
        Cardboard.SDK.TapIsTrigger = true;
    }