Skip to content

Commit 5d6f786

Browse files
author
Jared Bienz
committed
Added serialization to WorldAnchorAlignment.
1 parent 210d765 commit 5d6f786

File tree

3 files changed

+199
-2
lines changed

3 files changed

+199
-2
lines changed

SpatialAlignment-Unity/Assets/SpatialAlignment-Examples/Persistence/Scenes/SA-Persistence.unity

Lines changed: 160 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -508,7 +508,7 @@ Transform:
508508
m_LocalScale: {x: 0.3, y: 0.3, z: 0.3}
509509
m_Children: []
510510
m_Father: {fileID: 0}
511-
m_RootOrder: 8
511+
m_RootOrder: 9
512512
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
513513
--- !u!114 &404797282
514514
MonoBehaviour:
@@ -541,6 +541,12 @@ MonoBehaviour:
541541
position: {x: 0, y: 0, z: 0}
542542
rotation: {x: 0, y: 0, z: 0}
543543
scale: {x: 0.3, y: 0.3, z: 0.3}
544+
- frame: {fileID: 1368736513}
545+
minimumAccuracy: {x: 0, y: 0, z: 0}
546+
minimuState: 2
547+
position: {x: 0, y: 0, z: 0}
548+
rotation: {x: 0, y: 0, z: 0}
549+
scale: {x: 0.3, y: 0.3, z: 0.3}
544550
referenceTransform: {fileID: 0}
545551
updateFrequency: 1
546552
--- !u!114 &404797283
@@ -680,6 +686,7 @@ MonoBehaviour:
680686
- {fileID: 1478666017}
681687
- {fileID: 1891623029}
682688
- {fileID: 332004590}
689+
- {fileID: 1368736513}
683690
- {fileID: 404797283}
684691
--- !u!4 &1034952783
685692
Transform:
@@ -693,7 +700,7 @@ Transform:
693700
m_LocalScale: {x: 1, y: 1, z: 1}
694701
m_Children: []
695702
m_Father: {fileID: 0}
696-
m_RootOrder: 9
703+
m_RootOrder: 10
697704
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
698705
--- !u!1 &1231208087
699706
GameObject:
@@ -786,6 +793,157 @@ MeshFilter:
786793
m_PrefabAsset: {fileID: 0}
787794
m_GameObject: {fileID: 1231208087}
788795
m_Mesh: {fileID: 10207, guid: 0000000000000000e000000000000000, type: 0}
796+
--- !u!1 &1368736511
797+
GameObject:
798+
m_ObjectHideFlags: 0
799+
m_CorrespondingSourceObject: {fileID: 0}
800+
m_PrefabInstance: {fileID: 0}
801+
m_PrefabAsset: {fileID: 0}
802+
serializedVersion: 6
803+
m_Component:
804+
- component: {fileID: 1368736514}
805+
- component: {fileID: 1368736513}
806+
- component: {fileID: 1368736512}
807+
m_Layer: 0
808+
m_Name: Parent4
809+
m_TagString: Untagged
810+
m_Icon: {fileID: 0}
811+
m_NavMeshLayer: 0
812+
m_StaticEditorFlags: 0
813+
m_IsActive: 1
814+
--- !u!114 &1368736512
815+
MonoBehaviour:
816+
m_ObjectHideFlags: 0
817+
m_CorrespondingSourceObject: {fileID: 0}
818+
m_PrefabInstance: {fileID: 0}
819+
m_PrefabAsset: {fileID: 0}
820+
m_GameObject: {fileID: 1368736511}
821+
m_Enabled: 1
822+
m_EditorHideFlags: 0
823+
m_Script: {fileID: 11500000, guid: 6dd105514384ea44196f0f5d83aa5356, type: 3}
824+
m_Name:
825+
m_EditorClassIdentifier:
826+
anchorId: Parent4Anchor
827+
loadOnStart: 0
828+
--- !u!114 &1368736513
829+
MonoBehaviour:
830+
m_ObjectHideFlags: 0
831+
m_CorrespondingSourceObject: {fileID: 0}
832+
m_PrefabInstance: {fileID: 0}
833+
m_PrefabAsset: {fileID: 0}
834+
m_GameObject: {fileID: 1368736511}
835+
m_Enabled: 1
836+
m_EditorHideFlags: 0
837+
m_Script: {fileID: 11500000, guid: a0f610d7a18b59247bad01d88be94815, type: 3}
838+
m_Name:
839+
m_EditorClassIdentifier:
840+
id: Parent4
841+
--- !u!4 &1368736514
842+
Transform:
843+
m_ObjectHideFlags: 0
844+
m_CorrespondingSourceObject: {fileID: 0}
845+
m_PrefabInstance: {fileID: 0}
846+
m_PrefabAsset: {fileID: 0}
847+
m_GameObject: {fileID: 1368736511}
848+
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
849+
m_LocalPosition: {x: 2, y: 0, z: 0}
850+
m_LocalScale: {x: 1, y: 1, z: 1}
851+
m_Children:
852+
- {fileID: 1453222603}
853+
m_Father: {fileID: 0}
854+
m_RootOrder: 8
855+
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
856+
--- !u!1 &1453222602
857+
GameObject:
858+
m_ObjectHideFlags: 0
859+
m_CorrespondingSourceObject: {fileID: 0}
860+
m_PrefabInstance: {fileID: 0}
861+
m_PrefabAsset: {fileID: 0}
862+
serializedVersion: 6
863+
m_Component:
864+
- component: {fileID: 1453222603}
865+
- component: {fileID: 1453222606}
866+
- component: {fileID: 1453222605}
867+
- component: {fileID: 1453222604}
868+
m_Layer: 0
869+
m_Name: Sphere
870+
m_TagString: Untagged
871+
m_Icon: {fileID: 0}
872+
m_NavMeshLayer: 0
873+
m_StaticEditorFlags: 0
874+
m_IsActive: 1
875+
--- !u!4 &1453222603
876+
Transform:
877+
m_ObjectHideFlags: 0
878+
m_CorrespondingSourceObject: {fileID: 0}
879+
m_PrefabInstance: {fileID: 0}
880+
m_PrefabAsset: {fileID: 0}
881+
m_GameObject: {fileID: 1453222602}
882+
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
883+
m_LocalPosition: {x: 0, y: 0, z: 0}
884+
m_LocalScale: {x: 0.1, y: 0.1, z: 0.1}
885+
m_Children: []
886+
m_Father: {fileID: 1368736514}
887+
m_RootOrder: 0
888+
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
889+
--- !u!135 &1453222604
890+
SphereCollider:
891+
m_ObjectHideFlags: 0
892+
m_CorrespondingSourceObject: {fileID: 0}
893+
m_PrefabInstance: {fileID: 0}
894+
m_PrefabAsset: {fileID: 0}
895+
m_GameObject: {fileID: 1453222602}
896+
m_Material: {fileID: 0}
897+
m_IsTrigger: 0
898+
m_Enabled: 1
899+
serializedVersion: 2
900+
m_Radius: 0.5
901+
m_Center: {x: 0, y: 0, z: 0}
902+
--- !u!23 &1453222605
903+
MeshRenderer:
904+
m_ObjectHideFlags: 0
905+
m_CorrespondingSourceObject: {fileID: 0}
906+
m_PrefabInstance: {fileID: 0}
907+
m_PrefabAsset: {fileID: 0}
908+
m_GameObject: {fileID: 1453222602}
909+
m_Enabled: 1
910+
m_CastShadows: 1
911+
m_ReceiveShadows: 1
912+
m_DynamicOccludee: 1
913+
m_MotionVectors: 1
914+
m_LightProbeUsage: 1
915+
m_ReflectionProbeUsage: 1
916+
m_RenderingLayerMask: 1
917+
m_RendererPriority: 0
918+
m_Materials:
919+
- {fileID: 10303, guid: 0000000000000000f000000000000000, type: 0}
920+
m_StaticBatchInfo:
921+
firstSubMesh: 0
922+
subMeshCount: 0
923+
m_StaticBatchRoot: {fileID: 0}
924+
m_ProbeAnchor: {fileID: 0}
925+
m_LightProbeVolumeOverride: {fileID: 0}
926+
m_ScaleInLightmap: 1
927+
m_PreserveUVs: 0
928+
m_IgnoreNormalsForChartDetection: 0
929+
m_ImportantGI: 0
930+
m_StitchLightmapSeams: 0
931+
m_SelectedEditorRenderState: 3
932+
m_MinimumChartSize: 4
933+
m_AutoUVMaxDistance: 0.5
934+
m_AutoUVMaxAngle: 89
935+
m_LightmapParameters: {fileID: 0}
936+
m_SortingLayerID: 0
937+
m_SortingLayer: 0
938+
m_SortingOrder: 0
939+
--- !u!33 &1453222606
940+
MeshFilter:
941+
m_ObjectHideFlags: 0
942+
m_CorrespondingSourceObject: {fileID: 0}
943+
m_PrefabInstance: {fileID: 0}
944+
m_PrefabAsset: {fileID: 0}
945+
m_GameObject: {fileID: 1453222602}
946+
m_Mesh: {fileID: 10207, guid: 0000000000000000e000000000000000, type: 0}
789947
--- !u!1 &1478666014
790948
GameObject:
791949
m_ObjectHideFlags: 0

SpatialAlignment-Unity/Assets/SpatialAlignment-Examples/Persistence/Scripts/PersistenceExampleManager.cs

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,15 @@ public class PersistenceExampleManager : MonoBehaviour
7878
},
7979
{
8080
""$id"": ""4"",
81+
""alignmentStrategy"": {
82+
""$type"": ""Microsoft.SpatialAlignment.WorldAnchorAlignment, Assembly-CSharp"",
83+
""anchorId"": ""Parent4Anchor"",
84+
""loadOnStart"": false
85+
},
86+
""id"": ""Parent4""
87+
},
88+
{
89+
""$id"": ""5"",
8190
""alignmentStrategy"": {
8291
""$type"": ""Microsoft.SpatialAlignment.MultiParentAlignment, Assembly-CSharp"",
8392
""parentOptions"": [
@@ -158,6 +167,32 @@ public class PersistenceExampleManager : MonoBehaviour
158167
""y"": 0.3,
159168
""z"": 0.3
160169
}
170+
},
171+
{
172+
""frame"": {
173+
""$ref"": ""4""
174+
},
175+
""minimumAccuracy"": {
176+
""x"": 0.0,
177+
""y"": 0.0,
178+
""z"": 0.0
179+
},
180+
""minimuState"": ""Resolved"",
181+
""position"": {
182+
""x"": 0.0,
183+
""y"": 0.0,
184+
""z"": 0.0
185+
},
186+
""rotation"": {
187+
""x"": 0.0,
188+
""y"": 0.0,
189+
""z"": 0.0
190+
},
191+
""scale"": {
192+
""x"": 0.3,
193+
""y"": 0.3,
194+
""z"": 0.3
195+
}
161196
}
162197
],
163198
""updateFrequency"": 1.0

SpatialAlignment-Unity/Assets/SpatialAlignment/Strategies/WorldAnchorAlignment.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
using System;
2828
using System.Collections;
2929
using System.Collections.Generic;
30+
using System.Runtime.Serialization;
3031
using System.Threading.Tasks;
3132
using UnityEngine;
3233
using UnityEngine.XR.WSA;
@@ -37,6 +38,7 @@ namespace Microsoft.SpatialAlignment
3738
/// <summary>
3839
/// An alignment strategy that attaches the object to a HoloLens world anchor.
3940
/// </summary>
41+
[DataContract]
4042
public class WorldAnchorAlignment : AlignmentStrategy, INativePersistence
4143
{
4244
#region Member Variables
@@ -45,10 +47,12 @@ public class WorldAnchorAlignment : AlignmentStrategy, INativePersistence
4547
#endregion // Member Variables
4648

4749
#region Unity Inspector Variables
50+
[DataMember]
4851
[SerializeField]
4952
[Tooltip("The ID of the anchor to load.")]
5053
private string anchorId;
5154

55+
[DataMember]
5256
[SerializeField]
5357
[Tooltip("Whether the anchor should be loaded when the behavior starts.")]
5458
private bool loadOnStart = false;

0 commit comments

Comments
 (0)