Skip to content

Commit

Permalink
Merge pull request #339 from De-Panther/auto_load_from_webxrsettings
Browse files Browse the repository at this point in the history
Added options to auto-load WebXRManager and WebXRInputSystem
  • Loading branch information
De-Panther authored Jan 16, 2024
2 parents 6bf7e41 + 9eb9e66 commit 321d65a
Show file tree
Hide file tree
Showing 16 changed files with 91 additions and 111 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,8 @@ MonoBehaviour:
VROptionalFeatures: 2
ARRequiredReferenceSpace: 2
AROptionalFeatures: -1
UseFramebufferScaleFactor: 0
UseNativeResolution: 0
FramebufferScaleFactor: 1
AutoLoadWebXRManager: 1
AutoLoadWebXRInputSystem: 0
2 changes: 1 addition & 1 deletion DebugProjects/Unity2020.3/Packages/packages-lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"depth": 0,
"source": "embedded",
"dependencies": {
"com.de-panther.webxr": "0.20.0"
"com.de-panther.webxr": "0.20.1-preview"
}
},
"com.unity.burst": {
Expand Down
2 changes: 2 additions & 0 deletions MainProject/Assets/XR/Settings/Web XR Settings.asset
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,5 @@ MonoBehaviour:
UseFramebufferScaleFactor: 0
UseNativeResolution: 0
FramebufferScaleFactor: 1
AutoLoadWebXRManager: 1
AutoLoadWebXRInputSystem: 1
2 changes: 1 addition & 1 deletion MainProject/Packages/packages-lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"depth": 0,
"source": "embedded",
"dependencies": {
"com.de-panther.webxr": "0.20.0"
"com.de-panther.webxr": "0.20.1-preview"
}
},
"com.unity.burst": {
Expand Down
3 changes: 1 addition & 2 deletions MainProject/ProjectSettings/GraphicsSettings.asset
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@ GraphicsSettings:
m_AlwaysIncludedShaders:
- {fileID: 7, guid: 0000000000000000f000000000000000, type: 0}
- {fileID: 10770, guid: 0000000000000000f000000000000000, type: 0}
- {fileID: -6465566751694194690, guid: 90c26dfde11bf4ff69ef936c6e6b1ed1, type: 3}
- {fileID: -6465566751694194690, guid: ba6d401c74b2c4f96af7edf0fe32241e, type: 3}
- {fileID: -6465566751694194690, guid: b9d29dfa1474148e792ac720cbd45122, type: 3}
m_PreloadedShaders: []
m_PreloadShadersBatchTimeLimit: -1
m_SpritesDefaultMaterial: {fileID: 10754, guid: 0000000000000000f000000000000000,
Expand Down
3 changes: 3 additions & 0 deletions Packages/webxr-interactions/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Added
- An option to auto-load WebXRInputSystem on start in WebXRSettings.

### Changed
- Minimum WebXR Input Profiles Loader version 0.6.0.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ public static string[] GetRightProfiles()
}
#if UNITY_INPUT_SYSTEM_1_4_4_OR_NEWER
private static bool initialized = false;
private static int instances = 0;
private static WebXRController left = null;
private static WebXRController right = null;
private static bool hasLeftProfiles = false;
Expand All @@ -49,6 +50,18 @@ public static string[] GetRightProfiles()
private static XRHandProviderUtility.SubsystemUpdater subsystemUpdater;
#endif

[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.AfterSceneLoad)]
private static void TryAutoLoad()
{
WebXRSettings settings = WebXRSettings.GetSettings();
if (settings?.AutoLoadWebXRInputSystem == true)
{
var webxrInputSystem = new GameObject("WebXRInputSystem");
webxrInputSystem.AddComponent<WebXRInputSystem>();
DontDestroyOnLoad(webxrInputSystem);
}
}

private void Awake()
{
if (initialized)
Expand Down Expand Up @@ -77,6 +90,11 @@ private void Awake()

private void OnEnable()
{
instances++;
if (instances > 1)
{
return;
}
unsafe
{
InputSystem.onDeviceCommand += HandleOnDeviceCommand;
Expand All @@ -92,6 +110,11 @@ private void OnEnable()

private void OnDisable()
{
instances--;
if (instances > 0)
{
return;
}
unsafe
{
InputSystem.onDeviceCommand -= HandleOnDeviceCommand;
Expand All @@ -109,6 +132,10 @@ private void OnDisable()
#if XR_HANDS_1_1_OR_NEWER
private void OnDestroy()
{
if (instances > 0)
{
return;
}
if (MetaAimHand.left != null && MetaAimHand.left.added)
{
InputSystem.RemoveDevice(MetaAimHand.left);
Expand Down
25 changes: 8 additions & 17 deletions Packages/webxr-interactions/Runtime/Prefabs/WebXRCameraSet.prefab
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ GameObject:
serializedVersion: 6
m_Component:
- component: {fileID: 4545079059221816}
- component: {fileID: 114038308936181916}
m_Layer: 0
m_Name: WebXRCameraSet
m_TagString: Untagged
Expand All @@ -34,18 +33,6 @@ Transform:
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &114038308936181916
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1611361787474004}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 519f6ee6510174b44bbe9a8a2d3b6a6a, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!1 &1799026754646168
GameObject:
m_ObjectHideFlags: 0
Expand Down Expand Up @@ -108,6 +95,7 @@ FixedJoint:
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1799026754646168}
m_ConnectedBody: {fileID: 0}
m_ConnectedArticulationBody: {fileID: 0}
m_BreakForce: Infinity
m_BreakTorque: Infinity
m_EnableCollision: 0
Expand Down Expand Up @@ -144,8 +132,7 @@ MonoBehaviour:
animationStateName:
controllerVisuals:
- {fileID: 3858442981242374931}
handJointPrefab: {fileID: 8513787482403080262, guid: 67541c9d1fd5e2c4798986ee73c07923,
type: 3}
handJointPrefab: {fileID: 8513787482403080262, guid: 67541c9d1fd5e2c4798986ee73c07923, type: 3}
useCollidersForHandJoints: 1
useInputProfile: 1
inputProfileObject: {fileID: 1611361787474004}
Expand Down Expand Up @@ -363,6 +350,7 @@ FixedJoint:
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1986733487743170}
m_ConnectedBody: {fileID: 0}
m_ConnectedArticulationBody: {fileID: 0}
m_BreakForce: Infinity
m_BreakTorque: Infinity
m_EnableCollision: 0
Expand Down Expand Up @@ -399,8 +387,7 @@ MonoBehaviour:
animationStateName:
controllerVisuals:
- {fileID: 2954843634523120171}
handJointPrefab: {fileID: 8513787482403080262, guid: 67541c9d1fd5e2c4798986ee73c07923,
type: 3}
handJointPrefab: {fileID: 8513787482403080262, guid: 67541c9d1fd5e2c4798986ee73c07923, type: 3}
useCollidersForHandJoints: 1
useInputProfile: 1
inputProfileObject: {fileID: 1611361787474004}
Expand Down Expand Up @@ -569,6 +556,7 @@ MeshRenderer:
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_RayTracingMode: 2
m_RayTraceProcedural: 0
m_RenderingLayerMask: 1
m_RendererPriority: 0
m_Materials:
Expand All @@ -593,6 +581,7 @@ MeshRenderer:
m_SortingLayerID: 0
m_SortingLayer: 0
m_SortingOrder: 0
m_AdditionalVertexStreams: {fileID: 0}
--- !u!65 &4365337428889893541
BoxCollider:
m_ObjectHideFlags: 0
Expand Down Expand Up @@ -692,6 +681,7 @@ MeshRenderer:
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_RayTracingMode: 2
m_RayTraceProcedural: 0
m_RenderingLayerMask: 1
m_RendererPriority: 0
m_Materials:
Expand All @@ -716,6 +706,7 @@ MeshRenderer:
m_SortingLayerID: 0
m_SortingLayer: 0
m_SortingOrder: 0
m_AdditionalVertexStreams: {fileID: 0}
--- !u!65 &2314441812177900445
BoxCollider:
m_ObjectHideFlags: 0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ SkinnedMeshRenderer:
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_RayTracingMode: 0
m_RayTraceProcedural: 0
m_RenderingLayerMask: 4294967295
m_RendererPriority: 0
m_Materials:
Expand Down Expand Up @@ -744,7 +745,6 @@ GameObject:
serializedVersion: 6
m_Component:
- component: {fileID: 4545079059221816}
- component: {fileID: 114038308936181916}
m_Layer: 0
m_Name: WebXRCameraSet
m_TagString: Untagged
Expand All @@ -769,18 +769,6 @@ Transform:
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &114038308936181916
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1611361787474004}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 519f6ee6510174b44bbe9a8a2d3b6a6a, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!1 &1644691530447244
GameObject:
m_ObjectHideFlags: 0
Expand Down Expand Up @@ -950,6 +938,7 @@ SkinnedMeshRenderer:
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_RayTracingMode: 0
m_RayTraceProcedural: 0
m_RenderingLayerMask: 4294967295
m_RendererPriority: 0
m_Materials:
Expand Down Expand Up @@ -1141,6 +1130,7 @@ FixedJoint:
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1799026754646168}
m_ConnectedBody: {fileID: 0}
m_ConnectedArticulationBody: {fileID: 0}
m_BreakForce: Infinity
m_BreakTorque: Infinity
m_EnableCollision: 0
Expand Down Expand Up @@ -1197,8 +1187,7 @@ MonoBehaviour:
controllerVisuals:
- {fileID: 1136128897566686}
- {fileID: 1664295426898042}
handJointPrefab: {fileID: 8513787482403080262, guid: 67541c9d1fd5e2c4798986ee73c07923,
type: 3}
handJointPrefab: {fileID: 8513787482403080262, guid: 67541c9d1fd5e2c4798986ee73c07923, type: 3}
useCollidersForHandJoints: 1
useInputProfile: 1
inputProfileObject: {fileID: 1611361787474004}
Expand Down Expand Up @@ -1663,6 +1652,7 @@ FixedJoint:
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1986733487743170}
m_ConnectedBody: {fileID: 0}
m_ConnectedArticulationBody: {fileID: 0}
m_BreakForce: Infinity
m_BreakTorque: Infinity
m_EnableCollision: 0
Expand Down Expand Up @@ -1719,8 +1709,7 @@ MonoBehaviour:
controllerVisuals:
- {fileID: 1644997114004198}
- {fileID: 1091283458777958}
handJointPrefab: {fileID: 8513787482403080262, guid: 67541c9d1fd5e2c4798986ee73c07923,
type: 3}
handJointPrefab: {fileID: 8513787482403080262, guid: 67541c9d1fd5e2c4798986ee73c07923, type: 3}
useCollidersForHandJoints: 1
useInputProfile: 1
inputProfileObject: {fileID: 1611361787474004}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ Transform:
- {fileID: 4763085287912399982}
- {fileID: 4763085286836561809}
- {fileID: 4763085287379932445}
- {fileID: 2735015572710088185}
- {fileID: 104277457138784657}
m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
Expand Down Expand Up @@ -224,50 +223,6 @@ MonoBehaviour:
m_ActionAssets:
- {fileID: -944628639613478452, guid: c348712bda248c246b8c49b3db54643f, type: 3}
- {fileID: -944628639613478452, guid: 256061f5afc1f4c49bfcb9ca2bc787e1, type: 3}
--- !u!1 &6691460237591051992
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 2735015572710088185}
- component: {fileID: 635145867105466161}
m_Layer: 0
m_Name: WebXRInputSystem
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &2735015572710088185
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 6691460237591051992}
serializedVersion: 2
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 5773256366622995465}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &635145867105466161
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 6691460237591051992}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 30257f473861cfd4a9269b5bf4020e6c, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!1001 &405369273336542956
PrefabInstance:
m_ObjectHideFlags: 0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -952,7 +952,6 @@ GameObject:
- component: {fileID: 6232745470614056095}
- component: {fileID: 5826056641483426609}
- component: {fileID: 5033801203051696737}
- component: {fileID: 2902162407738710112}
m_Layer: 2
m_Name: XR Origin (WebXR Rig)
m_TagString: Untagged
Expand Down Expand Up @@ -1091,18 +1090,6 @@ MonoBehaviour:
m_AimAssistRequiredSpeed: 0.25
m_AimAssistPercent: 0.8
m_AimAssistMaxSpeedPercent: 10
--- !u!114 &2902162407738710112
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1717954561962503725}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 519f6ee6510174b44bbe9a8a2d3b6a6a, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!1 &1787516059220952802
GameObject:
m_ObjectHideFlags: 0
Expand Down
2 changes: 1 addition & 1 deletion Packages/webxr-interactions/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,6 @@
}
],
"dependencies": {
"com.de-panther.webxr": "0.20.0"
"com.de-panther.webxr": "0.20.1-preview"
}
}
4 changes: 4 additions & 0 deletions Packages/webxr/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Added
- An option to auto-load WebXRManager on start in WebXRSettings.
- An option to auto-load WebXRInputSystem on start in WebXRSettings.

## [0.20.0] - 2023-12-18
### Added
- Native XRSubsystem for WebXR Display rendering.
Expand Down
Loading

0 comments on commit 321d65a

Please sign in to comment.