Skip to content

Commit fb69c3f

Browse files
committed
use spatial mapping if possible to find a good anchor position.
1 parent 69560fa commit fb69c3f

File tree

4 files changed

+389
-25
lines changed

4 files changed

+389
-25
lines changed

Assets/HoloToolkit/SharingWithUNET/Scenes/sharingwithunet.unity

Lines changed: 181 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,119 @@ NavMeshSettings:
109109
tileSize: 256
110110
accuratePlacement: 0
111111
m_NavMeshData: {fileID: 0}
112+
--- !u!1 &74016788
113+
GameObject:
114+
m_ObjectHideFlags: 0
115+
m_PrefabParentObject: {fileID: 0}
116+
m_PrefabInternal: {fileID: 0}
117+
serializedVersion: 5
118+
m_Component:
119+
- component: {fileID: 74016789}
120+
- component: {fileID: 74016793}
121+
- component: {fileID: 74016792}
122+
- component: {fileID: 74016791}
123+
- component: {fileID: 74016790}
124+
m_Layer: 0
125+
m_Name: New Text
126+
m_TagString: Untagged
127+
m_Icon: {fileID: 0}
128+
m_NavMeshLayer: 0
129+
m_StaticEditorFlags: 0
130+
m_IsActive: 1
131+
--- !u!4 &74016789
132+
Transform:
133+
m_ObjectHideFlags: 0
134+
m_PrefabParentObject: {fileID: 0}
135+
m_PrefabInternal: {fileID: 0}
136+
m_GameObject: {fileID: 74016788}
137+
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
138+
m_LocalPosition: {x: 0, y: 0.24, z: 0}
139+
m_LocalScale: {x: 0.01, y: 0.01, z: 0.01}
140+
m_Children: []
141+
m_Father: {fileID: 106937171}
142+
m_RootOrder: 2
143+
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
144+
--- !u!65 &74016790
145+
BoxCollider:
146+
m_ObjectHideFlags: 0
147+
m_PrefabParentObject: {fileID: 0}
148+
m_PrefabInternal: {fileID: 0}
149+
m_GameObject: {fileID: 74016788}
150+
m_Material: {fileID: 0}
151+
m_IsTrigger: 0
152+
m_Enabled: 1
153+
serializedVersion: 2
154+
m_Size: {x: 72.799995, y: 13.406249, z: 0}
155+
m_Center: {x: 36.399998, y: -6.703155, z: 0}
156+
--- !u!114 &74016791
157+
MonoBehaviour:
158+
m_ObjectHideFlags: 0
159+
m_PrefabParentObject: {fileID: 0}
160+
m_PrefabInternal: {fileID: 0}
161+
m_GameObject: {fileID: 74016788}
162+
m_Enabled: 1
163+
m_EditorHideFlags: 0
164+
m_Script: {fileID: 11500000, guid: 76bb4107aed53a54ca76f5b4fb92dc16, type: 3}
165+
m_Name:
166+
m_EditorClassIdentifier:
167+
--- !u!102 &74016792
168+
TextMesh:
169+
serializedVersion: 3
170+
m_ObjectHideFlags: 0
171+
m_PrefabParentObject: {fileID: 0}
172+
m_PrefabInternal: {fileID: 0}
173+
m_GameObject: {fileID: 74016788}
174+
m_Text: Reset Anchor
175+
m_OffsetZ: 0
176+
m_CharacterSize: 1
177+
m_LineSpacing: 1
178+
m_Anchor: 0
179+
m_Alignment: 0
180+
m_TabSize: 4
181+
m_FontSize: 120
182+
m_FontStyle: 0
183+
m_RichText: 1
184+
m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0}
185+
m_Color:
186+
serializedVersion: 2
187+
rgba: 4279242986
188+
--- !u!23 &74016793
189+
MeshRenderer:
190+
m_ObjectHideFlags: 0
191+
m_PrefabParentObject: {fileID: 0}
192+
m_PrefabInternal: {fileID: 0}
193+
m_GameObject: {fileID: 74016788}
194+
m_Enabled: 1
195+
m_CastShadows: 1
196+
m_ReceiveShadows: 1
197+
m_MotionVectors: 1
198+
m_LightProbeUsage: 1
199+
m_ReflectionProbeUsage: 1
200+
m_Materials:
201+
- {fileID: 10100, guid: 0000000000000000e000000000000000, type: 0}
202+
m_StaticBatchInfo:
203+
firstSubMesh: 0
204+
subMeshCount: 0
205+
m_StaticBatchRoot: {fileID: 0}
206+
m_ProbeAnchor: {fileID: 0}
207+
m_LightProbeVolumeOverride: {fileID: 0}
208+
m_ScaleInLightmap: 1
209+
m_PreserveUVs: 0
210+
m_IgnoreNormalsForChartDetection: 0
211+
m_ImportantGI: 0
212+
m_SelectedEditorRenderState: 3
213+
m_MinimumChartSize: 4
214+
m_AutoUVMaxDistance: 0.5
215+
m_AutoUVMaxAngle: 89
216+
m_LightmapParameters: {fileID: 0}
217+
m_SortingLayerID: 0
218+
m_SortingLayer: 0
219+
m_SortingOrder: 0
220+
--- !u!4 &106937171 stripped
221+
Transform:
222+
m_PrefabParentObject: {fileID: 4780174366001566, guid: 2617ed8230126704a992bd57fe1c7440,
223+
type: 2}
224+
m_PrefabInternal: {fileID: 1410349150}
112225
--- !u!1 &543313553
113226
GameObject:
114227
m_ObjectHideFlags: 0
@@ -270,6 +383,74 @@ MonoBehaviour:
270383
m_Name:
271384
m_EditorClassIdentifier:
272385
SendConnectionPort: 11000
386+
--- !u!1001 &1198442812
387+
Prefab:
388+
m_ObjectHideFlags: 0
389+
serializedVersion: 2
390+
m_Modification:
391+
m_TransformParent: {fileID: 0}
392+
m_Modifications:
393+
- target: {fileID: 4000013298573622, guid: 2ed75ffdf9031c94e8bce4b3d17b9928, type: 2}
394+
propertyPath: m_LocalPosition.x
395+
value: 0
396+
objectReference: {fileID: 0}
397+
- target: {fileID: 4000013298573622, guid: 2ed75ffdf9031c94e8bce4b3d17b9928, type: 2}
398+
propertyPath: m_LocalPosition.y
399+
value: 0
400+
objectReference: {fileID: 0}
401+
- target: {fileID: 4000013298573622, guid: 2ed75ffdf9031c94e8bce4b3d17b9928, type: 2}
402+
propertyPath: m_LocalPosition.z
403+
value: 0
404+
objectReference: {fileID: 0}
405+
- target: {fileID: 4000013298573622, guid: 2ed75ffdf9031c94e8bce4b3d17b9928, type: 2}
406+
propertyPath: m_LocalRotation.x
407+
value: 0
408+
objectReference: {fileID: 0}
409+
- target: {fileID: 4000013298573622, guid: 2ed75ffdf9031c94e8bce4b3d17b9928, type: 2}
410+
propertyPath: m_LocalRotation.y
411+
value: 0
412+
objectReference: {fileID: 0}
413+
- target: {fileID: 4000013298573622, guid: 2ed75ffdf9031c94e8bce4b3d17b9928, type: 2}
414+
propertyPath: m_LocalRotation.z
415+
value: 0
416+
objectReference: {fileID: 0}
417+
- target: {fileID: 4000013298573622, guid: 2ed75ffdf9031c94e8bce4b3d17b9928, type: 2}
418+
propertyPath: m_LocalRotation.w
419+
value: 1
420+
objectReference: {fileID: 0}
421+
- target: {fileID: 4000013298573622, guid: 2ed75ffdf9031c94e8bce4b3d17b9928, type: 2}
422+
propertyPath: m_RootOrder
423+
value: 8
424+
objectReference: {fileID: 0}
425+
- target: {fileID: 114000011154029958, guid: 2ed75ffdf9031c94e8bce4b3d17b9928,
426+
type: 2}
427+
propertyPath: drawVisualMeshes
428+
value: 0
429+
objectReference: {fileID: 0}
430+
- target: {fileID: 114000012698980792, guid: 2ed75ffdf9031c94e8bce4b3d17b9928,
431+
type: 2}
432+
propertyPath: Extents.x
433+
value: 4
434+
objectReference: {fileID: 0}
435+
- target: {fileID: 114000012698980792, guid: 2ed75ffdf9031c94e8bce4b3d17b9928,
436+
type: 2}
437+
propertyPath: Extents.y
438+
value: 4
439+
objectReference: {fileID: 0}
440+
- target: {fileID: 114000012698980792, guid: 2ed75ffdf9031c94e8bce4b3d17b9928,
441+
type: 2}
442+
propertyPath: Extents.z
443+
value: 4
444+
objectReference: {fileID: 0}
445+
- target: {fileID: 114000012698980792, guid: 2ed75ffdf9031c94e8bce4b3d17b9928,
446+
type: 2}
447+
propertyPath: TrianglesPerCubicMeter
448+
value: 1500
449+
objectReference: {fileID: 0}
450+
m_RemovedComponents:
451+
- {fileID: 114000012149591842, guid: 2ed75ffdf9031c94e8bce4b3d17b9928, type: 2}
452+
m_ParentPrefab: {fileID: 100100000, guid: 2ed75ffdf9031c94e8bce4b3d17b9928, type: 2}
453+
m_IsPrefabParent: 0
273454
--- !u!1001 &1203127917
274455
Prefab:
275456
m_ObjectHideFlags: 0

Assets/HoloToolkit/SharingWithUNET/Scripts/NetworkDiscoveryWithAnchors.cs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -294,8 +294,8 @@ public void StartHosting(string SessionName)
294294
StartAsServer();
295295

296296
#if !UNITY_EDITOR
297-
// Start creating an anchor.
298-
UNetAnchorManager.Instance.CreateAnchor();
297+
// Invoke creating an anchor in a couple frames to give all the Unet network objects time to spawn.
298+
Invoke("InvokeCreateAnchor", 0.25f);
299299
#else
300300
Debug.LogWarning("This script will need modification to work in the Unity Editor");
301301
#endif
@@ -304,6 +304,15 @@ public void StartHosting(string SessionName)
304304
SignalConnectionStatusEvent();
305305
}
306306

307+
/// <summary>
308+
/// The UNetAnchorManager won't be ready immediately after a scene is started so we defer calling
309+
/// create anchor using unity's 'Invoke' on this function.
310+
/// </summary>
311+
void InvokeCreateAnchor()
312+
{
313+
UNetAnchorManager.Instance.CreateAnchor();
314+
}
315+
307316
/// <summary>
308317
/// Called when sessions have been added or removed
309318
/// </summary>

0 commit comments

Comments
 (0)