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

TextureSettingsGUI.cs 18KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383
  1. //using System;
  2. //using System.Collections;
  3. //using System.Collections.Generic;
  4. //using UnityEditor;
  5. //using UnityEngine;
  6. //namespace UnityEditor.U2D
  7. //{
  8. // public class TextureSettingsGUI
  9. // {
  10. // public SerializedProperty colorTexture;
  11. // public SerializedProperty readable;
  12. // public SerializedProperty npotScale;
  13. // public SerializedProperty filterMode;
  14. // public SerializedProperty aniso;
  15. // public SerializedProperty enablePostProcessor;
  16. // readonly int[] m_FilterModeOptions = (int[])(Enum.GetValues(typeof(FilterMode)));
  17. // public TextureSettingsGUI(SerializedProperty sp)
  18. // {
  19. // colorTexture = sp.FindPropertyRelative("m_ColorTexture");
  20. // readable = sp.FindPropertyRelative("m_Readable");
  21. // npotScale = sp.FindPropertyRelative("m_NPOTScale");
  22. // filterMode = sp.FindPropertyRelative("m_FilterMode");
  23. // aniso = sp.FindPropertyRelative("m_Aniso");
  24. // enablePostProcessor = sp.FindPropertyRelative("m_EnablePostProcessor");
  25. // }
  26. // public void OnInspectorGUI(bool isPOT, bool isNormalMap, bool hasMipMap, bool isCubeMap, bool hasMipmapFadeout)
  27. // {
  28. // TextureSettingsGUIUtils.ToggleFromInt(colorTexture, TextureSettingsGUIUtils.s_Styles.sRGBTexture);
  29. // TextureSettingsGUIUtils.ToggleFromInt(readable, TextureSettingsGUIUtils.s_Styles.readWrite);
  30. // using (new EditorGUI.DisabledScope(isPOT))
  31. // {
  32. // TextureSettingsGUIUtils.EnumPopup(npotScale, typeof(TextureImporterNPOTScale), TextureSettingsGUIUtils.s_Styles.npot);
  33. // }
  34. // EditorGUI.BeginChangeCheck();
  35. // // Filter mode
  36. // EditorGUI.showMixedValue = filterMode.hasMultipleDifferentValues;
  37. // FilterMode filter = (FilterMode)filterMode.intValue;
  38. // if ((int)filter == -1)
  39. // {
  40. // if (hasMipmapFadeout || isNormalMap)
  41. // filter = FilterMode.Trilinear;
  42. // else
  43. // filter = FilterMode.Bilinear;
  44. // }
  45. // filter = (FilterMode)EditorGUILayout.IntPopup(TextureSettingsGUIUtils.s_Styles.filterMode, (int)filter, TextureSettingsGUIUtils.s_Styles.filterModeOptions, m_FilterModeOptions);
  46. // EditorGUI.showMixedValue = false;
  47. // if (EditorGUI.EndChangeCheck())
  48. // filterMode.intValue = (int)filter;
  49. // // Aniso
  50. // bool showAniso = (FilterMode)filter != FilterMode.Point && hasMipMap && isCubeMap;
  51. // using (new EditorGUI.DisabledScope(!showAniso))
  52. // {
  53. // EditorGUI.BeginChangeCheck();
  54. // EditorGUI.showMixedValue = aniso.hasMultipleDifferentValues;
  55. // int anisoValue = aniso.intValue;
  56. // if (anisoValue == -1)
  57. // anisoValue = 1;
  58. // //aniso = EditorGUILayout.IntSlider("Aniso Level", aniso, 0, 16);
  59. // EditorGUI.showMixedValue = false;
  60. // if (EditorGUI.EndChangeCheck())
  61. // aniso.intValue = anisoValue;
  62. // if (anisoValue > 1)
  63. // {
  64. // if (QualitySettings.anisotropicFiltering == AnisotropicFiltering.Disable)
  65. // EditorGUILayout.HelpBox("Anisotropic filtering is disabled for all textures in Quality Settings.", MessageType.Info);
  66. // else if (QualitySettings.anisotropicFiltering == AnisotropicFiltering.ForceEnable)
  67. // EditorGUILayout.HelpBox("Anisotropic filtering is enabled for all textures in Quality Settings.", MessageType.Info);
  68. // }
  69. // }
  70. // }
  71. // }
  72. // public class TextureSpriteSettingsGUI
  73. // {
  74. // public SerializedProperty packingTag;
  75. // public SerializedProperty ppu;
  76. // public SerializedProperty meshType;
  77. // public SerializedProperty extrudeEdges;
  78. // public TextureSpriteSettingsGUI(SerializedProperty sp)
  79. // {
  80. // packingTag = sp.FindPropertyRelative("m_PackingTag");
  81. // ppu = sp.FindPropertyRelative("m_PixelsPerUnit");
  82. // meshType = sp.FindPropertyRelative("m_MeshType");
  83. // extrudeEdges = sp.FindPropertyRelative("m_ExtrudeEdges");
  84. // }
  85. // public void OnInspectorGUI()
  86. // {
  87. // //// Show generic attributes
  88. // //if (m_SpriteMode.intValue != 0)
  89. // //{
  90. // // EditorGUILayout.PropertyField(m_SpritePackingTag, s_Styles.spritePackingTag);
  91. // // EditorGUILayout.PropertyField(m_SpritePixelsToUnits, s_Styles.spritePixelsPerUnit);
  92. // // if (m_SpriteMode.intValue != (int)SpriteImportMode.Polygon && !m_SpriteMode.hasMultipleDifferentValues)
  93. // // {
  94. // // EditorGUILayout.IntPopup(m_SpriteMeshType, s_Styles.spriteMeshTypeOptions, new[] { 0, 1 }, s_Styles.spriteMeshType);
  95. // // }
  96. // // EditorGUILayout.EndFadeGroup();
  97. // // EditorGUILayout.IntSlider(m_SpriteExtrude, 0, 32, s_Styles.spriteExtrude);
  98. // // if (m_SpriteMode.intValue == 1)
  99. // // {
  100. // // EditorGUILayout.IntPopup(m_Alignment, s_Styles.spriteAlignmentOptions, new[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }, s_Styles.spriteAlignment);
  101. // // if (m_Alignment.intValue == (int)SpriteAlignment.Custom)
  102. // // {
  103. // // GUILayout.BeginHorizontal();
  104. // // EditorGUILayout.PropertyField(m_SpritePivot, new GUIContent());
  105. // // GUILayout.EndHorizontal();
  106. // // }
  107. // // }
  108. // //}
  109. // }
  110. // }
  111. // public class TextureWrapSettingsGUI
  112. // {
  113. // public SerializedProperty wrapMode;
  114. // public SerializedProperty wrapModeU;
  115. // public SerializedProperty wrapModeV;
  116. // public SerializedProperty wrapModeW;
  117. // public TextureWrapSettingsGUI(SerializedProperty sp)
  118. // {
  119. // wrapMode = sp.FindPropertyRelative("m_WrapMode");
  120. // wrapModeU = sp.FindPropertyRelative("m_WrapModeU");
  121. // wrapModeV = sp.FindPropertyRelative("m_WrapModeV");
  122. // wrapModeW = sp.FindPropertyRelative("m_WrapModeW");
  123. // }
  124. // public void OnInspectorGUI()
  125. // {
  126. // }
  127. // }
  128. // public class TextureAlphaSettingsGUI
  129. // {
  130. // public SerializedProperty tolerance;
  131. // public SerializedProperty source;
  132. // public TextureAlphaSettingsGUI(SerializedProperty sp)
  133. // {
  134. // tolerance = sp.FindPropertyRelative("m_AlphaTolerance");
  135. // source = sp.FindPropertyRelative("m_AlphaSource");
  136. // }
  137. // public void OnInspectorGUI()
  138. // {
  139. // }
  140. // }
  141. // public class TextureMipmapSettingsGUI
  142. // {
  143. // public SerializedProperty filter;
  144. // public SerializedProperty borderMipmap;
  145. // public SerializedProperty fadeout;
  146. // public SerializedProperty preserveCoverage;
  147. // public SerializedProperty fadeDistanceStart;
  148. // public SerializedProperty fadeDistanceEnd;
  149. // public TextureMipmapSettingsGUI(SerializedProperty sp)
  150. // {
  151. // filter = sp.FindPropertyRelative("m_Filter");
  152. // borderMipmap = sp.FindPropertyRelative("m_BorderMipmap");
  153. // fadeout = sp.FindPropertyRelative("m_Fadeout");
  154. // preserveCoverage = sp.FindPropertyRelative("m_PreserveCoverage");
  155. // fadeDistanceStart = sp.FindPropertyRelative("m_FadeDistanceStart");
  156. // fadeDistanceEnd = sp.FindPropertyRelative("m_FadeDistanceEnd");
  157. // }
  158. // public void OnInspectorGUI()
  159. // {
  160. // }
  161. // }
  162. // public class TextureNormalSettingsGUI
  163. // {
  164. // public SerializedProperty filter;
  165. // public SerializedProperty generateFromGrayScale;
  166. // public SerializedProperty bumpiness;
  167. // public TextureNormalSettingsGUI(SerializedProperty sp)
  168. // {
  169. // filter = sp.FindPropertyRelative("m_Filter");
  170. // generateFromGrayScale = sp.FindPropertyRelative("m_GenerateFromGrayScale");
  171. // bumpiness = sp.FindPropertyRelative("m_Bumpiness");
  172. // }
  173. // public void OnInspectorGUI()
  174. // {
  175. // }
  176. // }
  177. // public class TextureCubemapSettingsGUI
  178. // {
  179. // public SerializedProperty convolution;
  180. // public SerializedProperty mode;
  181. // public SerializedProperty seamless;
  182. // public TextureCubemapSettingsGUI(SerializedProperty sp)
  183. // {
  184. // convolution = sp.FindPropertyRelative("m_Convolution");
  185. // mode = sp.FindPropertyRelative("m_Mode");
  186. // seamless = sp.FindPropertyRelative("m_Seamless");
  187. // }
  188. // public void OnInspectorGUI()
  189. // {
  190. // }
  191. // }
  192. // static class TextureSettingsGUIUtils
  193. // {
  194. // public static void ToggleFromInt(SerializedProperty property, GUIContent label)
  195. // {
  196. // EditorGUI.BeginChangeCheck();
  197. // EditorGUI.showMixedValue = property.hasMultipleDifferentValues;
  198. // int value = EditorGUILayout.Toggle(label, property.intValue > 0) ? 1 : 0;
  199. // EditorGUI.showMixedValue = false;
  200. // if (EditorGUI.EndChangeCheck())
  201. // property.intValue = value;
  202. // }
  203. // public static void EnumPopup(SerializedProperty property, System.Type type, GUIContent label)
  204. // {
  205. // EditorGUILayout.IntPopup(label.text, property.intValue,
  206. // System.Enum.GetNames(type),
  207. // System.Enum.GetValues(type) as int[]);
  208. // }
  209. // internal class Styles
  210. // {
  211. // public readonly GUIContent textureTypeTitle = new GUIContent("Texture Type", "What will this texture be used for?");
  212. // public readonly GUIContent[] textureTypeOptions =
  213. // {
  214. // new GUIContent("Default", "Texture is a normal image such as a diffuse texture or other."),
  215. // new GUIContent("Sprite (2D and UI)", "Texture is used for a sprite."),
  216. // };
  217. // public readonly int[] textureTypeValues =
  218. // {
  219. // (int)TextureImporterType.Default,
  220. // (int)TextureImporterType.Sprite,
  221. // };
  222. // public readonly GUIContent textureShape = new GUIContent("Texture Shape", "What shape is this texture?");
  223. // private readonly GUIContent textureShape2D = new GUIContent("2D, Texture is 2D.");
  224. // private readonly GUIContent textureShapeCube = new GUIContent("Cube", "Texture is a Cubemap.");
  225. // public readonly Dictionary<TextureImporterShape, GUIContent[]> textureShapeOptionsDictionnary = new Dictionary<TextureImporterShape, GUIContent[]>();
  226. // public readonly Dictionary<TextureImporterShape, int[]> textureShapeValuesDictionnary = new Dictionary<TextureImporterShape, int[]>();
  227. // public readonly GUIContent filterMode = new GUIContent("Filter Mode");
  228. // public readonly GUIContent[] filterModeOptions =
  229. // {
  230. // new GUIContent("Point (no filter)"),
  231. // new GUIContent("Bilinear"),
  232. // new GUIContent("Trilinear")
  233. // };
  234. // public readonly GUIContent textureFormat = new GUIContent("Format");
  235. // public readonly GUIContent defaultPlatform = new GUIContent("Default");
  236. // public readonly GUIContent mipmapFadeOutToggle = new GUIContent("Fadeout Mip Maps");
  237. // public readonly GUIContent mipmapFadeOut = new GUIContent("Fade Range");
  238. // public readonly GUIContent readWrite = new GUIContent("Read/Write Enabled", "Enable to be able to access the raw pixel data from code.");
  239. // public readonly GUIContent alphaSource = new GUIContent("Alpha Source", "How is the alpha generated for the imported texture.");
  240. // public readonly GUIContent[] alphaSourceOptions =
  241. // {
  242. // new GUIContent("None", "No Alpha will be used."),
  243. // new GUIContent("Input Texture Alpha", "Use Alpha from the input texture if one is provided."),
  244. // new GUIContent("From Gray Scale", "Generate Alpha from image gray scale."),
  245. // };
  246. // public readonly int[] alphaSourceValues =
  247. // {
  248. // (int)TextureImporterAlphaSource.None,
  249. // (int)TextureImporterAlphaSource.FromInput,
  250. // (int)TextureImporterAlphaSource.FromGrayScale,
  251. // };
  252. // public readonly GUIContent generateMipMaps = new GUIContent("Generate Mip Maps");
  253. // public readonly GUIContent sRGBTexture = new GUIContent("sRGB (Color Texture)", "Texture content is stored in gamma space. Non-HDR color textures should enable this flag (except if used for IMGUI).");
  254. // public readonly GUIContent borderMipMaps = new GUIContent("Border Mip Maps");
  255. // public readonly GUIContent mipMapsPreserveCoverage = new GUIContent("Mip Maps Preserve Coverage", "The alpha channel of generated Mip Maps will preserve coverage during the alpha test.");
  256. // public readonly GUIContent alphaTestReferenceValue = new GUIContent("Alpha Cutoff Value", "The reference value used during the alpha test. Controls Mip Map coverage.");
  257. // public readonly GUIContent mipMapFilter = new GUIContent("Mip Map Filtering");
  258. // public readonly GUIContent[] mipMapFilterOptions =
  259. // {
  260. // new GUIContent("Box"),
  261. // new GUIContent("Kaiser"),
  262. // };
  263. // public readonly GUIContent npot = new GUIContent("Non Power of 2", "How non-power-of-two textures are scaled on import.");
  264. // public readonly GUIContent compressionQuality = new GUIContent("Compressor Quality");
  265. // public readonly GUIContent compressionQualitySlider = new GUIContent("Compressor Quality", "Use the slider to adjust compression quality from 0 (Fastest) to 100 (Best)");
  266. // public readonly GUIContent[] mobileCompressionQualityOptions =
  267. // {
  268. // new GUIContent("Fast"),
  269. // new GUIContent("Normal"),
  270. // new GUIContent("Best")
  271. // };
  272. // public readonly GUIContent spriteMode = new GUIContent("Sprite Mode");
  273. // public readonly GUIContent[] spriteModeOptions =
  274. // {
  275. // new GUIContent("Single"),
  276. // new GUIContent("Multiple"),
  277. // new GUIContent("Polygon"),
  278. // };
  279. // public readonly GUIContent[] spriteMeshTypeOptions =
  280. // {
  281. // new GUIContent("Full Rect"),
  282. // new GUIContent("Tight"),
  283. // };
  284. // public readonly GUIContent spritePackingTag = new GUIContent("Packing Tag", "Tag for the Sprite Packing system.");
  285. // public readonly GUIContent spritePixelsPerUnit = new GUIContent("Pixels Per Unit", "How many pixels in the sprite correspond to one unit in the world.");
  286. // public readonly GUIContent spriteExtrude = new GUIContent("Extrude Edges", "How much empty area to leave around the sprite in the generated mesh.");
  287. // public readonly GUIContent spriteMeshType = new GUIContent("Mesh Type", "Type of sprite mesh to generate.");
  288. // public readonly GUIContent spriteAlignment = new GUIContent("Pivot", "Sprite pivot point in its localspace. May be used for syncing animation frames of different sizes.");
  289. // public readonly GUIContent[] spriteAlignmentOptions =
  290. // {
  291. // new GUIContent("Center"),
  292. // new GUIContent("Top Left"),
  293. // new GUIContent("Top"),
  294. // new GUIContent("Top Right"),
  295. // new GUIContent("Left"),
  296. // new GUIContent("Right"),
  297. // new GUIContent("Bottom Left"),
  298. // new GUIContent("Bottom"),
  299. // new GUIContent("Bottom Right"),
  300. // new GUIContent("Custom"),
  301. // };
  302. // public readonly GUIContent alphaIsTransparency = new GUIContent("Alpha Is Transparency", "If the provided alpha channel is transparency, enable this to pre-filter the color to avoid texture filtering artifacts. This is not supported for HDR textures.");
  303. // public readonly GUIContent etc1Compression = new GUIContent("Compress using ETC1 (split alpha channel)|Alpha for this texture will be preserved by splitting the alpha channel to another texture, and both resulting textures will be compressed using ETC1.");
  304. // public readonly GUIContent crunchedCompression = new GUIContent("Use Crunch Compression", "Texture is crunch-compressed to save space on disk when applicable.");
  305. // public readonly GUIContent showAdvanced = new GUIContent("Advanced", "Show advanced settings.");
  306. // public Styles()
  307. // {
  308. // // This is far from ideal, but it's better than having tons of logic in the GUI code itself.
  309. // // The combination should not grow too much anyway since only Texture3D will be added later.
  310. // GUIContent[] s2D_Options = { textureShape2D };
  311. // GUIContent[] sCube_Options = { textureShapeCube };
  312. // GUIContent[] s2D_Cube_Options = { textureShape2D, textureShapeCube };
  313. // textureShapeOptionsDictionnary.Add(TextureImporterShape.Texture2D, s2D_Options);
  314. // textureShapeOptionsDictionnary.Add(TextureImporterShape.TextureCube, sCube_Options);
  315. // textureShapeOptionsDictionnary.Add(TextureImporterShape.Texture2D | TextureImporterShape.TextureCube, s2D_Cube_Options);
  316. // int[] s2D_Values = { (int)TextureImporterShape.Texture2D };
  317. // int[] sCube_Values = { (int)TextureImporterShape.TextureCube };
  318. // int[] s2D_Cube_Values = { (int)TextureImporterShape.Texture2D, (int)TextureImporterShape.TextureCube };
  319. // textureShapeValuesDictionnary.Add(TextureImporterShape.Texture2D, s2D_Values);
  320. // textureShapeValuesDictionnary.Add(TextureImporterShape.TextureCube, sCube_Values);
  321. // textureShapeValuesDictionnary.Add(TextureImporterShape.Texture2D | TextureImporterShape.TextureCube, s2D_Cube_Values);
  322. // }
  323. // }
  324. // internal static Styles s_Styles;
  325. // }
  326. //}