public void FillListsWithGeneratorsAsset(MapMagic.GeneratorsAsset generatorsAsset) { if (generatorsAsset == null) { return; } foreach (MapMagic.Generator generator in generatorsAsset.list) { // biome if (generator is MapMagic.Biome) { MapMagic.Biome biome = (MapMagic.Biome)generator; FillListsWithGeneratorsAsset(biome.data); } // detail instancing else if (generator is MapMagic.GrassOutput) { MapMagic.GrassOutput gen = (MapMagic.GrassOutput)generator; for (int i = 0; i < gen.baseLayers.Length; i++) { if (gen.baseLayers[i].det != null) { terrainDetailPrototypes.Add(gen.baseLayers[i].det); } else { Debug.LogWarning("Map Magic generator contains unassigned Grass Output values. Please assign or remove these values."); } } } // tree instancing else if (generator is MapMagic.TreesOutput) { MapMagic.TreesOutput gen = (MapMagic.TreesOutput)generator; for (int i = 0; i < gen.baseLayers.Length; i++) { if (gen.baseLayers[i].prefab != null) { terrainTreePrototypes.Add(new TreePrototype() { prefab = gen.baseLayers[i].prefab }); } else { Debug.LogWarning("Map Magic generator contains unassigned Trees Output values. Please assign or remove these values."); } } } // prefab instancing else if (generator is MapMagic.ObjectOutput) { MapMagic.ObjectOutput gen = (MapMagic.ObjectOutput)generator; for (int i = 0; i < gen.baseLayers.Length; i++) { if (gen.baseLayers[i].prefab != null && !prefabs.Contains(gen.baseLayers[i].prefab.gameObject)) { #if UNITY_EDITOR #if UNITY_2018_3_OR_NEWER if (PrefabUtility.GetPrefabAssetType(gen.baseLayers[i].prefab.gameObject) == PrefabAssetType.Model) #else if (PrefabUtility.GetPrefabType(gen.baseLayers[i].prefab.gameObject) == PrefabType.ModelPrefab) #endif { Debug.LogWarning(GPUInstancerConstants.TEXT_PREFAB_TYPE_WARNING_3D + " " + gen.baseLayers[i].prefab.gameObject.name, gen.baseLayers[i].prefab.gameObject); } else #endif prefabs.Add(gen.baseLayers[i].prefab.gameObject); } } } } }
public void SetUpWithGeneratorsAsset() { SetDefaultGPUInstancerShaderBindings(); SetDefaultGPUInstancerBillboardAtlasBindings(); terrainDetailPrototypes = new List <DetailPrototype>(); terrainTreePrototypes = new List <TreePrototype>(); prefabs = new List <GameObject>(); if (selectedPrefabs == null) { selectedPrefabs = new List <GameObject>(); } if (mapMagicInstance == null) { return; } MapMagic.GeneratorsAsset generatorsAsset = mapMagicInstance.gens; if (generatorsAsset == null) { return; } foreach (MapMagic.Generator generator in generatorsAsset.list) { // detail instancing if (generator is MapMagic.GrassOutput) { MapMagic.GrassOutput gen = (MapMagic.GrassOutput)generator; for (int i = 0; i < gen.baseLayers.Length; i++) { terrainDetailPrototypes.Add(gen.baseLayers[i].det); } } // tree instancing else if (generator is MapMagic.TreesOutput) { MapMagic.TreesOutput gen = (MapMagic.TreesOutput)generator; for (int i = 0; i < gen.baseLayers.Length; i++) { if (gen.baseLayers[i].prefab != null) { terrainTreePrototypes.Add(new TreePrototype() { prefab = gen.baseLayers[i].prefab }); } } } // prefab instancing else if (generator is MapMagic.ObjectOutput) { MapMagic.ObjectOutput gen = (MapMagic.ObjectOutput)generator; for (int i = 0; i < gen.baseLayers.Length; i++) { if (!prefabs.Contains(gen.baseLayers[i].prefab.gameObject)) { prefabs.Add(gen.baseLayers[i].prefab.gameObject); } } } } if (selectedPrefabs.Count > 0) { selectedPrefabs.RemoveAll(p => !prefabs.Contains(p)); } else if (_selectAllPrefabs) { selectedPrefabs.AddRange(prefabs); _selectAllPrefabs = false; } }