Exemplo n.º 1
0
		Texture GetVoxelPaint(string textureName, Texture prevTexture){
			if (textureName == "null")
				return null;

			if(textureName == "")
				return prevTexture;

			if (textureName.EndsWith ("_s")) {
				textureName = textureName.Substring (0, textureName.Length - 2);
				textureName += "_c";
			}

			terrainManager = FindObjectOfType<AGF_TerrainManager> ();

			foreach (KeyValuePair<string,Texture2D> texture in terrainManager.GetLoadedColormaps ()) {
				if(texture.Value.name == textureName){
					return texture.Value;
				}
			}
			foreach (KeyValuePair<string,Texture2D> texture in terrainManager.GetLoadedNormalmaps()) {
				if(texture.Value.name == textureName){
					return texture.Value;
				}
			}
			foreach (Texture2D tex in terrainManager.defaultTextures) {
				if (tex.name == textureName) {
					return tex;
				}
			}

			Debug.LogError ("Could not find terrain " + textureName + " in loaded asset bundles");
			return prevTexture;
		}
Exemplo n.º 2
0
    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;
    }