Exemplo n.º 1
0
    IEnumerator MoveMenu(WandController C)
    {
        C.cursor.SetCursorState(CursorController.CursorState.lockRadNorm);
        InputController.inUse = true;
        _Grabbed = true;
        C.VibratePeriod(3, 0.02f);

        MenuGroupController.EnableMenuGroups();

        transform.Find("MenuButton").GetComponent <Toggle> ().group = null;
        transform.parent = null;

        Transform menuDock = null;

        while (C.triggerPress)
        {
            Transform foundMenuDock = null;

            //position button
            transform.position = C.cursor.transform.position;
            transform.forward  = -C.cursor.transform.up;

            //check if you hit a menudock
            Collider[] hits = Physics.OverlapSphere(C.cursor.transform.position, 0.02f);
            foreach (Collider col in hits)
            {
                if (col.gameObject.tag == "MenuDock")
                {
                    col.SendMessage("Entered");
                    foundMenuDock = col.transform;
                    C.VibratePeriod(3, 0.05f);
                }
            }

            menuDock = (foundMenuDock == null) ? null : foundMenuDock;

            yield return(null);
        }

        yield return(null);

        MenuGroupController.DisableMenuGroups();

        //if menu is in menudock, place it there, otherwise, put it in place
        if (menuDock != null)
        {
            transform.parent = menuDock.parent.Find("MenuDock");
            transform.GetComponent <RectTransform> ().anchoredPosition3D = new Vector3(
                transform.GetComponent <RectTransform> ().anchoredPosition3D.x,
                transform.GetComponent <RectTransform> ().anchoredPosition3D.y,
                0f
                );
            transform.GetComponent <Canvas> ().worldCamera = GameObject.Find("Controller UI Camera").GetComponent <Camera> ();
            transform.Find("MenuButton").GetComponent <Toggle> ().group = menuDock.parent.Find("MenuDock").GetComponent <ToggleGroup> ();
            transform.GetComponent <RectTransform> ().localRotation     = Quaternion.identity;
        }
        else
        {
            transform.parent = null;
            transform.GetComponent <RectTransform> ().position          = C.cursor.transform.position;
            transform.GetComponent <Canvas> ().worldCamera              = GameObject.Find("Controller UI Camera").GetComponent <Camera> ();
            transform.Find("MenuButton").GetComponent <Toggle> ().group = null;
        }


        InputController.inUse = false;
        _Grabbed = false;
        MenuGroupController.RecalcTabDock();
        PositionTab();
        C.cursor.SetCursorState(CursorController.CursorState.unlocked);
    }