Beispiel #1
0
    private void loadFileObjs()
    {
        // Now needs to list out all the valid files
        int levelCounter = -1;

        for (int i = 0; i < fileList.Count; i++)
        {
            if (i % 20 == 0)
            {
                levelCounter++;
            }
            GameObject g = Instantiate(filePanelObject, Vector3.zero, Quaternion.identity);
            g.transform.SetParent(filePanelBase);
            g.transform.rotation = filePanelBase.rotation;
            g.transform.position = new Vector3(filePanelBase.position.x,
                                               filePanelBase.position.y - 0.05f * i + 1f * levelCounter, filePanelBase.position.z - .75f * levelCounter);
            ImageFilePanel ifp = g.GetComponent <ImageFilePanel>();
            ifp.filePath  = fileList[i];
            ifp.text.text = ifp.filePath.Replace(startPath, "").Remove(0, 7); // leaves only the file name
            ifp.index     = i;
            ifp.iScript   = this;
            filePanelScripts.Add(ifp);
        }
        if (fileList.Count > 0)
        {
            filePanelScripts[0].Select();
        }
    }
Beispiel #2
0
    // Update is called once per frame
    void Update()
    {
        if (controller == null)
        {
            Debug.Log("Null Controller!");
            return;
        }

        triggerPressed = controller.GetPress(triggerButton);

        if (controller.GetPressDown(menuButton))
        {
            zoomMode = !zoomMode;
            if (zoomMode)
            {
                zoomModeMat.SetColor("_TintColor", Color.magenta);
            }
            else
            {
                zoomModeMat.SetColor("_TintColor", Color.blue);
            }
        }

        RaycastHit hit;

        if (controller.GetPressDown(triggerButton))
        {
            //print("GotPress, Looking Forward: " + (transform.rotation * -Vector3.up));
            if (fileMode)
            {
                if (Physics.Raycast(transform.position, transform.rotation * castDir, out hit, 10000, vFileLayer))
                {
                    ImageFilePanel ifp = hit.collider.gameObject.GetComponent <ImageFilePanel>();
                    ifp.Select();
                    iScript.GoToIndex(ifp.index);
                }
                else if (Physics.Raycast(transform.position, transform.rotation * castDir, out hit, 10000, vFileLayer))
                {
                    FolderPanel fp = hit.collider.gameObject.GetComponent <FolderPanel>();
                    fp.Select();
                    iScript.fScript.OpenDirectory(fp.filePath);
                }
                // Check for clicking Video Mode or Quit
                else if (Physics.Raycast(transform.position, transform.rotation * castDir, out hit, 10000, modeLayer))
                {
                    UnityEngine.Application.LoadLevel(1);
                }
                else if (Physics.Raycast(transform.position, transform.rotation * castDir, out hit, 10000, quitLayer))
                {
                    UnityEngine.Application.Quit();
                }
                else if (Physics.Raycast(transform.position, transform.rotation * castDir, out hit, 10000, proportionLayer))
                {
                    HighlightButton hb = hit.collider.gameObject.GetComponent <HighlightButton>();
                    hb.EngageModeCommand();
                }
                else if (Physics.Raycast(transform.position, transform.rotation * castDir, out hit, 10000, arrangementLayer))
                {
                    HighlightButton hb = hit.collider.gameObject.GetComponent <HighlightButton>();
                    hb.EngageModeCommand();
                }
                else if (Physics.Raycast(transform.position, transform.rotation * castDir, out hit, 10000, centerLayer))
                {
                    iScript.ResetPosition();
                    proximityFactor = 1.5f;
                    otherController.proximityFactor = proximityFactor;
                }
                // Registers click on "Load Copied Directory"
                else if (Physics.Raycast(transform.position, transform.rotation * castDir, out hit, 10000, loadLayer))
                {
                    castOffset = Vector3.zero;
                    if (Clipboard.ContainsText())
                    {
                        string text = Clipboard.GetText();
                        loadText.text = text;
                        //print("Text: " + text);
                        if (text.Length > 0)
                        {
                            dirScriptObject.SendMessage("LoadText", text);
                            startupOverlay.SetActive(false);
                        }
                    }
                }
                // Registers click on folder
                else if (Physics.Raycast(transform.position, transform.rotation * castDir, out hit, 10000, folderLayer))
                {
                }
                // Registers click on scroll button - needs to manage movement afterward while held!
                else if (Physics.Raycast(transform.position, transform.rotation * castDir, out hit, 10000, folderScrollLayer))
                {
                    if (!holdingFolderScroll)
                    {
                        oldPos = hit.point - scrollScript.transform.position;
                    }
                    else
                    {
                        scrollScript.Scroll((hit.point - scrollScript.transform.position - oldPos).x);
                        oldPos = hit.point - scrollScript.transform.position;
                    }

                    holdingFolderScroll = true;
                }
            }
            else if (Physics.Raycast(transform.position, transform.rotation * castDir, out hit, 10000))
            {
                castOffset = hit.point - imageTransform.position;
                //print("Offset: " + castOffset);
            }
            else
            {
                castOffset          = Vector3.zero;
                holdingFolderScroll = false;
            }
        }

        if (triggerPressed && castOffset.magnitude > 0 && !fileMode)
        {
            // Enables dragging of the image
            if (Physics.Raycast(transform.position, transform.rotation * castDir, out hit, 10000))
            {
                //castOffset = hit.point - imageTransform.position;
                //print("Offset: " + castOffset);
                imageTransform.position = hit.point - castOffset;
                iScript.UpdateActiveImage();
            }
        }
        if (controller.GetPressDown(dButton))
        {
            Vector2 padDir = controller.GetAxis(Valve.VR.EVRButtonId.k_EButton_Axis0);
            if (padDir.x > 0.7f)
            {
                dirScriptObject.SendMessage("IndexUp");
            }
            else if (padDir.x < -0.7f)
            {
                dirScriptObject.SendMessage("IndexDown");
            }
        }
        if (controller.GetPress(dButton))
        {
            Vector2 padDir = controller.GetAxis(Valve.VR.EVRButtonId.k_EButton_Axis0);
            if (zoomMode)
            {
                if (padDir.y > 0.7f)
                {
                    if (Physics.Raycast(transform.position, transform.rotation * castDir, out hit, 10000))
                    {
                        print("HitPoint: " + hit.collider.gameObject); // is triggered

                        dirScriptObject.SendMessage("ZoomIn", hit.point);
                    }
                    else
                    {
                        dirScriptObject.SendMessage("ZoomIn", imageTransform.position);
                    }
                }
                else if (padDir.y < -0.7f)
                {
                    if (Physics.Raycast(transform.position, transform.rotation * castDir, out hit, 10000))
                    {
                        print("HitPoint: " + hit.collider.gameObject); // is triggered
                        dirScriptObject.SendMessage("ZoomOut", hit.point);
                    }
                    else
                    {
                        dirScriptObject.SendMessage("ZoomOut", imageTransform.position);
                    }
                }
            }
            else
            {
                // Next to player at -29
                if (padDir.y > 0.7f)
                {
                    proximityFactor += 1.25f * Time.deltaTime;
                    otherController.proximityFactor = proximityFactor;
                    //imageTransform.position = new Vector3(imageTransform.position.x, imageTransform.position.y,
                    //                                imageTransform.position.z + 4 * Time.deltaTime);
                }
                else if (padDir.y < -0.7f)
                {
                    proximityFactor -= 1.25f * Time.deltaTime;
                    otherController.proximityFactor = proximityFactor;
                    //imageTransform.position = new Vector3(imageTransform.position.x, imageTransform.position.y,
                    //                                imageTransform.position.z - 4 * Time.deltaTime);
                }
                // default proximityFactor is 1.5
                float zPos = 0.2963f * Mathf.Pow(proximityFactor, 3) - 29;
                imageTransform.localPosition = new Vector3(imageTransform.localPosition.x, imageTransform.localPosition.y,
                                                           zPos);
            }
        }

        if (controller.GetPressDown(gripButton))
        {
            //dirScriptObject.SendMessage("LoadText");
            fileMode = !fileMode;
            loadManager.SetActive(fileMode);
        }
        if (Physics.Raycast(transform.position, transform.rotation * castDir, out hit, 10000, modeLayer))
        {
            HighlightPanel hp = hit.collider.gameObject.GetComponent <HighlightPanel>();
            hp.isHighlighted = true;
        }
        if (Physics.Raycast(transform.position, transform.rotation * castDir, out hit, 10000, quitLayer))
        {
            HighlightPanel hp = hit.collider.gameObject.GetComponent <HighlightPanel>();
            hp.isHighlighted = true;
        }
        if (Physics.Raycast(transform.position, transform.rotation * castDir, out hit, 10000, loadLayer))
        {
            HighlightPanel hp = hit.collider.gameObject.GetComponent <HighlightPanel>();
            hp.isHighlighted = true;
        }
        if (Physics.Raycast(transform.position, transform.rotation * castDir, out hit, 10000, vFileLayer))
        {
            ImageFilePanel ifp = hit.collider.gameObject.GetComponent <ImageFilePanel>();
            ifp.isHighlighted = true;
            ifp.text.color    = Color.white;
        }
        if (Physics.Raycast(transform.position, transform.rotation * castDir, out hit, 10000, proportionLayer))
        {
            HighlightButton hb = hit.collider.gameObject.GetComponent <HighlightButton>();
            hb.isHighlighted = true;
        }
        if (Physics.Raycast(transform.position, transform.rotation * castDir, out hit, 10000, arrangementLayer))
        {
            HighlightButton hb = hit.collider.gameObject.GetComponent <HighlightButton>();
            hb.isHighlighted = true;
        }
        if (Physics.Raycast(transform.position, transform.rotation * castDir, out hit, 10000, centerLayer))
        {
            HighlightButton hb = hit.collider.gameObject.GetComponent <HighlightButton>();
            hb.isHighlighted = true;
        }
    }