Skip to content

Commit 411ec8a

Browse files
authored
Merge pull request #3832 from Railboy/mrtk_appbar_touch_fix
Update AppBar to make touch events work in all cases
2 parents b94a92f + d0f9648 commit 411ec8a

File tree

2 files changed

+5
-19
lines changed

2 files changed

+5
-19
lines changed

Assets/MixedRealityToolkit.SDK/Features/UX/Scripts/AppBar/AppBarButton.cs

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public class AppBarButton : MonoBehaviour
1818

1919
public int DisplayOrder { get { return displayOrder; } }
2020

21-
public bool Visible { get { return visible; } }
21+
public bool Visible { get { return gameObject.activeSelf; } }
2222

2323
[SerializeField]
2424
private PressableButton button = null;
@@ -34,8 +34,6 @@ public class AppBarButton : MonoBehaviour
3434
private AppBar.ButtonTypeEnum buttonType = AppBar.ButtonTypeEnum.Custom;
3535
[SerializeField]
3636
private int displayOrder;
37-
[SerializeField]
38-
private bool visible;
3937

4038
private AppBar parentToolBar;
4139
private Vector3 targetPosition;
@@ -81,26 +79,14 @@ public void InitializeButtonContent(AppBar parentToolBar)
8179
primaryLabels[i].text = buttonText;
8280

8381
seeItSayItLabel.text = "Say \"" + buttonText + "\"";
84-
85-
// TODO use property blocks once Interactable no longer uses instanced materials
86-
/*if (iconPropertyBlock == null)
87-
iconPropertyBlock = new MaterialPropertyBlock();
88-
89-
if (icon.HasPropertyBlock())
90-
{
91-
icon.GetPropertyBlock(iconPropertyBlock);
92-
}
93-
iconPropertyBlock.SetTexture("_MainTex", buttonIcon);
94-
icon.SetPropertyBlock(iconPropertyBlock);*/
95-
9682
icon.material.mainTexture = buttonIcon;
9783
break;
9884
}
9985
}
10086

10187
private void UpdateButton()
10288
{
103-
transform.localPosition = Vector3.Lerp(transform.localPosition, visible ? targetPosition : Vector3.zero, Time.deltaTime * changeSpeed);
89+
transform.localPosition = Vector3.Lerp(transform.localPosition, Visible ? targetPosition : Vector3.zero, Time.deltaTime * changeSpeed);
10490
}
10591

10692
public void SetTargetPosition(Vector3 targetPosition)
@@ -110,11 +96,11 @@ public void SetTargetPosition(Vector3 targetPosition)
11096

11197
public void SetVisible(bool visible)
11298
{
113-
this.visible = visible;
114-
99+
gameObject.SetActive(visible);
115100
// Use the interactable theme to make button invisible
116101
button.enabled = visible;
117102
interactable.Enabled = visible;
103+
118104
}
119105
}
120106
}

Assets/MixedRealityToolkit.Services/InputSystem/NearInteractionTouchable.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ private enum TouchableSurface
9494
public static IReadOnlyCollection<NearInteractionTouchable> Instances { get { return instances.AsReadOnly(); } }
9595
private static readonly List<NearInteractionTouchable> instances = new List<NearInteractionTouchable>();
9696

97-
public bool ColliderEnabled { get { return !usesCollider || touchableCollider.enabled; } }
97+
public bool ColliderEnabled { get { return !usesCollider || touchableCollider.enabled && touchableCollider.gameObject.activeInHierarchy; } }
9898

9999
/// <summary>
100100
/// Local space forward direction

0 commit comments

Comments
 (0)