コード例 #1
0
ファイル: ToTXT.cs プロジェクト: panhao4812/MeshClassLibrary
 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;
 }
コード例 #2
0
        public static void Write(this Texture2D texture, Stream stream, TextureFileType fileType)
        {
            ValidateWrite(texture);
            ValidateWrite(stream);

            InternalWrite(texture, stream, fileType);
        }
コード例 #3
0
 private static void ValidateWrite(TextureFileType fileType)
 {
     if (!Enum.IsDefined(typeof(TextureFileType), fileType))
     {
         throw new NotSupportedException();
     }
 }
コード例 #4
0
        public static string GetFileExtension(TextureFileType fileType)
        {
            switch (fileType)
            {
            case TextureFileType.PNG:
                return(PNGFileExtension);

            case TextureFileType.JPG:
                return(JPGFileExtension);

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
コード例 #5
0
        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);
        }
コード例 #6
0
        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();
            }
        }
コード例 #7
0
        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);
            }
        }
コード例 #8
0
        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));
        }