Example #1
0
    private void FixRaycaster(GameObject go, bool shouldCopyProperties)
    {
        if (go == null)
        {
            return;
        }

        GraphicRaycaster oldRaycaster = go.GetComponent <GraphicRaycaster>();

        Destroy(oldRaycaster);

        bool addedRaycaster;
        GvrPointerGraphicRaycaster raycaster;

        raycaster = GetOrAddComponent <GvrPointerGraphicRaycaster>(go, out addedRaycaster);

        if (shouldCopyProperties)
        {
            GvrPointerGraphicRaycaster templateRaycaster = GetTemplateRaycaster();
            if (addedRaycaster && templateRaycaster != null)
            {
                CopyRaycasterProperties(templateRaycaster, raycaster);
            }
        }
    }
Example #2
0
    public override void HaSidoMirado()
    {
        InventarioScript inventario = player.GetComponent <InventarioScript>();

        if (inventario.objetoEnInventario != null)
        {
            if (inventario.objetoEnInventario.tag == this.gameObject.tag)
            {
                audioHole.PlayOneShot(audioHole.clip);
                isActivated = true;
                GameObject objetoADuplicar = inventario.objetoEnInventario;
                GameObject copiaObjeto     = Instantiate(objetoADuplicar);
                copiaObjeto.SetActive(true);
                copiaObjeto.transform.position = new Vector3(this.gameObject.transform.position.x, this.gameObject.transform.position.y + 2, this.gameObject.transform.position.z);
                ColliderLowPolyBox colliderBox = copiaObjeto.GetComponent <ColliderLowPolyBox>();
                copiaObjeto.GetComponent <Renderer>().material.color = Color.white;
                Destroy(colliderBox);
                GvrPointerGraphicRaycaster gaze = copiaObjeto.GetComponent <GvrPointerGraphicRaycaster>();
                Destroy(gaze);
                GvrPointerPhysicsRaycaster physicsRaycaster = copiaObjeto.GetComponent <GvrPointerPhysicsRaycaster>();
                Destroy(physicsRaycaster);
                CheckForRoomSolved();
                inventario.objetoEnInventario = null;
            }
        }
    }
Example #3
0
    public override void HaSidoMirado()
    {
        InventarioScript inventario = player.GetComponent <InventarioScript>();

        if (inventario.objetoEnInventario != null)
        {
            if (inventario.objetoEnInventario.tag == this.gameObject.tag)
            {
                GameObject piezaEscaleraInventario = inventario.objetoEnInventario;
                GameObject copiaPiezaEscalera      = Instantiate(piezaEscaleraInventario);
                copiaPiezaEscalera.SetActive(true);
                copiaPiezaEscalera.transform.position = new Vector3(this.gameObject.transform.position.x, this.gameObject.transform.position.y + 1f, this.gameObject.transform.position.z);
                copiaPiezaEscalera.gameObject.tag     = "ObjectInButton";
                //Eliminar collider y Gvr Pointer Graphic Raycaster de la pieza para que no se pueda interaccionar con ella
                ColliderLowPolyBox         colliderBox = copiaPiezaEscalera.GetComponent <ColliderLowPolyBox>();
                GvrPointerGraphicRaycaster grvPointer  = copiaPiezaEscalera.GetComponent <GvrPointerGraphicRaycaster>();
                Destroy(colliderBox);
                Destroy(grvPointer);
                copiaPiezaEscalera.GetComponent <Renderer>().material.color = Color.white;
                planeActivated = true;
                //Vaciado de inventario
                inventario.objetoEnInventario = null;
                CheckForFullStair();
                this.gameObject.SetActive(false);
                //TODO congelar posición "y" con una task con delay después de hacer el deploy a 1 metro
            }
        }
    }
Example #4
0
    private void CopyRaycasterProperties(GvrPointerGraphicRaycaster source, GvrPointerGraphicRaycaster dest)
    {
        if (source == null || dest == null)
        {
            return;
        }

        dest.blockingMask           = source.blockingMask;
        dest.blockingObjects        = source.blockingObjects;
        dest.ignoreReversedGraphics = source.ignoreReversedGraphics;
    }
Example #5
0
 public void enableAction(GameObject obj, bool act)
 {
     if (obj)
     {
         GvrPointerGraphicRaycaster action = obj.GetComponent <GvrPointerGraphicRaycaster>();
         if (action)
         {
             action.enabled = act;
         }
     }
 }
Example #6
0
 private void Awake()
 {
     player     = GameObject.Find("Player").GetComponent <Transform>();
     gvrRaycast = GetComponentInChildren(typeof(GvrPointerGraphicRaycaster), true) as GvrPointerGraphicRaycaster;
     for (int x = 0; x < dialogGameObject.Length; x++)
     {
         dialogButton[x] = dialogGameObject[x].GetComponentInChildren <Button>();
         dialog[x]       = dialogGameObject[x].GetComponentInChildren <Text>();
         //optionSelected[x] = false;
     }
     EventManager.startListening(Events.EventList.STATE_Pause, pauseIsOn);
     EventManager.startListening(Events.EventList.STATE_Continue, pauseIsOff);
     //EventManager.startListening(Events.EventList.DIALOG_Selected, setOptionXSelected);
 }
Example #7
0
    // canavas for text messages
    public static GameObject CreateCanvas(string name, Vector3 loc, Vector2 size)
    {
        //logDebug("CreateCanvas");
        GameObject objCanvas = new GameObject(name);
        Canvas     c         = objCanvas.AddComponent <Canvas>();

        c.renderMode = RenderMode.WorldSpace;
        objCanvas.AddComponent <CanvasScaler>();
        RectTransform NewCanvasRect       = objCanvas.GetComponent <RectTransform>();
        GvrPointerGraphicRaycaster action = objCanvas.AddComponent <GvrPointerGraphicRaycaster>();

        //action.enabled = false;
        NewCanvasRect.localPosition = loc;
        NewCanvasRect.sizeDelta     = size;
        NewCanvasRect.localScale    = new Vector3(0.01f, 0.01f, 1f);
        return(objCanvas);
    }
Example #8
0
    public override void HaSidoMirado()
    {
        InventarioScript inventario = player.GetComponent <InventarioScript>();

        if (inventario.objetoEnInventario != null)
        {
            GameObject cuboInventario = inventario.objetoEnInventario;
            GameObject copiaCubo      = Instantiate(cuboInventario);
            copiaCubo.SetActive(true);
            copiaCubo.transform.position = new Vector3(foso.transform.position.x, foso.transform.position.y + 2, foso.transform.position.z);
            copiaCubo.gameObject.tag     = "ObjectInHole";
            ColliderLowPolyBox colliderBox = copiaCubo.GetComponent <ColliderLowPolyBox>();
            Destroy(colliderBox);
            GvrPointerGraphicRaycaster gaze = copiaCubo.GetComponent <GvrPointerGraphicRaycaster>();
            Destroy(gaze);
        }
    }
 void Awake()
 {
     raycaster = this.transform.GetComponent <GvrPointerGraphicRaycaster>();
     // We fetch the accessibility scripts from each panel.
     panelsScripts = new PanelNavigationAccessibility[panels.Length];
     for (int i = 0; i < panels.Length; i++)
     {
         panelsScripts[i] = panels[i].GetComponent <PanelNavigationAccessibility>();
     }
     // We set the focus mode to the one that is found in
     // the player preferences. it defaults to FALSE (0) if not
     // found.
     // TODO: Might be a good idea to check here if user has
     // talkback enabled on his/her phone.
     SetFocusMode(PlayerPrefs.GetInt("focus_mode", 0) == 1);
     SetSweepMode(PlayerPrefs.GetInt("sweep_mode", 0) == 1);
     longerLongPressMode = PlayerPrefs.GetInt("longer_long_press_duration", 0) == 1;
     SetLongPressDuration(longerLongPressMode);
 }
        void Start()
        {
            armModels = GameObject.Find("ModesArmModel");
            Assert.IsNotNull(armModels);
            modeController = SceneHelpers.FindObjectOfType <ModeController>(true);
            Assert.IsNotNull(modeController);
            initialPointer = GvrPointerInputModule.Pointer;
            for (int i = 0; i < Camera.allCameras.Length; i++)
            {
                GvrPointerPhysicsRaycaster raycaster = Camera.allCameras[i].GetComponent <GvrPointerPhysicsRaycaster>();
                if (raycaster != null)
                {
                    physicsRaycasters.Add(raycaster);
                }
            }

            wasPhysicsRaycasterEnabledArray = new bool[physicsRaycasters.Count];

            GameObject customizeMenu = GameObject.Find("CustomizeArmModelUI");

            Assert.IsNotNull(customizeMenu);
            graphicRaycaster = customizeMenu.GetComponent <GvrPointerGraphicRaycaster>();
            Assert.IsNotNull(graphicRaycaster);
        }
    private void UpdateStatusMessage()
    {
        if (messageText == null || messageCanvas == null)
        {
            return;
        }
        bool isVrSdkListEmpty = !playerSettingsHasCardboard() && !playerSettingsHasDaydream();

        if (!isDaydream)
        {
            if (messageCanvas.activeSelf)
            {
                messageText.text = EMPTY_VR_SDK_WARNING_MESSAGE;
                messageCanvas.SetActive(false || isVrSdkListEmpty);
            }
            return;
        }

        string vrSdkWarningMessage = isVrSdkListEmpty ? EMPTY_VR_SDK_WARNING_MESSAGE : "";
        string controllerMessage   = "";
        GvrPointerGraphicRaycaster graphicRaycaster =
            messageCanvas.GetComponent <GvrPointerGraphicRaycaster>();

        // This is an example of how to process the controller's state to display a status message.
        switch (GvrController.State)
        {
        case GvrConnectionState.Connected:
            break;

        case GvrConnectionState.Disconnected:
            controllerMessage = CONTROLLER_DISCONNECTED_MESSAGE;
            messageText.color = Color.white;
            break;

        case GvrConnectionState.Scanning:
            controllerMessage = CONTROLLER_SCANNING_MESSAGE;
            messageText.color = Color.cyan;
            break;

        case GvrConnectionState.Connecting:
            controllerMessage = CONTROLLER_CONNECTING_MESSAGE;
            messageText.color = Color.yellow;
            break;

        case GvrConnectionState.Error:
            controllerMessage = "ERROR: " + GvrController.ErrorDetails;
            messageText.color = Color.red;
            break;

        default:
            // Shouldn't happen.
            Debug.LogError("Invalid controller state: " + GvrController.State);
            break;
        }
        messageText.text = string.Format("{0}{1}", vrSdkWarningMessage, controllerMessage);
        if (graphicRaycaster != null)
        {
            graphicRaycaster.enabled =
                !isVrSdkListEmpty || GvrController.State != GvrConnectionState.Connected;
        }
        messageCanvas.SetActive(isVrSdkListEmpty ||
                                (GvrController.State != GvrConnectionState.Connected));
    }
Example #12
0
 void Start()
 {
     raycast         = canvas.GetComponent <GvrPointerGraphicRaycaster>();
     raycast.enabled = false;
     StartCoroutine(WaitTimeToCheck());
 }
Example #13
0
        private void UpdateStatusMessage()
        {
            if (messageText == null || messageCanvas == null)
            {
                return;
            }

#if !UNITY_ANDROID && !UNITY_IOS
            messageText.text = NON_GVR_PLATFORM;
            messageCanvas.SetActive(true);
            return;
#else
#if UNITY_EDITOR
            if (!UnityEditor.PlayerSettings.virtualRealitySupported)
            {
                messageText.text = VR_SUPPORT_NOT_CHECKED;
                messageCanvas.SetActive(true);
                return;
            }
#endif  // UNITY_EDITOR

            bool isVrSdkListEmpty = !playerSettingsHasCardboard() && !playerSettingsHasDaydream();
            if (!isDaydream)
            {
                if (messageCanvas.activeSelf)
                {
                    messageText.text = EMPTY_VR_SDK_WARNING_MESSAGE;
                    messageCanvas.SetActive(isVrSdkListEmpty);
                }
                return;
            }

            string vrSdkWarningMessage = isVrSdkListEmpty ? EMPTY_VR_SDK_WARNING_MESSAGE : "";
            string controllerMessage   = "";
            GvrPointerGraphicRaycaster graphicRaycaster =
                messageCanvas.GetComponent <GvrPointerGraphicRaycaster>();
            // This is an example of how to process the controller's state to display a status message.
            switch (GvrControllerInput.State)
            {
            case GvrConnectionState.Connected:
                break;

            case GvrConnectionState.Disconnected:
                controllerMessage = CONTROLLER_DISCONNECTED_MESSAGE;
                messageText.color = Color.white;
                break;

            case GvrConnectionState.Scanning:
                controllerMessage = CONTROLLER_SCANNING_MESSAGE;
                messageText.color = Color.cyan;
                break;

            case GvrConnectionState.Connecting:
                controllerMessage = CONTROLLER_CONNECTING_MESSAGE;
                messageText.color = Color.yellow;
                break;

            case GvrConnectionState.Error:
                controllerMessage = "ERROR: " + GvrControllerInput.ErrorDetails;
                messageText.color = Color.red;
                break;

            default:
                // Shouldn't happen.
                Debug.LogError("Invalid controller state: " + GvrControllerInput.State);
                break;
            }
            messageText.text = string.Format("{0}\n{1}", vrSdkWarningMessage, controllerMessage);
            if (graphicRaycaster != null)
            {
                graphicRaycaster.enabled =
                    !isVrSdkListEmpty || GvrControllerInput.State != GvrConnectionState.Connected;
            }
            messageCanvas.SetActive(isVrSdkListEmpty ||
                                    (GvrControllerInput.State != GvrConnectionState.Connected));
#endif  // !UNITY_ANDROID && !UNITY_IOS
        }
Example #14
0
    public void CreateInterface(Question question)
    {
        // Setup Canvas game object.
        quizInterface = new GameObject("QuizInterface");
        Canvas quizCanvas = quizInterface.AddComponent <Canvas>();

        quizInterface.AddComponent <CanvasScaler>();
        GvrPointerGraphicRaycaster quizRaycaster = quizInterface.AddComponent <GvrPointerGraphicRaycaster>();

        quizInterface.transform.position   = new Vector3(0, 0, 2.2f);
        quizInterface.transform.localScale = new Vector3(0.01f, 0.01f, 0.01f);
        quizInterface.layer = 5;
        quizCanvas.GetComponent <RectTransform>().sizeDelta = new Vector2(1101, 567);
        quizCanvas.renderMode = RenderMode.WorldSpace;
        quizRaycaster.ignoreReversedGraphics = true;
        quizRaycaster.blockingObjects        = GvrPointerGraphicRaycaster.BlockingObjects.ThreeD;

        // Setup Text game object.
        GameObject questionTextObject = new GameObject("QuestionText");

        questionTextObject.AddComponent <CanvasRenderer>();
        Text          questionText     = questionTextObject.AddComponent <Text>();
        RectTransform questionTextRect = questionText.GetComponent <RectTransform>();

        questionTextObject.transform.parent = quizInterface.transform;
        questionText.transform.localScale   = new Vector3(1, 1, 1);
        questionTextRect.localPosition      = new Vector3(0, 30, 0);
        questionTextRect.sizeDelta          = new Vector2(160, 30);
        questionText.alignment = TextAnchor.MiddleCenter;
        questionText.font      = Resources.GetBuiltinResource(typeof(Font), "Arial.ttf") as Font;
        questionText.color     = Color.white;

        questionText.text = question.QuestionText;

        // Setup Button game objects.
        for (int index = 0; index < question.Answers.Count; index++)
        {
            int x = (index * 160) - ((question.Answers.Count - 1) * 160 / 2);
            int y = 0;

            GameObject answerButtonObject = new GameObject($"{question.Answers[index].AnswerText}Button");
            answerButtonObject.AddComponent <CanvasRenderer>();
            Image answerButtonImage = answerButtonObject.AddComponent <Image>();
            answerButtonObject.AddComponent <Button>();
            RectTransform answerButtonRect   = answerButtonObject.GetComponent <RectTransform>();
            VRButton      answerVRButton     = answerButtonObject.AddComponent <VRButton>();
            EventTrigger  answerEventTrigger = answerButtonObject.AddComponent <EventTrigger>();
            //EventTrigger.Entry answerEventEntry = new EventTrigger.Entry();

            answerButtonObject.transform.parent     = quizInterface.transform;
            answerButtonObject.transform.localScale = new Vector3(1, 1, 1);
            answerButtonRect.localPosition          = new Vector3(x, -50 + y, 0);
            answerButtonRect.sizeDelta = new Vector2(160, 30);
            answerButtonImage.sprite   = UnityEditor.AssetDatabase.GetBuiltinExtraResource <Sprite>("UI/Skin/UISprite.psd");
            answerButtonImage.type     = Image.Type.Sliced;
            answerVRButton.cursor      = GameObject.Find("HoverReticle").GetComponent <Image>();
            //answerEventEntry.eventID = EventTriggerType.PointerEnter;
            //answerEventEntry.callback.AddListener(new UnityAction<BaseEventData>((eventData) => { answerVRButton.GVROn(); }));
            answerEventTrigger.AddListener(EventTriggerType.PointerEnter, (PointerEventData eventData) => { answerVRButton.GVROn(); });



            GameObject answerTextObject = new GameObject($"{question.Answers[index].AnswerText}ButtonText");
            answerTextObject.AddComponent <CanvasRenderer>();
            Text          answerText     = answerTextObject.AddComponent <Text>();
            RectTransform answerTextRect = answerText.GetComponent <RectTransform>();

            answerTextObject.transform.parent = answerButtonObject.transform;
            answerText.transform.localScale   = new Vector3(1, 1, 1);
            answerTextRect.anchorMin          = new Vector2(0, 0);
            answerTextRect.anchorMax          = new Vector2(1, 1);
            answerTextRect.localPosition      = new Vector3(0, 0, 0);
            answerTextRect.sizeDelta          = new Vector2(0, 0);
            answerText.text      = question.QuestionText;
            answerText.alignment = TextAnchor.MiddleCenter;
            answerText.font      = Resources.GetBuiltinResource(typeof(Font), "Arial.ttf") as Font;
            answerText.color     = Color.black;

            answerText.text = question.Answers[index].AnswerText;
        }
    }