/// <summary> /// Creates a label for a building. /// </summary> /// <param name="buildingGameObject">The GameObject of the building.</param> /// <param name="placeId">The place ID of the building.</param> /// <param name="displayName">The name to display on the label for the building.</param> void CreateLabel(GameObject buildingGameObject, string placeId, string displayName) { if (Random.value > Ratio) { return; } if (!Labeller.enabled) { return; } // Ignore uninteresting names. if (displayName.Equals("ExtrudedStructure") || displayName.Equals("ModeledStructure")) { return; } Label label = Labeller.NameObject(buildingGameObject, placeId, displayName); if (label != null) { MapsGamingExamplesUtils.PlaceUIMarker(buildingGameObject, label.transform); } }
/// <summary> /// Create a new road name label when a <see cref="Google.Maps.Feature.Segment"/> GameObject is /// created while loading the map. /// </summary> void OnSegmentCreated(DidCreateSegmentArgs args) { if (!Labeller.enabled) { return; } Label label = Labeller.NameObject( args.GameObject, args.MapFeature.Metadata.PlaceId, args.MapFeature.Metadata.Name); if (label != null) { // Get transformer component for re-positioning the label after road segment updates. RoadLabelMover roadLabelMover = label.GetComponent <RoadLabelMover>(); if (roadLabelMover == null) { roadLabelMover = label.gameObject.AddComponent <RoadLabelMover>(); } // Add road chunk to transformer. roadLabelMover.Add(args.GameObject, args.MapFeature.Shape.Lines[0]); } }