Texture GetVoxelPaint(string textureName, Texture prevTexture) { if(textureName == "") return prevTexture; m_AssetLoader = FindObjectOfType<AGF_AssetLoader> (); m_TerrainManager = FindObjectOfType<AGF_TerrainManager> (); foreach (Texture2D texture in m_AssetLoader.GetCustomPaint()) { if(texture.name == textureName){ Texture2D newTexture = new Texture2D(texture.width, texture.height,TextureFormat.ARGB32,false); newTexture.SetPixels(texture.GetPixels()); newTexture.name = textureName; newTexture.Apply(); return newTexture; } } foreach (Texture2D texture in m_AssetLoader.GetCustomPaintNormals()) { if(texture.name == textureName){ Texture2D newTexture = new Texture2D(texture.width, texture.height,TextureFormat.ARGB32,false); newTexture.SetPixels(texture.GetPixels()); newTexture.name = textureName; newTexture.Apply(); return newTexture; } } foreach (KeyValuePair<string,Texture2D> texture in m_TerrainManager.GetLoadedColormaps ()) { if(texture.Value.name == textureName){ Texture2D newTexture = new Texture2D(texture.Value.width, texture.Value.height,TextureFormat.ARGB32,false); newTexture.SetPixels(texture.Value.GetPixels()); newTexture.name = textureName; newTexture.Apply(); return newTexture; } } foreach (KeyValuePair<string,Texture2D> texture in m_TerrainManager.GetLoadedNormalmaps()) { if(texture.Value.name == textureName){ Texture2D newTexture = new Texture2D(texture.Value.width, texture.Value.height,TextureFormat.ARGB32,false); newTexture.SetPixels(texture.Value.GetPixels()); newTexture.name = textureName; newTexture.Apply(); return newTexture; } } return prevTexture; }
void Start() { m_AssetLoader = FindObjectOfType<AGF_AssetLoader> (); m_TerrainManager = FindObjectOfType<AGF_TerrainManager> (); }
public void SetVoxelGrass(string textureName, string bundleName, int grassSlot) { if(textureName == "") return; if(!m_TerrainManager) m_TerrainManager = FindObjectOfType<AGF_TerrainManager>(); if(!m_AssetLoader) m_AssetLoader = FindObjectOfType<AGF_AssetLoader>(); if (bundleName == "") { foreach (Texture2D texture in m_AssetLoader.GetCustomVegetations()) { if (texture.name == textureName) { voxelTerrain[selectedTerrain].types[grassSlot].grassMaterial.mainTexture = texture; voxelTerrain[selectedTerrain].types[grassSlot].grassBundle = ""; } } } else { foreach (KeyValuePair<string,Texture2D> texture in m_TerrainManager.GetLoadedVegetationTextures ()) { if (texture.Value.name == textureName && texture.Key == bundleName) { voxelTerrain[selectedTerrain].types[grassSlot].grassMaterial.mainTexture = texture.Value; voxelTerrain[selectedTerrain].types[grassSlot].grassBundle = texture.Key; } } } }