Skip to content

Commit 32715d6

Browse files
author
lawwong
committed
Update to v1.8.2
* Bug fix - Fix define symbols sometimes not handle correctly when switching build target - Disable vr support if device list is empty - Add code to avoid NullReferenceException in VRModule - Add SetValueByIndex method to IndexedTable - Fix StickyGrabbable not working in certain cases
2 parents baa9df9 + 47cfb63 commit 32715d6

File tree

11 files changed

+182
-272
lines changed

11 files changed

+182
-272
lines changed

Assets/HTC.UnityPlugin/Utility/Container/IndexedTable.cs

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -75,20 +75,7 @@ public IndexedTable(int capacity)
7575
m_ValueList = new List<TValue>(capacity);
7676
}
7777

78-
public int Count
79-
{
80-
get
81-
{
82-
if (m_Dictionary.Count != m_KeyList.Count || m_Dictionary.Count != m_ValueList.Count)
83-
{
84-
UnityEngine.Debug.LogWarning("m_Dictionary.Count=" + m_Dictionary.Count + " m_KeyList.Count=" + m_KeyList.Count + " m_ValueList.Count=" + m_ValueList.Count);
85-
UnityEngine.Debug.LogWarning(m_Dictionary.ToString());
86-
UnityEngine.Debug.LogWarning(m_KeyList.ToString());
87-
UnityEngine.Debug.LogWarning(m_ValueList.ToString());
88-
}
89-
return m_Dictionary.Count;
90-
}
91-
}
78+
public int Count { get { return m_Dictionary.Count; } }
9279

9380
public bool IsReadOnly { get { return false; } }
9481

@@ -114,6 +101,11 @@ public TValue GetValueByIndex(int index)
114101
return m_ValueList[index];
115102
}
116103

104+
public void SetValueByIndex(int index, TValue value)
105+
{
106+
m_ValueList[index] = value;
107+
}
108+
117109
public KeyValuePair<TKey, TValue> GetKeyValuePairByIndex(int index)
118110
{
119111
return new KeyValuePair<TKey, TValue>(m_KeyList[index], m_ValueList[index]);

Assets/HTC.UnityPlugin/VRModule/Editor/VRModuleManagerEditor.cs

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ namespace HTC.UnityPlugin.VRModuleManagement
1212
{
1313
// This script manage define symbols used by VIU
1414
public class VRModuleManagerEditor : UnityEditor.AssetModificationProcessor
15+
#if UNITY_2017_1_OR_NEWER
16+
, UnityEditor.Build.IActiveBuildTargetChanged
17+
#endif
1518
{
1619
private class SymbolRequirement
1720
{
@@ -39,6 +42,14 @@ public class ReqMethodInfo
3942

4043
private static Dictionary<string, Type> s_foundTypes;
4144

45+
public static void ResetFoundTypes()
46+
{
47+
if (s_foundTypes != null)
48+
{
49+
s_foundTypes.Clear();
50+
}
51+
}
52+
4253
public void FindRequiredTypesInAssembly(Assembly assembly)
4354
{
4455
if (reqTypeNames != null)
@@ -255,10 +266,23 @@ static VRModuleManagerEditor()
255266
symbol = "VIU_BINDING_INTERFACE_SWITCH",
256267
reqFileNames = new string[] { "" },
257268
});
269+
270+
#if !UNITY_2017_1_OR_NEWER
271+
EditorUserBuildSettings.activeBuildTargetChanged += UpdateScriptingDefineSymbols;
272+
#endif
258273
}
259274

275+
#if UNITY_2017_1_OR_NEWER
276+
public int callbackOrder { get { return 0; } }
277+
278+
public void OnActiveBuildTargetChanged(BuildTarget previousTarget, BuildTarget newTarget)
279+
{
280+
UpdateScriptingDefineSymbols();
281+
}
282+
#endif
283+
260284
[DidReloadScripts]
261-
private static void UpdateScriptingDefineSymbols()
285+
public static void UpdateScriptingDefineSymbols()
262286
{
263287
foreach (var assembly in AppDomain.CurrentDomain.GetAssemblies())
264288
{
@@ -306,9 +330,12 @@ private static void UpdateScriptingDefineSymbols()
306330
{
307331
SetDefineSymbols(defineSymbols);
308332
}
333+
334+
SymbolRequirement.ResetFoundTypes();
309335
}
310336

311337
private static bool s_delayCallRemoveRegistered;
338+
312339
// This is called when ever an asset deleted
313340
// If the deleted asset include sdk files, then remove all symbols defined by VIU
314341
public static AssetDeleteResult OnWillDeleteAsset(string assetPath, RemoveAssetOptions option)

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,5 +260,5 @@ private static string QueryDeviceStringProperty(CVRSystem system, uint deviceInd
260260
return result;
261261
}
262262
#endif
263-
}
263+
}
264264
}

Assets/HTC.UnityPlugin/VRModule/VRModuleManager.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,8 @@ protected override void OnSingletonBehaviourInitialized()
8989

9090
private void Update()
9191
{
92+
if (!IsInstance) { return; }
93+
9294
m_isUpdating = true;
9395

9496
// Get should activate module
@@ -295,13 +297,11 @@ private void DeactivateModule()
295297
{
296298
if (m_activatedModule == VRModuleActiveEnum.Uninitialized)
297299
{
298-
Debug.LogError("activatedModule is already Uninitialized!");
299300
return;
300301
}
301302

302303
if (m_activatedModuleBase == null)
303304
{
304-
Debug.LogError("activatedModule is already null!");
305305
return;
306306
}
307307

0 commit comments

Comments
 (0)