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); }
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); }
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)); }