Пример #1
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;
    }