public IEnumerator BrowseForTexture() { TextureRow textureRow = null; yield return(textureRow.StartCoroutine(textureRow.Editor.FileDialog.Open(null, ".png|.jpg", "OPEN FILE", null, (long)-1, true))); if (textureRow.Editor.FileDialog.result == null) { yield break; } FileInfo fileInfo = new FileInfo(textureRow.Editor.FileDialog.result); try { textureRow.Load(fileInfo.FullName); } catch (Exception exception) { UnityEngine.Debug.LogWarning(string.Concat("Couldn't load texture: ", exception.Message)); } }
private IEnumerator DoSaveFile() { TextureRow textureRow = null; yield return(textureRow.StartCoroutine(textureRow.Editor.FileDialog.Save(null, ".png", "SAVE FILE", null, true))); if (string.IsNullOrEmpty(textureRow.Editor.FileDialog.result)) { yield break; } UnityEngine.Debug.Log(string.Concat("Save Png to ", textureRow.Editor.FileDialog.result)); UnityEngine.Texture targetImage = textureRow.TargetImage.texture; if (textureRow.IsNormalMap) { targetImage = Facepunch.Utility.Texture.CreateReadableCopy(targetImage as Texture2D, 0, 0); (targetImage as Texture2D).DecompressNormals(); } targetImage.SaveAsPng(textureRow.Editor.FileDialog.result); if (textureRow.IsNormalMap) { UnityEngine.Object.Destroy(targetImage); } }