Skip to content

Commit 6424850

Browse files
author
ChengNan Yang
committed
Fix WaveVR cannot be selected in previous SDK version
* Fix compile error in WaveSDK 2.0.x * Fix no EHmdButtons enum in WaveSDK 3.0.2
1 parent 738bc91 commit 6424850

File tree

3 files changed

+42
-6
lines changed

3 files changed

+42
-6
lines changed

Assets/HTC.UnityPlugin/VRModule/Modules/Editor/WaveVRModuleEditor.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ public WaveVRSymbolRequirementCollection()
2929
{
3030
symbol = "VIU_WAVEVR_RENDER",
3131
reqTypeNames = new string[] { "WaveVR_Render" },
32+
reqFileNames = new string[] { "WaveVR_Render.cs" },
3233
});
3334

3435
Add(new SymbolRequirement()

Assets/HTC.UnityPlugin/VRModule/Modules/WaveVRModule.cs

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ public override void UpdateRenderModel()
136136
case WVR_DeviceType.WVR_DeviceType_Controller_Left:
137137
#if VIU_WAVEVR_3_0_0_OR_NEWER
138138
loader.WhichHand = s_moduleInstance.m_deviceHands[LEFT_INDEX];
139-
#else
139+
#elif VIU_WAVEVR_2_1_0_OR_NEWER
140140
if (Interop.WVR_GetWaveRuntimeVersion() >= 3 && WaveVR_Controller.IsLeftHanded)
141141
{
142142
loader.WhichHand = WaveVR_ControllerLoader.ControllerHand.Controller_Right;
@@ -145,6 +145,8 @@ public override void UpdateRenderModel()
145145
{
146146
loader.WhichHand = WaveVR_ControllerLoader.ControllerHand.Controller_Left;
147147
}
148+
#else
149+
loader.WhichHand = WaveVR_ControllerLoader.ControllerHand.Controller_Left;
148150
#endif
149151
loaderGO.SetActive(true);
150152

@@ -312,7 +314,7 @@ public override void OnActivated()
312314
VRModule.Instance.gameObject.AddComponent<WaveVR_Init>();
313315
}
314316

315-
#if !UNITY_EDITOR && VIU_WAVEVR_3_0_0_OR_NEWER
317+
#if !UNITY_EDITOR && VIU_WAVEVR_3_1_0_OR_NEWER
316318
if (Object.FindObjectOfType<WaveVR_ButtonList>() == null)
317319
{
318320
VRModule.Instance.gameObject.AddComponent<WaveVR_ButtonList>();
@@ -340,6 +342,34 @@ public override void OnActivated()
340342
};
341343
}
342344
}
345+
#elif !UNITY_EDITOR && VIU_WAVEVR_3_0_0_OR_NEWER
346+
if (Object.FindObjectOfType<WaveVR_ButtonList>() == null)
347+
{
348+
VRModule.Instance.gameObject.AddComponent<WaveVR_ButtonList>();
349+
350+
var buttonList = VRModule.Instance.gameObject.GetComponent<WaveVR_ButtonList>();
351+
if (buttonList != null)
352+
{
353+
buttonList.HmdButtons = new List<WaveVR_ButtonList.EButtons>()
354+
{
355+
WaveVR_ButtonList.EButtons.HMDEnter
356+
};
357+
buttonList.DominantButtons = new List<WaveVR_ButtonList.EButtons>()
358+
{
359+
WaveVR_ButtonList.EButtons.Grip,
360+
WaveVR_ButtonList.EButtons.Menu,
361+
WaveVR_ButtonList.EButtons.Touchpad,
362+
WaveVR_ButtonList.EButtons.Trigger
363+
};
364+
buttonList.NonDominantButtons = new List<WaveVR_ButtonList.EButtons>()
365+
{
366+
WaveVR_ButtonList.EButtons.Grip,
367+
WaveVR_ButtonList.EButtons.Menu,
368+
WaveVR_ButtonList.EButtons.Touchpad,
369+
WaveVR_ButtonList.EButtons.Trigger
370+
};
371+
}
372+
}
343373
#endif
344374

345375
EnsureDeviceStateLength(DEVICE_COUNT);

Assets/HTC.UnityPlugin/ViveInputUtility/Scripts/Editor/VRPlatformSettings/WaveVRSettings.cs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ private class WaveVRSettings : VRPlatformSetting
8080
#if UNITY_2018_1_OR_NEWER
8181
, IPreprocessBuildWithReport
8282
#elif UNITY_5_6_OR_NEWER
83-
, IPreprocessBuild
83+
, IPreprocessBuild
8484
#endif
8585
{
8686
private Foldouter m_foldouter = new Foldouter();
@@ -130,14 +130,15 @@ public override bool support
130130
{
131131
if (!canSupport) { return false; }
132132
if (!VIUSettings.activateWaveVRModule) { return false; }
133-
133+
134134
#if !VIU_WAVEVR_3_0_0_OR_NEWER
135135
if (virtualRealitySupported) { return false; }
136-
#endif
136+
#else
137137
if (!((VRModule.isWaveVRRenderDetected && MockHMDSDK.enabled) || XRPluginManagementUtils.IsXRLoaderEnabled(WAVEVR_LOADER_NAME, requirdPlatform)))
138138
{
139139
return false;
140140
}
141+
#endif
141142

142143
if (PlayerSettings.Android.minSdkVersion < AndroidSdkVersions.AndroidApiLevel23) { return false; }
143144
if (PlayerSettings.colorSpace == ColorSpace.Linear && !GraphicsAPIContainsOnly(BuildTarget.Android, GraphicsDeviceType.OpenGLES3)) { return false; }
@@ -149,7 +150,9 @@ public override bool support
149150

150151
if (value)
151152
{
152-
#if !VIU_WAVEVR_3_0_0_OR_NEWER
153+
#if VIU_WAVEVR_3_0_0_OR_NEWER
154+
virtualRealitySupported = value;
155+
#else
153156
virtualRealitySupported = false;
154157
#endif
155158

@@ -167,12 +170,14 @@ public override bool support
167170
supportOculusGo = false;
168171
}
169172

173+
#if VIU_WAVEVR_3_0_0_OR_NEWER
170174
if (virtualRealitySupported)
171175
{
172176
MockHMDSDK.enabled = value;
173177
}
174178

175179
XRPluginManagementUtils.SetXRLoaderEnabled(WAVEVR_LOADER_CLASS_NAME, requirdPlatform, value);
180+
#endif
176181

177182
VIUSettings.activateWaveVRModule = value;
178183
}

0 commit comments

Comments
 (0)