@@ -18,7 +18,7 @@ public class ImportExportAnchorManager : Singleton<ImportExportAnchorManager>
1818 /// <summary>
1919 /// Enum to track the progress through establishing a shared coordinate system.
2020 /// </summary>
21- enum ImportExportState
21+ private enum ImportExportState
2222 {
2323 // Overall states
2424 Start ,
@@ -39,7 +39,7 @@ enum ImportExportState
3939 Importing
4040 }
4141
42- ImportExportState currentState = ImportExportState . Start ;
42+ private ImportExportState currentState = ImportExportState . Start ;
4343
4444 public string StateName
4545 {
@@ -60,78 +60,87 @@ public bool AnchorEstablished
6060 /// <summary>
6161 /// WorldAnchorTransferBatch is the primary object in serializing/deserializing anchors.
6262 /// </summary>
63- WorldAnchorTransferBatch sharedAnchorInterface ;
63+ private WorldAnchorTransferBatch sharedAnchorInterface ;
6464
6565 /// <summary>
6666 /// Keeps track of stored anchor data blob.
6767 /// </summary>
68- byte [ ] rawAnchorData = null ;
68+ private byte [ ] rawAnchorData = null ;
6969
7070 /// <summary>
7171 /// Keeps track of locally stored anchors.
7272 /// </summary>
73- WorldAnchorStore anchorStore = null ;
73+ private WorldAnchorStore anchorStore = null ;
7474
7575 /// <summary>
7676 /// Keeps track of the name of the anchor we are exporting.
7777 /// </summary>
78- string exportingAnchorName { get ; set ; }
78+ private string exportingAnchorName { get ; set ; }
7979
8080 /// <summary>
8181 /// The datablob of the anchor.
8282 /// </summary>
83- List < byte > exportingAnchorBytes = new List < byte > ( ) ;
83+ private List < byte > exportingAnchorBytes = new List < byte > ( ) ;
8484
8585 /// <summary>
8686 /// Keeps track of if the sharing service is ready.
8787 /// We need the sharing service to be ready so we can
8888 /// upload and download data for sharing anchors.
8989 /// </summary>
90- bool sharingServiceReady = false ;
90+ private bool sharingServiceReady = false ;
9191
9292 /// <summary>
9393 /// The room manager API for the sharing service.
9494 /// </summary>
95- RoomManager roomManager ;
95+ private RoomManager roomManager ;
9696
9797 /// <summary>
9898 /// Keeps track of the current room we are connected to. Anchors
9999 /// are kept in rooms.
100100 /// </summary>
101- Room currentRoom ;
101+ private Room currentRoom ;
102102
103103 /// <summary>
104104 /// Sometimes we'll see a really small anchor blob get generated.
105105 /// These tend to not work, so we have a minimum trustable size.
106106 /// </summary>
107- const uint minTrustworthySerializedAnchorDataSize = 100000 ;
107+ private const uint minTrustworthySerializedAnchorDataSize = 100000 ;
108108
109109 /// <summary>
110110 /// Some room ID for indicating which room we are in.
111111 /// </summary>
112- const long roomID = 8675309 ;
112+ private const long roomID = 8675309 ;
113113
114114 /// <summary>
115115 /// Provides updates when anchor data is uploaded/downloaded.
116116 /// </summary>
117- RoomManagerAdapter roomManagerCallbacks ;
117+ private RoomManagerAdapter roomManagerCallbacks ;
118118
119- void Start ( )
119+ private void Awake ( )
120120 {
121121 Debug . Log ( "Import Export Manager starting" ) ;
122-
123- currentState = ImportExportState . Ready ;
124-
125122 // We need to get our local anchor store started up.
126123 currentState = ImportExportState . AnchorStore_Initializing ;
127124 WorldAnchorStore . GetAsync ( AnchorStoreReady ) ;
125+ }
128126
127+ private void Start ( )
128+ {
129129 //Wait for a notification that the sharing manager has been initialized (connected to sever)
130130 SharingStage . Instance . SharingManagerConnected += SharingManagerConnected ;
131+
132+ // We will register for session joined to indicate when the sharing service
133+ // is ready for us to make room related requests.
134+ SharingSessionTracker . Instance . SessionJoined += Instance_SessionJoined ;
131135 }
132136
133- void OnDestroy ( )
137+ private void OnDestroy ( )
134138 {
139+ if ( SharingStage . Instance != null )
140+ {
141+ SharingStage . Instance . SharingManagerConnected -= SharingManagerConnected ;
142+ }
143+
135144 if ( roomManagerCallbacks != null )
136145 {
137146 roomManagerCallbacks . AnchorsDownloadedEvent -= RoomManagerCallbacks_AnchorsDownloaded ;
@@ -153,10 +162,6 @@ private void SharingManagerConnected(object sender, EventArgs e)
153162 roomManagerCallbacks . AnchorsDownloadedEvent += RoomManagerCallbacks_AnchorsDownloaded ;
154163 roomManagerCallbacks . AnchorUploadedEvent += RoomManagerCallbacks_AnchorUploaded ;
155164 roomManager . AddListener ( roomManagerCallbacks ) ;
156-
157- // We will register for session joined to indicate when the sharing service
158- // is ready for us to make room related requests.
159- SharingSessionTracker . Instance . SessionJoined += Instance_SessionJoined ;
160165 }
161166
162167 /// <summary>
@@ -202,7 +207,7 @@ private void RoomManagerCallbacks_AnchorsDownloaded(bool successful, AnchorDownl
202207 /// Called when the local anchor store is ready.
203208 /// </summary>
204209 /// <param name="store"></param>
205- void AnchorStoreReady ( WorldAnchorStore store )
210+ private void AnchorStoreReady ( WorldAnchorStore store )
206211 {
207212 anchorStore = store ;
208213 currentState = ImportExportState . AnchorStore_Initialized ;
@@ -224,15 +229,15 @@ private void Instance_SessionJoined(object sender, SharingSessionTracker.Session
224229 Invoke ( "MarkSharingServiceReady" , 5 ) ;
225230 }
226231
227- void MarkSharingServiceReady ( )
232+ private void MarkSharingServiceReady ( )
228233 {
229234 sharingServiceReady = true ;
230235 }
231236
232237 /// <summary>
233238 /// Initializes the room api.
234239 /// </summary>
235- void InitRoomApi ( )
240+ private void InitRoomApi ( )
236241 {
237242 // If we have a room, we'll join the first room we see.
238243 // If we are the user with the lowest user ID, we will create the room.
@@ -262,7 +267,7 @@ void InitRoomApi()
262267 }
263268 }
264269
265- bool LocalUserHasLowestUserId ( )
270+ private bool LocalUserHasLowestUserId ( )
266271 {
267272 long localUserId = CustomMessages . Instance . localUserID ;
268273 foreach ( long userid in SharingSessionTracker . Instance . UserIds )
@@ -279,7 +284,7 @@ bool LocalUserHasLowestUserId()
279284 /// <summary>
280285 /// Kicks off the process of creating the shared space.
281286 /// </summary>
282- void StartAnchorProcess ( )
287+ private void StartAnchorProcess ( )
283288 {
284289 // First, are there any anchors in this room?
285290 int anchorCount = currentRoom . GetAnchorCount ( ) ;
@@ -306,7 +311,7 @@ void StartAnchorProcess()
306311 /// <summary>
307312 /// Kicks off getting the datablob required to import the shared anchor.
308313 /// </summary>
309- void MakeAnchorDataRequest ( )
314+ private void MakeAnchorDataRequest ( )
310315 {
311316 if ( roomManager . DownloadAnchor ( currentRoom , currentRoom . GetAnchorName ( 0 ) ) )
312317 {
@@ -319,7 +324,7 @@ void MakeAnchorDataRequest()
319324 }
320325 }
321326
322- void Update ( )
327+ private void Update ( )
323328 {
324329 switch ( currentState )
325330 {
@@ -353,7 +358,7 @@ void Update()
353358 /// <summary>
354359 /// Starts establishing a new anchor.
355360 /// </summary>
356- void CreateAnchorLocally ( )
361+ private void CreateAnchorLocally ( )
357362 {
358363 WorldAnchor anchor = GetComponent < WorldAnchor > ( ) ;
359364 if ( anchor == null )
@@ -394,7 +399,7 @@ private void Anchor_OnTrackingChanged_InitialAnchor(WorldAnchor self, bool locat
394399 /// Attempts to attach to an anchor by anchorName in the local store..
395400 /// </summary>
396401 /// <returns>True if it attached, false if it could not attach</returns>
397- bool AttachToCachedAnchor ( string AnchorName )
402+ private bool AttachToCachedAnchor ( string AnchorName )
398403 {
399404 Debug . Log ( "Looking for " + AnchorName ) ;
400405 string [ ] ids = anchorStore . GetAllIds ( ) ;
@@ -446,7 +451,7 @@ private void ImportExportAnchorManager_OnTrackingChanged_Attaching(WorldAnchor s
446451 /// </summary>
447452 /// <param name="status"></param>
448453 /// <param name="wat"></param>
449- void ImportComplete ( SerializationCompletionReason status , WorldAnchorTransferBatch wat )
454+ private void ImportComplete ( SerializationCompletionReason status , WorldAnchorTransferBatch wat )
450455 {
451456 if ( status == SerializationCompletionReason . Succeeded && wat . GetAllIds ( ) . Length > 0 )
452457 {
@@ -469,7 +474,7 @@ void ImportComplete(SerializationCompletionReason status, WorldAnchorTransferBat
469474 /// <summary>
470475 /// Exports the currently created anchor.
471476 /// </summary>
472- void Export ( )
477+ private void Export ( )
473478 {
474479 WorldAnchor anchor = GetComponent < WorldAnchor > ( ) ;
475480
0 commit comments