Beispiel #1
0
        public async Task SaveNormalDetailElementAsync(string filename, TextureWithSize textureWithSize)
        {
            var path      = _mainDictionaryPath + filename + _extension;
            var texture2d = await ChangeNormalTextureToTexture2DAsync(textureWithSize.Texture);

            await AsyncFileUtils.SaveTextureToPngFileAsync(path, texture2d, _commonExecutor);
        }
Beispiel #2
0
        public static async Task <Texture2D> LoadPngTextureFromFileAsync(string path, int width, int height,
                                                                         TextureFormat format, bool apply = true, bool generateMipmaps = false)
        {
            var newTexture = new Texture2D(width, height, format, generateMipmaps);

            newTexture.LoadImage(await AsyncFileUtils.ReadAllBytesAsync(path));
            if (apply)
            {
                newTexture.Apply();
            }

            Preconditions.Assert(width == newTexture.width,
                                 "Loaded texture width is not equal to expected one " + newTexture.width);
            Preconditions.Assert(height == newTexture.height,
                                 "Loaded texture height is not equal to expected one " + newTexture.height);
            return(newTexture);
        }
Beispiel #3
0
        public static Task SaveTextureToPngFileAsync(string path, Texture2D texture)
        {
            var wholeBytes = texture.EncodeToPNG();

            return(AsyncFileUtils.WriteAllBytesAsync(path, wholeBytes));
        }
        private async Task SaveTextureToFile(Texture texture, string path)
        {
            var tex2d = await ChangeTextureToTexture2DAsync(texture);

            await AsyncFileUtils.SaveTextureToPngFileAsync(path, tex2d, _commonExecutor);
        }
 private async Task <Texture> LoadTextureFromFile(string path) //todo not remove texture2D but renderTexture
 {
     return(await AsyncFileUtils.LoadTextureFromPngFileAsync(path, true, _commonExecutor));
 }