暫無描述
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.

TexturePlatformSettingsModal.cs 16KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380
  1. namespace UnityEditor.U2D.PSD
  2. {
  3. internal static class TexturePlatformSettingsModal
  4. {
  5. public static readonly TextureImporterFormat[] kFormatsWithCompressionSettings =
  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. #if UNITY_2019_1_OR_NEWER
  18. TextureImporterFormat.ASTC_4x4,
  19. TextureImporterFormat.ASTC_5x5,
  20. TextureImporterFormat.ASTC_6x6,
  21. TextureImporterFormat.ASTC_8x8,
  22. TextureImporterFormat.ASTC_10x10,
  23. TextureImporterFormat.ASTC_12x12,
  24. #else
  25. TextureImporterFormat.ASTC_RGB_4x4,
  26. TextureImporterFormat.ASTC_RGB_5x5,
  27. TextureImporterFormat.ASTC_RGB_6x6,
  28. TextureImporterFormat.ASTC_RGB_8x8,
  29. TextureImporterFormat.ASTC_RGB_10x10,
  30. TextureImporterFormat.ASTC_RGB_12x12,
  31. TextureImporterFormat.ASTC_RGBA_4x4,
  32. TextureImporterFormat.ASTC_RGBA_5x5,
  33. TextureImporterFormat.ASTC_RGBA_6x6,
  34. TextureImporterFormat.ASTC_RGBA_8x8,
  35. TextureImporterFormat.ASTC_RGBA_10x10,
  36. TextureImporterFormat.ASTC_RGBA_12x12
  37. #endif
  38. };
  39. public struct BuildPlatformData
  40. {
  41. public string buildTargetName;
  42. public TextureImporterFormat defaultTextureFormat;
  43. public BuildTarget[] buildTarget;
  44. }
  45. // Add new platforms here
  46. public static readonly BuildPlatformData[] kValidBuildPlatform = new BuildPlatformData[]
  47. {
  48. new BuildPlatformData()
  49. {
  50. buildTargetName = "Default",
  51. defaultTextureFormat = TextureImporterFormat.Automatic,
  52. buildTarget = new[]
  53. {
  54. BuildTarget.NoTarget
  55. }
  56. },
  57. new BuildPlatformData()
  58. {
  59. buildTargetName = "PC, Mac & Linux Standalone",
  60. defaultTextureFormat = TextureImporterFormat.RGBA32,
  61. buildTarget = new[]
  62. {
  63. BuildTarget.StandaloneWindows,
  64. BuildTarget.StandaloneWindows64,
  65. BuildTarget.StandaloneLinux64,
  66. BuildTarget.StandaloneOSX,
  67. }
  68. },
  69. new BuildPlatformData()
  70. {
  71. buildTargetName = "iOS",
  72. defaultTextureFormat = TextureImporterFormat.RGBA32,
  73. buildTarget = new[] { BuildTarget.iOS }
  74. },
  75. new BuildPlatformData()
  76. {
  77. buildTargetName = "tvOS",
  78. defaultTextureFormat = TextureImporterFormat.RGBA32,
  79. buildTarget = new[] { BuildTarget.tvOS }
  80. },
  81. new BuildPlatformData()
  82. {
  83. buildTargetName = "Android",
  84. defaultTextureFormat = TextureImporterFormat.RGBA32,
  85. buildTarget = new[] { BuildTarget.Android }
  86. },
  87. new BuildPlatformData()
  88. {
  89. buildTargetName = "Universal Windows Platform",
  90. defaultTextureFormat = TextureImporterFormat.RGBA32,
  91. buildTarget = new[] { BuildTarget.WSAPlayer }
  92. },
  93. };
  94. public static readonly int[] kTextureFormatsValueApplePVR =
  95. {
  96. (int)TextureImporterFormat.PVRTC_RGB2,
  97. (int)TextureImporterFormat.PVRTC_RGBA2,
  98. (int)TextureImporterFormat.PVRTC_RGB4,
  99. (int)TextureImporterFormat.PVRTC_RGBA4,
  100. #if UNITY_2019_1_OR_NEWER
  101. (int)TextureImporterFormat.ASTC_4x4,
  102. (int)TextureImporterFormat.ASTC_5x5,
  103. (int)TextureImporterFormat.ASTC_6x6,
  104. (int)TextureImporterFormat.ASTC_8x8,
  105. (int)TextureImporterFormat.ASTC_10x10,
  106. (int)TextureImporterFormat.ASTC_12x12,
  107. #else
  108. (int)TextureImporterFormat.ASTC_RGB_4x4,
  109. (int)TextureImporterFormat.ASTC_RGB_5x5,
  110. (int)TextureImporterFormat.ASTC_RGB_6x6,
  111. (int)TextureImporterFormat.ASTC_RGB_8x8,
  112. (int)TextureImporterFormat.ASTC_RGB_10x10,
  113. (int)TextureImporterFormat.ASTC_RGB_12x12,
  114. (int)TextureImporterFormat.ASTC_RGBA_4x4,
  115. (int)TextureImporterFormat.ASTC_RGBA_5x5,
  116. (int)TextureImporterFormat.ASTC_RGBA_6x6,
  117. (int)TextureImporterFormat.ASTC_RGBA_8x8,
  118. (int)TextureImporterFormat.ASTC_RGBA_10x10,
  119. (int)TextureImporterFormat.ASTC_RGBA_12x12,
  120. #endif
  121. (int)TextureImporterFormat.RGB16,
  122. (int)TextureImporterFormat.RGB24,
  123. (int)TextureImporterFormat.Alpha8,
  124. (int)TextureImporterFormat.RGBA16,
  125. (int)TextureImporterFormat.RGBA32
  126. };
  127. public static readonly int[] kTextureFormatsValueAndroid =
  128. {
  129. (int)TextureImporterFormat.DXT1,
  130. (int)TextureImporterFormat.DXT5,
  131. #if ENABLE_CRUNCH_TEXTURE_COMPRESSION
  132. (int)TextureImporterFormat.DXT1Crunched,
  133. (int)TextureImporterFormat.DXT5Crunched,
  134. #endif
  135. (int)TextureImporterFormat.ETC_RGB4,
  136. (int)TextureImporterFormat.ETC2_RGB4,
  137. (int)TextureImporterFormat.ETC2_RGB4_PUNCHTHROUGH_ALPHA,
  138. (int)TextureImporterFormat.ETC2_RGBA8,
  139. (int)TextureImporterFormat.PVRTC_RGB2,
  140. (int)TextureImporterFormat.PVRTC_RGBA2,
  141. (int)TextureImporterFormat.PVRTC_RGB4,
  142. (int)TextureImporterFormat.PVRTC_RGBA4,
  143. (int)TextureImporterFormat.ETC_RGB4,
  144. (int)TextureImporterFormat.ETC2_RGBA8,
  145. #if UNITY_2019_1_OR_NEWER
  146. (int)TextureImporterFormat.ASTC_4x4,
  147. (int)TextureImporterFormat.ASTC_5x5,
  148. (int)TextureImporterFormat.ASTC_6x6,
  149. (int)TextureImporterFormat.ASTC_8x8,
  150. (int)TextureImporterFormat.ASTC_10x10,
  151. (int)TextureImporterFormat.ASTC_12x12,
  152. #else
  153. (int)TextureImporterFormat.ASTC_RGB_4x4,
  154. (int)TextureImporterFormat.ASTC_RGB_5x5,
  155. (int)TextureImporterFormat.ASTC_RGB_6x6,
  156. (int)TextureImporterFormat.ASTC_RGB_8x8,
  157. (int)TextureImporterFormat.ASTC_RGB_10x10,
  158. (int)TextureImporterFormat.ASTC_RGB_12x12,
  159. (int)TextureImporterFormat.ASTC_RGBA_4x4,
  160. (int)TextureImporterFormat.ASTC_RGBA_5x5,
  161. (int)TextureImporterFormat.ASTC_RGBA_6x6,
  162. (int)TextureImporterFormat.ASTC_RGBA_8x8,
  163. (int)TextureImporterFormat.ASTC_RGBA_10x10,
  164. (int)TextureImporterFormat.ASTC_RGBA_12x12,
  165. #endif
  166. (int)TextureImporterFormat.RGB16,
  167. (int)TextureImporterFormat.RGB24,
  168. (int)TextureImporterFormat.Alpha8,
  169. (int)TextureImporterFormat.RGBA16,
  170. (int)TextureImporterFormat.RGBA32
  171. };
  172. public static readonly int[] kTextureFormatsValueSTV =
  173. {
  174. (int)TextureImporterFormat.ETC_RGB4,
  175. (int)TextureImporterFormat.RGB16,
  176. (int)TextureImporterFormat.RGB24,
  177. (int)TextureImporterFormat.Alpha8,
  178. (int)TextureImporterFormat.RGBA16,
  179. (int)TextureImporterFormat.RGBA32,
  180. };
  181. public static readonly int[] kTextureFormatsValueWebGL =
  182. {
  183. (int)TextureImporterFormat.DXT1,
  184. (int)TextureImporterFormat.DXT5,
  185. #if ENABLE_CRUNCH_TEXTURE_COMPRESSION
  186. (int)TextureImporterFormat.DXT1Crunched,
  187. (int)TextureImporterFormat.DXT5Crunched,
  188. #endif
  189. (int)TextureImporterFormat.RGB16,
  190. (int)TextureImporterFormat.RGB24,
  191. (int)TextureImporterFormat.Alpha8,
  192. (int)TextureImporterFormat.ARGB16,
  193. (int)TextureImporterFormat.RGBA32
  194. };
  195. public static readonly int[] kNormalFormatsValueDefault =
  196. {
  197. (int)TextureImporterFormat.BC5,
  198. (int)TextureImporterFormat.BC7,
  199. (int)TextureImporterFormat.DXT5,
  200. #if ENABLE_CRUNCH_TEXTURE_COMPRESSION
  201. (int)TextureImporterFormat.DXT5Crunched,
  202. #endif
  203. (int)TextureImporterFormat.ARGB16,
  204. (int)TextureImporterFormat.RGBA32,
  205. };
  206. public static readonly int[] kTextureFormatsValueDefault =
  207. {
  208. (int)TextureImporterFormat.DXT1,
  209. (int)TextureImporterFormat.DXT5,
  210. #if ENABLE_CRUNCH_TEXTURE_COMPRESSION
  211. (int)TextureImporterFormat.DXT1Crunched,
  212. (int)TextureImporterFormat.DXT5Crunched,
  213. #endif
  214. (int)TextureImporterFormat.RGB16,
  215. (int)TextureImporterFormat.RGB24,
  216. (int)TextureImporterFormat.Alpha8,
  217. (int)TextureImporterFormat.ARGB16,
  218. (int)TextureImporterFormat.RGBA32,
  219. (int)TextureImporterFormat.RGBAHalf,
  220. (int)TextureImporterFormat.BC4,
  221. (int)TextureImporterFormat.BC5,
  222. (int)TextureImporterFormat.BC6H,
  223. (int)TextureImporterFormat.BC7,
  224. };
  225. public static readonly int[] kTextureFormatsValueSingleChannel =
  226. {
  227. (int)TextureImporterFormat.Alpha8,
  228. (int)TextureImporterFormat.BC4,
  229. };
  230. internal static string[] s_TextureFormatStringsWebGL;
  231. internal static string[] s_TextureFormatStringsApplePVR;
  232. internal static string[] s_TextureFormatStringsAndroid;
  233. internal static string[] s_TextureFormatStringsSTV;
  234. internal static string[] s_TextureFormatStringsSingleChannel;
  235. internal static string[] s_TextureFormatStringsDefault;
  236. static TexturePlatformSettingsModal()
  237. {
  238. s_TextureFormatStringsApplePVR = BuildTextureStrings(kTextureFormatsValueApplePVR);
  239. s_TextureFormatStringsAndroid = BuildTextureStrings(kTextureFormatsValueAndroid);
  240. s_TextureFormatStringsSTV = BuildTextureStrings(kTextureFormatsValueSTV);
  241. s_TextureFormatStringsWebGL = BuildTextureStrings(kTextureFormatsValueWebGL);
  242. s_TextureFormatStringsDefault = BuildTextureStrings(kTextureFormatsValueDefault);
  243. s_TextureFormatStringsSingleChannel = BuildTextureStrings(kTextureFormatsValueSingleChannel);
  244. }
  245. internal static string[] BuildTextureStrings(int[] texFormatValues)
  246. {
  247. string[] retval = new string[texFormatValues.Length];
  248. for (int i = 0; i < texFormatValues.Length; i++)
  249. {
  250. int val = texFormatValues[i];
  251. retval[i] = GetTextureFormatString((TextureImporterFormat)val);
  252. }
  253. return retval;
  254. }
  255. static string GetTextureFormatString(TextureImporterFormat format)
  256. {
  257. switch (format)
  258. {
  259. case TextureImporterFormat.DXT1:
  260. return "RGB Crunched DTX1";
  261. case TextureImporterFormat.DXT5:
  262. return "RGB Crunched DTX5";
  263. case TextureImporterFormat.RGB16:
  264. return "RGB 16 bit";
  265. case TextureImporterFormat.RGB24:
  266. return "RGB 24 bit";
  267. case TextureImporterFormat.Alpha8:
  268. return "Alpha 8";
  269. case TextureImporterFormat.ARGB16:
  270. return "ARGB 16 bit";
  271. case TextureImporterFormat.RGBA32:
  272. return "RGBA 32 bit";
  273. case TextureImporterFormat.ARGB32:
  274. return "ARGB 32 bit";
  275. case TextureImporterFormat.RGBA16:
  276. return "RGBA 16 bit";
  277. case TextureImporterFormat.RGBAHalf:
  278. return "RGBA Half";
  279. case TextureImporterFormat.BC4:
  280. return "R Compressed BC4";
  281. case TextureImporterFormat.BC5:
  282. return "RG Compressed BC5";
  283. case TextureImporterFormat.BC6H:
  284. return "RGB HDR Compressed BC6H";
  285. case TextureImporterFormat.BC7:
  286. return "RGB(A) Compressed BC7";
  287. case TextureImporterFormat.PVRTC_RGB2:
  288. return "RGB Compressed PVRTC 2 bits";
  289. case TextureImporterFormat.PVRTC_RGBA2:
  290. return "RGBA Compressed PVRTC 2 bits";
  291. case TextureImporterFormat.PVRTC_RGB4:
  292. return "RGB Compressed PVRTC 4 bits";
  293. case TextureImporterFormat.PVRTC_RGBA4:
  294. return "RGBA Compressed PVRTC 4 bits";
  295. case TextureImporterFormat.ETC_RGB4:
  296. return "RGB Compressed ETC 4 bits";
  297. case TextureImporterFormat.EAC_R:
  298. return "11-bit R Compressed EAC 4 bit";
  299. case TextureImporterFormat.EAC_R_SIGNED:
  300. return "11-bit signed R Compressed EAC 4 bit";
  301. case TextureImporterFormat.EAC_RG:
  302. return "11-bit RG Compressed EAC 8 bit";
  303. case TextureImporterFormat.EAC_RG_SIGNED:
  304. return "11-bit signed RG Compressed EAC 8 bit";
  305. case TextureImporterFormat.ETC2_RGB4:
  306. return "RGB Compressed ETC2 4 bits";
  307. case TextureImporterFormat.ETC2_RGB4_PUNCHTHROUGH_ALPHA:
  308. return "RGB + 1-bit Alpha Compressed ETC2 4 bits";
  309. case TextureImporterFormat.ETC2_RGBA8:
  310. return "RGBA Compressed ETC2 8 bits";
  311. #if UNITY_2019_1_OR_NEWER
  312. case TextureImporterFormat.ASTC_4x4:
  313. return "RGB(A) Compressed ASTC 4 x 4 block";
  314. case TextureImporterFormat.ASTC_5x5:
  315. return "RGB(A) Compressed ASTC 5 x 5 block";
  316. case TextureImporterFormat.ASTC_6x6:
  317. return "RGB(A) Compressed ASTC 6 x 6 block";
  318. case TextureImporterFormat.ASTC_8x8:
  319. return "RGB(A) Compressed ASTC 8 x 8 block";
  320. case TextureImporterFormat.ASTC_10x10:
  321. return "RGB(A) Compressed ASTC 10 x 10 block";
  322. case TextureImporterFormat.ASTC_12x12:
  323. return "RGB(A) Compressed ASTC 12 x 12 block";
  324. #else
  325. case TextureImporterFormat.ASTC_RGB_4x4:
  326. return "RGB Compressed ASTC 4 x 4 block";
  327. case TextureImporterFormat.ASTC_RGB_5x5:
  328. return "RGB Compressed ASTC 5 x 5 block";
  329. case TextureImporterFormat.ASTC_RGB_6x6:
  330. return "RGB Compressed ASTC 6 x 6 block";
  331. case TextureImporterFormat.ASTC_RGB_8x8:
  332. return "RGB Compressed ASTC 8 x 8 block";
  333. case TextureImporterFormat.ASTC_RGB_10x10:
  334. return "RGB Compressed ASTC 10 x 10 block";
  335. case TextureImporterFormat.ASTC_RGB_12x12:
  336. return "RGB Compressed ASTC 12 x 12 block";
  337. case TextureImporterFormat.ASTC_RGBA_4x4:
  338. return "RGBA Compressed ASTC 4 x 4 block";
  339. case TextureImporterFormat.ASTC_RGBA_5x5:
  340. return "RGBA Compressed ASTC 5 x 5 block";
  341. case TextureImporterFormat.ASTC_RGBA_6x6:
  342. return "RGBA Compressed ASTC 6 x 6 block";
  343. case TextureImporterFormat.ASTC_RGBA_8x8:
  344. return "RGBA Compressed ASTC 8 x 8 block";
  345. case TextureImporterFormat.ASTC_RGBA_10x10:
  346. return "RGBA Compressed ASTC 10 x 10 block";
  347. case TextureImporterFormat.ASTC_RGBA_12x12:
  348. return "RGBA Compressed ASTC 12 x 12 block";
  349. #endif
  350. }
  351. return "Unsupported";
  352. }
  353. }
  354. }