No Description
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

TexturePlatformSettingsModel.cs 12KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310
  1. namespace UnityEditor.U2D.Aseprite
  2. {
  3. internal static class TexturePlatformSettingsModal
  4. {
  5. static readonly TextureImporterFormat[] k_FormatsWithCompressionSettings =
  6. {
  7. TextureImporterFormat.PVRTC_RGB2,
  8. TextureImporterFormat.PVRTC_RGB4,
  9. TextureImporterFormat.PVRTC_RGBA2,
  10. TextureImporterFormat.PVRTC_RGBA4,
  11. TextureImporterFormat.ETC_RGB4,
  12. TextureImporterFormat.ETC2_RGBA8,
  13. TextureImporterFormat.ETC_RGB4,
  14. TextureImporterFormat.ETC2_RGB4,
  15. TextureImporterFormat.ETC2_RGB4_PUNCHTHROUGH_ALPHA,
  16. TextureImporterFormat.ETC2_RGBA8,
  17. TextureImporterFormat.ASTC_4x4,
  18. TextureImporterFormat.ASTC_5x5,
  19. TextureImporterFormat.ASTC_6x6,
  20. TextureImporterFormat.ASTC_8x8,
  21. TextureImporterFormat.ASTC_10x10,
  22. TextureImporterFormat.ASTC_12x12,
  23. };
  24. public struct BuildPlatformData
  25. {
  26. public string buildTargetName;
  27. public TextureImporterFormat defaultTextureFormat;
  28. public BuildTarget[] buildTarget;
  29. }
  30. // Add new platforms here
  31. public static readonly BuildPlatformData[] validBuildPlatform = new BuildPlatformData[]
  32. {
  33. new BuildPlatformData()
  34. {
  35. buildTargetName = "Default",
  36. defaultTextureFormat = TextureImporterFormat.Automatic,
  37. buildTarget = new[]
  38. {
  39. BuildTarget.NoTarget
  40. }
  41. },
  42. new BuildPlatformData()
  43. {
  44. buildTargetName = "PC, Mac & Linux Standalone",
  45. defaultTextureFormat = TextureImporterFormat.RGBA32,
  46. buildTarget = new[]
  47. {
  48. BuildTarget.StandaloneWindows,
  49. BuildTarget.StandaloneWindows64,
  50. BuildTarget.StandaloneLinux64,
  51. BuildTarget.StandaloneOSX,
  52. }
  53. },
  54. new BuildPlatformData()
  55. {
  56. buildTargetName = "iOS",
  57. defaultTextureFormat = TextureImporterFormat.RGBA32,
  58. buildTarget = new[] { BuildTarget.iOS }
  59. },
  60. new BuildPlatformData()
  61. {
  62. buildTargetName = "tvOS",
  63. defaultTextureFormat = TextureImporterFormat.RGBA32,
  64. buildTarget = new[] { BuildTarget.tvOS }
  65. },
  66. new BuildPlatformData()
  67. {
  68. buildTargetName = "Android",
  69. defaultTextureFormat = TextureImporterFormat.RGBA32,
  70. buildTarget = new[] { BuildTarget.Android }
  71. },
  72. new BuildPlatformData()
  73. {
  74. buildTargetName = "Universal Windows Platform",
  75. defaultTextureFormat = TextureImporterFormat.RGBA32,
  76. buildTarget = new[] { BuildTarget.WSAPlayer }
  77. },
  78. };
  79. static readonly int[] k_TextureFormatsValueApplePVR =
  80. {
  81. (int)TextureImporterFormat.PVRTC_RGB2,
  82. (int)TextureImporterFormat.PVRTC_RGBA2,
  83. (int)TextureImporterFormat.PVRTC_RGB4,
  84. (int)TextureImporterFormat.PVRTC_RGBA4,
  85. (int)TextureImporterFormat.ASTC_4x4,
  86. (int)TextureImporterFormat.ASTC_5x5,
  87. (int)TextureImporterFormat.ASTC_6x6,
  88. (int)TextureImporterFormat.ASTC_8x8,
  89. (int)TextureImporterFormat.ASTC_10x10,
  90. (int)TextureImporterFormat.ASTC_12x12,
  91. (int)TextureImporterFormat.RGB16,
  92. (int)TextureImporterFormat.RGB24,
  93. (int)TextureImporterFormat.Alpha8,
  94. (int)TextureImporterFormat.RGBA16,
  95. (int)TextureImporterFormat.RGBA32
  96. };
  97. static readonly int[] k_TextureFormatsValueAndroid =
  98. {
  99. (int)TextureImporterFormat.DXT1,
  100. (int)TextureImporterFormat.DXT5,
  101. #if ENABLE_CRUNCH_TEXTURE_COMPRESSION
  102. (int)TextureImporterFormat.DXT1Crunched,
  103. (int)TextureImporterFormat.DXT5Crunched,
  104. #endif
  105. (int)TextureImporterFormat.ETC_RGB4,
  106. (int)TextureImporterFormat.ETC2_RGB4,
  107. (int)TextureImporterFormat.ETC2_RGB4_PUNCHTHROUGH_ALPHA,
  108. (int)TextureImporterFormat.ETC2_RGBA8,
  109. (int)TextureImporterFormat.PVRTC_RGB2,
  110. (int)TextureImporterFormat.PVRTC_RGBA2,
  111. (int)TextureImporterFormat.PVRTC_RGB4,
  112. (int)TextureImporterFormat.PVRTC_RGBA4,
  113. (int)TextureImporterFormat.ETC_RGB4,
  114. (int)TextureImporterFormat.ETC2_RGBA8,
  115. (int)TextureImporterFormat.ASTC_4x4,
  116. (int)TextureImporterFormat.ASTC_5x5,
  117. (int)TextureImporterFormat.ASTC_6x6,
  118. (int)TextureImporterFormat.ASTC_8x8,
  119. (int)TextureImporterFormat.ASTC_10x10,
  120. (int)TextureImporterFormat.ASTC_12x12,
  121. (int)TextureImporterFormat.RGB16,
  122. (int)TextureImporterFormat.RGB24,
  123. (int)TextureImporterFormat.Alpha8,
  124. (int)TextureImporterFormat.RGBA16,
  125. (int)TextureImporterFormat.RGBA32
  126. };
  127. static readonly int[] k_TextureFormatsValueSTV =
  128. {
  129. (int)TextureImporterFormat.ETC_RGB4,
  130. (int)TextureImporterFormat.RGB16,
  131. (int)TextureImporterFormat.RGB24,
  132. (int)TextureImporterFormat.Alpha8,
  133. (int)TextureImporterFormat.RGBA16,
  134. (int)TextureImporterFormat.RGBA32,
  135. };
  136. static readonly int[] k_TextureFormatsValueWebGL =
  137. {
  138. (int)TextureImporterFormat.DXT1,
  139. (int)TextureImporterFormat.DXT5,
  140. #if ENABLE_CRUNCH_TEXTURE_COMPRESSION
  141. (int)TextureImporterFormat.DXT1Crunched,
  142. (int)TextureImporterFormat.DXT5Crunched,
  143. #endif
  144. (int)TextureImporterFormat.RGB16,
  145. (int)TextureImporterFormat.RGB24,
  146. (int)TextureImporterFormat.Alpha8,
  147. (int)TextureImporterFormat.ARGB16,
  148. (int)TextureImporterFormat.RGBA32
  149. };
  150. public static readonly int[] kNormalFormatsValueDefault =
  151. {
  152. (int)TextureImporterFormat.BC5,
  153. (int)TextureImporterFormat.BC7,
  154. (int)TextureImporterFormat.DXT5,
  155. #if ENABLE_CRUNCH_TEXTURE_COMPRESSION
  156. (int)TextureImporterFormat.DXT5Crunched,
  157. #endif
  158. (int)TextureImporterFormat.ARGB16,
  159. (int)TextureImporterFormat.RGBA32,
  160. };
  161. static readonly int[] k_TextureFormatsValueDefault =
  162. {
  163. (int)TextureImporterFormat.DXT1,
  164. (int)TextureImporterFormat.DXT5,
  165. #if ENABLE_CRUNCH_TEXTURE_COMPRESSION
  166. (int)TextureImporterFormat.DXT1Crunched,
  167. (int)TextureImporterFormat.DXT5Crunched,
  168. #endif
  169. (int)TextureImporterFormat.RGB16,
  170. (int)TextureImporterFormat.RGB24,
  171. (int)TextureImporterFormat.Alpha8,
  172. (int)TextureImporterFormat.ARGB16,
  173. (int)TextureImporterFormat.RGBA32,
  174. (int)TextureImporterFormat.RGBAHalf,
  175. (int)TextureImporterFormat.BC4,
  176. (int)TextureImporterFormat.BC5,
  177. (int)TextureImporterFormat.BC6H,
  178. (int)TextureImporterFormat.BC7,
  179. };
  180. static readonly int[] k_TextureFormatsValueSingleChannel =
  181. {
  182. (int)TextureImporterFormat.Alpha8,
  183. (int)TextureImporterFormat.BC4,
  184. };
  185. static string[] s_TextureFormatStringsWebGL;
  186. static string[] s_TextureFormatStringsApplePVR;
  187. static string[] s_TextureFormatStringsAndroid;
  188. static string[] s_TextureFormatStringsSTV;
  189. static string[] s_TextureFormatStringsSingleChannel;
  190. static string[] s_TextureFormatStringsDefault;
  191. static TexturePlatformSettingsModal()
  192. {
  193. s_TextureFormatStringsApplePVR = BuildTextureStrings(k_TextureFormatsValueApplePVR);
  194. s_TextureFormatStringsAndroid = BuildTextureStrings(k_TextureFormatsValueAndroid);
  195. s_TextureFormatStringsSTV = BuildTextureStrings(k_TextureFormatsValueSTV);
  196. s_TextureFormatStringsWebGL = BuildTextureStrings(k_TextureFormatsValueWebGL);
  197. s_TextureFormatStringsDefault = BuildTextureStrings(k_TextureFormatsValueDefault);
  198. s_TextureFormatStringsSingleChannel = BuildTextureStrings(k_TextureFormatsValueSingleChannel);
  199. }
  200. static string[] BuildTextureStrings(int[] texFormatValues)
  201. {
  202. var retval = new string[texFormatValues.Length];
  203. for (var i = 0; i < texFormatValues.Length; i++)
  204. {
  205. var val = texFormatValues[i];
  206. retval[i] = GetTextureFormatString((TextureImporterFormat)val);
  207. }
  208. return retval;
  209. }
  210. static string GetTextureFormatString(TextureImporterFormat format)
  211. {
  212. switch (format)
  213. {
  214. case TextureImporterFormat.DXT1:
  215. return "RGB Crunched DTX1";
  216. case TextureImporterFormat.DXT5:
  217. return "RGB Crunched DTX5";
  218. case TextureImporterFormat.RGB16:
  219. return "RGB 16 bit";
  220. case TextureImporterFormat.RGB24:
  221. return "RGB 24 bit";
  222. case TextureImporterFormat.Alpha8:
  223. return "Alpha 8";
  224. case TextureImporterFormat.ARGB16:
  225. return "ARGB 16 bit";
  226. case TextureImporterFormat.RGBA32:
  227. return "RGBA 32 bit";
  228. case TextureImporterFormat.ARGB32:
  229. return "ARGB 32 bit";
  230. case TextureImporterFormat.RGBA16:
  231. return "RGBA 16 bit";
  232. case TextureImporterFormat.RGBAHalf:
  233. return "RGBA Half";
  234. case TextureImporterFormat.BC4:
  235. return "R Compressed BC4";
  236. case TextureImporterFormat.BC5:
  237. return "RG Compressed BC5";
  238. case TextureImporterFormat.BC6H:
  239. return "RGB HDR Compressed BC6H";
  240. case TextureImporterFormat.BC7:
  241. return "RGB(A) Compressed BC7";
  242. case TextureImporterFormat.PVRTC_RGB2:
  243. return "RGB Compressed PVRTC 2 bits";
  244. case TextureImporterFormat.PVRTC_RGBA2:
  245. return "RGBA Compressed PVRTC 2 bits";
  246. case TextureImporterFormat.PVRTC_RGB4:
  247. return "RGB Compressed PVRTC 4 bits";
  248. case TextureImporterFormat.PVRTC_RGBA4:
  249. return "RGBA Compressed PVRTC 4 bits";
  250. case TextureImporterFormat.ETC_RGB4:
  251. return "RGB Compressed ETC 4 bits";
  252. case TextureImporterFormat.EAC_R:
  253. return "11-bit R Compressed EAC 4 bit";
  254. case TextureImporterFormat.EAC_R_SIGNED:
  255. return "11-bit signed R Compressed EAC 4 bit";
  256. case TextureImporterFormat.EAC_RG:
  257. return "11-bit RG Compressed EAC 8 bit";
  258. case TextureImporterFormat.EAC_RG_SIGNED:
  259. return "11-bit signed RG Compressed EAC 8 bit";
  260. case TextureImporterFormat.ETC2_RGB4:
  261. return "RGB Compressed ETC2 4 bits";
  262. case TextureImporterFormat.ETC2_RGB4_PUNCHTHROUGH_ALPHA:
  263. return "RGB + 1-bit Alpha Compressed ETC2 4 bits";
  264. case TextureImporterFormat.ETC2_RGBA8:
  265. return "RGBA Compressed ETC2 8 bits";
  266. case TextureImporterFormat.ASTC_4x4:
  267. return "RGB(A) Compressed ASTC 4 x 4 block";
  268. case TextureImporterFormat.ASTC_5x5:
  269. return "RGB(A) Compressed ASTC 5 x 5 block";
  270. case TextureImporterFormat.ASTC_6x6:
  271. return "RGB(A) Compressed ASTC 6 x 6 block";
  272. case TextureImporterFormat.ASTC_8x8:
  273. return "RGB(A) Compressed ASTC 8 x 8 block";
  274. case TextureImporterFormat.ASTC_10x10:
  275. return "RGB(A) Compressed ASTC 10 x 10 block";
  276. case TextureImporterFormat.ASTC_12x12:
  277. return "RGB(A) Compressed ASTC 12 x 12 block";
  278. }
  279. return "Unsupported";
  280. }
  281. }
  282. }