Zinnia.Unity
Zinnia.Unity copied to clipboard
Add documentation / prefab on how to properly use PlatformDeviceAssociation with object state switcher
It would be nice to have some sort of prefab on how to auto-enable target SDK rig (depending on the currently found HMD). It is even better if you could put a prefab for Oculus in there.
Copy from https://github.com/ExtendRealityLtd/Tilia.Utilities.ObjectStateSwitcher.Unity/issues/34
PlatformDeviceAssociation Changed to https://github.com/ExtendRealityLtd/Zinnia.Unity/commit/219d1eb52b39f7e0111fae14c0366e9fae1cad1e
From discord chat:
ok so there are 3 new PattermMatchers
-
XRSettingsPatternMatcher
-
XRDevicePatternMatcher
-
SystemInfoPatternMatcher
each one works very simply
you select a source of a string of what you want to match on, and a regular expression to match with so for example
XRDevicePatternMatcher you can select the Property Source as Model
which should report the model of the headset
so in the Pattern
you could put like Oculus
and then when that PatternMatcher
has the DoMatch
method run on it, if you're using an Oculus headset then the Model
will report as Oculus
and the PatternMatcher
will match as true
so now you can use that with with a PatternMatcherRule
where one or many patterns can belong to that rule. so if all of the given patterns match then the rule will be true
now... you can use that Rule
with the new Rule Association
component
which is a collection of gameobjects to turn on if the rule is true, or turn off if the rule is false
so now you can have a pattern that says if model is oculus
-> then my rule will be true if i'm using an oculus
-> therefore turn on these gameobjects because i'm on oculus
you can then run this into the GameObjects Association Activator
which will turn them on when the scene is enabled
XRDevicePatternMatcher looking for the string Oculus*
(anything that starts with Oculus)
then we create a rule based on that matched pattern (in the PatternMatcherRule). this says if the rule we give it is true then the rule is true.
then we add a RuleAssociation, that says if the given rule is true then we're going to assume the list of gameobjects should be active
Then finally we use a GameObjectsAsscciationActivator to say go through the rule associations and toggle on/off their gameobject collections if their rules are true/false this is the pain and joy of v4. its very powerful, but that inherently makes it more complicated making this super easy and dumbed down would make it a complete pain to support other devices or use cases right now with this system you could do things like
if oculus then make the teleport pointer blue, or if htc vice then make the teleport pointer green
etc
Let's leave this open as this needs official documentation still
- Windows -> Zinnia -> Observable List Component Generator
Choose Game Objects Association Activator
then press Generate Component
-
Choose
Rule Association
, type inOculus Association
then pressGenerate Component
-
Drag the desired game objects associated with oculus (e.g. CameraRig.OculusIntegration) into the
Game Objects
array of rule association -
Choose
Pattern Rule Matcher
, type inDetect Oculus
then pressGenerate Component
-
Add component
XRDevicePatternMatcher
, set Pattern=Oculus*
, PropertySource=Model
, DeviceSource=Head
Drag the component into thePatterns
array of the pattern rule matcher -
Drag this rule into the rule association
-
Drag the rule association into the game objects association activator
When play, if the rule detects oculus, it will activate the CameraRig.OculusIntegration.
Repeat steps 2-7 to detect other things
https://www.youtube.com/watch?v=9hpP5JDPmgo