/// <summary> /// When a modeled structure has been loaded, monitor its destroy phase by adding a custom /// <see cref="ListenToDestroy"/> component. /// </summary> /// <remarks> /// This will be used to keep the dictionary of loaded place ids up-to-date. /// </remarks> void OnModeledStructureCreated(DidCreateModeledStructureArgs args) { if (!PlaceIdToGameObjectDict.ContainsKey(args.MapFeature.Metadata.PlaceId)) { PlaceIdToGameObjectDict.Add(args.MapFeature.Metadata.PlaceId, args.GameObject); // We are interested in the lifecycle of this GameObject // Let's attach a component listening to its OnDestroy event // When destroyed the object will notify our local cache for cleanup if (args.GameObject.GetComponent <ListenToDestroy>() == null) { ListenToDestroy ltd = args.GameObject.AddComponent <ListenToDestroy>(); if (ltd != null) { ltd.PlaceId = args.MapFeature.Metadata.PlaceId; if (ltd.MapFeatureDestroyed == null) { ltd.MapFeatureDestroyed = new MapFeatureDestroyedEvent(); } else { ltd.MapFeatureDestroyed.AddListener(OnMapFeatureDestroyed); } } } } else { PlaceIdToGameObjectDict[args.MapFeature.Metadata.PlaceId] = args.GameObject; } }
/// <summary> /// Triggered by the Maps SDK during the loading process. /// Re-parents the newly created GameObject if a container was provided for this map feature /// category. /// </summary> void OnModeledStructureCreated(DidCreateModeledStructureArgs args) { if (ModeledStructuresContainer != null) { // Note: Care should be taken when reparenting SDK created object. // See note above in ClearContainer() args.GameObject.transform.SetParent(ModeledStructuresContainer.transform, true); } }
void OnModeledStructureCreated(DidCreateModeledStructureArgs args) { CreateLabel(args.GameObject, args.MapFeature.Metadata.PlaceId, args.MapFeature.Metadata.Name); }
void OnModeledStructureCreated(DidCreateModeledStructureArgs args) { UpdateBuilding(args.GameObject); }