using Google.Maps.Examples.Shared; using System.Collections; using System.Collections.Generic; using UnityEngine; [RequireComponent(typeof(DynamicMapsService))] public class addLOD : MonoBehaviour { private string[] strs = { "Parapet", "Border" }; // Start is called before the first frame update void Start() { } // Update is called once per frame void Update() { } private void Awake() { // Get the required Dynamic Maps Service on this GameObject. DynamicMapsService dynamicMapsService = GetComponent(); // Sign up to event called after each new building is loaded, so can assign Materials to this // new building. Note that: // - DynamicMapsService.MapsService is auto-found on first access (so will not be null). // - This event must be set now during Awake, so that when Dynamic Maps Service starts loading // the map during Start, this event will be triggered for all Extruded Structures. dynamicMapsService.MapsService.Events.ExtrudedStructureEvents.DidCreate.AddListener( args => { //LOD[] lods = new LOD[2]; //lods[0] = new LOD(); //lods[0].renderers[0] = args.GameObject.GetComponent(); //lods[1] = new LOD(); //lods[1].renderers[0] = args.GameObject.AddComponent(); //GameObject dup = Instantiate(obj); //dup.name = "dup"; //dup.transform.SetParent(args.GameObject.transform); LODGroup group = args.GameObject.AddComponent(); LOD[] lods = new LOD[3]; lods[0] = new LOD(); Debug.LogError(args.GameObject.transform.childCount); //foreach (var baum in ) //{ // List renderers = new List(lods[0].renderers) // { // baum.GetComponent() // }; // lods[0].renderers = renderers.ToArray(); //} group.SetLODs(lods); //group.SetLODs(lods); }); } }