RealityUI is a collection of User Interface classes for RealityKit. The classes included in RealityUI aim to offer familiar User Interface guidelines, but in a 3D setting for Augmented and Virtual Reality through RealityKit.
The User Interface controls in this repository so far are made to be familiar to what people are used to with 2D interfaces, however the plan is to expand the tools on offer to new and unique controls, which are more appropriate for an Augmented Reality and Virtual Reality context.
Add the URL of this repository to your Xcode 11+ Project under
Project > Swift Packages.
import RealityUI to the top of your swift file to start.
All components used in RealityUI must be registered before they are used, simply call
RealityUI.registerComponents() anywhere in your app before any classes starting with
RUI are initialised to avoid issues with that. For more information on what is meant by registering components see Apple's documentation here.
If you plan on using RUISwitch or RUIStepper, then you should at least enable
.pan, but I would just recommend using
.all to avoid issues, as these will inevitably move around ad RealityUI develops, and will not interfere with the rest of your RealityKit scene.
RealityUI.enableGestures(.all, on: arView)
By default all RealityUI Entities are quite large. This is used to standardize the sizes so that you always know what to expect. For example, all UI thumbs are spheres with a diameter of 1 meter, which is 1 unit in RealityKit, ± any padding adjustments. All RealityUI Entities face
[0, 0, -1] by default. To have them point at the user camera, or
.zero, you can use the
.look(at:,from:,relativeTo:) method like so:
.look(at: .zero, from: [0, 0, 1]). Or if you want it to turn around straight away if you've positioned it at
[0, 0, -1], set the orientation to
simd_quatf(angle: .pi, axis: [0, 1, 0]). Using the .look() method works here by setting the
at: value to the direction the button should be used from.
RUISwitch is a 3D toggle switch with an on and off state. Default bounding box is 2x1x1m
RUIStepper is used to increment or decrement a value. Default bounding box is 2x1x0.25m
An interactive track to represent an interpolated value. Default bounding box is 10x1x1m including thumb.
RUIButton is used to initiate a specified action. The action here will only trigger if the gesture begins on a button, and also ends on the same button. This is similar to the touchUpInside UIControl Event.
Default button bounding box before depressing the button into the base is
[1, 1, 0.3]
All of the RealityUI Control Entities use custom gestures that aren't standard in RealityKit, but some of them have been isolated so anyone can use them to manipulate their own RealityKit scene.
Unlock the ability to rotate a RealityKit entity with just one finger.
Create an object in your RealityKit scene with an action, and it will automatically be picked up whenever the user taps on it!
There aren't many animations added by default to RealityKit, especially none that you can set to repeat. See the wiki page on how to use these animations.
Spin an Entity around an axis easily using ruiSpin.
Shake an entity to attract attention, or signal something was incorrect.
It's already possible to place text in RealityKit, but I felt it needed a little upgrade.
With RUIText you can easily create an Entity with the specified text placed with its bounding box centre at the middle of your entity.
Also see the Example Project for iOS in this repository.
|Last commit: 4 weeks ago|