Skip to content

Commit 19644e6

Browse files
author
Robert El-Soudani
committed
Change OverrideFocusedObjectTest scene to use global listener mechanism
In a recent change, the OverrideFocusedObject concept was removed from FocusManager since it was redundant with global listeners and modal handlers. This change fixes up the OverrideFocusedObjectTest scene to use the global listener mechanism. It also adds a box collider to the text so it can be clicked when not overriding focus and makes the text easier to understand by counting clicks and saying whether or not focus is currently overridden.
1 parent 91944f7 commit 19644e6

File tree

2 files changed

+85
-12
lines changed

2 files changed

+85
-12
lines changed

Assets/HoloToolkit/Input/Tests/Scenes/OverrideFocusedObjectTest.unity

Lines changed: 42 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ OcclusionCullingSettings:
1313
--- !u!104 &2
1414
RenderSettings:
1515
m_ObjectHideFlags: 0
16-
serializedVersion: 7
16+
serializedVersion: 8
1717
m_Fog: 0
1818
m_FogColor: {r: 0.5, g: 0.5, b: 0.5, a: 1}
1919
m_FogMode: 3
@@ -25,6 +25,7 @@ RenderSettings:
2525
m_AmbientGroundColor: {r: 0.047, g: 0.043, b: 0.035, a: 1}
2626
m_AmbientIntensity: 1
2727
m_AmbientMode: 0
28+
m_SubtractiveShadowColor: {r: 0.42, g: 0.478, b: 0.627, a: 1}
2829
m_SkyboxMaterial: {fileID: 10304, guid: 0000000000000000f000000000000000, type: 0}
2930
m_HaloStrength: 0.5
3031
m_FlareStrength: 1
@@ -37,11 +38,11 @@ RenderSettings:
3738
m_ReflectionIntensity: 1
3839
m_CustomReflection: {fileID: 0}
3940
m_Sun: {fileID: 0}
40-
m_IndirectSpecularColor: {r: 0.44657874, g: 0.4964127, b: 0.5748172, a: 1}
41+
m_IndirectSpecularColor: {r: 0.44657886, g: 0.4964128, b: 0.57481706, a: 1}
4142
--- !u!157 &3
4243
LightmapSettings:
4344
m_ObjectHideFlags: 0
44-
serializedVersion: 7
45+
serializedVersion: 9
4546
m_GIWorkflowMode: 0
4647
m_GISettings:
4748
serializedVersion: 2
@@ -53,7 +54,7 @@ LightmapSettings:
5354
m_EnableBakedLightmaps: 1
5455
m_EnableRealtimeLightmaps: 1
5556
m_LightmapEditorSettings:
56-
serializedVersion: 4
57+
serializedVersion: 8
5758
m_Resolution: 2
5859
m_BakeResolution: 40
5960
m_TextureWidth: 1024
@@ -66,13 +67,27 @@ LightmapSettings:
6667
m_LightmapParameters: {fileID: 0}
6768
m_LightmapsBakeMode: 1
6869
m_TextureCompression: 1
69-
m_DirectLightInLightProbes: 1
7070
m_FinalGather: 0
7171
m_FinalGatherFiltering: 1
7272
m_FinalGatherRayCount: 256
7373
m_ReflectionCompression: 2
74+
m_MixedBakeMode: 1
75+
m_BakeBackend: 0
76+
m_PVRSampling: 1
77+
m_PVRDirectSampleCount: 32
78+
m_PVRSampleCount: 500
79+
m_PVRBounces: 2
80+
m_PVRFiltering: 0
81+
m_PVRFilteringMode: 1
82+
m_PVRCulling: 1
83+
m_PVRFilteringGaussRadiusDirect: 1
84+
m_PVRFilteringGaussRadiusIndirect: 5
85+
m_PVRFilteringGaussRadiusAO: 2
86+
m_PVRFilteringAtrousColorSigma: 1
87+
m_PVRFilteringAtrousNormalSigma: 1
88+
m_PVRFilteringAtrousPositionSigma: 1
7489
m_LightingDataAsset: {fileID: 0}
75-
m_RuntimeCPUUsage: 25
90+
m_ShadowMaskMode: 2
7691
--- !u!196 &4
7792
NavMeshSettings:
7893
serializedVersion: 2
@@ -89,6 +104,8 @@ NavMeshSettings:
89104
minRegionArea: 2
90105
manualCellSize: 0
91106
cellSize: 0.16666667
107+
manualTileSize: 0
108+
tileSize: 256
92109
accuratePlacement: 0
93110
m_NavMeshData: {fileID: 0}
94111
--- !u!1 &10687557
@@ -114,7 +131,7 @@ Light:
114131
m_PrefabInternal: {fileID: 0}
115132
m_GameObject: {fileID: 10687557}
116133
m_Enabled: 1
117-
serializedVersion: 7
134+
serializedVersion: 8
118135
m_Type: 1
119136
m_Color: {r: 1, g: 0.95686275, b: 0.8392157, a: 1}
120137
m_Intensity: 1
@@ -139,6 +156,8 @@ Light:
139156
m_Lightmapping: 4
140157
m_AreaSize: {x: 1, y: 1}
141158
m_BounceIntensity: 1
159+
m_ColorTemperature: 6570
160+
m_UseColorTemperature: 0
142161
m_ShadowRadius: 0
143162
m_ShadowAngle: 0
144163
--- !u!4 &10687559
@@ -147,7 +166,7 @@ Transform:
147166
m_PrefabParentObject: {fileID: 0}
148167
m_PrefabInternal: {fileID: 0}
149168
m_GameObject: {fileID: 10687557}
150-
m_LocalRotation: {x: 0.40821788, y: -0.23456968, z: 0.10938163, w: 0.8754261}
169+
m_LocalRotation: {x: 0.4082179, y: -0.23456971, z: 0.10938164, w: 0.8754262}
151170
m_LocalPosition: {x: 0, y: 3, z: 0}
152171
m_LocalScale: {x: 1, y: 1, z: 1}
153172
m_Children: []
@@ -217,6 +236,7 @@ GameObject:
217236
- component: {fileID: 221526973}
218237
- component: {fileID: 221526972}
219238
- component: {fileID: 221526975}
239+
- component: {fileID: 221526976}
220240
m_Layer: 0
221241
m_Name: TestMessages
222242
m_TagString: Untagged
@@ -231,7 +251,7 @@ TextMesh:
231251
m_PrefabParentObject: {fileID: 0}
232252
m_PrefabInternal: {fileID: 0}
233253
m_GameObject: {fileID: 221526971}
234-
m_Text: Hello World
254+
m_Text: The click handler was called 0 times. Currently, focus is not overridden.
235255
m_OffsetZ: 0
236256
m_CharacterSize: 1
237257
m_LineSpacing: 1
@@ -275,6 +295,7 @@ MeshRenderer:
275295
m_AutoUVMaxAngle: 89
276296
m_LightmapParameters: {fileID: 0}
277297
m_SortingLayerID: 0
298+
m_SortingLayer: 0
278299
m_SortingOrder: 0
279300
--- !u!4 &221526974
280301
Transform:
@@ -300,6 +321,18 @@ MonoBehaviour:
300321
m_Script: {fileID: 11500000, guid: cac20ddb16c1fe54cac9ae87c0d6680c, type: 3}
301322
m_Name:
302323
m_EditorClassIdentifier:
324+
--- !u!65 &221526976
325+
BoxCollider:
326+
m_ObjectHideFlags: 0
327+
m_PrefabParentObject: {fileID: 0}
328+
m_PrefabInternal: {fileID: 0}
329+
m_GameObject: {fileID: 221526971}
330+
m_Material: {fileID: 0}
331+
m_IsTrigger: 0
332+
m_Enabled: 1
333+
serializedVersion: 2
334+
m_Size: {x: 41.5, y: 1.4523438, z: 0}
335+
m_Center: {x: 20.75, y: -0.7261719, z: -0}
303336
--- !u!1 &774281391
304337
GameObject:
305338
m_ObjectHideFlags: 0

Assets/HoloToolkit/Input/Tests/Scripts/TestOverrideFocusedObject.cs

Lines changed: 43 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,25 +7,65 @@ public class TestOverrideFocusedObject : MonoBehaviour, IInputClickHandler
77
InputManager inputManager;
88
TextMesh textMesh;
99

10+
int clickCount;
11+
bool isOverridingFocus;
12+
1013
void Start()
1114
{
1215
inputManager = InputManager.Instance;
1316

1417
if (inputManager != null)
1518
{
16-
inputManager.OverrideFocusedObject = gameObject;
19+
OverrideFocus();
1720
}
1821

1922
textMesh = GameObject.FindObjectOfType<TextMesh>();
23+
24+
if (textMesh != null)
25+
{
26+
UpdateText();
27+
}
2028
}
2129

2230
public void OnInputClicked(InputClickedEventData eventData)
2331
{
2432
if (textMesh != null && inputManager != null)
2533
{
26-
textMesh.text = "Air tap worked and OverrideFocusedObject is null.";
27-
inputManager.OverrideFocusedObject = null;
34+
clickCount++;
35+
36+
if (isOverridingFocus)
37+
{
38+
UndoOverrideFocus();
39+
}
40+
else
41+
{
42+
OverrideFocus();
43+
}
44+
45+
UpdateText();
46+
47+
eventData.Use();
2848
}
2949
}
50+
51+
private void OverrideFocus()
52+
{
53+
inputManager.AddGlobalListener(gameObject);
54+
isOverridingFocus = true;
55+
}
56+
57+
private void UndoOverrideFocus()
58+
{
59+
inputManager.RemoveGlobalListener(gameObject);
60+
isOverridingFocus = false;
61+
}
62+
63+
private void UpdateText()
64+
{
65+
textMesh.text = string.Format("The click handler was called {0} times. Currently, focus is {1}.",
66+
clickCount,
67+
isOverridingFocus ? "overridden" : "not overridden"
68+
);
69+
}
3070
}
3171
}

0 commit comments

Comments
 (0)