void Update() { // Note: SwapSlots is now taken care of on UMASimpleLOD if (characterCount > 0) { if (!isBuilding) { characterCount--; isBuilding = true; crowd.ResetSpawnPos(); var go = crowd.GenerateUMA(Random.Range(0, 2), transform.position + new Vector3(Random.Range(-range, range), 0, Random.Range(-range, range))); go.transform.localRotation = Quaternion.Euler(0, Random.Range(0, 360), 0); UMAData umaData = go.GetComponent <UMAData>(); umaData.CharacterCreated.AddListener(CharacterCreated); var lod = go.AddComponent <UMASimpleLOD>(); var display = go.AddComponent <LODDisplay>(); display.LODDisplayPrefab = LODDisplayPrefab; lod.lodDistance = lodDistance; lod.swapSlots = swapSlots; lod.lodOffset = lodOffset; lod.Update(); } } }
void Update() { if (swapSlots != _swapSlots || lodOffset != _lodOffset) { _swapSlots = swapSlots; _lodOffset = lodOffset; var lods = transform.GetComponentsInChildren <UMASimpleLOD>(); foreach (var lod in lods) { lod.SetSwapSlots(_swapSlots, _lodOffset); } } if (characterCount > 0) { if (!isBuilding) { characterCount--; isBuilding = true; crowd.ResetSpawnPos(); var go = crowd.GenerateUMA(Random.Range(0, 2), transform.position + new Vector3(Random.Range(-range, range), 0, Random.Range(-range, range))); go.transform.localRotation = Quaternion.Euler(0, Random.Range(0, 360), 0); // Add the display prefab GameObject tm = (GameObject)GameObject.Instantiate(LODDisplayPrefab, go.transform.position, go.transform.rotation); tm.transform.SetParent(go.transform); tm.transform.localPosition = new Vector3(0, 2f, 0f); tm.transform.localRotation = Quaternion.Euler(0f, 180f, 0f); var lod = go.AddComponent <UMASimpleLOD>(); lod.lodDistance = lodDistance; lod.lodDisplay = tm.GetComponent <TextMesh>(); lod.umaData = go.GetComponent <UMAData>(); lod.umaData.CharacterUpdated.AddListener(lod.CharacterUpdated); lod.umaData.CharacterCreated.AddListener(CharacterCreated); lod.swapSlots = swapSlots; lod.lodOffset = lodOffset; lod.Update(); } } }