Skip to content

Commit 761800c

Browse files
author
lawwong
committed
Fix unable to enable/disable custom render model in some case
This happens when RenderModelHook is switching different custom models for different devices
1 parent a19e2a6 commit 761800c

1 file changed

Lines changed: 14 additions & 14 deletions

File tree

Assets/HTC.UnityPlugin/ViveInputUtility/Scripts/Misc/RenderModelHook.cs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -521,27 +521,27 @@ public void UpdateModel()
521521

522522
if (shouldActiveCustomModel)
523523
{
524-
var shouldActiveCustomModelObj = m_customModelObjs[shouldActiveCustomModelNum];
525-
if (shouldActiveCustomModelObj == null)
524+
if (!lastCustomModelActive || lastActiveCustomModelNum != shouldActiveCustomModelNum)
526525
{
527-
// instantiate custom override model
528-
shouldActiveCustomModelObj = Instantiate(shouldActiveCustomModelPrefab);
529-
shouldActiveCustomModelObj.transform.position = Vector3.zero;
530-
shouldActiveCustomModelObj.transform.rotation = Quaternion.identity;
531-
shouldActiveCustomModelObj.transform.SetParent(transform, false);
532-
m_activeCustomModel = shouldActiveCustomModelNum;
533-
m_customModelObjs[shouldActiveCustomModelNum] = shouldActiveCustomModelObj;
534-
m_isCustomModelActivated = false;
535-
SendAfterModelCreatedMessage(shouldActiveCustomModelObj, this);
536-
}
526+
var shouldActiveCustomModelObj = m_customModelObjs[shouldActiveCustomModelNum];
527+
if (shouldActiveCustomModelObj == null)
528+
{
529+
// instantiate custom override model
530+
shouldActiveCustomModelObj = Instantiate(shouldActiveCustomModelPrefab);
531+
shouldActiveCustomModelObj.transform.position = Vector3.zero;
532+
shouldActiveCustomModelObj.transform.rotation = Quaternion.identity;
533+
shouldActiveCustomModelObj.transform.SetParent(transform, false);
534+
m_customModelObjs[shouldActiveCustomModelNum] = shouldActiveCustomModelObj;
535+
SendAfterModelCreatedMessage(shouldActiveCustomModelObj, this);
536+
}
537537

538-
if (!m_isCustomModelActivated)
539-
{
540538
// active custom override model
541539
if (SendBeforeModelActivatedMessage(shouldActiveCustomModelObj, this))
542540
{
543541
shouldActiveCustomModelObj.gameObject.SetActive(true);
544542
}
543+
544+
m_activeCustomModel = shouldActiveCustomModelNum;
545545
m_isCustomModelActivated = true;
546546
}
547547
}

0 commit comments

Comments
 (0)