12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 |
- 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<DynamicMapsService>();
- // 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<MeshRenderer>();
- //lods[1] = new LOD();
- //lods[1].renderers[0] = args.GameObject.AddComponent<MeshRenderer>();
- //GameObject dup = Instantiate(obj);
- //dup.name = "dup";
- //dup.transform.SetParent(args.GameObject.transform);
- LODGroup group = args.GameObject.AddComponent<LODGroup>();
- LOD[] lods = new LOD[3];
- lods[0] = new LOD();
- Debug.LogError(args.GameObject.transform.childCount);
-
- //foreach (var baum in )
- //{
- // List<Renderer> renderers = new List<Renderer>(lods[0].renderers)
- // {
- // baum.GetComponent<MeshRenderer>()
- // };
- // lods[0].renderers = renderers.ToArray();
- //}
- group.SetLODs(lods);
- //group.SetLODs(lods);
- });
- }
- }
|