Skip to content
This repository was archived by the owner on Mar 9, 2023. It is now read-only.

Commit 9c91b63

Browse files
authored
Update README.md
thx! @chitoku-k
1 parent 9130365 commit 9c91b63

File tree

1 file changed

+71
-6
lines changed

1 file changed

+71
-6
lines changed

README.md

Lines changed: 71 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,32 @@
11
# RxVRTK
2-
Extensions for converting all VRTK event to UniRx stream
32

4-
Extension scripts are [here](https://github.com/0V/RxVRTK/tree/master/Assets/RxVRTK/Scripts/Extensions) .
3+
Extensions for converting all the VRTK events to UniRx stream
54

6-
Release Notes, see [RxVRTK/releases](https://github.com/0V/RxVRTK/releases)
5+
6+
Scripts are [here](https://github.com/0V/RxVRTK/tree/master/Assets/RxVRTK/Scripts).
7+
8+
For Release Notes and unitypackage, see [RxVRTK/releases](https://github.com/0V/RxVRTK/releases).
79

810
## Dependencies
911
* VRTK v3.2.1
10-
[GitHub](https://github.com/thestonefox/VRTK) , [Asset Store](https://assetstore.unity.com/packages/tools/vrtk-virtual-reality-toolkit-vr-toolkit-64131)
12+
[GitHub](https://github.com/thestonefox/VRTK), [Asset Store](https://assetstore.unity.com/packages/tools/vrtk-virtual-reality-toolkit-vr-toolkit-64131)
1113
* UniRx
12-
[GitHub](https://github.com/neuecc/UniRx) , [Asset Store](https://assetstore.unity.com/packages/tools/integration/unirx-reactive-extensions-for-unity-17276)
14+
[GitHub](https://github.com/neuecc/UniRx), [Asset Store](https://assetstore.unity.com/packages/tools/integration/unirx-reactive-extensions-for-unity-17276)
15+
16+
17+
## What is RxVRTK?
18+
19+
RxVRTK mediates VRTK (VR Toolkit) and UniRx.
20+
21+
RxVRTK consists of two components: **Event extensions** and **RxVRTK components**.
22+
23+
### 1. Event extensions
24+
**Event extensions** provide extension methods to convert an exposed VRTK event such as ```VRTK_ControllerEvents.TriggerPressed``` to an Rx stream.
25+
26+
You can observe ```{EVENT NAME}``` by using ```{EVENT NAME}AsObservable()``` method.
1327

14-
## Usage
28+
29+
### Example: Event Extensions
1530

1631
``` csharp
1732
VRTK_ControllerEvents controllerEvents = GetComponent<VRTK_ControllerEvents>();
@@ -23,3 +38,53 @@ controllerEvents.TriggerPressedAsObservable()
2338
});
2439

2540
```
41+
42+
Event extensions have a prefix "RxVRTK_" and a suffix "Extension".
43+
44+
45+
### 2. RxVRTK components
46+
47+
**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.
48+
49+
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.
50+
51+
52+
### Note
53+
54+
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:
55+
56+
```csharp
57+
void StartUsing(VRTK_InteractUse currentUsingObject);
58+
```
59+
60+
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.
61+
62+
63+
### Example: RxVRTK components
64+
The base class of RxVRTK_InteractableObject is **VRTK_InteractableObject**. This class provides interactive events: StartUsing, StartTouching, Grabbed, etc.
65+
66+
``` csharp
67+
using RxVRTK;
68+
using UniRx;
69+
using UnityEngine;
70+
71+
public class SomeObject : RxVRTK_InteractableObject
72+
{
73+
protected void Start()
74+
{
75+
this.StartUsingAsObservable()
76+
.Subscribe(user =>
77+
{
78+
Debug.Log(user.name + " is using this object!");
79+
});
80+
}
81+
}
82+
83+
```
84+
85+
86+
RxVRTK components have a prefix "RxVRTK_" but no suffix.
87+
88+
89+
## License
90+
This library is released under the [MIT License](https://github.com/0V/RxVRTK/blob/master/LICENSE).

0 commit comments

Comments
 (0)