public string eSceneToBesiege(List<Mesh> z, string Folder, string ProgramName, TextureFileType filetype) { string output = ""; output += "Snow,size,0" + "\n"; output += "Wind,size,0" + "\n"; output += "Cloud,size,0" + "\n"; output += "Camera,farClipPlane,3000" + "\n"; output += "Water,size,0" + "\n"; output += "Triggers,size,0" + "\n"; output += "Meshes,size," + z.Count.ToString() + "\n"; int co = 0; Writebrackets(z, Folder, ProgramName); for (int i = 0; i < z.Count; i++) { if (filetype == TextureFileType.PNG) { output += eWriteScene(co, Folder + "/" + ProgramName + " (" + (i + 1).ToString() + ").obj", Folder + "/" + ProgramName + " (" + (i + 1).ToString() + ").png"); co++; } else if (filetype == TextureFileType.JPG) { output += eWriteScene(co, Folder + "/" + ProgramName + " (" + (i + 1).ToString() + ").obj", Folder + "/" + ProgramName + " (" + (i + 1).ToString() + ").jpg"); co++; } } return output; }
public static void Write(this Texture2D texture, Stream stream, TextureFileType fileType) { ValidateWrite(texture); ValidateWrite(stream); InternalWrite(texture, stream, fileType); }
private static void ValidateWrite(TextureFileType fileType) { if (!Enum.IsDefined(typeof(TextureFileType), fileType)) { throw new NotSupportedException(); } }
public static string GetFileExtension(TextureFileType fileType) { switch (fileType) { case TextureFileType.PNG: return(PNGFileExtension); case TextureFileType.JPG: return(JPGFileExtension); default: throw new ArgumentOutOfRangeException(); } }
public static string WriteTexture(Object sender, RenderTexture source, TextureFileType fileType = TextureFileType.PNG) { string path = Path.GetDirectoryName(AssetDatabase.GetAssetPath(sender)); path = EditorUtility.SaveFilePanelInProject("Save to", "Texture", TextureOutputHelper.GetFileExtension(fileType), "", path); if (path.Length > 0) { using (var stream = new FileStream(path, FileMode.Create)) { TextureOutputHelper.Write(source, stream, fileType); } AssetDatabase.ImportAsset(path); return(path); } return(null); }
private static void InternalWrite(Texture2D texture, Stream stream, TextureFileType fileType) { switch (fileType) { case TextureFileType.PNG: InternalWriteAsPNG(texture, stream); break; case TextureFileType.JPG: InternalWriteAsJPG(texture, stream); break; default: throw new NotSupportedException(); } }
public static void Write(this RenderTexture renderTexture, Stream stream, TextureFileType fileType) { if (renderTexture == null) { throw new ArgumentNullException(nameof(renderTexture)); } ValidateWrite(stream); ValidateWrite(fileType); Texture2D texture = renderTexture.CreateTexture2D(); try { InternalWrite(texture, stream, fileType); } finally { UnityEngine.Object.DestroyImmediate(texture); } }
static public Stream TextureFileOpenRead(string nameNoExt, StorageSource sources, TextureFileType fileType) { string filePath = string.Format(FULL_FILE_PATH_FORMAT, nameNoExt, fileType.ToString()); if (FileExists(filePath, sources)) { return(OpenRead(filePath, sources)); } throw new FileNotFoundException(String.Format("Texture2D file not found in {0}: {1}", sources, nameNoExt)); }