MegascansImporterWindow.cs 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699
  1. #if UNITY_EDITOR
  2. using UnityEditor;
  3. using UnityEngine;
  4. namespace Quixel
  5. {
  6. public class MegascansImporterWindow : EditorWindow
  7. {
  8. public static string version = "4.0";
  9. static private int texPack;
  10. static private int texPackUpdate;
  11. static private string[] texPacking = new string[] {
  12. "Metallic",
  13. "Specular",
  14. };
  15. static private int dispType;
  16. static private int dispTypeUpdate;
  17. static private string[] dispTypes = new string[] {
  18. "None",
  19. "Vertex",
  20. "Pixel",
  21. };
  22. static private int shaderType;
  23. static private int shaderTypeUpdate;
  24. static private string[] shaderTypes = new string[] {
  25. "HDRP",
  26. "URP (LWRP)",
  27. "Legacy",
  28. "Auto-Detect",
  29. };
  30. static private int importResolution;
  31. static private int importResolutionUpdate;
  32. static private string[] importResolutions = new string[] {
  33. "512",
  34. "1024",
  35. "2048",
  36. "4096",
  37. "8192",
  38. };
  39. static private int lodFadeMode;
  40. static private int lodFadeModeUpdate;
  41. static private string[] lodFadeModeSettings = new string[] {
  42. "None",
  43. "Cross Fade",
  44. "Speed Tree"
  45. };
  46. static private string path;
  47. static private string pathUpdate;
  48. static private Texture2D MSLogo;
  49. static private Texture2D BridgeLogo;
  50. static private Texture2D HelpLogo;
  51. static private GUIStyle MSLogoStyle;
  52. static private GUIStyle HelpLogoStyle;
  53. static private Texture2D MSBackground;
  54. static private GUIStyle MSField;
  55. static private GUIStyle MSPopup;
  56. static private GUIStyle MSText;
  57. static private GUIStyle MSCheckBox;
  58. static private GUIStyle MSHelpStyle;
  59. static private GUIStyle MSNormalTextStyle;
  60. static private GUIStyle MSWarningTextStyle;
  61. static private GUIStyle MSHeadingTextStyle;
  62. static private GUIStyle MSTabsStyle;
  63. static private GUIStyle MSStrechedWidthStyle;
  64. static private bool connection;
  65. static private bool connectionUpdate;
  66. static private bool setupCollision;
  67. static private bool applyToSelection;
  68. static private bool addAssetToScene;
  69. static private bool importLODs;
  70. static private bool setupLOD;
  71. static private bool setupPrefabs;
  72. static private bool setupCollisionUpdate;
  73. static private bool applyToSelectionUpdate;
  74. static private bool addAssetToSceneUpdate;
  75. static private bool importLODsUpdate;
  76. static private bool setupLODUpdate;
  77. static private bool setupPrefabsUpdate;
  78. static private bool importAllTextures;
  79. static private bool importAllTexturesUpdate;
  80. static private bool SuperHD;
  81. static private Vector2 size;
  82. static private Vector2 logoSize;
  83. static private Vector2 textSize;
  84. static private Vector2 textHeadingSize;
  85. static private Vector2 fieldSize;
  86. static private Rect collisionLoc;
  87. static private Rect applyToSelectionLoc;
  88. static private Rect addAssetToSceneLoc;
  89. static private Rect importLODsLoc;
  90. static private Rect setupLODLoc;
  91. static private Rect setupPrefabsLoc;
  92. static private Rect importAllTexturesLoc;
  93. static private Rect connectionLoc;
  94. static private float lineYLoc;
  95. //Decal Properties
  96. static private string decalBlend = "100";
  97. static private string decalSize = "1";
  98. //Decal Properties
  99. static private string decalBlendUpdate = "100";
  100. static private string decalSizeUpdate = "1";
  101. private int tab = 0;
  102. //Terrain tools properties
  103. static private string terrainMaterialName = "Terrain Material";
  104. static private string terrainMaterialPath = "Quixel/";
  105. static private string tiling = "10";
  106. static private string terrainMaterialNameUpdate = "Terrain Material";
  107. static private string terrainMaterialPathUpdate = "Quixel/";
  108. static private string tilingUpdate = "10";
  109. [MenuItem("Window/Quixel/Megascans Importer", false, 10)]
  110. public static void Init()
  111. {
  112. MegascansImporterWindow window = (MegascansImporterWindow)EditorWindow.GetWindow(typeof(MegascansImporterWindow));
  113. GUIContent header = new GUIContent();
  114. header.text = " Bridge Plugin v" + version;
  115. header.image = (Texture)MSLogo;
  116. header.tooltip = "Megascans Bridge Plugin.";
  117. window.titleContent = header;
  118. window.maxSize = size * 20f;
  119. window.minSize = size;
  120. window.Show();
  121. }
  122. void OnGUI()
  123. {
  124. GUI.DrawTexture(new Rect(0, 0, maxSize.x, maxSize.y), MSBackground, ScaleMode.StretchToFill);
  125. GUILayout.BeginHorizontal();
  126. GUILayout.Box("Bridge Plugin v" + version, MSHeadingTextStyle, GUILayout.Height(textHeadingSize.y));
  127. GUILayout.EndHorizontal();
  128. GUILayout.BeginHorizontal();
  129. if (GUILayout.Button(MSLogo, MSLogoStyle, GUILayout.Height(logoSize.y), GUILayout.Width(logoSize.x)))
  130. Application.OpenURL("https://quixel.com/megascans/library/latest");
  131. if (GUILayout.Button(BridgeLogo, MSLogoStyle, GUILayout.Height(logoSize.y), GUILayout.Width(logoSize.x)))
  132. Application.OpenURL("https://quixel.com/bridge");
  133. GUILayout.EndHorizontal();
  134. //GUILayout.BeginHorizontal();
  135. //tab = GUILayout.Toolbar(tab, new string[] { "Settings", "Utilities" }, MSTabsStyle, GUILayout.Height(textSize.y));
  136. //GUILayout.EndHorizontal();
  137. GUILayout.BeginHorizontal();
  138. Handles.color = Color.white;
  139. Handles.DrawLine(new Vector3(0f, lineYLoc), new Vector3(maxSize.x, lineYLoc));
  140. GUILayout.EndHorizontal();
  141. if (tab == 0)
  142. {
  143. GUILayout.BeginHorizontal();
  144. GUILayout.Label("Workflow", MSText, GUILayout.Height(textSize.y), GUILayout.Width(textSize.x));
  145. texPack = EditorGUILayout.Popup(texPack, texPacking, MSPopup, GUILayout.Height(fieldSize.y));
  146. GUILayout.EndHorizontal();
  147. GUILayout.BeginHorizontal();
  148. GUILayout.Label("Displacement", MSText, GUILayout.Height(textSize.y), GUILayout.Width(textSize.x));
  149. dispType = EditorGUILayout.Popup(dispType, dispTypes, MSPopup, GUILayout.Height(fieldSize.y));
  150. GUILayout.EndHorizontal();
  151. GUILayout.BeginHorizontal();
  152. GUILayout.Box("Shader Type", MSText, GUILayout.Height(textSize.y), GUILayout.Width(textSize.x));
  153. shaderType = EditorGUILayout.Popup(shaderType, shaderTypes, MSPopup, GUILayout.Height(fieldSize.y));
  154. GUILayout.EndHorizontal();
  155. GUILayout.BeginHorizontal();
  156. GUILayout.Box("Import Resolution", MSText, GUILayout.Height(textSize.y), GUILayout.Width(textSize.x));
  157. importResolution = EditorGUILayout.Popup(importResolution, importResolutions, MSPopup, GUILayout.Height(fieldSize.y));
  158. GUILayout.EndHorizontal();
  159. GUILayout.BeginHorizontal();
  160. GUILayout.Box("LOD Fade Mode", MSText, GUILayout.Height(textSize.y), GUILayout.Width(textSize.x));
  161. lodFadeMode = EditorGUILayout.Popup(lodFadeMode, lodFadeModeSettings, MSPopup, GUILayout.Height(fieldSize.y));
  162. GUILayout.EndHorizontal();
  163. GUILayout.BeginHorizontal();
  164. GUILayout.Box("Import Path", MSText, GUILayout.Height(textSize.y), GUILayout.Width(textSize.x));
  165. path = EditorGUILayout.TextField(path, MSField, GUILayout.Height(fieldSize.y));
  166. GUILayout.EndHorizontal();
  167. GUILayout.BeginHorizontal();
  168. setupCollision = EditorGUI.Toggle(collisionLoc, setupCollision, MSCheckBox);
  169. GUILayout.Box("Setup Collision", MSNormalTextStyle, GUILayout.Height(textSize.y), GUILayout.Width(textSize.x));
  170. GUILayout.EndHorizontal();
  171. GUILayout.BeginHorizontal();
  172. applyToSelection = EditorGUI.Toggle(applyToSelectionLoc, applyToSelection, MSCheckBox);
  173. GUILayout.Box("Apply To Selection (2D Surfaces)", MSNormalTextStyle, GUILayout.Height(textSize.y), GUILayout.Width(textSize.x));
  174. GUILayout.EndHorizontal();
  175. GUILayout.BeginHorizontal();
  176. addAssetToScene = EditorGUI.Toggle(addAssetToSceneLoc, addAssetToScene, MSCheckBox);
  177. GUILayout.Box("Add Asset to the Scene", MSNormalTextStyle, GUILayout.Height(textSize.y), GUILayout.Width(textSize.x));
  178. GUILayout.EndHorizontal();
  179. GUILayout.BeginHorizontal();
  180. setupPrefabs = EditorGUI.Toggle(setupPrefabsLoc, setupPrefabs, MSCheckBox);
  181. GUILayout.Box("Create Prefabs", MSNormalTextStyle, GUILayout.Height(textSize.y), GUILayout.Width(textSize.x));
  182. GUILayout.EndHorizontal();
  183. GUILayout.BeginHorizontal();
  184. importLODs = EditorGUI.Toggle(importLODsLoc, importLODs, MSCheckBox);
  185. GUILayout.Box("Import Lower LODs", MSNormalTextStyle, GUILayout.Height(textSize.y), GUILayout.Width(textSize.x));
  186. GUILayout.EndHorizontal();
  187. GUILayout.BeginHorizontal();
  188. setupLOD = EditorGUI.Toggle(setupLODLoc, setupLOD, MSCheckBox);
  189. GUILayout.Box("Create LOD Groups", MSNormalTextStyle, GUILayout.Height(textSize.y), GUILayout.Width(textSize.x));
  190. GUILayout.EndHorizontal();
  191. GUILayout.BeginHorizontal();
  192. importAllTextures = EditorGUI.Toggle(importAllTexturesLoc, importAllTextures, MSCheckBox);
  193. GUILayout.Box("Import All Textures", MSNormalTextStyle, GUILayout.Height(textSize.y), GUILayout.Width(textSize.x));
  194. GUILayout.EndHorizontal();
  195. GUILayout.BeginHorizontal();
  196. connection = EditorGUI.Toggle(connectionLoc, connection, MSCheckBox);
  197. GUILayout.Box("Enable Plugin", MSNormalTextStyle, GUILayout.Height(textSize.y));
  198. if (GUILayout.Button("Help...", MSHelpStyle, GUILayout.Width(textSize.x)))
  199. Application.OpenURL("https://docs.google.com/document/d/1XeK2nlkO6NSm34IBYJT8Kon0IxzGwCIv-tACs8i_X58");
  200. GUILayout.EndHorizontal();
  201. }
  202. else
  203. {
  204. /*
  205. #if (UNITY_2018 || UNITY_2019 || UNITY_2020 || UNITY_2021)
  206. GUILayout.BeginHorizontal();
  207. GUILayout.Box("Terrain Tools (Beta)", MSHeadingTextStyle, GUILayout.Height(textHeadingSize.y));
  208. GUILayout.EndHorizontal();
  209. if (MegascansUtilities.isLegacy())
  210. {
  211. GUILayout.BeginHorizontal();
  212. GUILayout.Box("Material Name", MSText, GUILayout.Height(textSize.y), GUILayout.Width(textSize.x));
  213. terrainMaterialName = EditorGUILayout.TextField(terrainMaterialName, MSField, GUILayout.Height(fieldSize.y), GUILayout.Width(fieldSize.x));
  214. GUILayout.EndHorizontal();
  215. GUILayout.BeginHorizontal();
  216. GUILayout.Box("Material Path", MSText, GUILayout.Height(textSize.y), GUILayout.Width(textSize.x));
  217. terrainMaterialPath = EditorGUILayout.TextField(terrainMaterialPath, MSField, GUILayout.Height(fieldSize.y), GUILayout.Width(fieldSize.x));
  218. GUILayout.EndHorizontal();
  219. }
  220. GUILayout.BeginHorizontal();
  221. GUILayout.Box("Texture Tiling", MSText, GUILayout.Height(textSize.y), GUILayout.Width(textSize.x));
  222. tiling = EditorGUILayout.TextField(tiling, MSField, GUILayout.Height(fieldSize.y));
  223. GUILayout.EndHorizontal();
  224. GUILayout.BeginHorizontal();
  225. if (GUILayout.Button("Setup Paint Layers", MSStrechedWidthStyle, GUILayout.Height(textSize.y)))
  226. MegascansTerrainTools.SetupTerrain();
  227. GUILayout.EndHorizontal();
  228. GUILayout.BeginHorizontal();
  229. string warningMsg = "Warning: This feature works properly with the metallic workflow only.";
  230. if (MegascansUtilities.isLegacy())
  231. warningMsg += "This feature requires HD Render Pipeline.";
  232. GUI.skin.label.wordWrap = true;
  233. GUILayout.Label(warningMsg, MSWarningTextStyle, GUILayout.Height(textSize.y));
  234. GUILayout.EndHorizontal();
  235. #endif
  236. #if (UNITY_2018_3 || UNITY_2018_4 || UNITY_2019 || UNITY_2020 || UNITY_2021)
  237. GUILayout.BeginHorizontal();
  238. GUILayout.Box("Material Tools (Beta)", MSHeadingTextStyle, GUILayout.Height(textHeadingSize.y));
  239. GUILayout.EndHorizontal();
  240. GUILayout.BeginHorizontal();
  241. if (GUILayout.Button("Create Terrain Paint Layer", MSStrechedWidthStyle, GUILayout.Height(textSize.y)))
  242. MegascansTerrainTools.CreateTerrainLayerFromMat();
  243. GUILayout.EndHorizontal();
  244. #endif
  245. #if HDRP && (UNITY_2018_2 || UNITY_2018_3 || UNITY_2018_4 || UNITY_2019 || UNITY_2020 || UNITY_2021)
  246. GUILayout.BeginHorizontal ();
  247. GUILayout.Box ("Decal Setup (Beta)", MSHeadingTextStyle, GUILayout.Height(textHeadingSize.y));
  248. GUILayout.EndHorizontal ();
  249. GUILayout.BeginHorizontal ();
  250. GUILayout.Box ("Global Opacity (%)", MSText, GUILayout.Height (textSize.y), GUILayout.Width (textSize.x));
  251. decalBlend = EditorGUILayout.TextField (decalBlend, MSField, GUILayout.Height(fieldSize.y));
  252. GUILayout.EndHorizontal ();
  253. if (!MegascansUtilities.isLegacy ()) {
  254. GUILayout.BeginHorizontal ();
  255. GUILayout.Box ("Scale", MSText, GUILayout.Height (textSize.y), GUILayout.Width (textSize.x));
  256. decalSize = EditorGUILayout.TextField (decalSize, MSField, GUILayout.Height(fieldSize.y));
  257. GUILayout.EndHorizontal ();
  258. }
  259. GUILayout.BeginHorizontal ();
  260. if (GUILayout.Button ("Create Decal Projector", MSStrechedWidthStyle, GUILayout.Height (textSize.y)))
  261. MegascansDecalTools.SetupDecalProjector ();
  262. GUILayout.EndHorizontal ();
  263. #endif
  264. */
  265. }
  266. if (!MSLogo)
  267. {
  268. InitStyle();
  269. Repaint();
  270. }
  271. }
  272. void OnEnable()
  273. {
  274. SuperHD = (Display.main.systemHeight > 1500);
  275. size = SuperHD ? new Vector2(750, 1400) : new Vector2(308, 796);
  276. textSize = SuperHD ? new Vector2(200, 54) : new Vector2(100, 30);
  277. textHeadingSize = SuperHD ? new Vector2(555, 64) : new Vector2(308, 40);
  278. fieldSize = SuperHD ? new Vector2(290, 54) : new Vector2(152, 30);
  279. collisionLoc = SuperHD ? new Rect(25, 632, 32, 32) : new Rect(13, 340, 17, 17);
  280. applyToSelectionLoc = SuperHD ? new Rect(25, 715, 32, 32) : new Rect(13, 384, 17, 17);
  281. addAssetToSceneLoc = SuperHD ? new Rect(25, 794, 32, 32) : new Rect(13, 427, 17, 17);
  282. setupPrefabsLoc = SuperHD ? new Rect(25, 875, 32, 32) : new Rect(13, 470, 17, 17);
  283. importLODsLoc = SuperHD ? new Rect(25, 957, 32, 32) : new Rect(13, 513, 17, 17);
  284. setupLODLoc = SuperHD ? new Rect(25, 1038, 32, 32) : new Rect(13, 556, 17, 17);
  285. importAllTexturesLoc = SuperHD ? new Rect(25, 1118, 32, 32) : new Rect(13, 599, 17, 17);
  286. connectionLoc = SuperHD ? new Rect(25, 1199, 32, 32) : new Rect(13, 642, 17, 17);
  287. lineYLoc = SuperHD ? 185f : 102f;
  288. logoSize = SuperHD ? new Vector2(64, 64) : new Vector2(34, 34);
  289. InitStyle();
  290. GetDefaults();
  291. Repaint();
  292. }
  293. //If the values dont exist in editor prefs they are replaced with the default values.
  294. internal static void GetDefaults()
  295. {
  296. path = EditorPrefs.GetString("QuixelDefaultPath", "Quixel/Megascans/");
  297. dispType = EditorPrefs.GetInt("QuixelDefaultDisplacement", 0);
  298. texPack = EditorPrefs.GetInt("QuixelDefaultTexPacking", 0);
  299. shaderType = EditorPrefs.GetInt("QuixelDefaultShader", 3);
  300. importResolution = EditorPrefs.GetInt("QuixelDefaultImportResolution", 4);
  301. lodFadeMode = EditorPrefs.GetInt("QuixelDefaultLodFadeMode", 1);
  302. connection = EditorPrefs.GetBool("QuixelDefaultConnection", true);
  303. setupCollision = EditorPrefs.GetBool("QuixelDefaultSetupCollision", true);
  304. applyToSelection = EditorPrefs.GetBool("QuixelDefaultApplyToSelection", false);
  305. addAssetToScene = EditorPrefs.GetBool("QuixelDefaultAddAssetToScene", false);
  306. importLODs = EditorPrefs.GetBool("QuixelDefaultImportLODs", true);
  307. setupLOD = EditorPrefs.GetBool("QuixelDefaultSetupLOD", true);
  308. setupPrefabs = EditorPrefs.GetBool("QuixelDefaultSetupPrefabs", true);
  309. importAllTextures = EditorPrefs.GetBool("QuixelDefaultImportAllTextures", false);
  310. decalBlend = EditorPrefs.GetString("QuixelDefaultDecalBlend", "100");
  311. decalSize = EditorPrefs.GetString("QuixelDefaultDecalSize", "1");
  312. terrainMaterialName = EditorPrefs.GetString("QuixelDefaultMaterialName", "Terrain Material");
  313. terrainMaterialPath = EditorPrefs.GetString("QuixelDefaultMaterialPath", "Quixel/");
  314. tiling = EditorPrefs.GetString("QuixelDefaultTiling", "10");
  315. pathUpdate = path;
  316. dispTypeUpdate = dispType;
  317. texPackUpdate = texPack;
  318. shaderTypeUpdate = shaderType;
  319. connectionUpdate = connection;
  320. setupCollisionUpdate = setupCollision;
  321. applyToSelectionUpdate = applyToSelection;
  322. addAssetToSceneUpdate = addAssetToScene;
  323. setupPrefabsUpdate = setupPrefabs;
  324. importLODsUpdate = importLODs;
  325. setupLODUpdate = setupLOD;
  326. importResolutionUpdate = importResolution;
  327. lodFadeModeUpdate = lodFadeMode;
  328. importAllTexturesUpdate = importAllTextures;
  329. //Decal Properties
  330. decalBlendUpdate = decalBlend;
  331. decalSizeUpdate = decalSize;
  332. //Terrain tool properties
  333. terrainMaterialNameUpdate = terrainMaterialName;
  334. terrainMaterialPathUpdate = terrainMaterialPath;
  335. tilingUpdate = tiling;
  336. if (connection)
  337. MegascansBridgeLink.ToggleServer();
  338. }
  339. static void SaveDefaults()
  340. {
  341. if (connection != connectionUpdate)
  342. {
  343. connectionUpdate = connection;
  344. MegascansBridgeLink.ToggleServer(connection);
  345. }
  346. EditorPrefs.SetString("QuixelDefaultPath", path);
  347. EditorPrefs.SetInt("QuixelDefaultDisplacement", dispType);
  348. EditorPrefs.SetInt("QuixelDefaultTexPacking", texPack);
  349. EditorPrefs.SetInt("QuixelDefaultShader", shaderType);
  350. EditorPrefs.SetBool("QuixelDefaultConnection", connection);
  351. EditorPrefs.SetBool("QuixelDefaultSetupCollision", setupCollision);
  352. EditorPrefs.SetBool("QuixelDefaultApplyToSelection", applyToSelection);
  353. EditorPrefs.SetBool("QuixelDefaultAddAssetToScene", addAssetToScene);
  354. EditorPrefs.SetBool("QuixelDefaultImportLODs", importLODs);
  355. EditorPrefs.SetBool("QuixelDefaultSetupLOD", setupLOD);
  356. EditorPrefs.SetBool("QuixelDefaultSetupPrefabs", setupPrefabs);
  357. EditorPrefs.SetInt("QuixelDefaultImportResolution", importResolution);
  358. EditorPrefs.SetInt("QuixelDefaultLodFadeMode", lodFadeMode);
  359. EditorPrefs.SetBool("QuixelDefaultImportAllTextures", importAllTextures);
  360. pathUpdate = path;
  361. dispTypeUpdate = dispType;
  362. texPackUpdate = texPack;
  363. shaderTypeUpdate = shaderType;
  364. importResolutionUpdate = importResolution;
  365. setupCollisionUpdate = setupCollision;
  366. applyToSelectionUpdate = applyToSelection;
  367. addAssetToSceneUpdate = addAssetToScene;
  368. setupPrefabsUpdate = setupPrefabs;
  369. importLODsUpdate = importLODs;
  370. setupLODUpdate = setupLOD;
  371. lodFadeModeUpdate = lodFadeMode;
  372. importAllTexturesUpdate = importAllTextures;
  373. //Decal Properties
  374. EditorPrefs.SetString("QuixelDefaultDecalBlend", decalBlend);
  375. EditorPrefs.SetString("QuixelDefaultDecalSize", decalSize);
  376. decalBlendUpdate = decalBlend;
  377. decalSizeUpdate = decalSize;
  378. //Terrain tool properties
  379. EditorPrefs.SetString("QuixelDefaultMaterialName", terrainMaterialName);
  380. EditorPrefs.SetString("QuixelDefaultMaterialPath", terrainMaterialPath);
  381. EditorPrefs.SetString("QuixelDefaultTiling", tiling);
  382. terrainMaterialNameUpdate = terrainMaterialName;
  383. terrainMaterialPathUpdate = terrainMaterialPath;
  384. tilingUpdate = tiling;
  385. }
  386. void ConstructPopUp()
  387. {
  388. MSPopup = new GUIStyle();
  389. MSPopup.normal.textColor = new Color(1.0f, 1.0f, 1.0f);
  390. MSPopup.normal.background = AssetDatabase.LoadAssetAtPath<Texture2D>("Assets/Quixel/Scripts/Images/Text_Background.png");
  391. MSPopup.font = AssetDatabase.LoadAssetAtPath<Font>("Assets/Quixel/Scripts/Fonts/SourceSansPro-Regular.ttf");
  392. MSPopup.fontSize = SuperHD ? 24 : 13;
  393. MSPopup.padding = SuperHD ? new RectOffset(20, 0, 10, 0) : new RectOffset(10, 5, 7, 4);
  394. MSPopup.margin = SuperHD ? new RectOffset(0, 20, 13, 7) : new RectOffset(0, 10, 6, 5);
  395. //MSPopup.
  396. }
  397. void ConstructText()
  398. {
  399. MSText = new GUIStyle();
  400. MSText.normal.textColor = new Color(0.4f, 0.4f, 0.4f);
  401. MSText.font = AssetDatabase.LoadAssetAtPath<Font>("Assets/Quixel/Scripts/Fonts/SourceSansPro-Regular.ttf");
  402. MSText.fontSize = SuperHD ? 24 : 13;
  403. MSText.padding = SuperHD ? new RectOffset(5, 0, 10, 0) : new RectOffset(5, 5, 7, 4);
  404. MSText.margin = SuperHD ? new RectOffset(20, 0, 13, 7) : new RectOffset(10, 20, 6, 5);
  405. }
  406. void ConstructBackground()
  407. {
  408. MSBackground = AssetDatabase.LoadAssetAtPath<Texture2D>("Assets/Quixel/Scripts/Images/Background.png");
  409. }
  410. void ConstructLogo()
  411. {
  412. MSLogo = AssetDatabase.LoadAssetAtPath<Texture2D>("Assets/Quixel/Scripts/Images/M.png");
  413. BridgeLogo = AssetDatabase.LoadAssetAtPath<Texture2D>("Assets/Quixel/Scripts/Images/B.png");
  414. MSLogoStyle = new GUIStyle();
  415. MSLogoStyle.margin = SuperHD ? new RectOffset(25, 0, 27, 33) : new RectOffset(15, 0, 15, 15);
  416. }
  417. void ConstructField()
  418. {
  419. MSField = new GUIStyle();
  420. MSField.normal.textColor = new Color(1.0f, 1.0f, 1.0f);
  421. MSField.normal.background = AssetDatabase.LoadAssetAtPath<Texture2D>("Assets/Quixel/Scripts/Images/Field_Background.png");
  422. MSField.font = AssetDatabase.LoadAssetAtPath<Font>("Assets/Quixel/Scripts/Fonts/SourceSansPro-Regular.ttf");
  423. MSField.clipping = TextClipping.Clip;
  424. MSField.fontSize = SuperHD ? 24 : 13;
  425. MSField.padding = SuperHD ? new RectOffset(20, 0, 10, 0) : new RectOffset(10, 5, 7, 4);
  426. MSField.margin = SuperHD ? new RectOffset(0, 20, 13, 7) : new RectOffset(0, 10, 6, 5);
  427. }
  428. void ConstructCheckBox()
  429. {
  430. MSCheckBox = new GUIStyle();
  431. MSCheckBox.normal.background = AssetDatabase.LoadAssetAtPath<Texture2D>("Assets/Quixel/Scripts/Images/CheckBoxOff.png");
  432. MSCheckBox.hover.background = AssetDatabase.LoadAssetAtPath<Texture2D>("Assets/Quixel/Scripts/Images/CheckBoxHover.png");
  433. MSCheckBox.onNormal.background = AssetDatabase.LoadAssetAtPath<Texture2D>("Assets/Quixel/Scripts/Images/CheckBoxOn.png");
  434. }
  435. void ConstructHelp()
  436. {
  437. MSHelpStyle = new GUIStyle();
  438. MSHelpStyle.normal.background = AssetDatabase.LoadAssetAtPath<Texture2D>("Assets/Quixel/Scripts/Images/Help.png");
  439. MSHelpStyle.font = AssetDatabase.LoadAssetAtPath<Font>("Assets/Quixel/Scripts/Fonts/SourceSansPro-Regular.ttf");
  440. MSHelpStyle.margin = SuperHD ? new RectOffset(152, 20, 35, 15) : new RectOffset(102, 0, 16, 5);
  441. MSHelpStyle.padding = SuperHD ? new RectOffset(20, 20, 10, 10) : new RectOffset(10, 10, 5, 5);
  442. MSHelpStyle.fontSize = SuperHD ? 24 : 12;
  443. MSHelpStyle.normal.textColor = new Color(0.16796875f, 0.59375f, 0.9375f);
  444. }
  445. void ConstructNormalText()
  446. {
  447. MSNormalTextStyle = new GUIStyle();
  448. MSNormalTextStyle.normal.textColor = new Color(1.0f, 1.0f, 1.0f);
  449. MSNormalTextStyle.font = AssetDatabase.LoadAssetAtPath<Font>("Assets/Quixel/Scripts/Fonts/SourceSansPro-Regular.ttf");
  450. MSNormalTextStyle.fontSize = SuperHD ? 24 : 13;
  451. MSNormalTextStyle.padding = SuperHD ? new RectOffset(5, 0, 15, 15) : new RectOffset(5, 5, 7, 4);
  452. MSNormalTextStyle.margin = SuperHD ? new RectOffset(72, 0, 27, 10) : new RectOffset(37, 20, 13, 5);
  453. }
  454. void ConstructWarningText()
  455. {
  456. MSWarningTextStyle = new GUIStyle();
  457. MSWarningTextStyle.normal.textColor = new Color(1.0f, 1.0f, 0.0f);
  458. MSWarningTextStyle.font = AssetDatabase.LoadAssetAtPath<Font>("Assets/Quixel/Scripts/Fonts/SourceSansPro-Regular.ttf");
  459. MSWarningTextStyle.fontSize = SuperHD ? 24 : 13;
  460. MSWarningTextStyle.padding = SuperHD ? new RectOffset(5, 0, 15, 15) : new RectOffset(5, 5, 7, 4);
  461. MSWarningTextStyle.margin = SuperHD ? new RectOffset(10, 0, 27, 10) : new RectOffset(10, 0, 13, 5);
  462. MSWarningTextStyle.wordWrap = true;
  463. }
  464. void ConstructHeadingText()
  465. {
  466. MSHeadingTextStyle = new GUIStyle();
  467. MSHeadingTextStyle.normal.textColor = new Color(1.0f, 1.0f, 1.0f);
  468. MSHeadingTextStyle.font = AssetDatabase.LoadAssetAtPath<Font>("Assets/Quixel/Scripts/Fonts/SourceSansPro-Regular.ttf");
  469. MSHeadingTextStyle.fontSize = SuperHD ? 30 : 16;
  470. MSHeadingTextStyle.alignment = TextAnchor.MiddleCenter;
  471. }
  472. void ContrauctTabs()
  473. {
  474. MSTabsStyle = new GUIStyle();
  475. MSTabsStyle.font = AssetDatabase.LoadAssetAtPath<Font>("Assets/Quixel/Scripts/Fonts/SourceSansPro-Regular.ttf");
  476. MSTabsStyle.normal.background = AssetDatabase.LoadAssetAtPath<Texture2D>("Assets/Quixel/Scripts/Images/Text_Background.png");
  477. MSTabsStyle.hover.background = AssetDatabase.LoadAssetAtPath<Texture2D>("Assets/Quixel/Scripts/Images/Field_Background.png");
  478. MSTabsStyle.hover.textColor = new Color(1.0f, 1.0f, 1.0f);
  479. MSTabsStyle.active.background = AssetDatabase.LoadAssetAtPath<Texture2D>("Assets/Quixel/Scripts/Images/Field_Background.png");
  480. MSTabsStyle.active.textColor = new Color(0.5f, 0.5f, 0.5f);
  481. MSTabsStyle.fontSize = SuperHD ? 26 : 15;
  482. MSTabsStyle.normal.textColor = new Color(1.0f, 1.0f, 1.0f);
  483. MSTabsStyle.margin = new RectOffset(5, 5, 10, 10);
  484. MSTabsStyle.alignment = TextAnchor.MiddleCenter;
  485. }
  486. void ContrauctStrechedWidth()
  487. {
  488. MSStrechedWidthStyle = new GUIStyle();
  489. MSStrechedWidthStyle.font = AssetDatabase.LoadAssetAtPath<Font>("Assets/Quixel/Scripts/Fonts/SourceSansPro-Regular.ttf");
  490. MSStrechedWidthStyle.normal.background = AssetDatabase.LoadAssetAtPath<Texture2D>("Assets/Quixel/Scripts/Images/Text_Background.png");
  491. MSStrechedWidthStyle.hover.background = AssetDatabase.LoadAssetAtPath<Texture2D>("Assets/Quixel/Scripts/Images/Field_Background.png");
  492. MSStrechedWidthStyle.hover.textColor = new Color(1.0f, 1.0f, 1.0f);
  493. MSStrechedWidthStyle.active.background = AssetDatabase.LoadAssetAtPath<Texture2D>("Assets/Quixel/Scripts/Images/Field_Background.png");
  494. MSStrechedWidthStyle.active.textColor = new Color(0.5f, 0.5f, 0.5f);
  495. MSStrechedWidthStyle.fontSize = SuperHD ? 26 : 15;
  496. MSStrechedWidthStyle.normal.textColor = new Color(1.0f, 1.0f, 1.0f);
  497. MSStrechedWidthStyle.margin = new RectOffset(0, 0, 10, 10);
  498. MSStrechedWidthStyle.alignment = TextAnchor.MiddleCenter;
  499. }
  500. void InitStyle()
  501. {
  502. ConstructBackground();
  503. ConstructLogo();
  504. ConstructPopUp();
  505. ConstructText();
  506. ConstructField();
  507. ConstructCheckBox();
  508. ConstructHelp();
  509. ConstructNormalText();
  510. ConstructWarningText();
  511. ConstructHeadingText();
  512. ContrauctTabs();
  513. ContrauctStrechedWidth();
  514. }
  515. private void Update()
  516. {
  517. if (
  518. (dispType != dispTypeUpdate) ||
  519. (shaderType != shaderTypeUpdate) ||
  520. (texPack != texPackUpdate) ||
  521. (path != pathUpdate) ||
  522. (connection != connectionUpdate) ||
  523. (importResolution != importResolutionUpdate) ||
  524. (lodFadeMode != lodFadeModeUpdate) ||
  525. (setupCollision != setupCollisionUpdate) ||
  526. (applyToSelection != applyToSelectionUpdate) ||
  527. (addAssetToScene != addAssetToSceneUpdate) ||
  528. (importLODs != importLODsUpdate) ||
  529. (setupLOD != setupLODUpdate) ||
  530. (setupPrefabs != setupPrefabsUpdate) ||
  531. (decalBlendUpdate != decalBlend) ||
  532. (decalSizeUpdate != decalSize) ||
  533. (terrainMaterialNameUpdate != terrainMaterialName) ||
  534. (terrainMaterialPathUpdate != terrainMaterialPath) ||
  535. (importAllTextures != importAllTexturesUpdate) ||
  536. (tilingUpdate != tiling)
  537. )
  538. {
  539. SaveDefaults();
  540. }
  541. }
  542. }
  543. }
  544. #endif