ToolProperties.cs 105 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079
  1. /*
  2. Copyright (c) 2020 Omar Duarte
  3. Unauthorized copying of this file, via any medium is strictly prohibited.
  4. Writen by Omar Duarte, 2020.
  5. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  6. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  7. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  8. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  9. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  10. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  11. THE SOFTWARE.
  12. */
  13. using System.Linq;
  14. using UnityEngine;
  15. namespace PluginMaster
  16. {
  17. public class ToolProperties : UnityEditor.EditorWindow
  18. {
  19. #region COMMON
  20. private const string UNDO_MSG = "Tool properties";
  21. private Vector2 _mainScrollPosition = Vector2.zero;
  22. private GUIContent _updateButtonContent = null;
  23. private GUISkin _skin = null;
  24. private GUIStyle _reloadBtnStyle = null;
  25. private static ToolProperties _instance = null;
  26. [UnityEditor.MenuItem("Tools/Plugin Master/Prefab World Builder/Tool Properties...", false, 1130)]
  27. public static void ShowWindow() => _instance = GetWindow<ToolProperties>("Tool Properties");
  28. public static void RepainWindow()
  29. {
  30. if (_instance != null) _instance.Repaint();
  31. }
  32. public static void CloseWindow()
  33. {
  34. if (_instance != null) _instance.Close();
  35. }
  36. private void OnEnable()
  37. {
  38. if (BrushManager.settings.paintOnMeshesWithoutCollider) PWBCore.UpdateTempColliders();
  39. _updateButtonContent
  40. = new GUIContent(Resources.Load<Texture2D>("Sprites/Update"), "Update Temp Colliders");
  41. _skin = Resources.Load<GUISkin>("PWBSkin");
  42. _reloadBtnStyle = _skin.GetStyle("EyeButton");
  43. UnityEditor.Undo.undoRedoPerformed += Repaint;
  44. }
  45. private void OnDisable()
  46. {
  47. PWBCore.DestroyTempColliders();
  48. UnityEditor.Undo.undoRedoPerformed -= Repaint;
  49. }
  50. private void OnGUI()
  51. {
  52. if (_instance == null) _instance = this;
  53. using (var scrollView = new UnityEditor.EditorGUILayout.ScrollViewScope(_mainScrollPosition,
  54. false, false, GUI.skin.horizontalScrollbar, GUI.skin.verticalScrollbar, GUIStyle.none))
  55. {
  56. _mainScrollPosition = scrollView.scrollPosition;
  57. #if UNITY_2021_2_OR_NEWER
  58. #else
  59. if (PWBToolbar.instance == null) PWBToolbar.ShowWindow();
  60. #endif
  61. if (ToolManager.tool == ToolManager.PaintTool.PIN) PinGroup();
  62. else if (ToolManager.tool == ToolManager.PaintTool.BRUSH) BrushGroup();
  63. else if (ToolManager.tool == ToolManager.PaintTool.ERASER) EraserGroup();
  64. else if (ToolManager.tool == ToolManager.PaintTool.GRAVITY) GravityGroup();
  65. else if (ToolManager.tool == ToolManager.PaintTool.EXTRUDE) ExtrudeGroup();
  66. else if (ToolManager.tool == ToolManager.PaintTool.LINE) LineGroup();
  67. else if (ToolManager.tool == ToolManager.PaintTool.SHAPE) ShapeGroup();
  68. else if (ToolManager.tool == ToolManager.PaintTool.TILING) TilingGroup();
  69. else if (ToolManager.tool == ToolManager.PaintTool.SELECTION) SelectionGroup();
  70. else if (ToolManager.tool == ToolManager.PaintTool.CIRCLE_SELECT) CircleSelectGroup();
  71. else if (ToolManager.tool == ToolManager.PaintTool.MIRROR) MirrorGroup();
  72. else if (ToolManager.tool == ToolManager.PaintTool.REPLACER) ReplacerGroup();
  73. else if (ToolManager.tool == ToolManager.PaintTool.FLOOR) FloorGroup();
  74. else if (ToolManager.tool == ToolManager.PaintTool.WALL) WallGroup();
  75. }
  76. if (Event.current.type == EventType.MouseDown && Event.current.button == 0)
  77. {
  78. GUI.FocusControl(null);
  79. Repaint();
  80. }
  81. }
  82. public static void ClearUndo()
  83. {
  84. if (_instance == null) return;
  85. UnityEditor.Undo.ClearUndo(_instance);
  86. }
  87. #endregion
  88. #region UNDO
  89. [SerializeField] private LineData _lineData = LineData.instance;
  90. [SerializeField] private TilingData _tilingData = TilingData.instance;
  91. [SerializeField] private MirrorSettings _mirrorSettings = MirrorManager.settings;
  92. [SerializeField] private ShapeData _shapeData = ShapeData.instance;
  93. [SerializeField] private TilingManager _tilingManager = TilingManager.instance as TilingManager;
  94. [SerializeField] private ShapeManager _shapeManager = ShapeManager.instance as ShapeManager;
  95. [SerializeField] private LineManager _lineManager = LineManager.instance as LineManager;
  96. public static void RegisterUndo(string commandName)
  97. {
  98. if (_instance != null) UnityEditor.Undo.RegisterCompleteObjectUndo(_instance, commandName);
  99. }
  100. #endregion
  101. #region TOOL PROFILE
  102. public class ProfileData
  103. {
  104. public readonly IToolManager toolManager = null;
  105. public readonly string profileName = string.Empty;
  106. public ProfileData(IToolManager toolManager, string profileName)
  107. => (this.toolManager, this.profileName) = (toolManager, profileName);
  108. }
  109. private void ToolProfileGUI(IToolManager toolManager)
  110. {
  111. using (new GUILayout.HorizontalScope(UnityEditor.EditorStyles.helpBox))
  112. {
  113. GUILayout.FlexibleSpace();
  114. GUILayout.Label("Tool Profile:");
  115. if (GUILayout.Button(toolManager.selectedProfileName,
  116. UnityEditor.EditorStyles.popup, GUILayout.MinWidth(100)))
  117. {
  118. GUI.FocusControl(null);
  119. var menu = new UnityEditor.GenericMenu();
  120. foreach (var profileName in toolManager.profileNames)
  121. menu.AddItem(new GUIContent(profileName), profileName == toolManager.selectedProfileName,
  122. SelectProfileItem, new ProfileData(toolManager, profileName));
  123. menu.AddSeparator(string.Empty);
  124. if (toolManager.selectedProfileName != ToolProfile.DEFAULT) menu.AddItem(new GUIContent("Save"),
  125. false, SaveProfile, toolManager);
  126. menu.AddItem(new GUIContent("Save As..."), false, SaveProfileAs,
  127. new ProfileData(toolManager, toolManager.selectedProfileName));
  128. if (toolManager.selectedProfileName != ToolProfile.DEFAULT)
  129. menu.AddItem(new GUIContent("Delete Selected Profile"), false, DeleteProfile,
  130. new ProfileData(toolManager, toolManager.selectedProfileName));
  131. menu.AddItem(new GUIContent("Revert Selected Profile"), false, RevertProfile, toolManager);
  132. menu.AddItem(new GUIContent("Factory Reset Selected Profile"), false,
  133. FactoryResetProfile, toolManager);
  134. menu.ShowAsContext();
  135. }
  136. }
  137. }
  138. private void SelectProfile(ProfileData profileData)
  139. {
  140. GUI.FocusControl(null);
  141. profileData.toolManager.selectedProfileName = profileData.profileName;
  142. Repaint();
  143. if (ToolManager.tool == ToolManager.PaintTool.MIRROR)
  144. UnityEditor.SceneView.lastActiveSceneView.LookAt(MirrorManager.settings.mirrorPosition);
  145. else if (ToolManager.tool == ToolManager.PaintTool.LINE)
  146. LineManager.settings.OnDataChanged();
  147. UnityEditor.SceneView.RepaintAll();
  148. }
  149. private void SelectProfileItem(object value) => SelectProfile(value as ProfileData);
  150. private void SaveProfile(object value)
  151. {
  152. var manager = value as IToolManager;
  153. manager.SaveProfile();
  154. }
  155. private void SaveProfileAs(object value)
  156. {
  157. var profiledata = value as ProfileData;
  158. SaveProfileWindow.ShowWindow(profiledata, OnSaveProfileDone);
  159. }
  160. private void OnSaveProfileDone(IToolManager toolManager, string profileName)
  161. {
  162. toolManager.SaveProfileAs(profileName);
  163. Repaint();
  164. }
  165. private class SaveProfileWindow : UnityEditor.EditorWindow
  166. {
  167. private IToolManager _toolManager = null;
  168. private string _profileName = string.Empty;
  169. private System.Action<IToolManager, string> OnDone;
  170. public static void ShowWindow(ProfileData data, System.Action<IToolManager, string> OnDone)
  171. {
  172. var window = GetWindow<SaveProfileWindow>(true, "Save Profile");
  173. window._toolManager = data.toolManager;
  174. window._profileName = data.profileName;
  175. window.OnDone = OnDone;
  176. window.minSize = window.maxSize = new Vector2(160, 50);
  177. UnityEditor.EditorGUIUtility.labelWidth = 70;
  178. UnityEditor.EditorGUIUtility.fieldWidth = 70;
  179. }
  180. private void OnGUI()
  181. {
  182. const string textFieldName = "NewProfileName";
  183. GUI.SetNextControlName(textFieldName);
  184. _profileName = UnityEditor.EditorGUILayout.TextField(_profileName).Trim();
  185. GUI.FocusControl(textFieldName);
  186. using (new UnityEditor.EditorGUI.DisabledGroupScope(_profileName == string.Empty))
  187. {
  188. if (GUILayout.Button("Save"))
  189. {
  190. OnDone(_toolManager, _profileName);
  191. Close();
  192. }
  193. }
  194. }
  195. }
  196. private void DeleteProfile(object value)
  197. {
  198. var profiledata = value as ProfileData;
  199. profiledata.toolManager.DeleteProfile();
  200. if (ToolManager.tool == ToolManager.PaintTool.MIRROR)
  201. UnityEditor.SceneView.lastActiveSceneView.LookAt(MirrorManager.settings.mirrorPosition);
  202. }
  203. private void RevertProfile(object value)
  204. {
  205. var manager = value as IToolManager;
  206. manager.Revert();
  207. if (ToolManager.tool == ToolManager.PaintTool.MIRROR)
  208. UnityEditor.SceneView.lastActiveSceneView.LookAt(MirrorManager.settings.mirrorPosition);
  209. }
  210. private void FactoryResetProfile(object value)
  211. {
  212. var manager = value as IToolManager;
  213. manager.FactoryReset();
  214. if (ToolManager.tool == ToolManager.PaintTool.MIRROR)
  215. UnityEditor.SceneView.lastActiveSceneView.LookAt(MirrorManager.settings.mirrorPosition);
  216. }
  217. #endregion
  218. #region COMMON PAINT SETTINGS
  219. private static float _maxRadius = 50f;
  220. private static Vector3[] _dir =
  221. {
  222. Vector3.right, Vector3.left,
  223. Vector3.up, Vector3.down,
  224. Vector3.forward, Vector3.back
  225. };
  226. private static string[] _dirNames = new string[] { "+X", "-X", "+Y", "-Y", "+Z", "-Z" };
  227. private static readonly string[] _brushShapeOptions = { "Point", "Circle", "Square" };
  228. private static readonly string[] _spacingOptions = { "Auto", "Custom" };
  229. private void PaintSettingsGUI(IPaintOnSurfaceToolSettings paintOnSurfaceSettings,
  230. IPaintToolSettings paintSettings)
  231. {
  232. using (new GUILayout.VerticalScope(UnityEditor.EditorStyles.helpBox))
  233. {
  234. void UpdateTempColliders()
  235. {
  236. if (paintOnSurfaceSettings.paintOnMeshesWithoutCollider) PWBCore.UpdateTempColliders();
  237. else PWBCore.DestroyTempColliders();
  238. }
  239. using (new UnityEditor.EditorGUI.DisabledGroupScope
  240. (PWBCore.staticData.tempCollidersAction == PWBData.TempCollidersAction.NEVER_CREATE))
  241. {
  242. using (new GUILayout.HorizontalScope())
  243. {
  244. UnityEditor.EditorGUIUtility.labelWidth = 150;
  245. using (var check = new UnityEditor.EditorGUI.ChangeCheckScope())
  246. {
  247. var paintOnMeshesWithoutCollider
  248. = UnityEditor.EditorGUILayout.ToggleLeft("Paint on meshes without collider",
  249. paintOnSurfaceSettings.paintOnMeshesWithoutCollider);
  250. if (check.changed)
  251. {
  252. paintOnSurfaceSettings.paintOnMeshesWithoutCollider = paintOnMeshesWithoutCollider;
  253. UpdateTempColliders();
  254. UnityEditor.SceneView.RepaintAll();
  255. }
  256. }
  257. using (new UnityEditor.EditorGUI.DisabledGroupScope
  258. (!paintOnSurfaceSettings.paintOnMeshesWithoutCollider))
  259. if (GUILayout.Button(_updateButtonContent, _reloadBtnStyle))
  260. PWBCore.UpdateTempColliders();
  261. }
  262. }
  263. UnityEditor.EditorGUIUtility.labelWidth = 110;
  264. using (var check = new UnityEditor.EditorGUI.ChangeCheckScope())
  265. {
  266. var paintOnPalettePrefabs = UnityEditor.EditorGUILayout.ToggleLeft("Paint on palette prefabs",
  267. paintOnSurfaceSettings.paintOnPalettePrefabs);
  268. var paintOnSelectedOnly = UnityEditor.EditorGUILayout.ToggleLeft("Paint on selected only",
  269. paintOnSurfaceSettings.paintOnSelectedOnly);
  270. if (check.changed)
  271. {
  272. paintOnSurfaceSettings.paintOnPalettePrefabs = paintOnPalettePrefabs;
  273. paintOnSurfaceSettings.paintOnSelectedOnly = paintOnSelectedOnly;
  274. UpdateTempColliders();
  275. UnityEditor.SceneView.RepaintAll();
  276. }
  277. }
  278. }
  279. PaintToolSettingsGUI(paintSettings);
  280. }
  281. private void ParentSettingsGUI(IPaintToolSettings paintSettings)
  282. {
  283. using (new GUILayout.VerticalScope(UnityEditor.EditorStyles.helpBox))
  284. {
  285. using (var check = new UnityEditor.EditorGUI.ChangeCheckScope())
  286. {
  287. var autoCreateParent
  288. = UnityEditor.EditorGUILayout.ToggleLeft("Create parent", paintSettings.autoCreateParent);
  289. if (check.changed)
  290. {
  291. paintSettings.autoCreateParent = autoCreateParent;
  292. }
  293. }
  294. if (!paintSettings.autoCreateParent)
  295. {
  296. paintSettings.setSurfaceAsParent = UnityEditor.EditorGUILayout.ToggleLeft("Set surface as parent",
  297. paintSettings.setSurfaceAsParent);
  298. if (!paintSettings.setSurfaceAsParent)
  299. {
  300. using (var check = new UnityEditor.EditorGUI.ChangeCheckScope())
  301. {
  302. var parent = (Transform)UnityEditor.EditorGUILayout.ObjectField("Parent Transform:",
  303. paintSettings.parent, typeof(Transform), true);
  304. if (check.changed)
  305. {
  306. paintSettings.parent = parent;
  307. }
  308. }
  309. }
  310. }
  311. using (var check = new UnityEditor.EditorGUI.ChangeCheckScope())
  312. {
  313. var createSubparent = UnityEditor.EditorGUILayout.ToggleLeft("Create sub-parents per palette",
  314. paintSettings.createSubparentPerPalette);
  315. if (check.changed)
  316. {
  317. paintSettings.createSubparentPerPalette = createSubparent;
  318. }
  319. }
  320. using (var check = new UnityEditor.EditorGUI.ChangeCheckScope())
  321. {
  322. var createSubparent = UnityEditor.EditorGUILayout.ToggleLeft("Create sub-parents per tool",
  323. paintSettings.createSubparentPerTool);
  324. if (check.changed)
  325. {
  326. paintSettings.createSubparentPerTool = createSubparent;
  327. }
  328. }
  329. using (var check = new UnityEditor.EditorGUI.ChangeCheckScope())
  330. {
  331. var createSubparent = UnityEditor.EditorGUILayout.ToggleLeft("Create sub-parents per brush",
  332. paintSettings.createSubparentPerBrush);
  333. if (check.changed)
  334. {
  335. paintSettings.createSubparentPerBrush = createSubparent;
  336. }
  337. }
  338. using (var check = new UnityEditor.EditorGUI.ChangeCheckScope())
  339. {
  340. var createSubparent = UnityEditor.EditorGUILayout.ToggleLeft("Create sub-parents per prefab",
  341. paintSettings.createSubparentPerPrefab);
  342. if (check.changed)
  343. {
  344. paintSettings.createSubparentPerPrefab = createSubparent;
  345. }
  346. }
  347. }
  348. }
  349. private void OverwriteLayerGUI(IPaintToolSettings paintSettings)
  350. {
  351. using (new GUILayout.VerticalScope(UnityEditor.EditorStyles.helpBox))
  352. {
  353. using (var check = new UnityEditor.EditorGUI.ChangeCheckScope())
  354. {
  355. var overwritePrefabLayer = UnityEditor.EditorGUILayout.ToggleLeft("Overwrite prefab layer",
  356. paintSettings.overwritePrefabLayer);
  357. int layer = paintSettings.layer;
  358. if (paintSettings.overwritePrefabLayer) layer = UnityEditor.EditorGUILayout.LayerField("Layer:",
  359. paintSettings.layer);
  360. if (check.changed)
  361. {
  362. paintSettings.overwritePrefabLayer = overwritePrefabLayer;
  363. paintSettings.layer = layer;
  364. UnityEditor.SceneView.RepaintAll();
  365. }
  366. }
  367. }
  368. }
  369. private void PaintToolSettingsGUI(IPaintToolSettings paintSettings)
  370. {
  371. ParentSettingsGUI(paintSettings);
  372. OverwriteLayerGUI(paintSettings);
  373. }
  374. private void RadiusSlider(CircleToolBase settings)
  375. {
  376. using (new GUILayout.HorizontalScope())
  377. {
  378. using (var check = new UnityEditor.EditorGUI.ChangeCheckScope())
  379. {
  380. if (settings.radius > _maxRadius)
  381. _maxRadius = Mathf.Max(Mathf.Floor(settings.radius / 10) * 20f, 10f);
  382. UnityEditor.EditorGUIUtility.labelWidth = 60;
  383. var radius = UnityEditor.EditorGUILayout.Slider("Radius:", settings.radius, 0.05f, _maxRadius);
  384. if (check.changed)
  385. {
  386. settings.radius = radius;
  387. UnityEditor.SceneView.RepaintAll();
  388. }
  389. }
  390. if (GUILayout.Button("|>", GUILayout.Width(20))) _maxRadius *= 2f;
  391. if (GUILayout.Button("|<", GUILayout.Width(20)))
  392. _maxRadius = Mathf.Min(Mathf.Floor(settings.radius / 10f) * 10f + 10f, _maxRadius);
  393. }
  394. }
  395. private void BrushToolBaseSettingsGUI(BrushToolBase settings)
  396. {
  397. using (new GUILayout.VerticalScope(UnityEditor.EditorStyles.helpBox))
  398. {
  399. UnityEditor.EditorGUIUtility.labelWidth = 60;
  400. using (var check = new UnityEditor.EditorGUI.ChangeCheckScope())
  401. {
  402. var brushShape = (BrushToolSettings.BrushShape)UnityEditor.EditorGUILayout.Popup("Shape:",
  403. (int)settings.brushShape, _brushShapeOptions);
  404. if (check.changed)
  405. {
  406. settings.brushShape = brushShape;
  407. UnityEditor.SceneView.RepaintAll();
  408. }
  409. }
  410. if (settings.brushShape != BrushToolBase.BrushShape.POINT)
  411. {
  412. using (new GUILayout.VerticalScope(UnityEditor.EditorStyles.helpBox))
  413. {
  414. using (var check = new UnityEditor.EditorGUI.ChangeCheckScope())
  415. {
  416. var randomize
  417. = UnityEditor.EditorGUILayout.ToggleLeft("Randomize positions", settings.randomizePositions);
  418. if (check.changed)
  419. {
  420. settings.randomizePositions = randomize;
  421. UnityEditor.SceneView.RepaintAll();
  422. }
  423. }
  424. using (var check = new UnityEditor.EditorGUI.ChangeCheckScope())
  425. {
  426. UnityEditor.EditorGUIUtility.labelWidth = 80;
  427. var randomness = UnityEditor.EditorGUILayout.Slider("Randomness:", settings.randomness, 0f, 1f);
  428. if (check.changed)
  429. {
  430. settings.randomness = randomness;
  431. UnityEditor.SceneView.RepaintAll();
  432. }
  433. UnityEditor.EditorGUIUtility.labelWidth = 60;
  434. }
  435. }
  436. RadiusSlider(settings);
  437. }
  438. using (var check = new UnityEditor.EditorGUI.ChangeCheckScope())
  439. {
  440. var density = UnityEditor.EditorGUILayout.IntSlider("Density:", settings.density, 0, 100);
  441. if (check.changed)
  442. {
  443. settings.density = density;
  444. UnityEditor.SceneView.RepaintAll();
  445. }
  446. }
  447. using (var check = new UnityEditor.EditorGUI.ChangeCheckScope())
  448. {
  449. using (new GUILayout.VerticalScope(UnityEditor.EditorStyles.helpBox))
  450. {
  451. UnityEditor.EditorGUIUtility.labelWidth = 90;
  452. var spacingType = (BrushToolBase.SpacingType)UnityEditor.EditorGUILayout.Popup("Min Spacing:",
  453. (int)settings.spacingType, _spacingOptions);
  454. var spacing = settings.minSpacing;
  455. using (new UnityEditor.EditorGUI.DisabledGroupScope(spacingType != BrushToolBase.SpacingType.CUSTOM))
  456. {
  457. spacing = UnityEditor.EditorGUILayout.FloatField("Value:", settings.minSpacing);
  458. }
  459. if (check.changed)
  460. {
  461. settings.spacingType = spacingType;
  462. settings.minSpacing = spacing;
  463. UnityEditor.SceneView.RepaintAll();
  464. }
  465. }
  466. }
  467. using (new GUILayout.VerticalScope(UnityEditor.EditorStyles.helpBox))
  468. {
  469. using (var check = new UnityEditor.EditorGUI.ChangeCheckScope())
  470. {
  471. var orientAlongBrushstroke = UnityEditor.EditorGUILayout.ToggleLeft("Orient Along the Brushstroke",
  472. settings.orientAlongBrushstroke);
  473. var additionalAngle = settings.additionalOrientationAngle;
  474. if (orientAlongBrushstroke)
  475. additionalAngle = UnityEditor.EditorGUILayout.Vector3Field("Additonal angle:", additionalAngle);
  476. if (check.changed)
  477. {
  478. settings.orientAlongBrushstroke = orientAlongBrushstroke;
  479. settings.additionalOrientationAngle = additionalAngle;
  480. UnityEditor.SceneView.RepaintAll();
  481. }
  482. }
  483. }
  484. }
  485. }
  486. private void EmbedInSurfaceSettingsGUI(SelectionToolBaseBasic settings)
  487. {
  488. using (new GUILayout.VerticalScope(UnityEditor.EditorStyles.helpBox))
  489. {
  490. using (new UnityEditor.EditorGUI.DisabledGroupScope
  491. (PWBCore.staticData.tempCollidersAction == PWBData.TempCollidersAction.NEVER_CREATE))
  492. {
  493. using (new GUILayout.HorizontalScope())
  494. {
  495. using (var check = new UnityEditor.EditorGUI.ChangeCheckScope())
  496. {
  497. var createTempColliders = UnityEditor.EditorGUILayout.ToggleLeft("Create Temp Colliders",
  498. settings.createTempColliders);
  499. if (check.changed)
  500. {
  501. settings.createTempColliders = createTempColliders;
  502. PWBCore.UpdateTempColliders();
  503. UnityEditor.SceneView.RepaintAll();
  504. }
  505. }
  506. using (new UnityEditor.EditorGUI.DisabledGroupScope(!settings.createTempColliders))
  507. if (GUILayout.Button(_updateButtonContent, _reloadBtnStyle))
  508. PWBCore.UpdateTempColliders();
  509. }
  510. }
  511. using (var check = new UnityEditor.EditorGUI.ChangeCheckScope())
  512. {
  513. UnityEditor.EditorGUIUtility.labelWidth = 60;
  514. var embedInSurface = UnityEditor.EditorGUILayout.ToggleLeft("Embed On the Surface",
  515. settings.embedInSurface);
  516. if (check.changed)
  517. {
  518. settings.embedInSurface = embedInSurface;
  519. if (embedInSurface && settings is SelectionToolSettings) PWBIO.EmbedSelectionInSurface();
  520. UnityEditor.SceneView.RepaintAll();
  521. }
  522. }
  523. if (settings.embedInSurface)
  524. {
  525. using (var check = new UnityEditor.EditorGUI.ChangeCheckScope())
  526. {
  527. var embedAtPivotHeight = UnityEditor.EditorGUILayout.ToggleLeft("Embed At Pivot Height",
  528. settings.embedAtPivotHeight);
  529. if (check.changed)
  530. {
  531. settings.embedAtPivotHeight = embedAtPivotHeight;
  532. if (settings.embedInSurface && settings is SelectionToolSettings) PWBIO.EmbedSelectionInSurface();
  533. UnityEditor.SceneView.RepaintAll();
  534. }
  535. }
  536. using (var check = new UnityEditor.EditorGUI.ChangeCheckScope())
  537. {
  538. UnityEditor.EditorGUIUtility.labelWidth = 110;
  539. var surfaceDistance = UnityEditor.EditorGUILayout.FloatField("Surface Distance:",
  540. settings.surfaceDistance);
  541. if (check.changed)
  542. {
  543. settings.surfaceDistance = surfaceDistance;
  544. if (settings is SelectionToolSettings) PWBIO.EmbedSelectionInSurface();
  545. UnityEditor.SceneView.RepaintAll();
  546. }
  547. }
  548. if (settings is SelectionToolBase)
  549. {
  550. using (var check = new UnityEditor.EditorGUI.ChangeCheckScope())
  551. {
  552. var selectionSettings = settings as SelectionToolBase;
  553. var rotateToTheSurface = UnityEditor.EditorGUILayout.ToggleLeft("Rotate To the Surface",
  554. selectionSettings.rotateToTheSurface);
  555. if (check.changed)
  556. {
  557. selectionSettings.rotateToTheSurface = rotateToTheSurface;
  558. if (settings.embedInSurface && settings is SelectionToolSettings)
  559. PWBIO.EmbedSelectionInSurface();
  560. UnityEditor.SceneView.RepaintAll();
  561. }
  562. }
  563. }
  564. }
  565. }
  566. }
  567. private struct BrushPropertiesGroupState
  568. {
  569. public bool brushPosGroupOpen;
  570. public bool brushRotGroupOpen;
  571. public bool brushScaleGroupOpen;
  572. public bool brushFlipGroupOpen;
  573. }
  574. private void OverwriteBrushPropertiesGUI(IPaintToolSettings settings,
  575. ref BrushPropertiesGroupState state)
  576. {
  577. using (new GUILayout.VerticalScope(UnityEditor.EditorStyles.helpBox))
  578. {
  579. using (var check = new UnityEditor.EditorGUI.ChangeCheckScope())
  580. {
  581. var overwriteBrushProperties = UnityEditor.EditorGUILayout.ToggleLeft("Overwrite Brush Properties",
  582. settings.overwriteBrushProperties);
  583. if (check.changed)
  584. {
  585. settings.overwriteBrushProperties = overwriteBrushProperties;
  586. UnityEditor.SceneView.RepaintAll();
  587. }
  588. }
  589. if (PaletteManager.selectedBrush != null)
  590. settings.brushSettings.isAsset2D = PaletteManager.selectedBrush.isAsset2D;
  591. else settings.brushSettings.isAsset2D = false;
  592. if (settings.overwriteBrushProperties)
  593. BrushProperties.BrushFields(settings.brushSettings,
  594. ref state.brushPosGroupOpen, ref state.brushRotGroupOpen,
  595. ref state.brushScaleGroupOpen, ref state.brushFlipGroupOpen);
  596. }
  597. }
  598. private static readonly string[] _editModeTypeOptions = { "Line nodes", "Line position and rotation" };
  599. private void EditModeToggle(IPersistentToolManager persistentToolManager)
  600. {
  601. using (new GUILayout.VerticalScope(UnityEditor.EditorStyles.helpBox))
  602. {
  603. using (new GUILayout.HorizontalScope())
  604. {
  605. using (var check = new UnityEditor.EditorGUI.ChangeCheckScope())
  606. {
  607. var editMode = UnityEditor.EditorGUILayout.ToggleLeft("Edit Mode", ToolManager.editMode);
  608. if (check.changed)
  609. {
  610. ToolManager.editMode = editMode;
  611. PWBIO.ResetLineRotation();
  612. PWBIO.repaint = true;
  613. UnityEditor.SceneView.RepaintAll();
  614. PWBItemsWindow.RepainWindow();
  615. }
  616. }
  617. if (persistentToolManager == LineManager.instance && ToolManager.editMode)
  618. {
  619. using (var check = new UnityEditor.EditorGUI.ChangeCheckScope())
  620. {
  621. var editModeType = (LineManager.EditModeType)UnityEditor.EditorGUILayout
  622. .Popup((int)LineManager.editModeType, _editModeTypeOptions);
  623. if (check.changed)
  624. {
  625. LineManager.editModeType = editModeType;
  626. PWBIO.ResetLineRotation();
  627. PWBIO.repaint = true;
  628. UnityEditor.SceneView.RepaintAll();
  629. }
  630. }
  631. }
  632. }
  633. if (ToolManager.editMode)
  634. {
  635. using (var check = new UnityEditor.EditorGUI.ChangeCheckScope())
  636. {
  637. var applyBrushToexisting = UnityEditor.EditorGUILayout.ToggleLeft(
  638. "Apply brush setings to Pre-existing objects", persistentToolManager.applyBrushToExisting);
  639. if (check.changed)
  640. {
  641. persistentToolManager.applyBrushToExisting = applyBrushToexisting;
  642. if (ToolManager.tool == ToolManager.PaintTool.LINE) PWBIO.PreviewSelectedPersistentLines();
  643. else if (ToolManager.tool == ToolManager.PaintTool.SHAPE) PWBIO.PreviewSelectedPersistentShapes();
  644. else if (ToolManager.tool == ToolManager.PaintTool.TILING)
  645. PWBIO.PreviewSelectedPersistentTilings();
  646. PWBIO.repaint = true;
  647. UnityEditor.SceneView.RepaintAll();
  648. }
  649. }
  650. }
  651. if (ToolManager.editMode)
  652. {
  653. if (GUILayout.Button("Open items window")) PWBItemsWindow.ShowWindow();
  654. }
  655. }
  656. }
  657. private void HandlePosition()
  658. {
  659. if (PWBIO.selectedPointIdx < 0) return;
  660. using (new GUILayout.VerticalScope(UnityEditor.EditorStyles.helpBox))
  661. {
  662. using (var check = new UnityEditor.EditorGUI.ChangeCheckScope())
  663. {
  664. PWBIO.handlePosition = UnityEditor.EditorGUILayout.Vector3Field("Handle position:", PWBIO.handlePosition);
  665. if (check.changed) PWBIO.UpdateHandlePosition();
  666. }
  667. }
  668. }
  669. private void HandleRotation()
  670. {
  671. if (PWBIO.selectedPointIdx < 0) return;
  672. using (new GUILayout.VerticalScope(UnityEditor.EditorStyles.helpBox))
  673. {
  674. using (var check = new UnityEditor.EditorGUI.ChangeCheckScope())
  675. {
  676. var eulerAngles = PWBIO.handleRotation.eulerAngles;
  677. eulerAngles = UnityEditor.EditorGUILayout.Vector3Field("Handle rotation:", eulerAngles);
  678. if (check.changed)
  679. {
  680. var newRotation = Quaternion.Euler(eulerAngles);
  681. PWBIO.handleRotation = newRotation;
  682. PWBIO.UpdateHandleRotation();
  683. }
  684. }
  685. }
  686. }
  687. #endregion
  688. #region SELECTION BRUSH AND MODIFIER SETTINGS
  689. private static readonly string[] _modifierCommandOptions = { "All", "Palette Prefabs", "Brush Prefabs" };
  690. private void SelectionBrushGroup(ISelectionBrushTool settings, string actionLabel)
  691. {
  692. using (new GUILayout.VerticalScope(UnityEditor.EditorStyles.helpBox))
  693. {
  694. UnityEditor.EditorGUIUtility.labelWidth = 60;
  695. using (var check = new UnityEditor.EditorGUI.ChangeCheckScope())
  696. {
  697. var command = (ModifierToolSettings.Command)UnityEditor.EditorGUILayout.Popup(actionLabel + ":",
  698. (int)settings.command, _modifierCommandOptions);
  699. if (check.changed)
  700. {
  701. settings.command = command;
  702. PWBIO.UpdateOctree();
  703. }
  704. }
  705. using (var check = new UnityEditor.EditorGUI.ChangeCheckScope())
  706. {
  707. var onlyTheClosest = UnityEditor.EditorGUILayout.ToggleLeft(actionLabel + " only the closest",
  708. settings.onlyTheClosest);
  709. if (check.changed)
  710. {
  711. settings.onlyTheClosest = onlyTheClosest;
  712. }
  713. }
  714. }
  715. }
  716. private void ModifierGroup(IModifierTool settings, string actionLabel)
  717. {
  718. using (new GUILayout.VerticalScope(UnityEditor.EditorStyles.helpBox))
  719. {
  720. UnityEditor.EditorGUIUtility.labelWidth = 60;
  721. using (var check = new UnityEditor.EditorGUI.ChangeCheckScope())
  722. {
  723. var allButSelected = UnityEditor.EditorGUILayout.ToggleLeft(actionLabel + " all but selected",
  724. settings.modifyAllButSelected);
  725. if (check.changed)
  726. {
  727. settings.modifyAllButSelected = allButSelected;
  728. PWBIO.UpdateOctree();
  729. }
  730. }
  731. }
  732. }
  733. #endregion
  734. #region PIN
  735. private static readonly string[] _pinModeNames = { "Auto", "Paint on surface", "Paint on grid" };
  736. private static BrushPropertiesGroupState _pinOverwriteGroupState;
  737. private void PinGroup()
  738. {
  739. ToolProfileGUI(PinManager.instance);
  740. using (new GUILayout.VerticalScope(UnityEditor.EditorStyles.helpBox))
  741. {
  742. using (var check = new UnityEditor.EditorGUI.ChangeCheckScope())
  743. {
  744. var mode = (PinSettings.PaintMode)UnityEditor.EditorGUILayout.Popup("Paint mode:",
  745. (int)PinManager.settings.mode, _pinModeNames);
  746. if (check.changed)
  747. {
  748. PinManager.settings.mode = mode;
  749. UnityEditor.SceneView.RepaintAll();
  750. }
  751. }
  752. using (var check = new UnityEditor.EditorGUI.ChangeCheckScope())
  753. {
  754. var repeat = UnityEditor.EditorGUILayout.ToggleLeft("Repeat multi-brush item", PinManager.settings.repeat);
  755. if (check.changed)
  756. {
  757. PinManager.settings.repeat = repeat;
  758. UnityEditor.SceneView.RepaintAll();
  759. }
  760. }
  761. using (var check = new UnityEditor.EditorGUI.ChangeCheckScope())
  762. {
  763. var avoidOverlapping = UnityEditor.EditorGUILayout.ToggleLeft("Avoid overlapping",
  764. PinManager.settings.avoidOverlapping);
  765. if (check.changed)
  766. {
  767. PinManager.settings.avoidOverlapping = avoidOverlapping;
  768. UnityEditor.SceneView.RepaintAll();
  769. }
  770. }
  771. using (var check = new UnityEditor.EditorGUI.ChangeCheckScope())
  772. {
  773. var snapRotationToGrid = UnityEditor.EditorGUILayout.ToggleLeft("Snap rotation to grid",
  774. PinManager.settings.snapRotationToGrid);
  775. if (check.changed)
  776. {
  777. PinManager.settings.snapRotationToGrid = snapRotationToGrid;
  778. UnityEditor.SceneView.RepaintAll();
  779. }
  780. }
  781. }
  782. using (new GUILayout.VerticalScope(UnityEditor.EditorStyles.helpBox))
  783. {
  784. UnityEditor.EditorGUIUtility.labelWidth = 60;
  785. using (var check = new UnityEditor.EditorGUI.ChangeCheckScope())
  786. {
  787. var flattenTerrain
  788. = UnityEditor.EditorGUILayout.ToggleLeft("Flatten the terrain", PinManager.settings.flattenTerrain);
  789. if (check.changed)
  790. {
  791. PinManager.settings.flattenTerrain = flattenTerrain;
  792. }
  793. }
  794. using (new UnityEditor.EditorGUI.DisabledGroupScope(!PinManager.settings.flattenTerrain))
  795. {
  796. var flatteningSettings = PinManager.settings.flatteningSettings;
  797. using (var check = new UnityEditor.EditorGUI.ChangeCheckScope())
  798. {
  799. var hardness = UnityEditor.EditorGUILayout.Slider("Hardness:", flatteningSettings.hardness, 0, 1);
  800. if (check.changed)
  801. {
  802. flatteningSettings.hardness = hardness;
  803. }
  804. }
  805. using (var check = new UnityEditor.EditorGUI.ChangeCheckScope())
  806. {
  807. var padding = UnityEditor.EditorGUILayout.FloatField("Padding:", flatteningSettings.padding);
  808. if (check.changed)
  809. {
  810. flatteningSettings.padding = padding;
  811. }
  812. }
  813. using (var check = new UnityEditor.EditorGUI.ChangeCheckScope())
  814. {
  815. var clearTrees = UnityEditor.EditorGUILayout.ToggleLeft("Clear trees", flatteningSettings.clearTrees);
  816. if (check.changed)
  817. {
  818. flatteningSettings.clearTrees = clearTrees;
  819. }
  820. }
  821. using (var check = new UnityEditor.EditorGUI.ChangeCheckScope())
  822. {
  823. var clearDetails
  824. = UnityEditor.EditorGUILayout.ToggleLeft("Clear details", flatteningSettings.clearDetails);
  825. if (check.changed)
  826. {
  827. flatteningSettings.clearDetails = clearDetails;
  828. }
  829. }
  830. }
  831. }
  832. PaintSettingsGUI(PinManager.settings, PinManager.settings);
  833. OverwriteBrushPropertiesGUI(PinManager.settings, ref _pinOverwriteGroupState);
  834. }
  835. #endregion
  836. #region BRUSH
  837. private static readonly string[] _heightTypeNames = { "Custom", "Radius" };
  838. private static readonly string[] _avoidOverlappingTypeNames = { "Disabled", "With Palette Prefabs",
  839. "With Brush Prefabs", "With Same Prefabs", "With All Objects" };
  840. private static BrushPropertiesGroupState _brushOverwriteGroupState;
  841. private void BrushGroup()
  842. {
  843. ToolProfileGUI(BrushManager.instance);
  844. using (new GUILayout.VerticalScope(UnityEditor.EditorStyles.helpBox))
  845. {
  846. BrushManager.settings.showPreview = UnityEditor.EditorGUILayout.ToggleLeft("Show Brushstroke Preview",
  847. BrushManager.settings.showPreview);
  848. if (BrushManager.settings.showPreview)
  849. UnityEditor.EditorGUILayout.HelpBox("The brushstroke preview can cause slowdown issues.",
  850. UnityEditor.MessageType.Info);
  851. UnityEditor.EditorGUILayout.LabelField("Brushstroke object count:", BrushstrokeManager.itemCount.ToString());
  852. }
  853. using (new GUILayout.VerticalScope(UnityEditor.EditorStyles.helpBox))
  854. {
  855. BrushToolBaseSettingsGUI(BrushManager.settings);
  856. UnityEditor.EditorGUIUtility.labelWidth = 150;
  857. using (var check = new UnityEditor.EditorGUI.ChangeCheckScope())
  858. {
  859. var avoidOverlapping = (BrushToolSettings.AvoidOverlappingType)
  860. UnityEditor.EditorGUILayout.Popup("Avoid Overlapping:",
  861. (int)BrushManager.settings.avoidOverlapping, _avoidOverlappingTypeNames);
  862. if (check.changed)
  863. {
  864. BrushManager.settings.avoidOverlapping = avoidOverlapping;
  865. }
  866. }
  867. if (BrushManager.settings.brushShape != BrushToolBase.BrushShape.POINT)
  868. {
  869. using (new GUILayout.VerticalScope(UnityEditor.EditorStyles.helpBox))
  870. {
  871. using (var check = new UnityEditor.EditorGUI.ChangeCheckScope())
  872. {
  873. var heightType = (BrushToolSettings.HeightType)
  874. UnityEditor.EditorGUILayout.Popup("Max Height From center:",
  875. (int)BrushManager.settings.heightType, _heightTypeNames);
  876. if (check.changed)
  877. {
  878. BrushManager.settings.heightType = heightType;
  879. if (heightType == BrushToolSettings.HeightType.RADIUS)
  880. BrushManager.settings.maxHeightFromCenter = BrushManager.settings.radius;
  881. UnityEditor.SceneView.RepaintAll();
  882. }
  883. }
  884. using (new UnityEditor.EditorGUI.DisabledGroupScope(
  885. BrushManager.settings.heightType == BrushToolSettings.HeightType.RADIUS))
  886. {
  887. using (var check = new UnityEditor.EditorGUI.ChangeCheckScope())
  888. {
  889. var maxHeightFromCenter = Mathf.Abs(UnityEditor.EditorGUILayout.FloatField("Value:",
  890. BrushManager.settings.maxHeightFromCenter));
  891. if (check.changed)
  892. {
  893. BrushManager.settings.maxHeightFromCenter = maxHeightFromCenter;
  894. UnityEditor.SceneView.RepaintAll();
  895. }
  896. }
  897. }
  898. }
  899. }
  900. }
  901. using (new GUILayout.VerticalScope(UnityEditor.EditorStyles.helpBox))
  902. {
  903. GUILayout.Label("Surface Filters", UnityEditor.EditorStyles.boldLabel);
  904. UnityEditor.EditorGUIUtility.labelWidth = 110;
  905. using (new GUILayout.HorizontalScope())
  906. {
  907. using (var check = new UnityEditor.EditorGUI.ChangeCheckScope())
  908. {
  909. var minSlope = BrushManager.settings.slopeFilter.min;
  910. var maxSlope = BrushManager.settings.slopeFilter.max;
  911. UnityEditor.EditorGUILayout.MinMaxSlider("Slope Angle:", ref minSlope, ref maxSlope, 0, 90);
  912. minSlope = Mathf.Round(minSlope);
  913. maxSlope = Mathf.Round(maxSlope);
  914. GUILayout.Label("[" + minSlope.ToString("00") + "°," + maxSlope.ToString("00") + "°]");
  915. if (check.changed)
  916. {
  917. BrushManager.settings.slopeFilter.v1 = minSlope;
  918. BrushManager.settings.slopeFilter.v2 = maxSlope;
  919. UnityEditor.SceneView.RepaintAll();
  920. }
  921. }
  922. }
  923. using (var check = new UnityEditor.EditorGUI.ChangeCheckScope())
  924. {
  925. var mask = UnityEditor.EditorGUILayout.MaskField("Layers:",
  926. EditorGUIUtils.LayerMaskToField(BrushManager.settings.layerFilter),
  927. UnityEditorInternal.InternalEditorUtility.layers);
  928. if (check.changed)
  929. {
  930. BrushManager.settings.layerFilter = EditorGUIUtils.FieldToLayerMask(mask);
  931. UnityEditor.SceneView.RepaintAll();
  932. }
  933. }
  934. UnityEditor.EditorGUIUtility.labelWidth = 108;
  935. var field = EditorGUIUtils.MultiTagField.Instantiate("Tags:", BrushManager.settings.tagFilter, null);
  936. field.OnChange += OnBrushTagFilterChanged;
  937. bool terrainFilterChanged = false;
  938. var terrainFilter = EditorGUIUtils.ObjectArrayFieldWithButtons("Terrain Layers:",
  939. BrushManager.settings.terrainLayerFilter, ref _terrainLayerFilterFoldout, out terrainFilterChanged);
  940. if (terrainFilterChanged)
  941. {
  942. BrushManager.settings.terrainLayerFilter = terrainFilter.ToArray();
  943. UnityEditor.SceneView.RepaintAll();
  944. }
  945. }
  946. PaintSettingsGUI(BrushManager.settings, BrushManager.settings);
  947. OverwriteBrushPropertiesGUI(BrushManager.settings, ref _brushOverwriteGroupState);
  948. }
  949. private bool _terrainLayerFilterFoldout = false;
  950. private void OnBrushTagFilterChanged(System.Collections.Generic.List<string> prevFilter,
  951. System.Collections.Generic.List<string> newFilter, string key)
  952. {
  953. BrushManager.settings.tagFilter = newFilter;
  954. }
  955. #endregion
  956. #region ERASER
  957. private void EraserGroup()
  958. {
  959. UnityEditor.EditorGUIUtility.labelWidth = 60;
  960. var settings = EraserManager.settings;
  961. using (new GUILayout.VerticalScope(UnityEditor.EditorStyles.helpBox)) RadiusSlider(settings);
  962. var actionLabel = "Erase";
  963. SelectionBrushGroup(settings, actionLabel);
  964. ModifierGroup(settings, actionLabel);
  965. using (new GUILayout.VerticalScope(UnityEditor.EditorStyles.helpBox))
  966. {
  967. using (var check = new UnityEditor.EditorGUI.ChangeCheckScope())
  968. {
  969. var outermostFilter = UnityEditor.EditorGUILayout.ToggleLeft("Outermost prefab filter",
  970. settings.outermostPrefabFilter);
  971. if (check.changed)
  972. {
  973. settings.outermostPrefabFilter = outermostFilter;
  974. }
  975. }
  976. if (!settings.outermostPrefabFilter)
  977. GUILayout.Label("When you delete a child of a prefab, the prefab will be unpacked.",
  978. UnityEditor.EditorStyles.helpBox);
  979. }
  980. }
  981. #endregion
  982. #region GRAVITY
  983. private static BrushPropertiesGroupState _gravityOverwriteGroupState;
  984. private void GravityGroup()
  985. {
  986. ToolProfileGUI(GravityToolManager.instance);
  987. BrushToolBaseSettingsGUI(GravityToolManager.settings);
  988. UnityEditor.EditorGUIUtility.labelWidth = 120;
  989. using (new GUILayout.VerticalScope(UnityEditor.EditorStyles.helpBox))
  990. {
  991. var settings = GravityToolManager.settings.Clone();
  992. var data = settings.simData;
  993. using (var check = new UnityEditor.EditorGUI.ChangeCheckScope())
  994. {
  995. settings.height = UnityEditor.EditorGUILayout.FloatField("Height:", settings.height);
  996. data.maxIterations = UnityEditor.EditorGUILayout.IntField("Max Iterations:", data.maxIterations);
  997. data.maxSpeed = UnityEditor.EditorGUILayout.FloatField("Max Speed:", data.maxSpeed);
  998. data.maxAngularSpeed = UnityEditor.EditorGUILayout.FloatField("Max Angular Speed:", data.maxAngularSpeed);
  999. data.mass = UnityEditor.EditorGUILayout.FloatField("Mass:", data.mass);
  1000. data.drag = UnityEditor.EditorGUILayout.FloatField("Drag:", data.drag);
  1001. data.angularDrag = UnityEditor.EditorGUILayout.FloatField("Angular Drag:", data.angularDrag);
  1002. if (check.changed)
  1003. {
  1004. GravityToolManager.settings.Copy(settings);
  1005. UnityEditor.SceneView.RepaintAll();
  1006. }
  1007. }
  1008. using (new UnityEditor.EditorGUI.DisabledGroupScope
  1009. (PWBCore.staticData.tempCollidersAction == PWBData.TempCollidersAction.NEVER_CREATE))
  1010. {
  1011. using (new GUILayout.HorizontalScope())
  1012. {
  1013. using (var check = new UnityEditor.EditorGUI.ChangeCheckScope())
  1014. {
  1015. var createTempColliders = UnityEditor.EditorGUILayout.ToggleLeft("Create Temp Colliders",
  1016. GravityToolManager.settings.createTempColliders);
  1017. if (check.changed)
  1018. {
  1019. GravityToolManager.settings.createTempColliders = createTempColliders;
  1020. PWBCore.UpdateTempColliders();
  1021. UnityEditor.SceneView.RepaintAll();
  1022. }
  1023. }
  1024. using (new UnityEditor.EditorGUI.DisabledGroupScope(!GravityToolManager.settings.createTempColliders))
  1025. if (GUILayout.Button(_updateButtonContent, _reloadBtnStyle))
  1026. PWBCore.UpdateTempColliders();
  1027. }
  1028. }
  1029. using (var check = new UnityEditor.EditorGUI.ChangeCheckScope())
  1030. {
  1031. data.ignoreSceneColliders = UnityEditor.EditorGUILayout.ToggleLeft("Ignore Scene Colliders",
  1032. data.ignoreSceneColliders);
  1033. using (new GUILayout.VerticalScope(UnityEditor.EditorStyles.helpBox))
  1034. {
  1035. data.changeLayer
  1036. = UnityEditor.EditorGUILayout.ToggleLeft("Change Layer Temporarily", data.changeLayer);
  1037. if (data.changeLayer)
  1038. data.tempLayer = UnityEditor.EditorGUILayout.LayerField("Temp layer:", data.tempLayer);
  1039. }
  1040. if (check.changed)
  1041. {
  1042. GravityToolManager.settings.Copy(settings);
  1043. UnityEditor.SceneView.RepaintAll();
  1044. }
  1045. }
  1046. }
  1047. PaintToolSettingsGUI(GravityToolManager.settings);
  1048. OverwriteBrushPropertiesGUI(GravityToolManager.settings, ref _gravityOverwriteGroupState);
  1049. }
  1050. #endregion
  1051. #region LINE
  1052. private static readonly string[] _lineModeNames = { "Auto", "Paint on surface", "Paint on the line" };
  1053. private static readonly string[] _lineSpacingNames = { "Bounds", "Constant" };
  1054. private static readonly string[] _lineAxesAlongTheLineNames = { "X", "Z" };
  1055. private static string[] _shapeProjDirNames = new string[] { "+X", "-X", "+Y", "-Y", "+Z", "-Z", "Plane Axis" };
  1056. private static int _lineProjDirIdx = 6;
  1057. private static BrushPropertiesGroupState _lineOverwriteGroupState;
  1058. private void LineBaseGUI<SETTINGS>(SETTINGS lineSettings) where SETTINGS : LineSettings
  1059. {
  1060. void OnValueChanged()
  1061. {
  1062. PWBIO.UpdateStroke();
  1063. PWBIO.repaint = true;
  1064. }
  1065. using (new GUILayout.VerticalScope(UnityEditor.EditorStyles.helpBox))
  1066. {
  1067. using (var check = new UnityEditor.EditorGUI.ChangeCheckScope())
  1068. {
  1069. var mode = (PaintOnSurfaceToolSettingsBase.PaintMode)
  1070. UnityEditor.EditorGUILayout.Popup("Paint Mode:", (int)lineSettings.mode, _lineModeNames);
  1071. if (check.changed)
  1072. {
  1073. lineSettings.mode = mode;
  1074. OnValueChanged();
  1075. }
  1076. }
  1077. if (lineSettings is ShapeSettings)
  1078. {
  1079. using (var check = new UnityEditor.EditorGUI.ChangeCheckScope())
  1080. {
  1081. var parallelToTheSurface = UnityEditor.EditorGUILayout.ToggleLeft(
  1082. lineSettings.mode == PaintOnSurfaceToolSettingsBase.PaintMode.ON_SHAPE
  1083. ? "Place objects perpendicular to the plane"
  1084. : "Place objects perpendicular to the surface",
  1085. lineSettings.perpendicularToTheSurface);
  1086. if (check.changed)
  1087. {
  1088. lineSettings.perpendicularToTheSurface = parallelToTheSurface;
  1089. OnValueChanged();
  1090. }
  1091. }
  1092. }
  1093. else
  1094. {
  1095. using (var check = new UnityEditor.EditorGUI.ChangeCheckScope())
  1096. {
  1097. var parallelToTheSurface
  1098. = UnityEditor.EditorGUILayout.ToggleLeft("Place objects perpendicular to the " +
  1099. (lineSettings.mode == PaintOnSurfaceToolSettingsBase.PaintMode.ON_SHAPE ? "line" : "surface"),
  1100. lineSettings.perpendicularToTheSurface);
  1101. if (check.changed)
  1102. {
  1103. lineSettings.perpendicularToTheSurface = parallelToTheSurface;
  1104. OnValueChanged();
  1105. }
  1106. }
  1107. }
  1108. var dirNames = lineSettings is ShapeSettings ? _shapeProjDirNames : _dirNames;
  1109. var shapeSettings = lineSettings as ShapeSettings;
  1110. if (shapeSettings != null)
  1111. {
  1112. _lineProjDirIdx = shapeSettings.projectInNormalDir ? _lineProjDirIdx = 6
  1113. : System.Array.IndexOf(_dir, lineSettings.projectionDirection);
  1114. }
  1115. else _lineProjDirIdx = System.Array.IndexOf(_dir, lineSettings.projectionDirection);
  1116. if (_lineProjDirIdx == -1) _lineProjDirIdx = 3;
  1117. using (var check = new UnityEditor.EditorGUI.ChangeCheckScope())
  1118. {
  1119. _lineProjDirIdx = UnityEditor.EditorGUILayout.Popup("Projection Direction:", _lineProjDirIdx, dirNames);
  1120. if (check.changed)
  1121. {
  1122. if (shapeSettings != null) shapeSettings.projectInNormalDir = _lineProjDirIdx == 6;
  1123. lineSettings.projectionDirection = _lineProjDirIdx == 6
  1124. ? PWBIO.GetShapePlaneNormal() : _dir[_lineProjDirIdx];
  1125. OnValueChanged();
  1126. }
  1127. }
  1128. }
  1129. using (new GUILayout.VerticalScope(UnityEditor.EditorStyles.helpBox))
  1130. {
  1131. using (var check = new UnityEditor.EditorGUI.ChangeCheckScope())
  1132. {
  1133. var objectsOrientedAlongTheLine
  1134. = UnityEditor.EditorGUILayout.ToggleLeft("Orient Along the Line",
  1135. lineSettings.objectsOrientedAlongTheLine);
  1136. if (check.changed)
  1137. {
  1138. lineSettings.objectsOrientedAlongTheLine = objectsOrientedAlongTheLine;
  1139. OnValueChanged();
  1140. }
  1141. }
  1142. if (lineSettings.objectsOrientedAlongTheLine)
  1143. {
  1144. UnityEditor.EditorGUIUtility.labelWidth = 170;
  1145. using (var check = new UnityEditor.EditorGUI.ChangeCheckScope())
  1146. {
  1147. var axisOrientedAlongTheLine = UnityEditor.EditorGUILayout.Popup("Axis Oriented Along the Line:",
  1148. lineSettings.axisOrientedAlongTheLine == AxesUtils.Axis.X ? 0 : 1,
  1149. _lineAxesAlongTheLineNames) == 0 ? AxesUtils.Axis.X : AxesUtils.Axis.Z;
  1150. if (check.changed)
  1151. {
  1152. lineSettings.axisOrientedAlongTheLine = axisOrientedAlongTheLine;
  1153. OnValueChanged();
  1154. }
  1155. }
  1156. }
  1157. }
  1158. using (new GUILayout.VerticalScope(UnityEditor.EditorStyles.helpBox))
  1159. {
  1160. UnityEditor.EditorGUIUtility.labelWidth = 120;
  1161. using (var check = new UnityEditor.EditorGUI.ChangeCheckScope())
  1162. {
  1163. var spacingType = (LineSettings.SpacingType)
  1164. UnityEditor.EditorGUILayout.Popup("Spacing:", (int)lineSettings.spacingType, _lineSpacingNames);
  1165. if (check.changed)
  1166. {
  1167. lineSettings.spacingType = spacingType;
  1168. OnValueChanged();
  1169. }
  1170. }
  1171. if (lineSettings.spacingType == LineSettings.SpacingType.CONSTANT)
  1172. {
  1173. using (var check = new UnityEditor.EditorGUI.ChangeCheckScope())
  1174. {
  1175. var spacing = UnityEditor.EditorGUILayout.FloatField("Value:", lineSettings.spacing);
  1176. if (check.changed)
  1177. {
  1178. lineSettings.spacing = spacing;
  1179. OnValueChanged();
  1180. }
  1181. }
  1182. }
  1183. using (var check = new UnityEditor.EditorGUI.ChangeCheckScope())
  1184. {
  1185. var gapSize = UnityEditor.EditorGUILayout.FloatField("Gap Size:", lineSettings.gapSize);
  1186. if (check.changed)
  1187. {
  1188. if (PaletteManager.selectedBrushIdx >= 0 && PaletteManager.selectedBrush != null)
  1189. {
  1190. var spacing = lineSettings.spacingType == LineSettings.SpacingType.CONSTANT
  1191. ? lineSettings.spacing : PaletteManager.selectedBrush.minBrushMagnitude;
  1192. var min = Mathf.Min(0, 0.05f - spacing);
  1193. gapSize = Mathf.Max(min, gapSize);
  1194. }
  1195. lineSettings.gapSize = gapSize;
  1196. OnValueChanged();
  1197. }
  1198. }
  1199. }
  1200. }
  1201. private void LineGroup()
  1202. {
  1203. ToolProfileGUI(LineManager.instance);
  1204. EditModeToggle(LineManager.instance);
  1205. HandlePosition();
  1206. UnityEditor.EditorGUIUtility.labelWidth = 120;
  1207. LineBaseGUI(LineManager.settings);
  1208. using (new GUILayout.VerticalScope(UnityEditor.EditorStyles.helpBox))
  1209. {
  1210. using (var check = new UnityEditor.EditorGUI.ChangeCheckScope())
  1211. {
  1212. var closed = UnityEditor.EditorGUILayout.ToggleLeft("Colsed Path", PWBIO.lineData.closed);
  1213. if (check.changed)
  1214. {
  1215. PWBIO.lineData.closed = closed;
  1216. PWBIO.UpdateStroke();
  1217. UnityEditor.SceneView.RepaintAll();
  1218. PWBIO.repaint = true;
  1219. }
  1220. }
  1221. }
  1222. PaintSettingsGUI(LineManager.settings, LineManager.settings);
  1223. OverwriteBrushPropertiesGUI(LineManager.settings, ref _lineOverwriteGroupState);
  1224. }
  1225. #endregion
  1226. #region SHAPE
  1227. private static readonly string[] _shapeTypeNames = { "Circle", "Polygon" };
  1228. private static BrushPropertiesGroupState _shapeOverwriteGroupState;
  1229. private static string[] _shapeDirNames = new string[] { "+X", "-X", "+Y", "-Y", "+Z", "-Z", "Normal to surface" };
  1230. private void ShapeGroup()
  1231. {
  1232. UnityEditor.EditorGUIUtility.labelWidth = 100;
  1233. ToolProfileGUI(ShapeManager.instance);
  1234. EditModeToggle(ShapeManager.instance);
  1235. HandlePosition();
  1236. HandleRotation();
  1237. using (new GUILayout.VerticalScope(UnityEditor.EditorStyles.helpBox))
  1238. {
  1239. using (var check = new UnityEditor.EditorGUI.ChangeCheckScope())
  1240. {
  1241. var shapeType = (ShapeSettings.ShapeType)UnityEditor.EditorGUILayout.Popup("Shape:",
  1242. (int)ShapeManager.settings.shapeType, _shapeTypeNames);
  1243. if (check.changed)
  1244. {
  1245. ShapeManager.settings.shapeType = shapeType;
  1246. if (shapeType == ShapeSettings.ShapeType.CIRCLE)
  1247. {
  1248. ShapeData.instance.UpdateCircleSideCount();
  1249. }
  1250. ShapeData.instance.Update(true);
  1251. PWBIO.UpdateStroke();
  1252. PWBIO.repaint = true;
  1253. }
  1254. }
  1255. if (ShapeManager.settings.shapeType == ShapeSettings.ShapeType.POLYGON)
  1256. {
  1257. using (var check = new UnityEditor.EditorGUI.ChangeCheckScope())
  1258. {
  1259. var sideCount = UnityEditor.EditorGUILayout.IntSlider("Number of sides:",
  1260. ShapeManager.settings.sidesCount, 3, 12);
  1261. if (check.changed)
  1262. {
  1263. ShapeManager.settings.sidesCount = sideCount;
  1264. ShapeData.instance.UpdateIntersections();
  1265. PWBIO.UpdateStroke();
  1266. PWBIO.repaint = true;
  1267. }
  1268. }
  1269. }
  1270. using (var check = new UnityEditor.EditorGUI.ChangeCheckScope())
  1271. {
  1272. var normalDirIdx = ShapeManager.settings.axisNormalToSurface
  1273. ? 6 : System.Array.IndexOf(_dir, ShapeManager.settings.normal);
  1274. UnityEditor.EditorGUIUtility.labelWidth = 120;
  1275. normalDirIdx = UnityEditor.EditorGUILayout.Popup("Initial axis direction:", normalDirIdx, _shapeDirNames);
  1276. var axisNormalToSurface = normalDirIdx == 6;
  1277. if (check.changed)
  1278. {
  1279. ShapeManager.settings.axisNormalToSurface = axisNormalToSurface;
  1280. ShapeManager.settings.normal = normalDirIdx == 6 ? Vector3.up : _dir[normalDirIdx];
  1281. PWBIO.UpdateStroke();
  1282. PWBIO.repaint = true;
  1283. }
  1284. }
  1285. }
  1286. UnityEditor.EditorGUIUtility.labelWidth = 120;
  1287. LineBaseGUI(ShapeManager.settings);
  1288. PaintSettingsGUI(ShapeManager.settings, ShapeManager.settings);
  1289. OverwriteBrushPropertiesGUI(ShapeManager.settings, ref _shapeOverwriteGroupState);
  1290. }
  1291. #endregion
  1292. #region TILING
  1293. private static readonly string[] _tilingModeNames = { "Auto", "Paint on surface", "Paint on the plane" };
  1294. private static readonly string[] _cellTypeNames = { "Smallest object", "Biggest object", "Custom" };
  1295. private static BrushPropertiesGroupState _tilingOverwriteGroupState;
  1296. private void TilingGroup()
  1297. {
  1298. ToolProfileGUI(TilingManager.instance);
  1299. EditModeToggle(TilingManager.instance);
  1300. HandlePosition();
  1301. if (!ToolManager.editMode)
  1302. {
  1303. using (new GUILayout.VerticalScope(UnityEditor.EditorStyles.helpBox))
  1304. {
  1305. TilingManager.settings.showPreview = UnityEditor.EditorGUILayout.ToggleLeft("Show Preview",
  1306. TilingManager.settings.showPreview);
  1307. if (TilingManager.settings.showPreview)
  1308. UnityEditor.EditorGUILayout.HelpBox("If you experience slowdown issues, disable preview.",
  1309. UnityEditor.MessageType.Info);
  1310. UnityEditor.EditorGUILayout.LabelField("Object count:", BrushstrokeManager.itemCount.ToString());
  1311. }
  1312. }
  1313. UnityEditor.EditorGUIUtility.labelWidth = 180;
  1314. using (var check = new UnityEditor.EditorGUI.ChangeCheckScope())
  1315. {
  1316. var settings = TilingManager.settings;
  1317. using (new GUILayout.VerticalScope(UnityEditor.EditorStyles.helpBox))
  1318. {
  1319. settings.mode = (TilingSettings.PaintMode)UnityEditor.EditorGUILayout.Popup("Paint mode:",
  1320. (int)settings.mode, _tilingModeNames);
  1321. using (var angleCheck = new UnityEditor.EditorGUI.ChangeCheckScope())
  1322. {
  1323. var eulerAngles = settings.rotation.eulerAngles;
  1324. eulerAngles = UnityEditor.EditorGUILayout.Vector3Field("Plane Rotation:", eulerAngles);
  1325. if (angleCheck.changed)
  1326. {
  1327. var newRotation = Quaternion.Euler(eulerAngles);
  1328. PWBIO.UpdateTilingRotation(newRotation);
  1329. settings.rotation = newRotation;
  1330. }
  1331. }
  1332. var axisIdx = UnityEditor.EditorGUILayout.Popup("Axis aligned with plane normal: ",
  1333. settings.axisAlignedWithNormal, _dirNames);
  1334. settings.axisAlignedWithNormal = axisIdx;
  1335. }
  1336. using (new GUILayout.VerticalScope(UnityEditor.EditorStyles.helpBox))
  1337. {
  1338. UnityEditor.EditorGUIUtility.labelWidth = 76;
  1339. settings.cellSizeType = (TilesUtils.SizeType)
  1340. UnityEditor.EditorGUILayout.Popup("Cell size:", (int)settings.cellSizeType, _cellTypeNames);
  1341. using (new UnityEditor.EditorGUI.DisabledGroupScope(
  1342. settings.cellSizeType != TilesUtils.SizeType.CUSTOM))
  1343. {
  1344. settings.cellSize = UnityEditor.EditorGUILayout.Vector2Field("", settings.cellSize);
  1345. }
  1346. }
  1347. using (new GUILayout.VerticalScope(UnityEditor.EditorStyles.helpBox))
  1348. {
  1349. settings.spacing = UnityEditor.EditorGUILayout.Vector2Field("Spacing", settings.spacing);
  1350. }
  1351. if (check.changed)
  1352. {
  1353. PWBIO.UpdateStroke();
  1354. UnityEditor.SceneView.RepaintAll();
  1355. }
  1356. }
  1357. PaintSettingsGUI(TilingManager.settings, TilingManager.settings);
  1358. OverwriteBrushPropertiesGUI(TilingManager.settings, ref _tilingOverwriteGroupState);
  1359. }
  1360. #endregion
  1361. #region EXTRUDE
  1362. private static readonly string[] _spaceOptions = { "Global", "Local" };
  1363. private static readonly string[] _rotationOptions = { "First Object Selected", "Last Object Selected" };
  1364. private static readonly string[] _extrudeSpacingOptions = { "Box Size", "Custom" };
  1365. private static readonly string[] _addRotationOptions = { "Constant", "Random" };
  1366. private void ExtrudeGroup()
  1367. {
  1368. ToolProfileGUI(ExtrudeManager.instance);
  1369. UnityEditor.EditorGUIUtility.labelWidth = 60;
  1370. using (var check = new UnityEditor.EditorGUI.ChangeCheckScope())
  1371. {
  1372. var extrudeSettings = ExtrudeManager.settings.Clone();
  1373. using (new GUILayout.VerticalScope(UnityEditor.EditorStyles.helpBox))
  1374. {
  1375. extrudeSettings.space = (Space)(UnityEditor.EditorGUILayout.Popup("Space:",
  1376. (int)extrudeSettings.space, _spaceOptions));
  1377. if (extrudeSettings.space == Space.Self)
  1378. {
  1379. UnityEditor.EditorGUIUtility.labelWidth = 150;
  1380. extrudeSettings.rotationAccordingTo = (ExtrudeSettings.RotationAccordingTo)UnityEditor
  1381. .EditorGUILayout.Popup("Set rotation according to:",
  1382. (int)extrudeSettings.rotationAccordingTo, _rotationOptions);
  1383. }
  1384. }
  1385. UnityEditor.EditorGUIUtility.labelWidth = 60;
  1386. using (new GUILayout.VerticalScope(UnityEditor.EditorStyles.helpBox))
  1387. {
  1388. extrudeSettings.spacingType = (ExtrudeSettings.SpacingType)UnityEditor.EditorGUILayout.Popup("Spacing:",
  1389. (int)extrudeSettings.spacingType, _extrudeSpacingOptions);
  1390. if (extrudeSettings.spacingType == ExtrudeSettings.SpacingType.BOX_SIZE)
  1391. extrudeSettings.multiplier
  1392. = UnityEditor.EditorGUILayout.Vector3Field("Multiplier:", extrudeSettings.multiplier);
  1393. else extrudeSettings.spacing
  1394. = UnityEditor.EditorGUILayout.Vector3Field("Value:", extrudeSettings.spacing);
  1395. }
  1396. if (extrudeSettings.space == Space.World)
  1397. {
  1398. using (new GUILayout.VerticalScope(UnityEditor.EditorStyles.helpBox))
  1399. {
  1400. UnityEditor.EditorGUIUtility.labelWidth = 80;
  1401. extrudeSettings.addRandomRotation = UnityEditor.EditorGUILayout.Popup("Add Rotation:",
  1402. extrudeSettings.addRandomRotation ? 1 : 0, _addRotationOptions) == 1;
  1403. if (extrudeSettings.addRandomRotation)
  1404. {
  1405. extrudeSettings.randomEulerOffset = EditorGUIUtils.Range3Field(string.Empty,
  1406. extrudeSettings.randomEulerOffset);
  1407. using (new GUILayout.HorizontalScope())
  1408. {
  1409. extrudeSettings.rotateInMultiples = UnityEditor.EditorGUILayout.ToggleLeft
  1410. ("Only in multiples of:", extrudeSettings.rotateInMultiples);
  1411. using (new UnityEditor.EditorGUI.DisabledGroupScope(!extrudeSettings.rotateInMultiples))
  1412. extrudeSettings.rotationFactor
  1413. = UnityEditor.EditorGUILayout.FloatField(extrudeSettings.rotationFactor);
  1414. }
  1415. }
  1416. else extrudeSettings.eulerOffset = UnityEditor.EditorGUILayout.Vector3Field(string.Empty,
  1417. extrudeSettings.eulerOffset);
  1418. }
  1419. }
  1420. using (new GUILayout.VerticalScope(UnityEditor.EditorStyles.helpBox))
  1421. {
  1422. extrudeSettings.sameParentAsSource
  1423. = UnityEditor.EditorGUILayout.ToggleLeft("Same parent as source", extrudeSettings.sameParentAsSource);
  1424. if (!extrudeSettings.sameParentAsSource)
  1425. {
  1426. extrudeSettings.autoCreateParent
  1427. = UnityEditor.EditorGUILayout.ToggleLeft("Create parent", extrudeSettings.autoCreateParent);
  1428. if (extrudeSettings.autoCreateParent) extrudeSettings.createSubparentPerPrefab
  1429. = UnityEditor.EditorGUILayout.ToggleLeft("Create sub-parent per prefab",
  1430. extrudeSettings.createSubparentPerPrefab);
  1431. else extrudeSettings.parent = (Transform)UnityEditor.EditorGUILayout.ObjectField("Parent Transform:",
  1432. extrudeSettings.parent, typeof(Transform), true);
  1433. }
  1434. }
  1435. using (new GUILayout.VerticalScope(UnityEditor.EditorStyles.helpBox))
  1436. {
  1437. extrudeSettings.overwritePrefabLayer
  1438. = UnityEditor.EditorGUILayout.ToggleLeft("Overwrite prefab layer",
  1439. extrudeSettings.overwritePrefabLayer);
  1440. if (extrudeSettings.overwritePrefabLayer)
  1441. extrudeSettings.layer = UnityEditor.EditorGUILayout.LayerField("Layer:", extrudeSettings.layer);
  1442. }
  1443. if (check.changed)
  1444. {
  1445. ExtrudeManager.settings.Copy(extrudeSettings);
  1446. UnityEditor.SceneView.RepaintAll();
  1447. PWBIO.ClearExtrudeAngles();
  1448. }
  1449. }
  1450. EmbedInSurfaceSettingsGUI(ExtrudeManager.settings);
  1451. }
  1452. #endregion
  1453. #region SELECTION TOOL
  1454. private void SelectionGroup()
  1455. {
  1456. ToolProfileGUI(SelectionToolManager.instance);
  1457. using (new GUILayout.VerticalScope(UnityEditor.EditorStyles.helpBox))
  1458. {
  1459. using (var check = new UnityEditor.EditorGUI.ChangeCheckScope())
  1460. {
  1461. UnityEditor.EditorGUIUtility.labelWidth = 90;
  1462. var handleSpace = (Space)(UnityEditor.EditorGUILayout.Popup("Handle Space:",
  1463. (int)SelectionToolManager.settings.handleSpace, _spaceOptions));
  1464. if (SelectionManager.topLevelSelection.Length > 1) SelectionToolManager.settings.boxSpace = Space.World;
  1465. var boxSpace = SelectionToolManager.settings.boxSpace;
  1466. using (new UnityEditor.EditorGUI.DisabledGroupScope(SelectionManager.topLevelSelection.Length > 1))
  1467. {
  1468. boxSpace = (Space)(UnityEditor.EditorGUILayout.Popup("Box Space:",
  1469. (int)SelectionToolManager.settings.boxSpace, _spaceOptions));
  1470. }
  1471. if (check.changed)
  1472. {
  1473. SelectionToolManager.settings.handleSpace = handleSpace;
  1474. SelectionToolManager.settings.boxSpace = boxSpace;
  1475. PWBIO.ResetSelectionRotation();
  1476. UnityEditor.SceneView.RepaintAll();
  1477. }
  1478. }
  1479. }
  1480. using (new GUILayout.VerticalScope(UnityEditor.EditorStyles.helpBox))
  1481. {
  1482. GUILayout.Label("Selection Filters", UnityEditor.EditorStyles.boldLabel);
  1483. using (var check = new UnityEditor.EditorGUI.ChangeCheckScope())
  1484. {
  1485. UnityEditor.EditorGUIUtility.labelWidth = 90;
  1486. var paletteFilter = UnityEditor.EditorGUILayout.ToggleLeft("Prefabs from selected palette only",
  1487. SelectionToolManager.settings.paletteFilter);
  1488. var brushFilter = UnityEditor.EditorGUILayout.ToggleLeft("Prefabs from selected brush only",
  1489. SelectionToolManager.settings.brushFilter);
  1490. var layerMask = UnityEditor.EditorGUILayout.MaskField("Layers:",
  1491. EditorGUIUtils.LayerMaskToField(SelectionToolManager.settings.layerFilter),
  1492. UnityEditorInternal.InternalEditorUtility.layers);
  1493. var tagField = EditorGUIUtils.MultiTagField.Instantiate("Tags:",
  1494. SelectionToolManager.settings.tagFilter, null);
  1495. tagField.OnChange += OnSelectionTagFilterChanged;
  1496. if (check.changed)
  1497. {
  1498. SelectionToolManager.settings.paletteFilter = paletteFilter;
  1499. SelectionToolManager.settings.brushFilter = brushFilter;
  1500. SelectionToolManager.settings.layerFilter = EditorGUIUtils.FieldToLayerMask(layerMask);
  1501. PWBIO.ApplySelectionFilters();
  1502. UnityEditor.SceneView.RepaintAll();
  1503. }
  1504. }
  1505. }
  1506. EmbedInSurfaceSettingsGUI(SelectionToolManager.settings);
  1507. }
  1508. private void OnSelectionTagFilterChanged(System.Collections.Generic.List<string> prevFilter,
  1509. System.Collections.Generic.List<string> newFilter, string key)
  1510. {
  1511. SelectionToolManager.settings.tagFilter = newFilter;
  1512. PWBIO.ApplySelectionFilters();
  1513. UnityEditor.SceneView.RepaintAll();
  1514. }
  1515. #endregion
  1516. #region CIRCLE SELECT
  1517. private void CircleSelectGroup()
  1518. {
  1519. UnityEditor.EditorGUIUtility.labelWidth = 60;
  1520. var settings = CircleSelectManager.settings;
  1521. using (new GUILayout.VerticalScope(UnityEditor.EditorStyles.helpBox)) RadiusSlider(settings);
  1522. SelectionBrushGroup(settings, actionLabel: "Select");
  1523. using (new GUILayout.VerticalScope(UnityEditor.EditorStyles.helpBox))
  1524. {
  1525. using (var check = new UnityEditor.EditorGUI.ChangeCheckScope())
  1526. {
  1527. var outermostFilter = UnityEditor.EditorGUILayout.ToggleLeft("Outermost prefab filter",
  1528. settings.outermostPrefabFilter);
  1529. if (check.changed)
  1530. {
  1531. settings.outermostPrefabFilter = outermostFilter;
  1532. }
  1533. }
  1534. }
  1535. }
  1536. #endregion
  1537. #region MIRROR
  1538. private static readonly string[] _mirrorActionNames = { "Transform", "Create" };
  1539. private void MirrorGroup()
  1540. {
  1541. ToolProfileGUI(MirrorManager.instance);
  1542. using (var check = new UnityEditor.EditorGUI.ChangeCheckScope())
  1543. {
  1544. var mirrorSettings = new MirrorSettings();
  1545. mirrorSettings.Copy(MirrorManager.settings);
  1546. using (var mirrorCheck = new UnityEditor.EditorGUI.ChangeCheckScope())
  1547. {
  1548. using (new GUILayout.VerticalScope(UnityEditor.EditorStyles.helpBox))
  1549. {
  1550. UnityEditor.EditorGUIUtility.labelWidth = 80;
  1551. mirrorSettings.mirrorPosition = UnityEditor.EditorGUILayout.Vector3Field("Position:",
  1552. mirrorSettings.mirrorPosition);
  1553. mirrorSettings.mirrorRotation = Quaternion.Euler(UnityEditor.EditorGUILayout.Vector3Field("Rotation:",
  1554. mirrorSettings.mirrorRotation.eulerAngles));
  1555. }
  1556. using (new GUILayout.VerticalScope(UnityEditor.EditorStyles.helpBox))
  1557. {
  1558. UnityEditor.EditorGUIUtility.labelWidth = 110;
  1559. mirrorSettings.invertScale
  1560. = UnityEditor.EditorGUILayout.ToggleLeft("Invert scale", mirrorSettings.invertScale);
  1561. mirrorSettings.reflectRotation
  1562. = UnityEditor.EditorGUILayout.ToggleLeft("Reflect rotation", mirrorSettings.reflectRotation);
  1563. mirrorSettings.action = (MirrorSettings.MirrorAction)UnityEditor.EditorGUILayout.Popup("Action:",
  1564. (int)mirrorSettings.action, _mirrorActionNames);
  1565. }
  1566. if (mirrorCheck.changed) UnityEditor.SceneView.RepaintAll();
  1567. }
  1568. if (mirrorSettings.action == MirrorSettings.MirrorAction.CREATE)
  1569. {
  1570. using (new GUILayout.VerticalScope(UnityEditor.EditorStyles.helpBox))
  1571. {
  1572. mirrorSettings.sameParentAsSource = UnityEditor.EditorGUILayout.ToggleLeft("Same parent as source",
  1573. mirrorSettings.sameParentAsSource);
  1574. if (!mirrorSettings.sameParentAsSource)
  1575. {
  1576. mirrorSettings.autoCreateParent
  1577. = UnityEditor.EditorGUILayout.ToggleLeft("Create parent", mirrorSettings.autoCreateParent);
  1578. if (mirrorSettings.autoCreateParent)
  1579. mirrorSettings.createSubparentPerPrefab
  1580. = UnityEditor.EditorGUILayout.ToggleLeft("Create sub-parent per prefab",
  1581. mirrorSettings.createSubparentPerPrefab);
  1582. else mirrorSettings.parent
  1583. = (Transform)UnityEditor.EditorGUILayout.ObjectField("Parent Transform:",
  1584. mirrorSettings.parent, typeof(Transform), true);
  1585. }
  1586. }
  1587. using (new GUILayout.VerticalScope(UnityEditor.EditorStyles.helpBox))
  1588. {
  1589. mirrorSettings.overwritePrefabLayer = UnityEditor.EditorGUILayout.ToggleLeft("Overwrite prefab layer",
  1590. mirrorSettings.overwritePrefabLayer);
  1591. if (mirrorSettings.overwritePrefabLayer)
  1592. mirrorSettings.layer = UnityEditor.EditorGUILayout.LayerField("Layer:", mirrorSettings.layer);
  1593. }
  1594. }
  1595. if (check.changed)
  1596. {
  1597. MirrorManager.settings.Copy(mirrorSettings);
  1598. UnityEditor.SceneView.RepaintAll();
  1599. }
  1600. }
  1601. EmbedInSurfaceSettingsGUI(MirrorManager.settings);
  1602. }
  1603. #endregion
  1604. #region REPLACER
  1605. private static BrushPropertiesGroupState _replacerOverwriteGroupState;
  1606. private static readonly string[] _replacerModeOptions = { "Target Center", "Target Pivot", "On Surface" };
  1607. private void ReplacerGroup()
  1608. {
  1609. UnityEditor.EditorGUIUtility.labelWidth = 60;
  1610. var settings = ReplacerManager.settings;
  1611. using (new GUILayout.VerticalScope(UnityEditor.EditorStyles.helpBox)) RadiusSlider(settings);
  1612. var actionLabel = "Replace";
  1613. SelectionBrushGroup(settings, actionLabel);
  1614. ModifierGroup(settings, actionLabel);
  1615. using (new GUILayout.VerticalScope(UnityEditor.EditorStyles.helpBox))
  1616. {
  1617. using (var check = new UnityEditor.EditorGUI.ChangeCheckScope())
  1618. {
  1619. var positionMode = (ReplacerSettings.PositionMode)UnityEditor.EditorGUILayout.Popup("Position:",
  1620. (int)settings.positionMode, _replacerModeOptions);
  1621. if (check.changed)
  1622. {
  1623. settings.positionMode = positionMode;
  1624. }
  1625. }
  1626. var keepTargetSize = settings.keepTargetSize;
  1627. using (var check = new UnityEditor.EditorGUI.ChangeCheckScope())
  1628. {
  1629. keepTargetSize = UnityEditor.EditorGUILayout.ToggleLeft("Keep target size", settings.keepTargetSize);
  1630. if (check.changed)
  1631. {
  1632. settings.keepTargetSize = keepTargetSize;
  1633. }
  1634. }
  1635. if (keepTargetSize)
  1636. {
  1637. using (var check = new UnityEditor.EditorGUI.ChangeCheckScope())
  1638. {
  1639. var maintainProportions = UnityEditor.EditorGUILayout.ToggleLeft("Maintain proportions",
  1640. settings.maintainProportions);
  1641. if (check.changed)
  1642. {
  1643. settings.maintainProportions = maintainProportions;
  1644. }
  1645. }
  1646. }
  1647. }
  1648. using (new GUILayout.VerticalScope(UnityEditor.EditorStyles.helpBox))
  1649. {
  1650. using (var check = new UnityEditor.EditorGUI.ChangeCheckScope())
  1651. {
  1652. var outermostFilter = UnityEditor.EditorGUILayout.ToggleLeft("Outermost prefab filter",
  1653. settings.outermostPrefabFilter);
  1654. if (check.changed) settings.outermostPrefabFilter = outermostFilter;
  1655. }
  1656. if (!settings.outermostPrefabFilter)
  1657. GUILayout.Label("When you replace a child of a prefab, the prefab will be unpacked.",
  1658. UnityEditor.EditorStyles.helpBox);
  1659. }
  1660. using (new GUILayout.VerticalScope(UnityEditor.EditorStyles.helpBox))
  1661. {
  1662. settings.sameParentAsTarget = UnityEditor.EditorGUILayout.ToggleLeft("Same Parent as the target",
  1663. settings.sameParentAsTarget);
  1664. if (!settings.sameParentAsTarget) ParentSettingsGUI(ReplacerManager.settings);
  1665. }
  1666. OverwriteLayerGUI(ReplacerManager.settings);
  1667. OverwriteBrushPropertiesGUI(ReplacerManager.settings, ref _replacerOverwriteGroupState);
  1668. using (new GUILayout.HorizontalScope(UnityEditor.EditorStyles.helpBox))
  1669. {
  1670. GUILayout.FlexibleSpace();
  1671. if (GUILayout.Button("Replace all selected"))
  1672. {
  1673. PWBIO.ReplaceAllSelected();
  1674. UnityEditor.SceneView.RepaintAll();
  1675. }
  1676. GUILayout.FlexibleSpace();
  1677. }
  1678. }
  1679. #endregion
  1680. #region FLOOR
  1681. private static BrushPropertiesGroupState _floorOverwriteGroupState;
  1682. private void FloorGroup()
  1683. {
  1684. ToolProfileGUI(FloorManager.instance);
  1685. var settings = FloorManager.settings;
  1686. UnityEditor.EditorGUIUtility.labelWidth = 80;
  1687. using (new GUILayout.VerticalScope(UnityEditor.EditorStyles.helpBox))
  1688. {
  1689. using (var check = new UnityEditor.EditorGUI.ChangeCheckScope())
  1690. {
  1691. var axisIdx = UnityEditor.EditorGUILayout.Popup("Upward axis:",
  1692. settings.upwardAxis, _dirNames);
  1693. if (check.changed)
  1694. {
  1695. settings.upwardAxis = axisIdx;
  1696. }
  1697. }
  1698. }
  1699. using (new GUILayout.VerticalScope(UnityEditor.EditorStyles.helpBox))
  1700. {
  1701. UnityEditor.EditorGUIUtility.labelWidth = 90;
  1702. using (var check = new UnityEditor.EditorGUI.ChangeCheckScope())
  1703. {
  1704. var moduleSizeType = (TilesUtils.SizeType)
  1705. UnityEditor.EditorGUILayout.Popup("Cell size type:", (int)settings.moduleSizeType, _cellTypeNames);
  1706. if (check.changed)
  1707. {
  1708. settings.moduleSizeType = moduleSizeType;
  1709. if(settings.moduleSizeType == TilesUtils.SizeType.CUSTOM) FloorManager.settings.ResetSize();
  1710. }
  1711. }
  1712. using (new GUILayout.HorizontalScope())
  1713. {
  1714. GUILayout.FlexibleSpace();
  1715. UnityEditor.EditorGUIUtility.labelWidth = 20;
  1716. using (var check = new UnityEditor.EditorGUI.ChangeCheckScope())
  1717. {
  1718. using (new UnityEditor.EditorGUI.DisabledGroupScope(
  1719. settings.moduleSizeType != TilesUtils.SizeType.CUSTOM))
  1720. {
  1721. var x = UnityEditor.EditorGUILayout.FloatField("X:", settings.moduleSize.x);
  1722. var z = UnityEditor.EditorGUILayout.FloatField("Z:", settings.moduleSize.z);
  1723. if (check.changed)
  1724. {
  1725. settings.moduleSize = new Vector3(x, 1, z);
  1726. }
  1727. }
  1728. }
  1729. if (GUILayout.Button("Swap"))
  1730. {
  1731. settings.SwapXZ();
  1732. RepainWindow();
  1733. }
  1734. }
  1735. if (settings.moduleSizeType == TilesUtils.SizeType.CUSTOM)
  1736. {
  1737. int sizeIndex = 0;
  1738. using (var check = new UnityEditor.EditorGUI.ChangeCheckScope())
  1739. {
  1740. UnityEditor.EditorGUIUtility.labelWidth = 70;
  1741. sizeIndex = UnityEditor.EditorGUILayout.Popup("Cell Size:", settings.GetIndexOfSelectedSize(),
  1742. settings.GetSizesNames());
  1743. if (check.changed)
  1744. {
  1745. settings.SelectSize(sizeIndex);
  1746. }
  1747. }
  1748. using (new GUILayout.HorizontalScope())
  1749. {
  1750. GUILayout.FlexibleSpace();
  1751. if (GUILayout.Button("Reset")) FloorManager.settings.ResetSize();
  1752. if (GUILayout.Button("Save..."))
  1753. {
  1754. RenameWindow.ShowWindow(position.position + Event.current.mousePosition,
  1755. FloorManager.settings.SaveSize, "Save Size", settings.selectedSizeName);
  1756. }
  1757. using (new UnityEditor.EditorGUI.DisabledGroupScope(sizeIndex == 0))
  1758. {
  1759. if (GUILayout.Button("Delete"))
  1760. {
  1761. FloorManager.settings.DeleteSelectedSize();
  1762. }
  1763. }
  1764. }
  1765. }
  1766. }
  1767. UnityEditor.EditorGUIUtility.labelWidth = 70;
  1768. using (new GUILayout.VerticalScope(UnityEditor.EditorStyles.helpBox))
  1769. {
  1770. using (var check = new UnityEditor.EditorGUI.ChangeCheckScope())
  1771. {
  1772. var spacing = UnityEditor.EditorGUILayout.Vector3Field("Spacing", settings.spacing);
  1773. if (check.changed)
  1774. {
  1775. settings.spacing = spacing;
  1776. PWBIO.UpdateStroke();
  1777. UnityEditor.SceneView.RepaintAll();
  1778. }
  1779. }
  1780. }
  1781. using (new GUILayout.VerticalScope(UnityEditor.EditorStyles.helpBox))
  1782. {
  1783. int originIndex = 0;
  1784. using (var check = new UnityEditor.EditorGUI.ChangeCheckScope())
  1785. {
  1786. originIndex = UnityEditor.EditorGUILayout.Popup("Grid origin:",
  1787. SnapManager.settings.GetIndexOfSelectedOrigin(), SnapManager.settings.GetOriginNames());
  1788. if (check.changed)
  1789. {
  1790. SnapManager.settings.SelectOrigin(originIndex);
  1791. UnityEditor.SceneView.RepaintAll();
  1792. }
  1793. }
  1794. using (new GUILayout.HorizontalScope())
  1795. {
  1796. GUILayout.Label("Position");
  1797. using (var check = new UnityEditor.EditorGUI.ChangeCheckScope())
  1798. {
  1799. var origin = UnityEditor.EditorGUILayout.Vector3Field(string.Empty,
  1800. SnapManager.settings.origin);
  1801. if (check.changed)
  1802. {
  1803. SnapManager.settings.origin = origin;
  1804. UnityEditor.SceneView.RepaintAll();
  1805. }
  1806. }
  1807. }
  1808. using (new GUILayout.HorizontalScope())
  1809. {
  1810. GUILayout.Label("Rotation");
  1811. using (var check = new UnityEditor.EditorGUI.ChangeCheckScope())
  1812. {
  1813. var angle = UnityEditor.EditorGUILayout.Vector3Field(string.Empty,
  1814. SnapManager.settings.rotation.eulerAngles);
  1815. if (check.changed)
  1816. {
  1817. SnapManager.settings.rotation = Quaternion.Euler(angle);
  1818. UnityEditor.SceneView.RepaintAll();
  1819. }
  1820. }
  1821. }
  1822. using (new GUILayout.HorizontalScope())
  1823. {
  1824. GUILayout.FlexibleSpace();
  1825. if(GUILayout.Button("Reset"))
  1826. {
  1827. SnapManager.settings.ResetOrigin();
  1828. }
  1829. if (GUILayout.Button("Save..."))
  1830. {
  1831. RenameWindow.ShowWindow(position.position + Event.current.mousePosition,
  1832. SnapManager.settings.SaveGridOrigin, "Save Origin", SnapManager.settings.selectedOrigin);
  1833. }
  1834. using (new UnityEditor.EditorGUI.DisabledGroupScope(originIndex == 0))
  1835. {
  1836. if (GUILayout.Button("Delete"))
  1837. {
  1838. SnapManager.settings.DeleteSelectedOrigin();
  1839. }
  1840. }
  1841. }
  1842. }
  1843. PaintToolSettingsGUI(FloorManager.settings);
  1844. OverwriteBrushPropertiesGUI(FloorManager.settings, ref _floorOverwriteGroupState);
  1845. }
  1846. #endregion
  1847. #region WALL
  1848. private static BrushPropertiesGroupState _wallOverwriteGroupState;
  1849. private void WallGroup()
  1850. {
  1851. ToolProfileGUI(WallManager.instance);
  1852. var settings = WallManager.settings;
  1853. UnityEditor.EditorGUIUtility.labelWidth = 80;
  1854. using (new GUILayout.VerticalScope(UnityEditor.EditorStyles.helpBox))
  1855. {
  1856. settings.autoCalculateAxes = UnityEditor.EditorGUILayout.ToggleLeft("Auto calculate axes",
  1857. settings.autoCalculateAxes);
  1858. using (new UnityEditor.EditorGUI.DisabledGroupScope(settings.autoCalculateAxes))
  1859. {
  1860. using (var check = new UnityEditor.EditorGUI.ChangeCheckScope())
  1861. {
  1862. var upAxisIdx = UnityEditor.EditorGUILayout.Popup("Upward axis:",
  1863. settings.upwardAxis, _dirNames);
  1864. if (check.changed) settings.upwardAxis = upAxisIdx;
  1865. }
  1866. using (var check = new UnityEditor.EditorGUI.ChangeCheckScope())
  1867. {
  1868. var forwardAxisIdx = UnityEditor.EditorGUILayout.Popup("Forward axis:",
  1869. settings.forwardAxis, _dirNames);
  1870. if (check.changed) settings.forwardAxis = forwardAxisIdx;
  1871. }
  1872. }
  1873. }
  1874. using (new GUILayout.VerticalScope(UnityEditor.EditorStyles.helpBox))
  1875. {
  1876. UnityEditor.EditorGUIUtility.labelWidth = 90;
  1877. using (var check = new UnityEditor.EditorGUI.ChangeCheckScope())
  1878. {
  1879. var moduleSizeType = (TilesUtils.SizeType)
  1880. UnityEditor.EditorGUILayout.Popup("Cell size type:", (int)settings.moduleSizeType, _cellTypeNames);
  1881. if (check.changed)
  1882. {
  1883. settings.moduleSizeType = moduleSizeType;
  1884. if (settings.moduleSizeType == TilesUtils.SizeType.CUSTOM) WallManager.settings.ResetSize();
  1885. }
  1886. }
  1887. using (new UnityEditor.EditorGUI.DisabledGroupScope(
  1888. settings.moduleSizeType != TilesUtils.SizeType.CUSTOM))
  1889. {
  1890. using (var check = new UnityEditor.EditorGUI.ChangeCheckScope())
  1891. {
  1892. var size = UnityEditor.EditorGUILayout.FloatField("Size:", settings.moduleSize.x);
  1893. if (check.changed) settings.SetSize(size);
  1894. }
  1895. }
  1896. if (settings.moduleSizeType == TilesUtils.SizeType.CUSTOM)
  1897. {
  1898. int sizeIndex = 0;
  1899. using (var check = new UnityEditor.EditorGUI.ChangeCheckScope())
  1900. {
  1901. UnityEditor.EditorGUIUtility.labelWidth = 70;
  1902. sizeIndex = UnityEditor.EditorGUILayout.Popup("Cell Size:", settings.GetIndexOfSelectedSize(),
  1903. settings.GetSizesNames());
  1904. if (check.changed)
  1905. {
  1906. settings.SelectSize(sizeIndex);
  1907. }
  1908. }
  1909. using (new GUILayout.HorizontalScope())
  1910. {
  1911. GUILayout.FlexibleSpace();
  1912. if (GUILayout.Button("Reset")) WallManager.settings.ResetSize();
  1913. if (GUILayout.Button("Save..."))
  1914. {
  1915. RenameWindow.ShowWindow(position.position + Event.current.mousePosition,
  1916. WallManager.settings.SaveSize, "Save Size", settings.selectedSizeName);
  1917. }
  1918. using (new UnityEditor.EditorGUI.DisabledGroupScope(sizeIndex == 0))
  1919. {
  1920. if (GUILayout.Button("Delete"))
  1921. {
  1922. WallManager.settings.DeleteSelectedSize();
  1923. }
  1924. }
  1925. }
  1926. }
  1927. }
  1928. using (new GUILayout.VerticalScope(UnityEditor.EditorStyles.helpBox))
  1929. {
  1930. settings.spacing = UnityEditor.EditorGUILayout.Vector3Field("Spacing", settings.spacing);
  1931. }
  1932. using (new GUILayout.VerticalScope(UnityEditor.EditorStyles.helpBox))
  1933. {
  1934. int originIndex = 0;
  1935. using (var check = new UnityEditor.EditorGUI.ChangeCheckScope())
  1936. {
  1937. originIndex = UnityEditor.EditorGUILayout.Popup("Grid origin:",
  1938. SnapManager.settings.GetIndexOfSelectedOrigin(), SnapManager.settings.GetOriginNames());
  1939. if (check.changed)
  1940. {
  1941. SnapManager.settings.SelectOrigin(originIndex);
  1942. UnityEditor.SceneView.RepaintAll();
  1943. }
  1944. }
  1945. using (new GUILayout.HorizontalScope())
  1946. {
  1947. GUILayout.Label("Position");
  1948. using (var check = new UnityEditor.EditorGUI.ChangeCheckScope())
  1949. {
  1950. var origin = UnityEditor.EditorGUILayout.Vector3Field(string.Empty,
  1951. SnapManager.settings.origin);
  1952. if (check.changed)
  1953. {
  1954. SnapManager.settings.origin = origin;
  1955. UnityEditor.SceneView.RepaintAll();
  1956. }
  1957. }
  1958. }
  1959. using (new GUILayout.HorizontalScope())
  1960. {
  1961. GUILayout.Label("Rotation");
  1962. using (var check = new UnityEditor.EditorGUI.ChangeCheckScope())
  1963. {
  1964. var angles = UnityEditor.EditorGUILayout.Vector3Field(string.Empty,
  1965. SnapManager.settings.rotation.eulerAngles);
  1966. if (check.changed)
  1967. {
  1968. SnapManager.settings.rotation = Quaternion.Euler(angles);
  1969. UnityEditor.SceneView.RepaintAll();
  1970. }
  1971. }
  1972. }
  1973. using (new GUILayout.HorizontalScope())
  1974. {
  1975. GUILayout.FlexibleSpace();
  1976. if (GUILayout.Button("Reset"))
  1977. {
  1978. SnapManager.settings.ResetOrigin();
  1979. }
  1980. if (GUILayout.Button("Save..."))
  1981. {
  1982. RenameWindow.ShowWindow(position.position + Event.current.mousePosition,
  1983. SnapManager.settings.SaveGridOrigin, "Save Origin", SnapManager.settings.selectedOrigin);
  1984. }
  1985. using (new UnityEditor.EditorGUI.DisabledGroupScope(originIndex == 0))
  1986. {
  1987. if (GUILayout.Button("Delete"))
  1988. {
  1989. SnapManager.settings.DeleteSelectedOrigin();
  1990. }
  1991. }
  1992. }
  1993. }
  1994. PaintToolSettingsGUI(FloorManager.settings);
  1995. OverwriteBrushPropertiesGUI(FloorManager.settings, ref _floorOverwriteGroupState);
  1996. }
  1997. #endregion
  1998. }
  1999. }