/* gets called from controller events when trigger clicked */
    public void activateIcosphere()
    {
        VRTK_SimplePointer simplePointer = gameObject.GetComponent <VRTK_SimplePointer>();
        SequenceChanger    sequenceChanger;

        if (sequenceChanger = simplePointer.pointerTarget.GetComponent <SequenceChanger>())
        {
            sequenceChanger.toggle = !sequenceChanger.toggle;
        }
    }
示例#2
0
    // Use this for initialization
    void Start()
    {
        pointer_script     = GetComponent <VRTK_SimplePointer>();
        game_manager       = GameObject.Find("GameManager").GetComponent <GameManager>();
        tracked_object     = GetComponent <SteamVR_TrackedObject>();
        controller_manager = camera_rig.GetComponent <SteamVR_ControllerManager>();
        controller_events  = GetComponent <VRTK_ControllerEvents>();
        controller_actions = GetComponent <VRTK_ControllerActions>();
        trail_renderer     = GetComponent <TrailRenderer>();

        cast_fx.SetActive(false);
    }
示例#3
0
    private void Update()
    {
        if (pointer == null)
        {
            pointer = GetComponent <VRTK_SimplePointer>();
        }
        //adapt rotation of the selection to track the parent
        if (updateRotation)
        {
            selection.transform.rotation = Quaternion.FromToRotation(initialRotationDiff, selection.transform.position - gameObject.transform.position) * Quaternion.Euler(initialRotationEulerAngles);
        }

        //adapt scaling based on the difference in height from the original starting point of the selection
        if (updateScaling)
        {
            float scaleDiff = 1 + (gameObject.transform.position.y - initialPosition.y) * 1.2f;
            selection.transform.localScale = initialScale * scaleDiff;
        }
    }
示例#4
0
    private void Start()
    {
        if (GetComponent <VRTK_SimplePointer>() == null || GetComponent <VRTK_ControllerEvents>() == null)
        {
            Debug.LogError("PointerEventListener is required to be attached to a SteamVR Controller that has the VRTK_SimplePointer script attached to it");
            return;
        }

        pointer    = GetComponent <VRTK_SimplePointer>();
        controller = GetComponent <VRTK_ControllerEvents>();

        //Setup pointer event listeners
        pointer.DestinationMarkerEnter += new DestinationMarkerEventHandler(selectObject);
        pointer.DestinationMarkerExit  += new DestinationMarkerEventHandler(deselectObject);
        pointer.DestinationMarkerSet   += new DestinationMarkerEventHandler(DoAction);

        //Setup controller button event Listener;
        controller.TriggerPressed  += new ControllerInteractionEventHandler(triggerPressed);
        controller.TriggerReleased += new ControllerInteractionEventHandler(triggerReleased);

        //initial mode
        MenuAction = defaultMenuAction;
    }
示例#5
0
 void Start()
 {
     simplePointer = gameObject.GetComponent <VRTK_SimplePointer>();
 }
 /// <summary>
 /// Observable DestinationMarkerSet event
 /// </summary>
 /// <param name="events"></param>
 /// <returns></returns>
 public static IObservable <DestinationMarkerEventArgs> DestinationMarkerSetAsObservable(this VRTK_SimplePointer events)
 {
     return(Observable.FromEvent <DestinationMarkerEventHandler, DestinationMarkerEventArgs>(
                h => (s, e) => h(e),
                h => events.DestinationMarkerSet += h,
                h => events.DestinationMarkerSet -= h));
 }