public void AddHighlight(ControllerHighlight highlight)
    {
        highlights.Add(highlight);

        if (!string.IsNullOrEmpty(highlight.tooltipText) && highlight.tooltipButton != VRTK_ControllerTooltips.TooltipButtons.None)
        {
            string tooltip = "";

            for (int i = 0; i < highlights.Count; ++i)
            {
                if (highlights[i].tooltipButton == highlight.tooltipButton)
                {
                    if (!string.IsNullOrEmpty(tooltip))
                    {
                        tooltip += "\n";
                    }
                    tooltip += highlights[i].tooltipText;
                }
            }
            tooltips.UpdateText(highlight.tooltipButton, tooltip);
        }

        if (highlight.highlightElements != null)
        {
            for (int i = 0; i < highlight.highlightElements.Length; ++i)
            {
                highlighter.HighlightElement(highlight.highlightElements[i], highlight.highlightColor);
            }
        }
    }
示例#2
0
        void SetMode(IHandMode mode)
        {
            var newActiveFuncs = mode.FuncTypes;

            TooltipButtons newTooltips = 0;

            foreach (var func in activeFuncs)
            {
                if (!newActiveFuncs.Contains(func))
                {
                    var fnObj = funcs[func];

                    fnObj.Disable(this);

                    foreach (var pair in fnObj.Tooltips)
                    {
                        tooltips.UpdateText(pair.Key, "");

                        newTooltips |= pair.Key;
                    }
                }
            }

            foreach (var func in newActiveFuncs)
            {
                if (!activeFuncs.Contains(func))
                {
                    var fnObj = funcs[func];

                    fnObj.Enable(this);

                    foreach (var pair in fnObj.Tooltips)
                    {
                        tooltips.UpdateText(pair.Key, pair.Value);

                        newTooltips |= pair.Key;
                    }
                }
            }

            // ...because apparently passing a mask to ToggleTips breaks it.
            foreach (TooltipButtons value in Enum.GetValues(typeof(TooltipButtons)))
            {
                if ((newTooltips & value) != 0)
                {
                    tooltips.ToggleTips(true, value);
                }
            }

            activeFuncs = newActiveFuncs;
        }
示例#3
0
 public void LearnTeleport()
 {
     if (currClip == 1 && !voiceSource.isPlaying)
     {
         PlayClip(); // 03
         leftTooltip.UpdateText(gripTooltip, "");
         rightTooltip.UpdateText(gripTooltip, "");
         leftTooltip.UpdateText(touchpadTooltip, "Teleport");
     }
 }
示例#4
0
    private void OnControllerCallback(InputManager.InputState inputState)
    {
        if (inputState.Buttons.HasFlag(InputManager.InputState.ActiveFunction.SequenceRecord))
        {
            tooltips.UpdateText(VRTK_ControllerTooltips.TooltipButtons.ButtonTwoTooltip, "");
            tooltips.UpdateText(VRTK_ControllerTooltips.TooltipButtons.TouchpadTooltip, "Save sequence into top or bottom slot");
        }

        if (tooltips.buttonTwoText.Length == 0 && (inputState.Buttons & InputManager.InputState.ActiveFunction.SequencePlaybacks) > 0)
        {
            tooltips.UpdateText(VRTK_ControllerTooltips.TooltipButtons.ButtonTwoTooltip, "Record a motion sequence");
            tooltips.UpdateText(VRTK_ControllerTooltips.TooltipButtons.TouchpadTooltip, "Replay sequence saved into top or bottom slot");
        }
    }
示例#5
0
 public void GrabToggle()
 {
     if (grab.GetComponent <Toggle> ().isOn)
     {
         PMD.currentTool = Tools.Grab;
         MenuSounds.Play();
         tooltip.UpdateText(VRTK_ControllerTooltips.TooltipButtons.GripTooltip, "Grip");
     }
     else if (!grab.GetComponent <Toggle> ().isOn)
     {
         MenuSounds.Play();
         tooltip.UpdateText(VRTK_ControllerTooltips.TooltipButtons.GripTooltip, "");
     }
 }
示例#6
0
    void Start()
    {
        InputManager.AddCallback(OnControllerCallback);

        tooltips = GetComponent <VRTK_ControllerTooltips>();

        tooltips.UpdateText(VRTK_ControllerTooltips.TooltipButtons.ButtonTwoTooltip, "Record a motion sequence");
    }
示例#7
0
    /// <summary>
    /// Set up event listeners from Controller and Pointer
    /// <returns></returns>
    ///
    void Awake()
    {
        //VRTK_ControllerEvents controller;

        //Set up event listeners
        pointer = GetComponent <VRTK_Pointer>();
        pointer.DestinationMarkerEnter += Pointer_DestinationMarkerEnter;
        pointer.DestinationMarkerExit  += Pointer_DestinationMarkerExit;

        controller = GetComponent <VRTK_ControllerEvents>();
        controller.TriggerPressed      += Controller_TriggerPressed;
        controller.TriggerReleased     += Controller_TriggerReleased;
        controller.TouchpadAxisChanged += Controller_TouchpadAxisChanged;
        controller.TouchpadReleased    += Controller_TouchpadReleased;
        controller.TouchpadPressed     += Controller_TouchpadPressed;
        controller.GripClicked         += Controller_GripClicked;

        lineRenderer                 = gameObject.AddComponent <LineRenderer>();
        lineRenderer.material        = new Material(Shader.Find("Sprites/Default"));
        lineRenderer.widthMultiplier = 0.02f;
        lineRenderer.positionCount   = 2;
        bundle  = true;
        sizeRay = 1;
        lineRenderer.material.color = Color.green;


        helpTooltip = gameObject.transform.GetChild(0).GetComponent <VRTK_ControllerTooltips>();
        helpTooltip.ToggleTips(false);


        dataToolTip = gameObject.transform.GetChild(1).GetComponent <VRTK_ControllerTooltips>();
        dataToolTip.ToggleTips(false);


        //Anonymous function to Update the dataToolTip text.
        changeText = delegate(string x) {
            dataToolTip.UpdateText(VRTK_ControllerTooltips.TooltipButtons.TouchpadTooltip, x);
        };
    }
示例#8
0
 /// <summary>
 /// 打开某按键提示
 /// </summary>
 /// <param name="button"></param>
 /// <param name="text"></param>
 public void TooltipOn(VRTK_ControllerTooltips.TooltipButtons button, string text)
 {
     tooltip.UpdateText(button, text);
 }
示例#9
0
        // Update is called once per frame
        void FixedUpdate()
        {
            try{
                RaycastHit tooltipRayCast;
                //tooltip to show the player where the buttons are located on the controller
                if (Physics.Raycast(Raypoint.position, Raypoint.forward, out tooltipRayCast, 100f))
                {
                    if (tooltipRayCast.collider.tag == "UI" && !tooltipUIIsActive)
                    {
                        //tooltip.touchpadText = "Touchpad";
                        tooltip.UpdateText(VRTK_ControllerTooltips.TooltipButtons.TouchpadTooltip, "Press Touchpad");
                        tooltip.UpdateText(VRTK_ControllerTooltips.TooltipButtons.TriggerTooltip, "");

                        if (tooltip == null)
                        {
                            tooltip = GameObject.FindGameObjectWithTag("tooltip").GetComponent <VRTK_ControllerTooltips> ();
                        }
                        //tooltip.triggerText = "";
                        tooltipUIIsActive  = true;
                        tooltipMESHsActive = false;
                        //tooltip.touchpadText = "Touchpad";
                        //Debug.Log("tag is UI = " + tooltip.touchpadText);
                    }
                    else if (tooltipRayCast.collider.tag == "Mesh" && !tooltipMESHsActive && UIN.isActive)
                    {
                        tooltip.UpdateText(VRTK_ControllerTooltips.TooltipButtons.TriggerTooltip, "Press Trigger");
                        tooltip.UpdateText(VRTK_ControllerTooltips.TooltipButtons.TouchpadTooltip, "");

                        if (tooltip == null)
                        {
                            tooltip = GameObject.FindGameObjectWithTag("tooltip").GetComponent <VRTK_ControllerTooltips> ();
                        }
                        //tooltip.touchpadText = "";
                        tooltipMESHsActive = true;
                        tooltipUIIsActive  = false;
                        //tooltip.triggerText = "Trigger";
                        //Debug.Log("tag is UI = " + tooltip.triggerText);
                        //Debug.Log("tag is Mesh");
                    }
                    else if (tooltipRayCast.collider.tag != "UI")
                    {
                        tooltip.UpdateText(VRTK_ControllerTooltips.TooltipButtons.TouchpadTooltip, "");
                        tooltipUIIsActive = false;
                    }
                }

                //manages which tool is being used
                //using an enum
                switch (currentTool)
                {
                //if sculpt is pressed, this finds the collider with a mesh tag. and
                //gets the meshfilter so it can be modified.
                case Tools.Sculpt:
                    try
                    {
                        hit = point.pointerRenderer.GetDestinationHit();
                        if (hit.transform.gameObject.tag != "Non-Modifiable")
                        {
                            //Debug.Log(hit.collider.name);
                            filter = hit.collider.GetComponent <MeshFilter>();
                            if (filter)
                            {
                                if (filter != unappliedMesh)
                                {
                                    ApplyMeshCollider();
                                    unappliedMesh = filter;
                                }
                                //Mesh Symmetry. simple but it works
                                Vector3 relativePoint = filter.transform.InverseTransformPoint(hit.point);
                                Vector3 inversePoint  = relativePoint;
                                inversePoint.x = -relativePoint.x;
                                if (isTriggerOn)
                                {
                                    //Debug.Log("is trigger on? " + isTriggerOn);
                                    DeformMesh(filter.mesh, relativePoint, pull * Time.deltaTime, radius);
                                    if (MeshSymmetryToggle.isOn)
                                    {
                                        DeformMesh(filter.mesh, inversePoint, pull * Time.deltaTime, radius);
                                    }
                                }
                            }
                        }
                    }
                    catch (System.NullReferenceException) { }
                    break;

                case Tools.Scale:
                    try{
                        if (MeshTransform == null)
                        {
                            MeshTransform = GameObject.FindGameObjectWithTag("Mesh").GetComponent <GetMeshTransform> ();
                        }
                        //Debug.Log("Scaling");
                        MeshTransform.Scale();
                    }catch (Exception ex) {
                        if (ex is NullReferenceException || ex is UnassignedReferenceException)
                        {
                            return;
                        }
                    }
                    break;

                case Tools.Rotate:
                    try{
                        if (MeshTransform == null)
                        {
                            MeshTransform = GameObject.FindGameObjectWithTag("Mesh").GetComponent <GetMeshTransform> ();
                        }
                        //Debug.Log("Rotating");
                        MeshTransform.Rotate();
                    }catch (Exception ex) {
                        if (ex is NullReferenceException || ex is UnassignedReferenceException)
                        {
                            return;
                        }
                    }
                    break;

                case Tools.Crease:

                    try
                    {
                        if (UIN == null)
                        {
                            UIN = GameObject.FindGameObjectWithTag("UINref").GetComponent <UINavigationSystem> ();
                        }
                        AddorSubtract.value = 1;
                        pull   = -UIN.CreaseStrength.value;
                        radius = .03f;


                        hit = point.pointerRenderer.GetDestinationHit();
                        if (hit.transform.gameObject.tag != "Non-Modifiable")
                        {
                            filter = hit.collider.GetComponent <MeshFilter>();
                            if (filter)
                            {
                                if (filter != unappliedMesh)
                                {
                                    ApplyMeshCollider();
                                    unappliedMesh = filter;
                                }
                                //Mesh Symmetry. simple but it works
                                Vector3 relativePoint = filter.transform.InverseTransformPoint(hit.point);
                                Vector3 inversePoint  = relativePoint;
                                inversePoint.x = -relativePoint.x;
                                if (isTriggerOn)
                                {
                                    //Debug.Log("trigger on");
                                    DeformMesh(filter.mesh, relativePoint, pull * Time.deltaTime, radius);
                                    //filter.gameObject.GetComponent<MeshCollider> ().sharedMesh = filter.mesh;
                                    if (MeshSymmetryToggle.isOn)
                                    {
                                        radius = .03f;
                                        //Debug.Log(pull + " pull value");
                                        DeformMesh(filter.mesh, inversePoint, pull * Time.deltaTime, radius);
                                        //filter.gameObject.GetComponent<MeshCollider> ().sharedMesh = filter.mesh;
                                    }
                                }
                            }
                        }
                    }
                    catch (System.NullReferenceException) { }

                    break;         //get out

                case Tools.Grab:
                    try{
                        if (MeshTransform == null)
                        {
                            MeshTransform = GameObject.FindGameObjectWithTag("Mesh").GetComponent <GetMeshTransform> ();
                        }
                        //if (GrabToggle.isOn) {
                        MeshTransform.Grab();

                        //Debug.Log("Moving");
                    }catch (Exception ex) {
                        if (ex is NullReferenceException || ex is UnassignedReferenceException)
                        {
                            return;
                        }
                    }

                    break;

                case Tools.Symmetry:
                    try{
                        //MeshSymmetryToggle.isOn = true;
                    }catch (Exception ex) {
                        if (ex is NullReferenceException || ex is UnassignedReferenceException)
                        {
                            return;
                        }
                    }
                    break;

                case Tools.Smooth:
                    //Debug.Log("Moving");

                    try{
                        isInSmoothPage = true;
                        if (dm == null)
                        {
                            dm.ClayMesh = ClayMesh.GetComponent <MeshFilter>();
                            dm          = GameObject.FindGameObjectWithTag("Mesh").GetComponent <VRSmooth> ();
                        }
                    }catch (Exception ex) {
                        if (ex is NullReferenceException || ex is UnassignedReferenceException)
                        {
                            return;
                        }
                    }

                    break;

                case Tools.Paint:
                    //Debug.Log("paint ON");
                    try{
                        if (texpaint == null)
                        {
                            texpaint = GameObject.FindGameObjectWithTag("TP").GetComponent <VRTexturePainter> ();
                        }
                        texpaint.enabled = true;
                    }catch (Exception ex) {
                        if (ex is NullReferenceException || ex is UnassignedReferenceException)
                        {
                            return;
                        }
                    }
                    break;
                }
            }catch (Exception ex) {
                if (ex is NullReferenceException || ex is UnassignedReferenceException)
                {
                    return;
                }
            }
        }
示例#10
0
 private void Unhighlight(VRTK_ControllerTooltips h)
 {
     h.UpdateText(tooltipButton, "");
 }
示例#11
0
 private void Highlight(VRTK_ControllerTooltips h)
 {
     h.UpdateText(tooltipButton, text);
 }