TC_TerrainAreaEditor.cs 85 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743
  1. using UnityEngine;
  2. using UnityEditor;
  3. using System.Collections;
  4. using System.Collections.Generic;
  5. using System.IO;
  6. using System;
  7. using System.Reflection;
  8. #if !UNITY_5_1 && !UNITY_5_2
  9. using UnityEditor.SceneManagement;
  10. #endif
  11. namespace TerrainComposer2
  12. {
  13. [CustomEditor(typeof(TC_TerrainArea), true)]
  14. public class TC_TerrainAreaEditor : Editor
  15. {
  16. Event eventCurrent;
  17. TC_TerrainArea terrainArea;
  18. TC_Settings settings;
  19. TC_GlobalSettings g;
  20. bool guiChanged;
  21. void OnEnable()
  22. {
  23. if (target == null) return;
  24. terrainArea = (TC_TerrainArea)target;
  25. settings = TC_Settings.instance;
  26. if (settings != null) g = settings.global;
  27. if (terrainArea != null) terrainArea.GetAll();
  28. TC.GetInstallPath();
  29. }
  30. void OnDisable()
  31. {
  32. if (target == null || settings == null || TC_Generate.instance == null) return;
  33. if (TC_Generate.instance.CheckForTerrain(false))
  34. {
  35. if (settings.masterTerrain != null) Apply();
  36. }
  37. }
  38. public override void OnInspectorGUI()
  39. {
  40. if (g == null)
  41. {
  42. EditorGUILayout.LabelField("Global Settings are not found.");
  43. return;
  44. }
  45. terrainArea = (TC_TerrainArea)target;
  46. terrainArea.transform.localScale = Vector3.one;
  47. eventCurrent = Event.current;
  48. if (button_splatmap == null) LoadButtonTextures();
  49. GUI.changed = false;
  50. GUILayout.Space(5);
  51. DrawCreateTerrain();
  52. GUILayout.Space(10);
  53. DrawTerrainAreaTiles();
  54. GUILayout.Space(10);
  55. DrawRTP();
  56. DrawTerrain(terrainArea.terrainSelect, -15);
  57. if (GUI.changed)
  58. {
  59. // Debug.Log("Set Dirty");
  60. EditorUtility.SetDirty(terrainArea);
  61. #if !UNITY_5_1 && !UNITY_5_2
  62. if (!Application.isPlaying) EditorSceneManager.MarkSceneDirty(EditorSceneManager.GetActiveScene());
  63. #else
  64. EditorApplication.MarkSceneDirty();
  65. #endif
  66. }
  67. if (TC_Settings.instance == null) return;
  68. if (TC_Settings.instance.drawDefaultInspector) base.OnInspectorGUI();
  69. }
  70. string tooltipText = ""; // !
  71. TCUnityTerrain currentTerrain; // !
  72. Rect rtp_rect1; // !
  73. Texture button_grass, button_reset, button_resolution, button_settings, button_size, button_splatmap, button_tree, button_folder; // !
  74. public void create_preview_window(Texture2D texture, string text) { } // !
  75. public void create_select_window(int mode) { } // !
  76. public void DrawRTP()
  77. {
  78. Type t = TC.FindRTP();
  79. if (t == null) return;
  80. TD.DrawSpacer();
  81. TD.DrawLabelWidthUnderline("RTP Detected", 14);
  82. bool addRTPButton = !terrainArea.IsRTPAddedToTerrains();
  83. if (addRTPButton)
  84. {
  85. if (GUILayout.Button("Enable RTP",GUILayout.Width(100)))
  86. {
  87. terrainArea.AddRTPTOTerrains();
  88. }
  89. }
  90. else
  91. {
  92. GUI.changed = false;
  93. EditorGUILayout.BeginHorizontal();
  94. EditorGUILayout.PrefixLabel("Assign colormap");
  95. settings.autoColormapRTP = EditorGUILayout.Toggle(settings.autoColormapRTP, GUILayout.Width(25));
  96. if (GUILayout.Button("Reset", EditorStyles.miniButtonMid, GUILayout.Width(55)))
  97. {
  98. terrainArea.ResetTextureRTP("ColorGlobal");
  99. }
  100. EditorGUILayout.EndHorizontal();
  101. EditorGUILayout.BeginHorizontal();
  102. EditorGUILayout.PrefixLabel("Assign normalmap");
  103. settings.autoNormalmapRTP = EditorGUILayout.Toggle(settings.autoNormalmapRTP, GUILayout.Width(25));
  104. if (GUILayout.Button("Reset", EditorStyles.miniButtonMid, GUILayout.Width(55)))
  105. {
  106. terrainArea.ResetTextureRTP("NormalGlobal");
  107. }
  108. EditorGUILayout.EndHorizontal();
  109. if (GUI.changed) EditorUtility.SetDirty(settings);
  110. }
  111. TD.DrawSpacer();
  112. }
  113. public void DrawCreateTerrain()
  114. {
  115. EditorGUILayout.BeginHorizontal();
  116. if (terrainArea.createTerrainTab) GUI.backgroundColor = Color.green;
  117. if (GUILayout.Button("Create Terrain", EditorStyles.miniButtonMid, GUILayout.Width(100), GUILayout.Height(19.0f)))
  118. {
  119. terrainArea.createTerrainTab = !terrainArea.createTerrainTab;
  120. }
  121. GUI.backgroundColor = Color.white;
  122. EditorGUILayout.EndHorizontal();
  123. GUILayout.Space(5);
  124. if (terrainArea.createTerrainTab)
  125. {
  126. TD.DrawLabelWidthUnderline("Create Terrain", 14);
  127. DrawCreateTerrain(0, 0);
  128. }
  129. }
  130. public void DrawTerrainAreaTiles()
  131. {
  132. int countTiles = terrainArea.tiles.x * terrainArea.tiles.y;
  133. if (countTiles <= 1) return;
  134. int terrainIndex = 0;
  135. for (int y = terrainArea.tiles.y - 1; y >= 0; y--)
  136. {
  137. EditorGUILayout.BeginHorizontal();
  138. for (int x = 0; x < terrainArea.tiles.x; x++)
  139. {
  140. terrainIndex = x + (y * terrainArea.tiles.x);
  141. TCUnityTerrain tcTerrain = terrainArea.terrains[terrainIndex];
  142. if (terrainArea.terrainSelect == terrainIndex)
  143. {
  144. if (tcTerrain.active) GUI.backgroundColor = Color.green; else GUI.backgroundColor = Color.yellow;
  145. }
  146. else if (tcTerrain.active) GUI.backgroundColor = Color.white; else GUI.backgroundColor = Color.red;
  147. if (GUILayout.Button("", EditorStyles.miniButtonMid, GUILayout.Width(25), GUILayout.Height(25)))
  148. {
  149. if (eventCurrent.button == 2)
  150. {
  151. tcTerrain.active = !tcTerrain.active;
  152. if (Event.current.shift)
  153. {
  154. for (int i = 0; i < terrainArea.terrains.Count; i++)
  155. {
  156. TCUnityTerrain tcTerrain2 = terrainArea.terrains[i];
  157. if (tcTerrain2.terrain != null)
  158. {
  159. tcTerrain2.terrain.gameObject.SetActive(tcTerrain.active);
  160. tcTerrain2.active = tcTerrain.active;
  161. }
  162. }
  163. }
  164. else
  165. {
  166. if (tcTerrain.terrain != null) tcTerrain.terrain.gameObject.SetActive(tcTerrain.active);
  167. }
  168. if (tcTerrain.active) TC.AutoGenerate();
  169. continue;
  170. }
  171. terrainArea.terrainSelect = terrainIndex;
  172. terrainArea.GetAll();
  173. tcTerrain = terrainArea.terrains[terrainIndex];
  174. if (eventCurrent.button == 1)
  175. {
  176. if (tcTerrain.terrain != null) Selection.activeTransform = tcTerrain.terrain.transform;
  177. eventCurrent.Use();
  178. }
  179. }
  180. GUILayout.Space(3);
  181. }
  182. EditorGUILayout.EndHorizontal();
  183. }
  184. GUI.backgroundColor = Color.white;
  185. }
  186. Color color_terrain; // !
  187. float progress_bar; // !
  188. TerrainCollider terrainCollider; // !
  189. public void ShowNotification(GUIContent guiContent) // !
  190. {
  191. }
  192. bool hasTerrain;
  193. bool hasTerrainData;
  194. bool validTerrain;
  195. public void ChangeTerrainData(Terrain terrain)
  196. {
  197. terrainCollider = terrain.GetComponent<TerrainCollider>();
  198. if (terrainCollider != null) terrainCollider.terrainData = terrain.terrainData;
  199. }
  200. public void DrawTerrain(int index, float space)
  201. {
  202. if (terrainArea.terrains == null) { terrainArea.createTerrainTab = true; return; }
  203. if (terrainArea.terrains.Count == 0) { terrainArea.createTerrainTab = true; return; }
  204. if (index > terrainArea.terrains.Count - 1) return;
  205. TD.DrawLabelWidthUnderline("Terrain Setup", 14);
  206. EditorGUILayout.BeginVertical("Box");
  207. GUILayout.Space(5);
  208. currentTerrain = terrainArea.terrains[index];
  209. hasTerrain = currentTerrain.terrain != null;
  210. if (!hasTerrain) hasTerrainData = false; else hasTerrainData = currentTerrain.terrain.terrainData != null;
  211. if (hasTerrain && hasTerrainData) validTerrain = true; else validTerrain = false;
  212. // TODO put somewhere else
  213. //EditorGUILayout.BeginHorizontal();
  214. //GUILayout.Space(space + 15));
  215. //if (hasTerrain) { EditorGUILayout.LabelField("Trees placed: " + currentTerrain.terrain.terrainData.treeInstances.Length, GUILayout.Width(250.0f)); }
  216. //EditorGUILayout.EndHorizontal();
  217. EditorGUILayout.BeginHorizontal();
  218. GUILayout.Space(space + 15);
  219. space -= 15;
  220. // terrain foldout
  221. currentTerrain.terrain = EditorGUILayout.ObjectField(currentTerrain.terrain, typeof(Terrain), true) as Terrain;
  222. if (hasTerrain && !hasTerrainData) EditorGUILayout.LabelField("Missing TerrainData. Fix this manually in the Scene or create a new terrain");
  223. EditorGUILayout.LabelField("Act", GUILayout.Width(28.0f));
  224. currentTerrain.active = EditorGUILayout.Toggle(currentTerrain.active, GUILayout.Width(25.0f));
  225. EditorGUILayout.EndHorizontal();
  226. // if (!hasTerrainData) return;
  227. EditorGUILayout.BeginHorizontal();
  228. GUI.backgroundColor = terrainArea.sizeTab ? Color.green : Color.white;
  229. if (GUILayout.Button(new GUIContent("Size", button_size), EditorStyles.miniButtonMid, GUILayout.Width(95.0f), GUILayout.Height(19.0f)))
  230. {
  231. if (!terrainArea.sizeTab)
  232. {
  233. CloseTerrainTabs();
  234. terrainArea.sizeTab = true;
  235. currentTerrain.GetSize();
  236. }
  237. else CloseTerrainTabs();
  238. }
  239. GUI.backgroundColor = terrainArea.resolutionsTab ? Color.green : Color.white;
  240. if (GUILayout.Button(new GUIContent("Resolutions", button_resolution), EditorStyles.miniButtonMid, GUILayout.Width(95.0f), GUILayout.Height(19.0f)))
  241. {
  242. if (!terrainArea.resolutionsTab)
  243. {
  244. CloseTerrainTabs();
  245. terrainArea.resolutionsTab = true;
  246. currentTerrain.GetResolutions();
  247. }
  248. else CloseTerrainTabs();
  249. }
  250. GUI.backgroundColor = terrainArea.resetTab ? Color.green : Color.white;
  251. if (GUILayout.Button(new GUIContent("Reset", button_reset), EditorStyles.miniButtonMid, GUILayout.Width(95.0f), GUILayout.Height(19.0f)))
  252. {
  253. if (!terrainArea.resetTab)
  254. {
  255. CloseTerrainTabs();
  256. terrainArea.resetTab = true;
  257. }
  258. else CloseTerrainTabs();
  259. }
  260. GUI.backgroundColor = terrainArea.settingsTab ? Color.green : Color.white;
  261. if (GUILayout.Button(new GUIContent("Settings", button_settings), EditorStyles.miniButtonMid, GUILayout.Width(95.0f), GUILayout.Height(19.0f)))
  262. {
  263. if (!terrainArea.settingsTab)
  264. {
  265. CloseTerrainTabs();
  266. terrainArea.settingsTab = true;
  267. }
  268. else CloseTerrainTabs();
  269. }
  270. EditorGUILayout.EndHorizontal();
  271. EditorGUILayout.BeginHorizontal();
  272. GUILayout.Space(space + 30);
  273. GUI.backgroundColor = terrainArea.splatTab ? Color.green : Color.white;
  274. if (GUILayout.Button(new GUIContent("Splat Textures", button_splatmap), EditorStyles.miniButtonMid, GUILayout.Width(95.0f), GUILayout.Height(19.0f)))
  275. {
  276. if (!terrainArea.splatTab)
  277. {
  278. CloseTerrainTabs();
  279. terrainArea.splatTab = true;
  280. currentTerrain.GetSplatTextures();
  281. }
  282. else CloseTerrainTabs();
  283. }
  284. GUI.backgroundColor = terrainArea.treeTab ? Color.green : Color.white;
  285. if (GUILayout.Button(new GUIContent("Trees", button_tree), EditorStyles.miniButtonMid, GUILayout.Width(95.0f), GUILayout.Height(19.0f)))
  286. {
  287. if (!terrainArea.treeTab)
  288. {
  289. CloseTerrainTabs();
  290. terrainArea.treeTab = true;
  291. currentTerrain.GetTrees();
  292. }
  293. else CloseTerrainTabs();
  294. }
  295. GUI.backgroundColor = terrainArea.grassTab ? Color.green : Color.white;
  296. if (GUILayout.Button(new GUIContent("Grass/Details", button_grass), EditorStyles.miniButtonMid, GUILayout.Width(95.0f), GUILayout.Height(19.0f)))
  297. {
  298. if (!terrainArea.grassTab)
  299. {
  300. CloseTerrainTabs();
  301. terrainArea.grassTab = true;
  302. currentTerrain.GetGrass();
  303. }
  304. else CloseTerrainTabs();
  305. }
  306. GUI.backgroundColor = Color.white;
  307. EditorGUILayout.EndHorizontal();
  308. GUILayout.Space(10);
  309. // Size Tab
  310. if (terrainArea.sizeTab)
  311. {
  312. TD.DrawLabelWidthUnderline("Terrain Size", 14);
  313. EditorGUILayout.BeginHorizontal();
  314. GUILayout.Space(30 + space);
  315. EditorGUILayout.LabelField("Size", GUILayout.Width(100));
  316. guiChanged = GUI.changed;
  317. GUI.changed = false;
  318. terrainArea.terrainSize = EditorGUILayout.Vector3Field("", terrainArea.terrainSize);
  319. if (GUI.changed)
  320. {
  321. if (terrainArea.terrainSize.x < 1) terrainArea.terrainSize.x = 1;
  322. if (terrainArea.terrainSize.y < 1) terrainArea.terrainSize.y = 1;
  323. guiChanged = true;
  324. }
  325. GUI.changed = guiChanged;
  326. terrainArea.terrainSize.z = terrainArea.terrainSize.x;
  327. EditorGUILayout.EndHorizontal();
  328. }
  329. // Resolutions Tab
  330. if (terrainArea.resolutionsTab)
  331. {
  332. TD.DrawLabelWidthUnderline("Terrain Resolutions", 14);
  333. EditorGUILayout.BeginHorizontal();
  334. GUILayout.Space(30 + space);
  335. EditorGUILayout.LabelField("Heightmap Resolution", GUILayout.Width(135.0f));
  336. guiChanged = GUI.changed;
  337. GUI.changed = false;
  338. currentTerrain.heightmapResolutionList = (int)GUILayout.HorizontalSlider((float)currentTerrain.heightmapResolutionList, 9.0f, 0.0f, GUILayout.Width(210.0f));
  339. if (GUI.changed)
  340. {
  341. if (currentTerrain.heightmapResolutionList > 7) { currentTerrain.heightmapResolutionList = 7; }
  342. guiChanged = true;
  343. }
  344. GUI.changed = guiChanged;
  345. currentTerrain.heightmapResolutionList = EditorGUILayout.Popup(currentTerrain.heightmapResolutionList, TC_TerrainArea.heightmapResolutionList, GUILayout.Width(70.0f));
  346. if (terrainArea.terrains.Count > 1) EditorGUILayout.LabelField("(" + (terrainArea.tiles.x * currentTerrain.heightmapResolution).ToString() + ")");
  347. EditorGUILayout.EndHorizontal();
  348. EditorGUILayout.BeginHorizontal();
  349. GUILayout.Space(30 + space);
  350. EditorGUILayout.LabelField("Splatmap Resolution", GUILayout.Width(135.0f));
  351. int list = currentTerrain.splatmapResolutionList + 1;
  352. guiChanged = GUI.changed;
  353. GUI.changed = false;
  354. list = (int)GUILayout.HorizontalSlider((float)list, 9.0f, 0.0f, GUILayout.Width(210.0f));
  355. if (GUI.changed)
  356. {
  357. if (list > 8) { list = 8; }
  358. if (list < 1) { list = 1; }
  359. guiChanged = true;
  360. }
  361. GUI.changed = guiChanged;
  362. currentTerrain.splatmapResolutionList = list - 1;
  363. currentTerrain.splatmapResolutionList = EditorGUILayout.Popup(currentTerrain.splatmapResolutionList, TC_TerrainArea.splatmapResolutionList, GUILayout.Width(70.0f));
  364. if (terrainArea.terrains.Count > 1) EditorGUILayout.LabelField("(" + (terrainArea.tiles.x * currentTerrain.splatmapResolution).ToString() + ")");
  365. EditorGUILayout.EndHorizontal();
  366. EditorGUILayout.BeginHorizontal();
  367. GUILayout.Space(30 + space);
  368. EditorGUILayout.LabelField("Basemap Resolution", GUILayout.Width(135.0f));
  369. list = currentTerrain.basemapResolutionList + 1;
  370. guiChanged = GUI.changed;
  371. GUI.changed = false;
  372. list = (int)GUILayout.HorizontalSlider((float)list, 9.0f, 0.0f, GUILayout.Width(210.0f));
  373. if (GUI.changed)
  374. {
  375. if (list > 8) { list = 8; }
  376. if (list < 1) { list = 1; }
  377. guiChanged = true;
  378. }
  379. GUI.changed = guiChanged;
  380. currentTerrain.basemapResolutionList = list - 1;
  381. currentTerrain.basemapResolutionList = EditorGUILayout.Popup(currentTerrain.basemapResolutionList, TC_TerrainArea.splatmapResolutionList, GUILayout.Width(70.0f));
  382. if (terrainArea.terrains.Count > 1) EditorGUILayout.LabelField("(" + (terrainArea.tiles.x * currentTerrain.basemapResolution).ToString() + ")");
  383. EditorGUILayout.EndHorizontal();
  384. EditorGUILayout.BeginHorizontal();
  385. GUILayout.Space(30 + space);
  386. EditorGUILayout.LabelField("Grass Resolution", GUILayout.Width(135 + 214.0f));
  387. guiChanged = GUI.changed;
  388. GUI.changed = false;
  389. currentTerrain.detailResolution = EditorGUILayout.IntField(currentTerrain.detailResolution, GUILayout.Width(70.0f));
  390. if (GUI.changed)
  391. {
  392. if (currentTerrain.detailResolution < 16) { currentTerrain.detailResolution = 16; }
  393. guiChanged = true;
  394. }
  395. GUI.changed = guiChanged;
  396. if (terrainArea.terrains.Count > 1) EditorGUILayout.LabelField("(" + (terrainArea.tiles.x * currentTerrain.detailResolution).ToString() + ")");
  397. EditorGUILayout.EndHorizontal();
  398. EditorGUILayout.BeginHorizontal();
  399. GUILayout.Space(30 + space);
  400. EditorGUILayout.LabelField("Grass Per Patch", GUILayout.Width(135.0f));
  401. list = currentTerrain.detailResolutionPerPatchList;
  402. guiChanged = GUI.changed;
  403. GUI.changed = false;
  404. list = (int)GUILayout.HorizontalSlider((float)list, 0.0f, 4.0f, GUILayout.Width(210.0f));
  405. if (GUI.changed)
  406. {
  407. if (list < 0) { list = 0; }
  408. guiChanged = true;
  409. }
  410. GUI.changed = guiChanged;
  411. currentTerrain.detailResolutionPerPatchList = list;
  412. currentTerrain.detailResolutionPerPatchList = EditorGUILayout.Popup(currentTerrain.detailResolutionPerPatchList, TC_TerrainArea.detailResolutionPerPatchList, GUILayout.Width(70.0f));
  413. EditorGUILayout.EndHorizontal();
  414. }
  415. // Settings Tab
  416. if (terrainArea.settingsTab)
  417. {
  418. TD.DrawLabelWidthUnderline("Terrain Settings", 14);
  419. EditorGUILayout.BeginHorizontal();
  420. GUILayout.Space(30 + space);
  421. GUI.backgroundColor = terrainArea.settingsEditor ? Color.green : Color.white;
  422. if (GUILayout.Button("Editor", EditorStyles.miniButtonMid, GUILayout.Width(70.0f)))
  423. {
  424. terrainArea.settingsEditor = true;
  425. terrainArea.GetSettings();
  426. }
  427. GUI.backgroundColor = !terrainArea.settingsEditor ? Color.green : Color.white;
  428. if (GUILayout.Button("Runtime", EditorStyles.miniButtonMid, GUILayout.Width(70.0f)))
  429. {
  430. terrainArea.settingsEditor = false;
  431. terrainArea.GetSettings();
  432. }
  433. GUI.backgroundColor = Color.white;
  434. EditorGUILayout.EndHorizontal();
  435. if (validTerrain)
  436. {
  437. EditorGUILayout.BeginHorizontal();
  438. GUILayout.Space(30 + space);
  439. EditorGUILayout.LabelField("Terrain Data", GUILayout.Width(160.0f));
  440. guiChanged = GUI.changed;
  441. GUI.changed = false;
  442. currentTerrain.terrain.terrainData = (TerrainData)EditorGUILayout.ObjectField(currentTerrain.terrain.terrainData, typeof(TerrainData), false);
  443. if (GUI.changed)
  444. {
  445. ChangeTerrainData(currentTerrain.terrain);
  446. guiChanged = true;
  447. }
  448. GUI.changed = guiChanged;
  449. EditorGUILayout.EndHorizontal();
  450. }
  451. guiChanged = GUI.changed;
  452. GUI.changed = false;
  453. EditorGUILayout.BeginHorizontal();
  454. GUILayout.Space(45 + space);
  455. EditorGUILayout.LabelField("Base Terrain", EditorStyles.boldLabel);
  456. EditorGUILayout.EndHorizontal();
  457. EditorGUILayout.BeginHorizontal();
  458. GUILayout.Space(60 + space);
  459. EditorGUILayout.LabelField("Draw", GUILayout.Width(147.0f));
  460. currentTerrain.drawHeightmap = EditorGUILayout.Toggle(currentTerrain.drawHeightmap, GUILayout.Width(25.0f));
  461. EditorGUILayout.EndHorizontal();
  462. EditorGUILayout.BeginHorizontal();
  463. GUILayout.Space(60 + space);
  464. GUI.color = !terrainArea.settingsEditor ? Color.green : Color.white;
  465. EditorGUILayout.LabelField("Pixel Error", GUILayout.Width(147.0f));
  466. currentTerrain.heightmapPixelError = EditorGUILayout.Slider(currentTerrain.heightmapPixelError, 1.0f, 200.0f);
  467. EditorGUILayout.EndHorizontal();
  468. EditorGUILayout.BeginHorizontal();
  469. GUILayout.Space(60 + space);
  470. GUI.color = !terrainArea.settingsEditor ? Color.green : Color.white;
  471. EditorGUILayout.LabelField("Heightmap Max LOD", GUILayout.Width(147.0f));
  472. currentTerrain.heightmapMaximumLOD = (int)EditorGUILayout.Slider((float)currentTerrain.heightmapMaximumLOD, 0.0f, 10.0f);
  473. EditorGUILayout.EndHorizontal();
  474. GUI.color = Color.white;
  475. // !! if (!current_terrain.rtp_script) {
  476. EditorGUILayout.BeginHorizontal();
  477. GUILayout.Space(60 + space);
  478. EditorGUILayout.LabelField("Basemap Distance", GUILayout.Width(147.0f));
  479. currentTerrain.basemapDistance = EditorGUILayout.FloatField(currentTerrain.basemapDistance);
  480. if (currentTerrain.basemapDistance < 1) currentTerrain.basemapDistance = 1;
  481. EditorGUILayout.EndHorizontal();
  482. //}
  483. EditorGUILayout.BeginHorizontal();
  484. GUILayout.Space(60 + space);
  485. EditorGUILayout.LabelField("Cast Shadows", GUILayout.Width(147.0f));
  486. currentTerrain.castShadows = EditorGUILayout.Toggle(currentTerrain.castShadows, GUILayout.Width(25.0f));
  487. EditorGUILayout.EndHorizontal();
  488. EditorGUILayout.BeginHorizontal();
  489. GUILayout.Space(60 + space);
  490. EditorGUILayout.LabelField("Material", GUILayout.Width(147.0f));
  491. currentTerrain.materialType = (Terrain.MaterialType)EditorGUILayout.EnumPopup(currentTerrain.materialType);
  492. EditorGUILayout.EndHorizontal();
  493. if (currentTerrain.materialType == Terrain.MaterialType.BuiltInStandard)
  494. {
  495. EditorGUILayout.BeginHorizontal();
  496. GUILayout.Space(60 + space);
  497. EditorGUILayout.LabelField("Reflection Probes", GUILayout.Width(147.0f));
  498. currentTerrain.reflectionProbeUsage = (UnityEngine.Rendering.ReflectionProbeUsage)EditorGUILayout.EnumPopup(currentTerrain.reflectionProbeUsage);
  499. EditorGUILayout.EndHorizontal();
  500. }
  501. else if (currentTerrain.materialType == Terrain.MaterialType.BuiltInLegacySpecular)
  502. {
  503. EditorGUILayout.BeginHorizontal();
  504. GUILayout.Space(75 + space);
  505. EditorGUILayout.LabelField("Specular Color", GUILayout.Width(147.0f));
  506. currentTerrain.legacySpecular = EditorGUILayout.ColorField(currentTerrain.legacySpecular);
  507. EditorGUILayout.EndHorizontal();
  508. EditorGUILayout.BeginHorizontal();
  509. GUILayout.Space(75 + space);
  510. EditorGUILayout.LabelField("Shininess", GUILayout.Width(147.0f));
  511. currentTerrain.legacyShininess = EditorGUILayout.FloatField(currentTerrain.legacyShininess);
  512. EditorGUILayout.EndHorizontal();
  513. }
  514. else if (currentTerrain.materialType == Terrain.MaterialType.Custom && currentTerrain.terrain != null)
  515. {
  516. EditorGUILayout.BeginHorizontal();
  517. GUILayout.Space(75 + space);
  518. EditorGUILayout.LabelField("Custom Material", GUILayout.Width(147.0f));
  519. currentTerrain.terrain.materialTemplate = (Material)EditorGUILayout.ObjectField(currentTerrain.terrain.materialTemplate, typeof(Material), true);
  520. EditorGUILayout.EndHorizontal();
  521. }
  522. EditorGUILayout.BeginHorizontal();
  523. GUILayout.Space(60 + space);
  524. EditorGUILayout.LabelField("Thickness", GUILayout.Width(147.0f));
  525. currentTerrain.thickness = EditorGUILayout.FloatField(currentTerrain.thickness);
  526. EditorGUILayout.EndHorizontal();
  527. EditorGUILayout.BeginHorizontal();
  528. GUILayout.Space(45 + space);
  529. EditorGUILayout.LabelField("Tree & Detail Terrain", EditorStyles.boldLabel);
  530. EditorGUILayout.EndHorizontal();
  531. EditorGUILayout.BeginHorizontal();
  532. GUILayout.Space(60 + space);
  533. EditorGUILayout.LabelField("Collect Detail Patches", GUILayout.Width(147.0f));
  534. currentTerrain.collectDetailPatches = EditorGUILayout.Toggle(currentTerrain.collectDetailPatches, GUILayout.Width(25.0f));
  535. EditorGUILayout.EndHorizontal();
  536. GUI.color = !terrainArea.settingsEditor ? Color.green : Color.white;
  537. EditorGUILayout.BeginHorizontal();
  538. GUILayout.Space(60 + space);
  539. EditorGUILayout.LabelField("Draw", GUILayout.Width(147.0f));
  540. currentTerrain.drawTreesAndFoliage = EditorGUILayout.Toggle(currentTerrain.drawTreesAndFoliage, GUILayout.Width(25.0f));
  541. EditorGUILayout.EndHorizontal();
  542. EditorGUILayout.BeginHorizontal();
  543. GUILayout.Space(60 + space);
  544. EditorGUILayout.LabelField("Grass Distance", GUILayout.Width(147.0f));
  545. if (terrainArea.settingsEditor) currentTerrain.detailObjectDistance = EditorGUILayout.Slider(currentTerrain.detailObjectDistance, 0.0f, 250f);
  546. else currentTerrain.detailObjectDistance = EditorGUILayout.Slider(currentTerrain.detailObjectDistance, 0.0f, 500f);
  547. EditorGUILayout.EndHorizontal();
  548. EditorGUILayout.BeginHorizontal();
  549. GUILayout.Space(60 + space);
  550. EditorGUILayout.LabelField("Grass Density", GUILayout.Width(147.0f));
  551. currentTerrain.detailObjectDensity = EditorGUILayout.Slider(currentTerrain.detailObjectDensity, 0.0f, 1.0f);
  552. EditorGUILayout.EndHorizontal();
  553. GUILayout.Space(2.0f);
  554. EditorGUILayout.BeginHorizontal();
  555. GUILayout.Space(60 + space);
  556. EditorGUILayout.LabelField("Tree Distance", GUILayout.Width(147.0f));
  557. if (terrainArea.settingsEditor) currentTerrain.treeDistance = EditorGUILayout.Slider(currentTerrain.treeDistance, 0.0f, 50000);
  558. else currentTerrain.treeDistance = EditorGUILayout.Slider(currentTerrain.treeDistance, 0.0f, 150000);
  559. EditorGUILayout.EndHorizontal();
  560. EditorGUILayout.BeginHorizontal();
  561. GUILayout.Space(60 + space);
  562. EditorGUILayout.LabelField("Billboard Start", GUILayout.Width(147.0f));
  563. currentTerrain.treeBillboardDistance = EditorGUILayout.Slider(currentTerrain.treeBillboardDistance, 0.0f, 2000.0f);
  564. EditorGUILayout.EndHorizontal();
  565. GUI.color = Color.white;
  566. EditorGUILayout.BeginHorizontal();
  567. GUILayout.Space(60 + space);
  568. EditorGUILayout.LabelField("Fade Length", GUILayout.Width(147.0f));
  569. if (terrainArea.settingsEditor) currentTerrain.treeCrossFadeLength = EditorGUILayout.Slider(currentTerrain.treeCrossFadeLength, 0.0f, 200);
  570. else currentTerrain.treeCrossFadeLength = EditorGUILayout.Slider(currentTerrain.treeCrossFadeLength, 0.0f, 100);
  571. EditorGUILayout.EndHorizontal();
  572. GUI.color = !terrainArea.settingsEditor ? Color.green : Color.white;
  573. EditorGUILayout.BeginHorizontal();
  574. GUILayout.Space(60 + space);
  575. EditorGUILayout.LabelField("Max Mesh Trees", GUILayout.Width(147.0f));
  576. if (terrainArea.settingsEditor) currentTerrain.treeMaximumFullLODCount = (int)EditorGUILayout.Slider((float)currentTerrain.treeMaximumFullLODCount, 0.0f, 10000);
  577. else currentTerrain.treeMaximumFullLODCount = (int)EditorGUILayout.Slider((float)currentTerrain.treeMaximumFullLODCount, 0.0f, 10000);
  578. EditorGUILayout.EndHorizontal();
  579. GUI.color = Color.white;
  580. EditorGUILayout.BeginHorizontal();
  581. GUILayout.Space(45 + space);
  582. EditorGUILayout.LabelField("Wind Settings", EditorStyles.boldLabel);
  583. EditorGUILayout.EndHorizontal();
  584. EditorGUILayout.BeginHorizontal();
  585. GUILayout.Space(60 + space);
  586. EditorGUILayout.LabelField("Speed", GUILayout.Width(147.0f));
  587. currentTerrain.wavingGrassStrength = EditorGUILayout.Slider(currentTerrain.wavingGrassStrength, 0.0f, 1.0f);
  588. EditorGUILayout.EndHorizontal();
  589. EditorGUILayout.BeginHorizontal();
  590. GUILayout.Space(60 + space);
  591. EditorGUILayout.LabelField("Size", GUILayout.Width(147.0f));
  592. currentTerrain.wavingGrassSpeed = EditorGUILayout.Slider(currentTerrain.wavingGrassSpeed, 0.0f, 1.0f);
  593. EditorGUILayout.EndHorizontal();
  594. EditorGUILayout.BeginHorizontal();
  595. GUILayout.Space(60 + space);
  596. EditorGUILayout.LabelField("Bending", GUILayout.Width(147.0f));
  597. currentTerrain.wavingGrassAmount = EditorGUILayout.Slider(currentTerrain.wavingGrassAmount, 0.0f, 1.0f);
  598. EditorGUILayout.EndHorizontal();
  599. EditorGUILayout.BeginHorizontal();
  600. GUILayout.Space(60 + space);
  601. EditorGUILayout.LabelField("Grass Tint", GUILayout.Width(147.0f));
  602. currentTerrain.wavingGrassTint = EditorGUILayout.ColorField(currentTerrain.wavingGrassTint);
  603. EditorGUILayout.EndHorizontal();
  604. if (GUI.changed)
  605. {
  606. terrainArea.ApplySettings();
  607. guiChanged = true;
  608. }
  609. GUI.changed = guiChanged;
  610. }
  611. // Splat Tab
  612. if (terrainArea.splatTab)
  613. {
  614. //if (settings.isRTPDetected)
  615. //{
  616. // EditorGUILayout.LabelField("Splat textures need to be setup in the ReliefTerrain script.");
  617. // EditorGUILayout.LabelField("Click on a terrain to see it.");
  618. // EditorGUILayout.EndVertical();
  619. // return;
  620. //}
  621. TD.DrawLabelWidthUnderline("Terrain Splat Textures", 14);
  622. EditorGUILayout.BeginHorizontal();
  623. GUILayout.Space(30 + space);
  624. if (currentTerrain.splatSettingsFoldout) GUI.backgroundColor = Color.green;
  625. if (GUILayout.Button("Settings", GUILayout.Width(70)))
  626. {
  627. currentTerrain.splatSettingsFoldout = !currentTerrain.splatSettingsFoldout;
  628. }
  629. GUI.backgroundColor = Color.white;
  630. EditorGUILayout.EndHorizontal();
  631. EditorGUILayout.BeginHorizontal();
  632. GUILayout.Space(30 + space);
  633. // if (currentTerrain.splatPrototypes.Count == 0)
  634. //{
  635. if (TC_Settings.instance.global.tooltip) tooltipText = "Add a new Splat Texture";
  636. if (GUILayout.Button(new GUIContent("+", tooltipText), GUILayout.Width(25.0f)))
  637. {
  638. UndoRegister("Add Splat Texture");
  639. currentTerrain.AddSplatTexture(currentTerrain.splatPrototypes.Count);
  640. }
  641. //}
  642. if (TC_Settings.instance.global.tooltip) tooltipText = "Enable/Disable Colormap as splat texture\n(Shift Click)";
  643. GUI.backgroundColor = Color.white;
  644. EditorGUILayout.EndHorizontal();
  645. GUILayout.Space(5);
  646. guiChanged = GUI.changed;
  647. GUI.changed = false;
  648. for (int countSplat = 0; countSplat < currentTerrain.splatPrototypes.Count; ++countSplat)
  649. {
  650. if (countSplat == 0)
  651. {
  652. EditorGUILayout.BeginHorizontal();
  653. GUILayout.Space(59 + space);
  654. EditorGUILayout.LabelField("Splat", GUILayout.Width(55.0f));
  655. EditorGUILayout.LabelField("Normal", GUILayout.Width(55.0f));
  656. EditorGUILayout.EndHorizontal();
  657. }
  658. EditorGUILayout.BeginHorizontal();
  659. GUILayout.Space(30 + space);
  660. EditorGUILayout.LabelField("" + (countSplat + 1) + ")", GUILayout.Width(25.0f));
  661. currentTerrain.splatPrototypes[countSplat].texture = (Texture2D)EditorGUILayout.ObjectField(currentTerrain.splatPrototypes[countSplat].texture, typeof(Texture), true, GUILayout.Width(55.0f), GUILayout.Height(55.0f));
  662. currentTerrain.splatPrototypes[countSplat].normalMap = (Texture2D)EditorGUILayout.ObjectField(currentTerrain.splatPrototypes[countSplat].normalMap, typeof(Texture), true, GUILayout.Width(55.0f), GUILayout.Height(55.0f));
  663. if (TC_Settings.instance.global.tooltip) tooltipText = "Move Splat Texture up";
  664. if (countSplat > 0)
  665. {
  666. if (GUILayout.Button(new GUIContent("▲", tooltipText), GUILayout.Width(25.0f))) currentTerrain.SwapSplatTexture(countSplat, countSplat - 1);
  667. }
  668. else GUILayout.Space(29.0f);
  669. if (countSplat < currentTerrain.splatPrototypes.Count - 1)
  670. {
  671. if (TC_Settings.instance.global.tooltip) tooltipText = "Move Splat Texture down";
  672. if (GUILayout.Button(new GUIContent("▼", tooltipText), GUILayout.Width(25.0f))) currentTerrain.SwapSplatTexture(countSplat, countSplat + 1);
  673. }
  674. else GUILayout.Space(29.0f);
  675. if (TC_Settings.instance.global.tooltip) tooltipText = "Insert a new Splat Texture";
  676. if (GUILayout.Button(new GUIContent("+", tooltipText), GUILayout.Width(25.0f))) currentTerrain.AddSplatTexture(countSplat + 1);
  677. if (TC_Settings.instance.global.tooltip) tooltipText = "Erase this Splat Texture";
  678. if (GUILayout.Button(new GUIContent("-", tooltipText), GUILayout.Width(25.0f)))
  679. {
  680. currentTerrain.EraseSplatTexture(countSplat);
  681. --countSplat;
  682. Repaint();
  683. continue;
  684. }
  685. EditorGUILayout.EndHorizontal();
  686. if (currentTerrain != null) //! Rtp
  687. {
  688. if (currentTerrain.splatSettingsFoldout)
  689. {
  690. EditorGUILayout.BeginHorizontal();
  691. GUILayout.Space(73 + space);
  692. float tileSize = currentTerrain.splatPrototypes[countSplat].tileSize.x;
  693. bool guiChanged2 = GUI.changed;
  694. GUI.changed = false;
  695. tileSize = EditorGUILayout.FloatField("Tile Size", tileSize);
  696. if (GUI.changed)
  697. {
  698. currentTerrain.splatPrototypes[countSplat].tileSize = new Vector2(tileSize, tileSize);
  699. Apply();
  700. SceneView.RepaintAll();
  701. guiChanged = true;
  702. }
  703. GUI.changed = guiChanged2;
  704. EditorGUILayout.EndHorizontal();
  705. EditorGUILayout.BeginHorizontal();
  706. GUILayout.Space(73 + space);
  707. // EditorGUILayout.LabelField("Tile Offset", GUILayout.Width(125.0f));
  708. currentTerrain.splatPrototypes[countSplat].tileOffset = EditorGUILayout.Vector2Field("Tile Offset", currentTerrain.splatPrototypes[countSplat].tileOffset);
  709. EditorGUILayout.EndHorizontal();
  710. }
  711. }
  712. else
  713. {
  714. EditorGUILayout.EndHorizontal();
  715. }
  716. }
  717. if (GUI.changed)
  718. {
  719. // Debug.Log("gui changed");
  720. Apply();
  721. SceneView.RepaintAll();
  722. guiChanged = true;
  723. }
  724. GUI.changed = guiChanged;
  725. // EditorGUILayout.BeginHorizontal();
  726. // GUILayout.Space(30 + space);
  727. // if (TC_Settings.instance.global.tooltip)
  728. // {
  729. // tooltipText = "Open Splat Texture Preset from saved file";
  730. // }
  731. // if (GUILayout.Button(new GUIContent("Open", tooltipText), GUILayout.Width(45.0f)))
  732. // {
  733. // string path_splat_open1 = EditorUtility.OpenFilePanel("Open Splat Preset", Application.dataPath + "/TerrainComposer/save/presets/splat", "prefab");
  734. // if (path_splat_open1.Length != 0)
  735. // {
  736. // load_splat_preset(path_splat_open1, currentTerrain, 0, false);
  737. // }
  738. // }
  739. // if (TC_Settings.instance.global.tooltip)
  740. // {
  741. // tooltipText = "Save Splat Texture Preset";
  742. // }
  743. // if (GUILayout.Button(new GUIContent("Save", tooltipText), GUILayout.Width(45.0f)))
  744. // {
  745. // string path_splat_save = EditorUtility.SaveFilePanel("Save Splat Preset", Application.dataPath + "/TerrainComposer/save/presets/splat", "", "prefab");
  746. // if (path_splat_save.Length != 0)
  747. // {
  748. // save_splat_preset1(path_splat_save, currentTerrain);
  749. // }
  750. // }
  751. // EditorGUILayout.EndHorizontal();
  752. }
  753. if (terrainArea.treeTab)
  754. {
  755. TD.DrawLabelWidthUnderline("Terrain Trees", 14);
  756. EditorGUILayout.BeginHorizontal();
  757. GUILayout.Space(30 + space);
  758. if (currentTerrain.treeSettingsFoldout) GUI.backgroundColor = Color.green;
  759. if (GUILayout.Button("Settings", GUILayout.Width(70)))
  760. {
  761. currentTerrain.treeSettingsFoldout = !currentTerrain.treeSettingsFoldout;
  762. }
  763. GUI.backgroundColor = Color.white;
  764. EditorGUILayout.EndHorizontal();
  765. // if (currentTerrain.treePrototypes.Count == 0)
  766. // {
  767. EditorGUILayout.BeginHorizontal();
  768. GUILayout.Space(30 + space);
  769. if (TC_Settings.instance.global.tooltip) tooltipText = "Add a new Tree";
  770. if (GUILayout.Button(new GUIContent("+", tooltipText), GUILayout.Width(25.0f)))
  771. {
  772. currentTerrain.add_treeprototype(currentTerrain.treePrototypes.Count);
  773. if (eventCurrent.shift && currentTerrain.treePrototypes.Count > 1)
  774. {
  775. // !script.copy_terrain_tree(currentTerrain.treePrototypes[currentTerrain.treePrototypes.Count - 2], currentTerrain.treePrototypes[currentTerrain.treePrototypes.Count - 1]);
  776. }
  777. }
  778. if (TC_Settings.instance.global.tooltip) tooltipText = "Erase the last Tree\n\n(Control Click)";
  779. EditorGUILayout.EndHorizontal();
  780. //}
  781. GUILayout.Space(5);
  782. // GUI.changed = false;
  783. for (int countTree = 0; countTree < currentTerrain.treePrototypes.Count; ++countTree)
  784. {
  785. EditorGUILayout.BeginHorizontal();
  786. GUILayout.Space(30 + space);
  787. if (currentTerrain.treePrototypes[countTree].prefab == null) { GUILayout.Button(new GUIContent("Empty"), EditorStyles.miniButtonMid, GUILayout.Width(64.0f), GUILayout.Height(64.0f)); }
  788. else
  789. {
  790. if (TC_Settings.instance.global.tooltip) tooltipText = "Click to preview\n\nClick again to close preview"; else tooltipText = "";
  791. if (GUILayout.Button(new GUIContent(AssetPreview.GetAssetPreview(currentTerrain.treePrototypes[countTree].prefab), tooltipText), EditorStyles.miniButtonMid, GUILayout.Width(64.0f), GUILayout.Height(64.0f)))
  792. {
  793. // create_preview_window(currentTerrain.treePrototypes[count_tree].texture, "Tree Preview");
  794. }
  795. }
  796. EditorGUILayout.LabelField("" + (countTree + 1) + ").", GUILayout.Width(28.0f));
  797. currentTerrain.treePrototypes[countTree].prefab = (GameObject)EditorGUILayout.ObjectField(currentTerrain.treePrototypes[countTree].prefab, typeof(GameObject), true, GUILayout.Width(250.0f));
  798. if (currentTerrain.treePrototypes.Count > 1)
  799. {
  800. if (countTree > 0)
  801. {
  802. if (TC_Settings.instance.global.tooltip) tooltipText = "Move Tree up";
  803. if (GUILayout.Button(new GUIContent("▲", tooltipText), GUILayout.Width(25.0f))) { currentTerrain.SwapTree(countTree, countTree - 1); }
  804. }
  805. else GUILayout.Space(29.0f);
  806. if (countTree < currentTerrain.treePrototypes.Count - 1)
  807. {
  808. if (TC_Settings.instance.global.tooltip) tooltipText = "Move Tree down";
  809. if (GUILayout.Button(new GUIContent("▼", tooltipText), GUILayout.Width(25.0f))) { currentTerrain.SwapTree(countTree, countTree + 1); }
  810. }
  811. else GUILayout.Space(29.0f);
  812. }
  813. if (TC_Settings.instance.global.tooltip) tooltipText = "Insert a new Tree";
  814. if (GUILayout.Button(new GUIContent("+", tooltipText), GUILayout.Width(25.0f)))
  815. {
  816. UndoRegister("Add Tree");
  817. currentTerrain.add_treeprototype(countTree + 1);
  818. if (eventCurrent.shift)
  819. {
  820. currentTerrain.CopyTree(currentTerrain.treePrototypes[countTree], currentTerrain.treePrototypes[countTree + 1]);
  821. }
  822. }
  823. if (TC_Settings.instance.global.tooltip) tooltipText = "Erase this Tree\n\n(Control Click)";
  824. if (GUILayout.Button(new GUIContent("-", tooltipText), GUILayout.Width(25.0f)))
  825. {
  826. UndoRegister("Erase Tree");
  827. currentTerrain.EraseTreeProtoType(countTree);
  828. }
  829. EditorGUILayout.EndHorizontal();
  830. if (currentTerrain.treeSettingsFoldout)
  831. {
  832. EditorGUILayout.BeginHorizontal();
  833. GUILayout.Space(45 + space);
  834. currentTerrain.treePrototypes[countTree].bendFactor = EditorGUILayout.FloatField("Bend Factor", currentTerrain.treePrototypes[countTree].bendFactor);
  835. //if (TC_Settings.instance.global.tooltip)
  836. //{
  837. // tooltipText = "Set this bendfactor to all Trees in this Terrain\n(Click)\n\nSet this bendfactor to all Trees in the Terrains\n(Shift Click)";
  838. //}
  839. //if (GUILayout.Button(new GUIContent(">Set All", tooltipText), EditorStyles.miniButtonMid, GUILayout.Width(65.0f)))
  840. //{
  841. // // UndoRegister("Set All Trees Settings");
  842. // if (!eventCurrent.shift)
  843. // {
  844. // // !script.set_all_trees_settings_terrain(current_terrain, count_tree);
  845. // }
  846. EditorGUILayout.EndHorizontal();
  847. }
  848. //if (GUI.changed)
  849. //{
  850. // Debug.Log("gui changed");
  851. // Apply();
  852. // SceneView.RepaintAll();
  853. //}
  854. }
  855. //EditorGUILayout.BeginHorizontal();
  856. //GUILayout.Space(30 + space);
  857. //if (TC_Settings.instance.global.tooltip)
  858. //{
  859. // tooltipText = "Open Tree Preset from saved file";
  860. //}
  861. //if (GUILayout.Button(new GUIContent("Open", tooltipText), GUILayout.Width(45.0f)))
  862. //{
  863. // string path_tree_open1 = EditorUtility.OpenFilePanel("Open Tree Preset", Application.dataPath + "/TerrainComposer/save/presets/tree", "prefab");
  864. // if (path_tree_open1.Length != 0)
  865. // {
  866. // load_tree_preset(path_tree_open1, currentTerrain, 0, false);
  867. // this.Repaint();
  868. // }
  869. //}
  870. //if (TC_Settings.instance.global.tooltip)
  871. //{
  872. // tooltipText = "Save Tree Texture Preset";
  873. //}
  874. //if (GUILayout.Button(new GUIContent("Save", tooltipText), GUILayout.Width(45.0f)))
  875. //{
  876. // string path_tree_save = EditorUtility.SaveFilePanel("Save Tree Preset", Application.dataPath + "/TerrainComposer/save/presets/tree", "", "prefab");
  877. // if (path_tree_save.Length != 0)
  878. // {
  879. // save_tree_preset1(path_tree_save, currentTerrain);
  880. // }
  881. //}
  882. //EditorGUILayout.EndHorizontal();
  883. }
  884. if (terrainArea.grassTab)
  885. {
  886. TD.DrawLabelWidthUnderline("Terrain Grass", 14);
  887. EditorGUILayout.BeginHorizontal();
  888. GUILayout.Space(30 + space);
  889. if (currentTerrain.detailSettingsFoldout) GUI.backgroundColor = Color.green;
  890. if (GUILayout.Button("Settings", GUILayout.Width(70)))
  891. {
  892. currentTerrain.detailSettingsFoldout = !currentTerrain.detailSettingsFoldout;
  893. }
  894. GUI.backgroundColor = Color.white;
  895. EditorGUILayout.EndHorizontal();
  896. //if (currentTerrain.detailPrototypes.Count == 0)
  897. //{
  898. EditorGUILayout.BeginHorizontal();
  899. GUILayout.Space(30 + space);
  900. if (TC_Settings.instance.global.tooltip) tooltipText = "Add a new Grass/Detail";
  901. if (GUILayout.Button(new GUIContent("+", tooltipText), GUILayout.Width(25.0f)))
  902. {
  903. currentTerrain.AddDetailPrototype(currentTerrain.detailPrototypes.Count);
  904. }
  905. EditorGUILayout.EndHorizontal();
  906. //}
  907. GUILayout.Space(5);
  908. for (int countGrass = 0; countGrass < currentTerrain.detailPrototypes.Count; ++countGrass)
  909. {
  910. EditorGUILayout.BeginHorizontal();
  911. GUILayout.Space(30 + space);
  912. if (currentTerrain.detailPrototypes[countGrass].usePrototypeMesh)
  913. {
  914. EditorGUILayout.LabelField("" + (countGrass + 1) + ")", GUILayout.Width(25.0f));
  915. currentTerrain.detailPrototypes[countGrass].prototype = EditorGUILayout.ObjectField(currentTerrain.detailPrototypes[countGrass].prototype, typeof(GameObject), true, GUILayout.Width(143.0f)) as GameObject;
  916. }
  917. else
  918. {
  919. EditorGUILayout.LabelField("" + (countGrass + 1) + ")", GUILayout.Width(24.0f));
  920. currentTerrain.detailPrototypes[countGrass].prototypeTexture = (Texture2D)EditorGUILayout.ObjectField(currentTerrain.detailPrototypes[countGrass].prototypeTexture, typeof(Texture2D), true, GUILayout.Width(55.0f), GUILayout.Height(55.0f));
  921. if (currentTerrain.detailPrototypes[countGrass].prototypeTexture != null)
  922. {
  923. EditorGUILayout.LabelField(currentTerrain.detailPrototypes[countGrass].prototypeTexture.name, GUILayout.Width(85));
  924. }
  925. else
  926. {
  927. GUILayout.Space(60.0f);
  928. }
  929. }
  930. EditorGUILayout.LabelField("Mesh", GUILayout.Width(35.0f));
  931. currentTerrain.detailPrototypes[countGrass].usePrototypeMesh = EditorGUILayout.Toggle(currentTerrain.detailPrototypes[countGrass].usePrototypeMesh, GUILayout.Width(20.0f));
  932. currentTerrain.detailPrototypes[countGrass].renderMode = (DetailRenderMode)EditorGUILayout.EnumPopup(currentTerrain.detailPrototypes[countGrass].renderMode, GUILayout.Width(100));
  933. //if (currentTerrain.detailPrototypes[countGrass].renderMode == DetailRenderMode.VertexLit)
  934. // currentTerrain.detailPrototypes[countGrass].usePrototypeMesh = true;
  935. //else
  936. // currentTerrain.detailPrototypes[countGrass].usePrototypeMesh = false;
  937. GUILayout.Space(5);
  938. if (countGrass > 0)
  939. {
  940. if (TC_Settings.instance.global.tooltip)
  941. {
  942. tooltipText = "Move Grass/Detail up";
  943. }
  944. if (GUILayout.Button(new GUIContent("▲", tooltipText), GUILayout.Width(25.0f)) && countGrass > 0) { TC.Swap(currentTerrain.detailPrototypes, countGrass, currentTerrain.detailPrototypes, countGrass - 1); }
  945. }
  946. else
  947. {
  948. GUILayout.Space(29.0f);
  949. }
  950. if (countGrass < currentTerrain.detailPrototypes.Count - 1)
  951. {
  952. if (TC_Settings.instance.global.tooltip) tooltipText = "Move Grass/Detail down";
  953. if (GUILayout.Button(new GUIContent("▼", tooltipText), GUILayout.Width(25.0f))) { TC.Swap(currentTerrain.detailPrototypes, countGrass, currentTerrain.detailPrototypes, countGrass + 1); }
  954. }
  955. else
  956. {
  957. GUILayout.Space(29.0f);
  958. }
  959. if (TC_Settings.instance.global.tooltip)
  960. {
  961. tooltipText = "Insert a new Grass/Detail";
  962. }
  963. if (GUILayout.Button(new GUIContent("+", tooltipText), GUILayout.Width(25.0f)))
  964. {
  965. currentTerrain.AddDetailPrototype(countGrass + 1);
  966. if (eventCurrent.shift)
  967. {
  968. // !script.copy_terrain_detail(currentTerrain.detailPrototypes[count_detail], currentTerrain.detailPrototypes[count_detail + 1]);
  969. }
  970. }
  971. if (TC_Settings.instance.global.tooltip)
  972. {
  973. tooltipText = "Erase this Grass/Detail";
  974. }
  975. if (GUILayout.Button(new GUIContent("-", tooltipText), GUILayout.Width(25.0f)))
  976. {
  977. // UndoRegister("Erase Grass");
  978. currentTerrain.EraseDetailPrototype(countGrass);
  979. Repaint();
  980. --countGrass;
  981. }
  982. EditorGUILayout.EndHorizontal();
  983. if (currentTerrain.detailSettingsFoldout)
  984. {
  985. if (!currentTerrain.detailPrototypes[countGrass].usePrototypeMesh)
  986. {
  987. EditorGUILayout.BeginHorizontal();
  988. GUILayout.Space(70 + space);
  989. currentTerrain.detailPrototypes[countGrass].minWidth = EditorGUILayout.FloatField("Min. Width", currentTerrain.detailPrototypes[countGrass].minWidth);
  990. EditorGUILayout.EndHorizontal();
  991. }
  992. EditorGUILayout.BeginHorizontal();
  993. GUILayout.Space(70 + space);
  994. if (!currentTerrain.detailPrototypes[countGrass].usePrototypeMesh)
  995. {
  996. currentTerrain.detailPrototypes[countGrass].maxWidth = EditorGUILayout.FloatField("Max. Width", currentTerrain.detailPrototypes[countGrass].maxWidth);
  997. }
  998. else
  999. {
  1000. currentTerrain.detailPrototypes[countGrass].maxWidth = EditorGUILayout.FloatField("Ramdom Width", currentTerrain.detailPrototypes[countGrass].maxWidth);
  1001. }
  1002. EditorGUILayout.EndHorizontal();
  1003. if (!currentTerrain.detailPrototypes[countGrass].usePrototypeMesh)
  1004. {
  1005. EditorGUILayout.BeginHorizontal();
  1006. GUILayout.Space(70 + space);
  1007. currentTerrain.detailPrototypes[countGrass].minHeight = EditorGUILayout.FloatField("Min. Height", currentTerrain.detailPrototypes[countGrass].minHeight);
  1008. EditorGUILayout.EndHorizontal();
  1009. }
  1010. EditorGUILayout.BeginHorizontal();
  1011. GUILayout.Space(70 + space);
  1012. if (!currentTerrain.detailPrototypes[countGrass].usePrototypeMesh)
  1013. {
  1014. currentTerrain.detailPrototypes[countGrass].maxHeight = EditorGUILayout.FloatField("Max. Height", currentTerrain.detailPrototypes[countGrass].maxHeight);
  1015. }
  1016. else
  1017. {
  1018. currentTerrain.detailPrototypes[countGrass].maxHeight = EditorGUILayout.FloatField("Random Height", currentTerrain.detailPrototypes[countGrass].maxHeight);
  1019. }
  1020. EditorGUILayout.EndHorizontal();
  1021. EditorGUILayout.BeginHorizontal();
  1022. GUILayout.Space(70 + space);
  1023. currentTerrain.detailPrototypes[countGrass].noiseSpread = EditorGUILayout.FloatField("Noise Spread", currentTerrain.detailPrototypes[countGrass].noiseSpread);
  1024. EditorGUILayout.EndHorizontal();
  1025. if (!currentTerrain.detailPrototypes[countGrass].usePrototypeMesh)
  1026. {
  1027. EditorGUILayout.BeginHorizontal();
  1028. GUILayout.Space(70 + space);
  1029. currentTerrain.detailPrototypes[countGrass].bendFactor = EditorGUILayout.FloatField("Bend Factor", currentTerrain.detailPrototypes[countGrass].bendFactor);
  1030. EditorGUILayout.EndHorizontal();
  1031. }
  1032. EditorGUILayout.BeginHorizontal();
  1033. GUILayout.Space(70 + space);
  1034. currentTerrain.detailPrototypes[countGrass].healthyColor = EditorGUILayout.ColorField("Healthy Color", currentTerrain.detailPrototypes[countGrass].healthyColor);
  1035. EditorGUILayout.EndHorizontal();
  1036. EditorGUILayout.BeginHorizontal();
  1037. GUILayout.Space(70 + space);
  1038. currentTerrain.detailPrototypes[countGrass].dryColor = EditorGUILayout.ColorField("Dry Color", currentTerrain.detailPrototypes[countGrass].dryColor);
  1039. EditorGUILayout.EndHorizontal();
  1040. EditorGUILayout.BeginHorizontal();
  1041. GUILayout.Space(70 + space);
  1042. currentTerrain.detailPrototypes[countGrass].renderMode = (DetailRenderMode)EditorGUILayout.EnumPopup("Render Mode", (Enum)currentTerrain.detailPrototypes[countGrass].renderMode);
  1043. EditorGUILayout.EndHorizontal();
  1044. }
  1045. }
  1046. if (currentTerrain.detailPrototypes.Count > 0)
  1047. {
  1048. GUILayout.Space(5);
  1049. EditorGUILayout.BeginHorizontal();
  1050. GUILayout.Space(30 + space);
  1051. EditorGUILayout.LabelField("Scale Multi", GUILayout.Width(147.0f));
  1052. currentTerrain.grassScaleMulti = EditorGUILayout.FloatField(currentTerrain.grassScaleMulti);
  1053. if (currentTerrain.grassScaleMulti < 0.01f) currentTerrain.grassScaleMulti = 0.01f;
  1054. EditorGUILayout.EndHorizontal();
  1055. }
  1056. //EditorGUILayout.BeginHorizontal();
  1057. //GUILayout.Space(30 + space);
  1058. //if (TC_Settings.instance.global.tooltip)
  1059. //{
  1060. // tooltipText = "Open Grass/Detail Preset from saved file";
  1061. //}
  1062. //if (GUILayout.Button(new GUIContent("Open", tooltipText), GUILayout.Width(45.0f)))
  1063. //{
  1064. // string path_grass_open1 = EditorUtility.OpenFilePanel("Open Grass/Detail Preset", Application.dataPath + "/TerrainComposer/save/presets/grass", "prefab");
  1065. // if (path_grass_open1.Length != 0)
  1066. // {
  1067. // load_grass_preset(path_grass_open1, currentTerrain, 0, false);
  1068. // }
  1069. //}
  1070. //if (TC_Settings.instance.global.tooltip)
  1071. //{
  1072. // tooltipText = "Save grass Texture Preset";
  1073. //}
  1074. //if (GUILayout.Button(new GUIContent("Save", tooltipText), GUILayout.Width(45.0f)))
  1075. //{
  1076. // string path_grass_save = EditorUtility.SaveFilePanel("Save Grass/Detail Preset", Application.dataPath + "/TerrainComposer/save/presets/grass", "", "prefab");
  1077. // if (path_grass_save.Length != 0)
  1078. // {
  1079. // save_grass_preset1(path_grass_save, currentTerrain);
  1080. // }
  1081. //}
  1082. //EditorGUILayout.EndHorizontal();
  1083. }
  1084. if (terrainArea.resetTab && currentTerrain.terrain != null)
  1085. {
  1086. TD.DrawLabelWidthUnderline("Terrain Reset", 14);
  1087. EditorGUILayout.BeginHorizontal();
  1088. GUILayout.Space(30 + space);
  1089. // EditorGUILayout.LabelField("Reset ->", EditorStyles.boldLabel, GUILayout.Width(60.0f));
  1090. if (TC_Settings.instance.global.tooltip)
  1091. {
  1092. tooltipText = "Reset Heightmap Data of " + currentTerrain.terrain.name + " in Scene\n(Control Click)\n\nReset Heightmap Data of all Terrains\n(Control Shift Click)";
  1093. }
  1094. DrawReset(terrainArea, currentTerrain, space);
  1095. if (TC_Settings.instance.global.tooltip)
  1096. {
  1097. tooltipText = "Reset Splatmap Data of " + currentTerrain.terrain.name + " in Scene\n(Control Click)\n\nReset Splatmap Data of all Terrains\n(Control Shift Click)";
  1098. }
  1099. if (TC_Settings.instance.global.tooltip)
  1100. {
  1101. tooltipText = "Reset placed Trees in " + currentTerrain.terrain.name + " in Scene\n(Control Click)\n\nReset placed Trees in all Terrains\n(Control Shift Click)";
  1102. }
  1103. if (TC_Settings.instance.global.tooltip)
  1104. {
  1105. tooltipText = "Reset Detail/Grass Data of " + currentTerrain.terrain.name + " in Scene\n(Control Click)\n\nReset Detail/Grass Data of all Terrains\n(Control Shift Click)";
  1106. }
  1107. if (TC_Settings.instance.global.tooltip)
  1108. {
  1109. tooltipText = "Erase placed Objects in Scene\n(Control Click)";
  1110. }
  1111. EditorGUILayout.EndHorizontal();
  1112. }
  1113. GUI.color = Color.white;
  1114. GUILayout.Space(20);
  1115. if (terrainArea.sizeTab || terrainArea.resolutionsTab || terrainArea.splatTab || terrainArea.treeTab || terrainArea.grassTab || terrainArea.resetTab)
  1116. {
  1117. EditorGUILayout.BeginHorizontal();
  1118. if (terrainArea.splatTab || terrainArea.resetTab) EditorGUILayout.LabelField("Apply to", GUILayout.Width(100));
  1119. else
  1120. {
  1121. if (GUILayout.Button("Apply", GUILayout.Width(100))) Apply();
  1122. EditorGUILayout.LabelField("to", GUILayout.Width(20f));
  1123. }
  1124. terrainArea.applyChanges = (ApplyChanges)EditorGUILayout.EnumPopup(terrainArea.applyChanges);
  1125. EditorGUILayout.EndHorizontal();
  1126. GUILayout.Space(5);
  1127. }
  1128. EditorGUILayout.EndVertical();
  1129. }
  1130. public void Apply()
  1131. {
  1132. bool generate = false;
  1133. // Debug.Log("Apply");
  1134. if (terrainArea.sizeTab)
  1135. {
  1136. terrainArea.ApplySize();
  1137. generate = true;
  1138. }
  1139. if (terrainArea.resolutionsTab)
  1140. {
  1141. terrainArea.ApplyResolution();
  1142. generate = true;
  1143. }
  1144. if (terrainArea.splatTab)
  1145. {
  1146. if (terrainArea.applyChanges == ApplyChanges.Terrain) terrainArea.terrains[terrainArea.terrainSelect].ApplySplatTextures();
  1147. else if (terrainArea.applyChanges == ApplyChanges.TerrainArea || terrainArea.applyChanges == ApplyChanges.AllTerrainAreas) terrainArea.ApplySplatTextures(currentTerrain);
  1148. // else if (terrainArea.applyChanges == ApplyChanges.AllTerrainAreas) GlobalManager.singleton.ApplySplatTexturesTerrainAreas(currentTerrain);
  1149. TC.RefreshOutputReferences(TC.splatOutput);
  1150. generate = true;
  1151. }
  1152. if (terrainArea.treeTab)
  1153. {
  1154. if (terrainArea.applyChanges == ApplyChanges.Terrain) terrainArea.terrains[terrainArea.terrainSelect].ApplyTrees();
  1155. else if (terrainArea.applyChanges == ApplyChanges.TerrainArea) terrainArea.ApplyTrees();
  1156. TC.RefreshOutputReferences(TC.treeOutput);
  1157. generate = true;
  1158. }
  1159. if (terrainArea.grassTab)
  1160. {
  1161. if (terrainArea.applyChanges == ApplyChanges.Terrain) terrainArea.terrains[terrainArea.terrainSelect].ApplyGrass();
  1162. else if (terrainArea.applyChanges == ApplyChanges.TerrainArea) terrainArea.ApplyGrass();
  1163. TC.RefreshOutputReferences(TC.grassOutput);
  1164. generate = true;
  1165. }
  1166. if (generate)
  1167. {
  1168. if (TC_Generate.instance != null)
  1169. {
  1170. if (TC_Generate.instance.autoGenerate) TC_Generate.instance.Generate(true);
  1171. }
  1172. }
  1173. }
  1174. public void DrawReset(TC_TerrainArea terrainArea, TCUnityTerrain preterrain, float space)
  1175. {
  1176. Rect rect = new Rect();
  1177. rect = GUILayoutUtility.GetLastRect();
  1178. rect.x += 64.0f;
  1179. rect.y += 2.0f;
  1180. if (GUILayout.Button("Heightmap", GUILayout.Width(75.0f)))
  1181. {
  1182. if (terrainArea.applyChanges == ApplyChanges.Terrain) terrainArea.terrains[terrainArea.terrainSelect].ResetHeightmap();
  1183. else if (terrainArea.applyChanges == ApplyChanges.TerrainArea) terrainArea.ResetHeightmap();
  1184. }
  1185. rect = GUILayoutUtility.GetLastRect();
  1186. rect.x += 79.0f;
  1187. if (GUILayout.Button("Splatmap", GUILayout.Width(75.0f)))
  1188. {
  1189. if (terrainArea.applyChanges == ApplyChanges.Terrain) terrainArea.terrains[terrainArea.terrainSelect].ResetSplatmap();
  1190. else if (terrainArea.applyChanges == ApplyChanges.TerrainArea) terrainArea.ResetSplatmap();
  1191. }
  1192. rect = GUILayoutUtility.GetLastRect();
  1193. rect.x += 79.0f;
  1194. if (GUILayout.Button("Trees", GUILayout.Width(75.0f)))
  1195. {
  1196. if (terrainArea.applyChanges == ApplyChanges.Terrain) terrainArea.terrains[terrainArea.terrainSelect].ResetTrees();
  1197. else if (terrainArea.applyChanges == ApplyChanges.TerrainArea) terrainArea.ResetTrees();
  1198. }
  1199. rect = GUILayoutUtility.GetLastRect();
  1200. rect.x += 79.0f;
  1201. if (GUILayout.Button("Grass", GUILayout.Width(75.0f)))
  1202. {
  1203. if (terrainArea.applyChanges == ApplyChanges.Terrain) terrainArea.terrains[terrainArea.terrainSelect].ResetGrass();
  1204. else if (terrainArea.applyChanges == ApplyChanges.TerrainArea) terrainArea.ResetGrass();
  1205. }
  1206. rect = GUILayoutUtility.GetLastRect();
  1207. rect.x += 79.0f;
  1208. if (GUILayout.Button("Objects", GUILayout.Width(75.0f)))
  1209. {
  1210. if (terrainArea.applyChanges == ApplyChanges.Terrain) terrainArea.terrains[terrainArea.terrainSelect].ResetObjects();
  1211. else if (terrainArea.applyChanges == ApplyChanges.TerrainArea) terrainArea.ResetObjects();
  1212. }
  1213. }
  1214. public TCUnityTerrain getSetPreterrain;
  1215. public void DrawCreateTerrain(float space, int draw_from)
  1216. {
  1217. GUI.color = Color.green;
  1218. EditorGUILayout.BeginVertical("Box");
  1219. GUI.color = Color.white;
  1220. EditorGUILayout.BeginHorizontal();
  1221. GUILayout.Space(space);
  1222. if (!terrainArea.terrainDataPath.Contains(Application.dataPath)) terrainArea.terrainDataPath = Application.dataPath;
  1223. EditorGUILayout.LabelField("Path", GUILayout.Width(160.0f));
  1224. if (draw_from == 0)
  1225. {
  1226. EditorGUILayout.LabelField("" + terrainArea.terrainDataPath);
  1227. }
  1228. else
  1229. {
  1230. //! EditorGUILayout.LabelField("" + script.terrain_slice_path);
  1231. }
  1232. Rect rect = GUILayoutUtility.GetLastRect();
  1233. if (GUI.Button(new Rect(EditorGUIUtility.currentViewWidth - 98, rect.y, 90, 19), new GUIContent("Change", button_folder)))
  1234. {
  1235. if (!eventCurrent.shift)
  1236. {
  1237. string terrain_path = null;
  1238. if (draw_from == 0)
  1239. {
  1240. terrain_path = EditorUtility.OpenFolderPanel("Export File Path", terrainArea.terrainDataPath, "");
  1241. if (terrain_path != "") { terrainArea.terrainDataPath = terrain_path; }
  1242. }
  1243. else
  1244. {
  1245. //! terrain_path = EditorUtility.OpenFolderPanel("Export File Path", script.terrain_slice_path, "");
  1246. //! if (terrain_path != "") { script.terrain_slice_path = terrain_path; }
  1247. }
  1248. }
  1249. else
  1250. {
  1251. if (draw_from == 0)
  1252. {
  1253. terrainArea.terrainDataPath = Application.dataPath;
  1254. }
  1255. else
  1256. {
  1257. //! script.terrain_slice_path = Application.dataPath;
  1258. }
  1259. }
  1260. }
  1261. EditorGUILayout.EndHorizontal();
  1262. GUILayout.Space(3);
  1263. EditorGUILayout.BeginHorizontal();
  1264. GUILayout.Space(space);
  1265. EditorGUILayout.LabelField("Terrain Name", GUILayout.Width(160.0f));
  1266. terrainArea.terrainName = EditorGUILayout.TextField(terrainArea.terrainName);
  1267. EditorGUILayout.EndHorizontal();
  1268. if (terrainArea.terrains == null)
  1269. {
  1270. terrainArea.terrains = new List<TCUnityTerrain>();
  1271. terrainArea.terrains.Add(new TCUnityTerrain());
  1272. }
  1273. if (terrainArea.terrains.Count > 1)
  1274. {
  1275. //EditorGUILayout.BeginHorizontal();
  1276. // GUILayout.Space(space);
  1277. // EditorGUILayout.LabelField("Copy Settings Terrain", GUILayout.Width(160.0f));
  1278. // // EditorGUILayout.LabelField("Terrain",GUILayout.Width(70));
  1279. // gui_changed_old = GUI.changed;
  1280. // gui_changed_window = GUI.changed; GUI.changed = false;
  1281. // current_terrain.copy_terrain = EditorGUILayout.IntField(current_terrain.copy_terrain, GUILayout.Width(50.0f));
  1282. // if (GUI.changed)
  1283. // {
  1284. // if (current_terrain.copy_terrain == i) { --current_terrain.copy_terrain; }
  1285. // if (current_terrain.copy_terrain < 0) { current_terrain.copy_terrain = 0; }
  1286. // if (current_terrain.copy_terrain > terrainArea.terrains.Count - 1) { current_terrain.copy_terrain = terrainArea.terrains.Count - 1; }
  1287. // }
  1288. // GUI.changed = gui_changed_old;
  1289. // current_terrain.copy_terrain_settings = EditorGUILayout.Toggle(current_terrain.copy_terrain_settings, GUILayout.Width(25.0f));
  1290. //EditorGUILayout.EndHorizontal();
  1291. EditorGUILayout.BeginHorizontal();
  1292. GUILayout.Space(space);
  1293. EditorGUILayout.LabelField("Copy Terrain Material", GUILayout.Width(160.0f));
  1294. // script.settings.copy_terrain_material = EditorGUILayout.Toggle(script.settings.copy_terrain_material, GUILayout.Width(25.0f));
  1295. EditorGUILayout.EndHorizontal();
  1296. }
  1297. guiChanged = GUI.changed;
  1298. GUI.changed = false;
  1299. EditorGUILayout.BeginHorizontal();
  1300. GUILayout.Space(space);
  1301. EditorGUILayout.LabelField("Tiles X", GUILayout.Width(160.0f));
  1302. int tileX = terrainArea.selectTiles.x;
  1303. tileX = EditorGUILayout.IntSlider(tileX, 1, 32);
  1304. EditorGUILayout.EndHorizontal();
  1305. EditorGUILayout.BeginHorizontal();
  1306. GUILayout.Space(space);
  1307. EditorGUILayout.LabelField("Tiles Y", GUILayout.Width(131.0f));
  1308. terrainArea.tileLink = EditorGUILayout.Toggle(terrainArea.tileLink, GUILayout.Width(25.0f));
  1309. int tileY;
  1310. if (terrainArea.tileLink) tileY = tileX; else tileY = terrainArea.selectTiles.y;
  1311. tileY = EditorGUILayout.IntSlider(tileY, 1, 32);
  1312. terrainArea.selectTiles = new Int2(tileX, tileY);
  1313. EditorGUILayout.EndHorizontal();
  1314. if (GUI.changed)
  1315. {
  1316. if (terrainArea.tileLink) terrainArea.tiles = new Int2(terrainArea.tiles.x, terrainArea.tiles.x);
  1317. // script.calc_terrain_needed_tiles();
  1318. guiChanged = true;
  1319. }
  1320. GUI.changed = guiChanged;
  1321. EditorGUILayout.BeginHorizontal();
  1322. GUILayout.Space(space);
  1323. if (GUILayout.Button("Create", GUILayout.Width(150.0f)))
  1324. {
  1325. terrainArea.CreateTerrains();
  1326. TC.AutoGenerate();
  1327. }
  1328. EditorGUILayout.EndHorizontal();
  1329. EditorGUILayout.EndVertical();
  1330. }
  1331. public void generate_auto() { } // !
  1332. public void CloseTerrainTabs()
  1333. {
  1334. terrainArea.sizeTab = terrainArea.resolutionsTab = terrainArea.settingsTab = terrainArea.splatTab = terrainArea.treeTab = terrainArea.grassTab = terrainArea.resetTab = false;
  1335. }
  1336. //public void save_splat_preset1(string path1, TCUnityTerrain preterrain1)
  1337. //{
  1338. // FileInfo file_info = new FileInfo(path1);
  1339. // path1 = path1.Replace(Application.dataPath + "/", "Assets/");
  1340. // GameObject object_cs2 = new GameObject();
  1341. // // save_splat_preset script3 = object_cs2.AddComponent<save_splat_preset>();
  1342. // // !script3.splatPrototypes = preterrain1.splatPrototypes;
  1343. // AssetDatabase.DeleteAsset(path1);
  1344. // UnityEngine.Object prefab = PrefabUtility.CreateEmptyPrefab(path1);
  1345. // PrefabUtility.ReplacePrefab(object_cs2, prefab, ReplacePrefabOptions.ReplaceNameBased);
  1346. // // VersionControl.Provider.Checkout(prefab,CheckoutMode.Both);
  1347. // DestroyImmediate(object_cs2);
  1348. // AssetDatabase.SaveAssets();
  1349. // AssetDatabase.Refresh();
  1350. //}
  1351. //public void save_tree_preset1(string path1, TCUnityTerrain preterrain1)
  1352. //{
  1353. // FileInfo file_info = new FileInfo(path1);
  1354. // path1 = path1.Replace(Application.dataPath + "/", "Assets/");
  1355. // GameObject object_cs3 = new GameObject();
  1356. // // save_tree_preset script3 = object_cs3.AddComponent<save_tree_preset>();
  1357. // // !script3.treePrototypes = preterrain1.treePrototypes;
  1358. // AssetDatabase.DeleteAsset(path1);
  1359. // UnityEngine.Object prefab = PrefabUtility.CreateEmptyPrefab(path1);
  1360. // PrefabUtility.ReplacePrefab(object_cs3, prefab, ReplacePrefabOptions.ReplaceNameBased);
  1361. // // VersionControl.Provider.Checkout(prefab,CheckoutMode.Both);
  1362. // DestroyImmediate(object_cs3);
  1363. // AssetDatabase.SaveAssets();
  1364. // AssetDatabase.Refresh();
  1365. //}
  1366. //public void save_grass_preset1(string path1, TCUnityTerrain preterrain1)
  1367. //{
  1368. // FileInfo file_info = new FileInfo(path1);
  1369. // path1 = path1.Replace(Application.dataPath + "/", "Assets/");
  1370. // GameObject object_cs4 = new GameObject();
  1371. // // save_grass_preset script3 = object_cs4.AddComponent<save_grass_preset>();
  1372. // // !script3.detailPrototypes = preterrain1.detailPrototypes;
  1373. // AssetDatabase.DeleteAsset(path1);
  1374. // UnityEngine.Object prefab = PrefabUtility.CreateEmptyPrefab(path1);
  1375. // PrefabUtility.ReplacePrefab(object_cs4, prefab, ReplacePrefabOptions.ReplaceNameBased);
  1376. // // VersionControl.Provider.Checkout(prefab,CheckoutMode.Both);
  1377. // DestroyImmediate(object_cs4);
  1378. // AssetDatabase.SaveAssets();
  1379. // AssetDatabase.Refresh();
  1380. //}
  1381. //public void load_splat_preset(string path1, TCUnityTerrain preterrain1, int splat_index, bool add)
  1382. //{
  1383. // path1 = path1.Replace(Application.dataPath + "/", "Assets/");
  1384. // GameObject object_cs5 = (GameObject)Instantiate(AssetDatabase.LoadAssetAtPath(path1, typeof(GameObject)));
  1385. // // save_splat_preset script3 = object_cs5.GetComponent<save_splat_preset>();
  1386. // //if (script3 != null)
  1387. // //{
  1388. // // if (!add)
  1389. // // {
  1390. // // // !preterrain1.splatPrototypes = script3.splatPrototypes;
  1391. // // }
  1392. // // else
  1393. // // {
  1394. // // for (int count_splat = 0; count_splat < script3.splatPrototypes.Count; ++count_splat)
  1395. // // {
  1396. // // // !preterrain1.splatPrototypes.Insert(splat_index, script3.splatPrototypes[count_splat]);
  1397. // // }
  1398. // // }
  1399. // // preterrain1.clear_null_splatprototype();
  1400. // //}
  1401. // //else { this.ShowNotification(new GUIContent("This file is not a Splat preset")); }
  1402. // DestroyImmediate(object_cs5);
  1403. //}
  1404. //public void load_tree_preset(string path1, TCUnityTerrain preterrain1, int tree_index, bool add)
  1405. //{
  1406. // path1 = path1.Replace(Application.dataPath + "/", "Assets/");
  1407. // GameObject object_cs6 = (GameObject)Instantiate(AssetDatabase.LoadAssetAtPath(path1, typeof(GameObject)));
  1408. // // save_tree_preset script3 = object_cs6.GetComponent<save_tree_preset>();
  1409. // //if (script3 != null)
  1410. // //{
  1411. // // if (!add)
  1412. // // {
  1413. // // // !preterrain1.treePrototypes = script3.treePrototypes;
  1414. // // }
  1415. // // else
  1416. // // {
  1417. // // for (int count_tree = 0; count_tree < script3.treePrototypes.Count; ++count_tree)
  1418. // // {
  1419. // // // !preterrain1.treePrototypes.Insert(tree_index, script3.treePrototypes[count_tree]);
  1420. // // }
  1421. // // }
  1422. // // preterrain1.clear_null_treeprototype();
  1423. // //}
  1424. // //else { this.ShowNotification(new GUIContent("This file is not a Tree preset")); }
  1425. // DestroyImmediate(object_cs6);
  1426. //}
  1427. //public void load_grass_preset(string path1, TCUnityTerrain preterrain1, int grass_index, bool add)
  1428. //{
  1429. // path1 = path1.Replace(Application.dataPath + "/", "Assets/");
  1430. // GameObject object_cs7 = (GameObject)Instantiate(AssetDatabase.LoadAssetAtPath(path1, typeof(GameObject)));
  1431. // // save_grass_preset script3 = object_cs7.GetComponent<save_grass_preset>();
  1432. // //if (script3 != null)
  1433. // //{
  1434. // // if (!add)
  1435. // // {
  1436. // // // !preterrain1.detailPrototypes = script3.detailPrototypes;
  1437. // // }
  1438. // // else
  1439. // // {
  1440. // // for (int count_grass = 0; count_grass < script3.detailPrototypes.Count; ++count_grass)
  1441. // // {
  1442. // // // !preterrain1.detailPrototypes.Insert(grass_index, script3.detailPrototypes[count_grass]);
  1443. // // }
  1444. // // }
  1445. // // preterrain1.clear_null_detailprototype();
  1446. // //}
  1447. // //else { this.ShowNotification(new GUIContent("This file is not a Grass/Detail preset")); }
  1448. // DestroyImmediate(object_cs7);
  1449. //}
  1450. void UndoRegister(string text)
  1451. {
  1452. return;
  1453. // Undo.RecordObject(currentTerrain, text);
  1454. }
  1455. public void LoadButtonTextures()
  1456. {
  1457. // button_heightmap = (Texture)AssetDatabase.LoadAssetAtPath(TC.installPath + "/GUI/Buttons/button_heightmap.png", typeof(Texture));
  1458. // button_colormap = (Texture)AssetDatabase.LoadAssetAtPath(TC.installPath + "/GUI/Buttons/button_colormap.png", typeof(Texture));
  1459. button_splatmap = (Texture)AssetDatabase.LoadAssetAtPath(TC.installPath + "/GUI/Buttons/button_splatmap.png", typeof(Texture));
  1460. button_tree = (Texture)AssetDatabase.LoadAssetAtPath(TC.installPath + "/GUI/Buttons/button_tree.png", typeof(Texture));
  1461. button_grass = (Texture)AssetDatabase.LoadAssetAtPath(TC.installPath + "/GUI/Buttons/button_grass.png", typeof(Texture));
  1462. // button_object = (Texture)AssetDatabase.LoadAssetAtPath(TC.installPath + "/GUI/Buttons/button_objects.png", typeof(Texture));
  1463. // button_export = (Texture)AssetDatabase.LoadAssetAtPath(TC.installPath + "/GUI/Buttons/button_savedisk.png", typeof(Texture));
  1464. // button_measure_tool = (Texture)AssetDatabase.LoadAssetAtPath(TC.installPath + "/GUI/Buttons/button_measure_tool.png", typeof(Texture));
  1465. // button_meshcapture_tool = (Texture)AssetDatabase.LoadAssetAtPath(TC.installPath + "/GUI/Buttons/button_meshcapture_tool.png", typeof(Texture));
  1466. // button_tools = (Texture)AssetDatabase.LoadAssetAtPath(TC.installPath + "/GUI/Buttons/button_tools.png", typeof(Texture));
  1467. // button_terrain = (Texture)AssetDatabase.LoadAssetAtPath(TC.installPath + "/GUI/Buttons/button_terrain.png", typeof(Texture));
  1468. // button_globe = (Texture)AssetDatabase.LoadAssetAtPath(TC.installPath + "/GUI/Buttons/button_globe.png", typeof(Texture));
  1469. // button_help = (Texture)AssetDatabase.LoadAssetAtPath(TC.installPath + "/GUI/Buttons/button_help.png", typeof(Texture));
  1470. button_reset = (Texture)AssetDatabase.LoadAssetAtPath(TC.installPath + "/GUI/Buttons/button_reset.png", typeof(Texture));
  1471. button_settings = (Texture)AssetDatabase.LoadAssetAtPath(TC.installPath + "/GUI/Buttons/button_settings.png", typeof(Texture));
  1472. button_resolution = (Texture)AssetDatabase.LoadAssetAtPath(TC.installPath + "/GUI/Buttons/button_resolution.png", typeof(Texture));
  1473. button_size = (Texture)AssetDatabase.LoadAssetAtPath(TC.installPath + "/GUI/Buttons/button_size.png", typeof(Texture));
  1474. // button_localArea = (Texture)AssetDatabase.LoadAssetAtPath(TC.installPath + "/GUI/Buttons/button_localArea.png", typeof(Texture));
  1475. // button_script = (Texture)AssetDatabase.LoadAssetAtPath(TC.installPath + "/GUI/Buttons/button_script.png", typeof(Texture));
  1476. // button_stitch = (Texture)AssetDatabase.LoadAssetAtPath(TC.installPath + "/GUI/Buttons/button_stitch.png", typeof(Texture));
  1477. // button_smooth = (Texture)AssetDatabase.LoadAssetAtPath(TC.installPath + "/GUI/Buttons/button_smooth.png", typeof(Texture));
  1478. // button_search = (Texture)AssetDatabase.LoadAssetAtPath(TC.installPath + "/GUI/Buttons/button_search.png", typeof(Texture));
  1479. // button_open = (Texture)AssetDatabase.LoadAssetAtPath(TC.installPath + "/GUI/Buttons/button_open.png", typeof(Texture));
  1480. // button_slice = (Texture)AssetDatabase.LoadAssetAtPath(TC.installPath + "/GUI/Buttons/button_slice.png", typeof(Texture));
  1481. // button_convert = (Texture)AssetDatabase.LoadAssetAtPath(TC.installPath + "/GUI/Buttons/button_convert.png", typeof(Texture));
  1482. // button_sun = (Texture)AssetDatabase.LoadAssetAtPath(TC.installPath + "/GUI/Buttons/button_sun.png", typeof(Texture));
  1483. // button_global = (Texture)AssetDatabase.LoadAssetAtPath(TC.installPath + "/GUI/Buttons/button_global.png", typeof(Texture));
  1484. button_folder = (Texture)AssetDatabase.LoadAssetAtPath(TC.installPath + "/GUI/Buttons/button_folder.png", typeof(Texture));
  1485. // button_rtp = (Texture)AssetDatabase.LoadAssetAtPath(TC.installPath + "/GUI/Buttons/button_rtp.png", typeof(Texture));
  1486. // palette_texture = (Texture)AssetDatabase.LoadAssetAtPath(TC.installPath + "/GUI/Buttons/Palette.png", typeof(Texture));
  1487. }
  1488. }
  1489. }