Skip to content

Commit b359cb4

Browse files
authored
Merge pull request #26 from maxxfrazer/visionos-readme
added visionOS snippets to README
2 parents d97a14b + 2f0f6bc commit b359cb4

File tree

2 files changed

+59
-13
lines changed

2 files changed

+59
-13
lines changed

README.md

Lines changed: 59 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -33,22 +33,36 @@ RealityUI also has a collection of components for interfacing with any Entity th
3333

3434
## Requirements
3535

36-
- iOS 13 or macOS 10.15
37-
- Swift 5.4
38-
- Xcode 12
36+
- iOS 13, macOS 10.15 or visionOS 1.0
37+
- Swift 5.8
38+
- Xcode 13
3939

4040
## Content
4141

42-
- [Installation](#installation)
43-
- [Usage](#usage)
44-
- [Control Entities](#control-entities)
45-
- [Gestures](#gestures)
46-
- [Animations](#animations)
47-
- [Text](#text)
48-
- [More](#more)
49-
- [RealityUI Wiki](https://github.com/maxxfrazer/RealityUI/wiki)
50-
- [Documentation](https://maxxfrazer.github.io/RealityUI/documentation/realityui/)
51-
- [Example Project](https://github.com/maxxfrazer/RealityUI/tree/main/RealityUI%2BExamples)
42+
- [RealityUI](#realityui)
43+
- [Requirements](#requirements)
44+
- [Content](#content)
45+
- [Installation](#installation)
46+
- [Swift Package Manager](#swift-package-manager)
47+
- [Usage](#usage)
48+
- [Registering RealityUI Components](#registering-realityui-components)
49+
- [Activating Gestures](#activating-gestures)
50+
- [visionOS](#visionos)
51+
- [iOS/macOS](#iosmacos)
52+
- [Control Entities](#control-entities)
53+
- [RUISwitch](#ruiswitch)
54+
- [RUIStepper](#ruistepper)
55+
- [RUISlider](#ruislider)
56+
- [RUIButton](#ruibutton)
57+
- [Gestures](#gestures)
58+
- [Drag](#drag)
59+
- [Turn](#turn)
60+
- [Tap](#tap)
61+
- [Animations](#animations)
62+
- [Spin](#spin)
63+
- [Shake](#shake)
64+
- [Text](#text)
65+
- [More](#more)
5266

5367
## Installation
5468

@@ -68,6 +82,38 @@ All components used in RealityUI must be registered before they are used, simply
6882

6983
#### Activating Gestures
7084

85+
##### visionOS
86+
87+
With visionOS, gestures can be enabled on a RealityView using `View/addRUIDragGesture()` or `View/addRUITapGesture()` modifiers, or by adding the gestures directly with `.gesture(RUIDragGesture())` or `.gesture(RUITapGesture())`. The RealityView might look something like this:
88+
89+
```swift
90+
RealityView { content in
91+
let swtch = RUISwitch()
92+
swtch.scale = .init(repeating: 0.1)
93+
content.add(swtch)
94+
}.addRUIDragGesture()
95+
```
96+
97+
> The above snippet adds an interactive switch/toggle to the scene.
98+
99+
This gesture works for any entity with RUIDragComponent, for example:
100+
101+
```swift
102+
RealityView { content in
103+
let movable = try! await ModelEntity(named: "toy_biplane")
104+
movable.generateCollisionShapes(recursive: false)
105+
106+
movable.components.set(RUIDragComponent(type: .move(nil)))
107+
movable.components.set(InputTargetComponent())
108+
109+
content.add(movable)
110+
}.addRUIDragGesture()
111+
```
112+
113+
![moving a biplane around in vision pro simulator](media/biplane_drag.gif)
114+
115+
##### iOS/macOS
116+
71117
Enabling RealityUI gestures can be doen by calling `RealityUI.enableGestures(.all, on: ARView)`, with `ARView` being your instance of an [ARView](https://developer.apple.com/documentation/realitykit/arview) object.
72118

73119
RUISlider, RUISwitch, RUIStepper and RUIButton all use ``RUIDragComponent``, which requires `.ruiDrag`. If you are adding elements that use the component `RUITapComponent` you can use the gesture `.tap`.

media/biplane_drag.gif

1.07 MB
Loading

0 commit comments

Comments
 (0)