暂无描述
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

TexturePlatformSettingsView.cs 7.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. using UnityEngine;
  2. namespace UnityEditor.U2D.PSD
  3. {
  4. internal class TexturePlatformSettingsView
  5. {
  6. class Styles
  7. {
  8. public readonly GUIContent textureFormatLabel = new GUIContent("Format");
  9. public readonly GUIContent maxTextureSizeLabel = new GUIContent("Max Texture Size", "Maximum size of the packed texture.");
  10. public readonly GUIContent compressionLabel = new GUIContent("Compression", "How will this texture be compressed?");
  11. public readonly GUIContent resizeAlgorithmLabel = new GUIContent("Resize", "Algorithm to use when resizing texture");
  12. public readonly GUIContent useCrunchedCompressionLabel = new GUIContent("Use Crunch Compression", "Texture is crunch-compressed to save space on disk when applicable.");
  13. public readonly GUIContent compressionQualityLabel = new GUIContent("Compressor Quality");
  14. public readonly GUIContent compressionQualitySliderLabel = new GUIContent("Compressor Quality", "Use the slider to adjust compression quality from 0 (Fastest) to 100 (Best)");
  15. public readonly int[] kMaxTextureSizeValues = { 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192 };
  16. public readonly GUIContent[] kMaxTextureSizeStrings;
  17. public readonly GUIContent[] kTextureCompressionOptions =
  18. {
  19. new GUIContent("None", "Texture is not compressed."),
  20. new GUIContent("Low Quality", "Texture compressed with low quality but high performance, high compression format."),
  21. new GUIContent("Normal Quality", "Texture is compressed with a standard format."),
  22. new GUIContent("High Quality", "Texture compressed with a high quality format."),
  23. };
  24. public readonly GUIContent[] kResizeAlgoritmOptions =
  25. {
  26. new GUIContent(TextureResizeAlgorithm.Mitchell.ToString()),
  27. new GUIContent(TextureResizeAlgorithm.Bilinear.ToString()),
  28. };
  29. public readonly int[] kTextureCompressionValues =
  30. {
  31. (int)TextureImporterCompression.Uncompressed,
  32. (int)TextureImporterCompression.CompressedLQ,
  33. (int)TextureImporterCompression.Compressed,
  34. (int)TextureImporterCompression.CompressedHQ
  35. };
  36. public readonly GUIContent[] kMobileCompressionQualityOptions =
  37. {
  38. new GUIContent("Fast"),
  39. new GUIContent("Normal"),
  40. new GUIContent("Best")
  41. };
  42. public Styles()
  43. {
  44. kMaxTextureSizeStrings = new GUIContent[kMaxTextureSizeValues.Length];
  45. for (var i = 0; i < kMaxTextureSizeValues.Length; ++i)
  46. kMaxTextureSizeStrings[i] = new GUIContent(string.Format("{0}", kMaxTextureSizeValues[i]));
  47. }
  48. }
  49. private static Styles s_Styles;
  50. public string buildPlatformTitle { get; set; }
  51. internal TexturePlatformSettingsView()
  52. {
  53. s_Styles = s_Styles ?? new Styles();
  54. }
  55. public virtual TextureResizeAlgorithm DrawResizeAlgorithm(TextureResizeAlgorithm defaultValue, bool isMixedValue, bool isDisabled, out bool changed)
  56. {
  57. using (new EditorGUI.DisabledScope(isDisabled))
  58. {
  59. EditorGUI.BeginChangeCheck();
  60. EditorGUI.showMixedValue = isMixedValue;
  61. defaultValue = (TextureResizeAlgorithm)EditorGUILayout.EnumPopup(s_Styles.resizeAlgorithmLabel, defaultValue);
  62. EditorGUI.showMixedValue = false;
  63. changed = EditorGUI.EndChangeCheck();
  64. }
  65. return defaultValue;
  66. }
  67. public virtual TextureImporterCompression DrawCompression(TextureImporterCompression defaultValue, bool isMixedValue, out bool changed)
  68. {
  69. EditorGUI.BeginChangeCheck();
  70. EditorGUI.showMixedValue = isMixedValue;
  71. defaultValue = (TextureImporterCompression)EditorGUILayout.IntPopup(s_Styles.compressionLabel, (int)defaultValue, s_Styles.kTextureCompressionOptions, s_Styles.kTextureCompressionValues);
  72. EditorGUI.showMixedValue = false;
  73. changed = EditorGUI.EndChangeCheck();
  74. return defaultValue;
  75. }
  76. public virtual bool DrawUseCrunchedCompression(bool defaultValue, bool isMixedValue, out bool changed)
  77. {
  78. EditorGUI.BeginChangeCheck();
  79. EditorGUI.showMixedValue = isMixedValue;
  80. defaultValue = EditorGUILayout.Toggle(s_Styles.useCrunchedCompressionLabel, defaultValue);
  81. EditorGUI.showMixedValue = false;
  82. changed = EditorGUI.EndChangeCheck();
  83. return defaultValue;
  84. }
  85. public virtual bool DrawOverride(bool defaultValue, bool isMixedValue, out bool changed)
  86. {
  87. EditorGUI.BeginChangeCheck();
  88. EditorGUI.showMixedValue = isMixedValue;
  89. defaultValue = EditorGUILayout.ToggleLeft(new GUIContent("Override"), defaultValue);
  90. EditorGUI.showMixedValue = false;
  91. changed = EditorGUI.EndChangeCheck();
  92. return defaultValue;
  93. }
  94. public virtual int DrawMaxSize(int defaultValue, bool isMixedValue, bool isDisabled, out bool changed)
  95. {
  96. using (new EditorGUI.DisabledScope(isDisabled))
  97. {
  98. EditorGUI.BeginChangeCheck();
  99. EditorGUI.showMixedValue = isMixedValue;
  100. defaultValue = EditorGUILayout.IntPopup(s_Styles.maxTextureSizeLabel, defaultValue, s_Styles.kMaxTextureSizeStrings, s_Styles.kMaxTextureSizeValues);
  101. EditorGUI.showMixedValue = false;
  102. changed = EditorGUI.EndChangeCheck();
  103. return defaultValue;
  104. }
  105. }
  106. public virtual TextureImporterFormat DrawFormat(TextureImporterFormat defaultValue, int[] displayValues, string[] displayStrings, bool isMixedValue, bool isDisabled, out bool changed)
  107. {
  108. using (new EditorGUI.DisabledScope(isDisabled))
  109. {
  110. EditorGUI.BeginChangeCheck();
  111. EditorGUI.showMixedValue = isMixedValue;
  112. defaultValue = (TextureImporterFormat)EditorGUILayout.IntPopup(s_Styles.textureFormatLabel.text, (int)defaultValue, displayStrings, displayValues);
  113. EditorGUI.showMixedValue = false;
  114. changed = EditorGUI.EndChangeCheck();
  115. return defaultValue;
  116. }
  117. }
  118. public virtual int DrawCompressionQualityPopup(int defaultValue, bool isMixedValue, out bool changed)
  119. {
  120. EditorGUI.BeginChangeCheck();
  121. EditorGUI.showMixedValue = isMixedValue;
  122. defaultValue = EditorGUILayout.Popup(s_Styles.compressionQualityLabel, defaultValue, s_Styles.kMobileCompressionQualityOptions);
  123. EditorGUI.showMixedValue = false;
  124. changed = EditorGUI.EndChangeCheck();
  125. return defaultValue;
  126. }
  127. public virtual int DrawCompressionQualitySlider(int defaultValue, bool isMixedValue, out bool changed)
  128. {
  129. EditorGUI.BeginChangeCheck();
  130. EditorGUI.showMixedValue = isMixedValue;
  131. defaultValue = EditorGUILayout.IntSlider(s_Styles.compressionQualitySliderLabel, defaultValue, 0, 100);
  132. EditorGUI.showMixedValue = false;
  133. changed = EditorGUI.EndChangeCheck();
  134. return defaultValue;
  135. }
  136. }
  137. }