GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - 0V/RxVRTK: Extensions for converting ALL the VRTK events to UniRx stream

This repository was archived by the owner on Mar 9, 2023. It is now read-only.
BranchesTags
Open more actions menu

Latest commit

 

History

19 Commits
19 Commits

Folders and files

NameName
Last commit message
Last commit date
Assets
Assets
 
 
Packages
Packages
 
 
ProjectSettings
ProjectSettings
 
 
.gitignore
.gitignore
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 

Repository files navigation

RxVRTK

Extensions for converting all the VRTK events to UniRx stream

Scripts are here.

For Release Notes and unitypackage, see RxVRTK/releases.

Dependencies

  • VRTK v3.2.1
    GitHub, Asset Store
  • UniRx
    GitHub, Asset Store

What is RxVRTK?

RxVRTK mediates VRTK (VR Toolkit) and UniRx.

RxVRTK consists of two components: Event extensions and RxVRTK components.

1. Event extensions

Event extensions provide extension methods to convert an exposed VRTK event such as VRTK_ControllerEvents.TriggerPressed to an Rx stream.

You can observe {EVENT NAME} by using {EVENT NAME}AsObservable() method.

Example: Event Extensions

// Add using directive
// using RxVRTK;

VRTK_ControllerEvents controllerEvents = GetComponent<VRTK_ControllerEvents>();

controllerEvents.TriggerPressedAsObservable()
    .Subscribe(_ =>
    {
        Debug.Log("Trigger Pressed!");
    });

Event extensions have a prefix "RxVRTK_" and a suffix "Extension".

2. RxVRTK components

RxVRTK components provide an event system that registers a callback by its method name and the registered callbacks are automatically called by the event system of VRTK.

An RxVRTK component inherits from VRTK classes and overrides the aforementioned methods so that it converts a VRTK event to Rx stream. When you use these components, you must not override such methods and must only use observable methods instead.

Note

Let's say you want to register a callback for "StartUsing". In this case, VRTK calls "StartUsing" of an VRTK_InteractableObject instance if it implements a method that matches the following signature:

void StartUsing(VRTK_InteractUse currentUsingObject);

As these methods are already overridden in RxVRTK_InteractableObject, which inherits VRTK_InteractableObject to fire UniRx events and RxVRTK utilizes this technique to register an event callback, ensure that you do not use neither "StartUsing" nor new to hide this method.

Example: RxVRTK components

The base class of RxVRTK_InteractableObject is VRTK_InteractableObject. This class provides interactive events: StartUsing, StartTouching, Grabbed, etc.

using RxVRTK;
using UniRx;
using UnityEngine;

public class SomeObject : RxVRTK_InteractableObject
{
    protected void Start()
    {
        this.StartUsingAsObservable()
            .Subscribe(user =>
            {
                Debug.Log(user.name + " is using this object!");
            });
    }
}

RxVRTK components have a prefix "RxVRTK_" but no suffix.

3. VRTK_UnityEvents<T>

VRTK_UnityEvents<T> uses UnityEvent<T>. UniRx has UnityEventExtensions which convert UnityEvent to Observable, so RxVRTK doesn't support UnityEvent. Please use UniRx.UnityEventExtensions.

Example: VRTK_UnityEvents<T>

AsObservable() is an extension method to convert UnityEvent to Observable.

// Add using directive
// using UniRx;

var controlEvents = GetComponent<VRTK_Control_UnityEvents>();
controlEvents.OnValueChanged.AsObservable()
    .Subscribe(e =>
    {
        Debug.Log("Changed: "+ e.Item2.value.ToString());
    });

License

This library is released under the MIT License.

About

Extensions for converting ALL the VRTK events to UniRx stream

Resources

Readme
MIT license
Activity

Stars

5 stars

Watchers

1 watching

Forks

0 forks
Report repository

Releases

Packages

Contributors

Languages

You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.