PageRenderTime 26ms CodeModel.GetById 18ms RepoModel.GetById 0ms app.codeStats 0ms

/Assets/TK2DROOT/tk2d/Editor/Sprites/SpriteCollectionEditor/tk2dSpriteCollectionEditorPopup.cs

https://bitbucket.org/Lukizanda/arrhythmia
C# | 730 lines | 619 code | 86 blank | 25 comment | 151 complexity | 344a9f223a101640c2f3cf1b1be76822 MD5 | raw file
  1. using UnityEngine;
  2. using UnityEditor;
  3. using System.Collections;
  4. using System.Collections.Generic;
  5. using System.Linq;
  6. using tk2dEditor.SpriteCollectionEditor;
  7. namespace tk2dEditor.SpriteCollectionEditor
  8. {
  9. public interface IEditorHost
  10. {
  11. void OnSpriteCollectionChanged(bool retainSelection);
  12. void OnSpriteCollectionSortChanged();
  13. Texture2D GetTextureForSprite(int spriteId);
  14. SpriteCollectionProxy SpriteCollection { get; }
  15. int InspectorWidth { get; }
  16. SpriteView SpriteView { get; }
  17. void SelectSpritesFromList(int[] indices);
  18. void SelectSpritesInSpriteSheet(int spriteSheetId, int[] spriteIds);
  19. }
  20. public class SpriteCollectionEditorEntry
  21. {
  22. public enum Type
  23. {
  24. None,
  25. Sprite,
  26. SpriteSheet,
  27. Font,
  28. MaxValue
  29. }
  30. public string name;
  31. public int index;
  32. public Type type;
  33. public bool selected = false;
  34. // list management
  35. public int listIndex; // index into the currently active list
  36. public int selectionKey; // a timestamp of when the entry was selected, to decide the last selected one
  37. }
  38. }
  39. public class tk2dSpriteCollectionEditorPopup : EditorWindow, IEditorHost
  40. {
  41. tk2dSpriteCollection _spriteCollection; // internal tmp var
  42. SpriteView spriteView;
  43. SettingsView settingsView;
  44. FontView fontView;
  45. SpriteSheetView spriteSheetView;
  46. // sprite collection we're editing
  47. SpriteCollectionProxy spriteCollectionProxy = null;
  48. public SpriteCollectionProxy SpriteCollection { get { return spriteCollectionProxy; } }
  49. public SpriteView SpriteView { get { return spriteView; } }
  50. // This lists all entries
  51. List<SpriteCollectionEditorEntry> entries = new List<SpriteCollectionEditorEntry>();
  52. // This lists all selected entries
  53. List<SpriteCollectionEditorEntry> selectedEntries = new List<SpriteCollectionEditorEntry>();
  54. // Callback when a sprite collection is changed and the selection needs to be refreshed
  55. public void OnSpriteCollectionChanged(bool retainSelection)
  56. {
  57. var oldSelection = selectedEntries.ToArray();
  58. PopulateEntries();
  59. if (retainSelection)
  60. {
  61. searchFilter = ""; // name may have changed
  62. foreach (var selection in oldSelection)
  63. {
  64. foreach (var entry in entries)
  65. {
  66. if (entry.type == selection.type && entry.index == selection.index)
  67. {
  68. entry.selected = true;
  69. break;
  70. }
  71. }
  72. }
  73. UpdateSelection();
  74. }
  75. }
  76. public void SelectSpritesFromList(int[] indices)
  77. {
  78. OnSpriteCollectionChanged(true); // clear filter
  79. selectedEntries = new List<SpriteCollectionEditorEntry>();
  80. // Clear selection
  81. foreach (var entry in entries)
  82. entry.selected = false;
  83. // Create new selection
  84. foreach (var index in indices)
  85. {
  86. foreach (var entry in entries)
  87. {
  88. if (entry.type == SpriteCollectionEditorEntry.Type.Sprite && entry.index == index)
  89. {
  90. entry.selected = true;
  91. selectedEntries.Add(entry);
  92. break;
  93. }
  94. }
  95. }
  96. }
  97. public void SelectSpritesInSpriteSheet(int spriteSheetId, int[] spriteIds)
  98. {
  99. OnSpriteCollectionChanged(true); // clear filter
  100. selectedEntries = new List<SpriteCollectionEditorEntry>();
  101. foreach (var entry in entries)
  102. {
  103. entry.selected = (entry.type == SpriteCollectionEditorEntry.Type.SpriteSheet && entry.index == spriteSheetId);
  104. if (entry.selected)
  105. {
  106. spriteSheetView.Select(spriteCollectionProxy.spriteSheets[spriteSheetId], spriteIds);
  107. }
  108. }
  109. UpdateSelection();
  110. }
  111. void UpdateSelection()
  112. {
  113. // clear settings view if its selected
  114. settingsView.show = false;
  115. selectedEntries = (from entry in entries where entry.selected == true orderby entry.selectionKey select entry).ToList();
  116. }
  117. void ClearSelection()
  118. {
  119. entries.ForEach((a) => a.selected = false);
  120. UpdateSelection();
  121. }
  122. // Callback when a sprite collection needs resorting
  123. public static bool Contains(string s, string text)
  124. {
  125. return s.ToLower().IndexOf(text.ToLower()) != -1;
  126. }
  127. // Callback when a sort criteria is changed
  128. public void OnSpriteCollectionSortChanged()
  129. {
  130. if (searchFilter.Length > 0)
  131. {
  132. // re-sort list
  133. entries = (from entry in entries where Contains(entry.name, searchFilter) orderby entry.type, entry.name select entry).ToList();
  134. }
  135. else
  136. {
  137. // re-sort list
  138. entries = (from entry in entries orderby entry.type, entry.name select entry).ToList();
  139. }
  140. for (int i = 0; i < entries.Count; ++i)
  141. entries[i].listIndex = i;
  142. }
  143. public int InspectorWidth { get { return tk2dPreferences.inst.spriteCollectionInspectorWidth; } }
  144. // populate the entries struct for display in the listbox
  145. void PopulateEntries()
  146. {
  147. entries = new List<SpriteCollectionEditorEntry>();
  148. selectedEntries = new List<SpriteCollectionEditorEntry>();
  149. if (spriteCollectionProxy == null)
  150. return;
  151. for (int spriteIndex = 0; spriteIndex < spriteCollectionProxy.textureParams.Count; ++spriteIndex)
  152. {
  153. var sprite = spriteCollectionProxy.textureParams[spriteIndex];
  154. var spriteSourceTexture = spriteCollectionProxy.textureRefs[spriteIndex];
  155. if (spriteSourceTexture == null) continue;
  156. var newEntry = new SpriteCollectionEditorEntry();
  157. newEntry.name = sprite.name;
  158. newEntry.index = spriteIndex;
  159. newEntry.type = SpriteCollectionEditorEntry.Type.Sprite;
  160. entries.Add(newEntry);
  161. }
  162. for (int i = 0; i < spriteCollectionProxy.spriteSheets.Count; ++i)
  163. {
  164. var spriteSheet = spriteCollectionProxy.spriteSheets[i];
  165. if (!spriteSheet.active) continue;
  166. var newEntry = new SpriteCollectionEditorEntry();
  167. newEntry.name = spriteSheet.Name;
  168. newEntry.index = i;
  169. newEntry.type = SpriteCollectionEditorEntry.Type.SpriteSheet;
  170. entries.Add(newEntry);
  171. }
  172. for (int i = 0; i < spriteCollectionProxy.fonts.Count; ++i)
  173. {
  174. var font = spriteCollectionProxy.fonts[i];
  175. if (!font.active) continue;
  176. var newEntry = new SpriteCollectionEditorEntry();
  177. newEntry.name = font.Name;
  178. newEntry.index = i;
  179. newEntry.type = SpriteCollectionEditorEntry.Type.Font;
  180. entries.Add(newEntry);
  181. }
  182. OnSpriteCollectionSortChanged();
  183. selectedEntries = new List<SpriteCollectionEditorEntry>();
  184. }
  185. public void SetGenerator(tk2dSpriteCollection spriteCollection)
  186. {
  187. this._spriteCollection = spriteCollection;
  188. spriteCollectionProxy = new SpriteCollectionProxy(spriteCollection);
  189. PopulateEntries();
  190. }
  191. public void SetGeneratorAndSelectedSprite(tk2dSpriteCollection spriteCollection, int selectedSprite)
  192. {
  193. searchFilter = "";
  194. SetGenerator(spriteCollection);
  195. foreach (var entry in entries)
  196. {
  197. if (entry.type == SpriteCollectionEditorEntry.Type.Sprite && entry.index == selectedSprite)
  198. {
  199. entry.selected = true;
  200. break;
  201. }
  202. }
  203. UpdateSelection();
  204. }
  205. int cachedSpriteId = -1;
  206. Texture2D cachedSpriteTexture = null;
  207. // Returns a texture for a given sprite, if the sprite is a region sprite, a new texture is returned
  208. public Texture2D GetTextureForSprite(int spriteId)
  209. {
  210. var param = spriteCollectionProxy.textureParams[spriteId];
  211. if (spriteId != cachedSpriteId)
  212. {
  213. ClearTextureCache();
  214. cachedSpriteId = spriteId;
  215. }
  216. if (param.extractRegion)
  217. {
  218. if (cachedSpriteTexture == null)
  219. {
  220. var tex = spriteCollectionProxy.textureRefs[spriteId];
  221. cachedSpriteTexture = new Texture2D(param.regionW, param.regionH);
  222. for (int y = 0; y < param.regionH; ++y)
  223. {
  224. for (int x = 0; x < param.regionW; ++x)
  225. {
  226. cachedSpriteTexture.SetPixel(x, y, tex.GetPixel(param.regionX + x, param.regionY + y));
  227. }
  228. }
  229. cachedSpriteTexture.Apply();
  230. }
  231. return cachedSpriteTexture;
  232. }
  233. else
  234. {
  235. return spriteCollectionProxy.textureRefs[spriteId];
  236. }
  237. }
  238. void ClearTextureCache()
  239. {
  240. if (cachedSpriteId != -1)
  241. cachedSpriteId = -1;
  242. if (cachedSpriteTexture != null)
  243. {
  244. DestroyImmediate(cachedSpriteTexture);
  245. cachedSpriteTexture = null;
  246. }
  247. }
  248. void OnEnable()
  249. {
  250. if (_spriteCollection != null)
  251. {
  252. SetGenerator(_spriteCollection);
  253. }
  254. spriteView = new SpriteView(this);
  255. settingsView = new SettingsView(this);
  256. fontView = new FontView(this);
  257. spriteSheetView = new SpriteSheetView(this);
  258. }
  259. void OnDisable()
  260. {
  261. ClearTextureCache();
  262. }
  263. string searchFilter = "";
  264. void DrawToolbar()
  265. {
  266. GUILayout.BeginHorizontal(EditorStyles.toolbar, GUILayout.ExpandWidth(true));
  267. // LHS
  268. GUILayout.BeginHorizontal(GUILayout.Width(leftBarWidth - 6));
  269. // Create Button
  270. GUIContent createButton = new GUIContent("Create");
  271. Rect createButtonRect = GUILayoutUtility.GetRect(createButton, EditorStyles.toolbarDropDown, GUILayout.ExpandWidth(false));
  272. if (GUI.Button(createButtonRect, createButton, EditorStyles.toolbarDropDown))
  273. {
  274. GUIUtility.hotControl = 0;
  275. GUIContent[] menuItems = new GUIContent[] {
  276. new GUIContent("Sprite Sheet"),
  277. new GUIContent("Font")
  278. };
  279. EditorUtility.DisplayCustomMenu(createButtonRect, menuItems, -1,
  280. delegate(object userData, string[] options, int selected) {
  281. switch (selected)
  282. {
  283. case 0:
  284. int addedSpriteSheetIndex = spriteCollectionProxy.FindOrCreateEmptySpriteSheetSlot();
  285. searchFilter = "";
  286. PopulateEntries();
  287. foreach (var entry in entries)
  288. {
  289. if (entry.type == SpriteCollectionEditorEntry.Type.SpriteSheet && entry.index == addedSpriteSheetIndex)
  290. entry.selected = true;
  291. }
  292. UpdateSelection();
  293. break;
  294. case 1:
  295. if (SpriteCollection.allowMultipleAtlases)
  296. {
  297. EditorUtility.DisplayDialog("Create Font",
  298. "Adding fonts to sprite collections isn't allowed when multi atlas spanning is enabled. " +
  299. "Please disable it and try again.", "Ok");
  300. }
  301. else
  302. {
  303. int addedFontIndex = spriteCollectionProxy.FindOrCreateEmptyFontSlot();
  304. searchFilter = "";
  305. PopulateEntries();
  306. foreach (var entry in entries)
  307. {
  308. if (entry.type == SpriteCollectionEditorEntry.Type.Font && entry.index == addedFontIndex)
  309. entry.selected = true;
  310. }
  311. UpdateSelection();
  312. }
  313. break;
  314. }
  315. }
  316. , null);
  317. }
  318. // Filter box
  319. GUILayout.Space(8);
  320. string newSearchFilter = GUILayout.TextField(searchFilter, tk2dEditorSkin.ToolbarSearch, GUILayout.ExpandWidth(true));
  321. if (newSearchFilter != searchFilter)
  322. {
  323. searchFilter = newSearchFilter;
  324. PopulateEntries();
  325. }
  326. if (searchFilter.Length > 0)
  327. {
  328. if (GUILayout.Button("", tk2dEditorSkin.ToolbarSearchClear, GUILayout.ExpandWidth(false)))
  329. {
  330. searchFilter = "";
  331. PopulateEntries();
  332. }
  333. }
  334. else
  335. {
  336. GUILayout.Label("", tk2dEditorSkin.ToolbarSearchRightCap);
  337. }
  338. GUILayout.EndHorizontal();
  339. // Label
  340. if (_spriteCollection != null)
  341. GUILayout.Label(_spriteCollection.name);
  342. // RHS
  343. GUILayout.FlexibleSpace();
  344. // Always in settings view when empty
  345. if (spriteCollectionProxy != null && spriteCollectionProxy.Empty)
  346. {
  347. GUILayout.Toggle(true, "Settings", EditorStyles.toolbarButton);
  348. }
  349. else
  350. {
  351. bool newSettingsView = GUILayout.Toggle(settingsView.show, "Settings", EditorStyles.toolbarButton);
  352. if (newSettingsView != settingsView.show)
  353. {
  354. ClearSelection();
  355. settingsView.show = newSettingsView;
  356. }
  357. }
  358. if (GUILayout.Button("Revert", EditorStyles.toolbarButton) && spriteCollectionProxy != null)
  359. {
  360. spriteCollectionProxy.CopyFromSource();
  361. OnSpriteCollectionChanged(false);
  362. }
  363. if (GUILayout.Button("Commit", EditorStyles.toolbarButton) && spriteCollectionProxy != null)
  364. {
  365. spriteCollectionProxy.CopyToTarget();
  366. tk2dSpriteCollectionBuilder.ResetCurrentBuild();
  367. tk2dSpriteCollectionBuilder.Rebuild(_spriteCollection);
  368. spriteCollectionProxy.CopyFromSource();
  369. }
  370. GUILayout.EndHorizontal();
  371. }
  372. Vector2 spriteListScroll = Vector2.zero;
  373. int spriteListSelectionKey = 0;
  374. void DrawSpriteList()
  375. {
  376. if (spriteCollectionProxy != null && spriteCollectionProxy.Empty)
  377. {
  378. DrawDropZone();
  379. return;
  380. }
  381. spriteListScroll = GUILayout.BeginScrollView(spriteListScroll, GUILayout.Width(leftBarWidth));
  382. GUILayout.BeginVertical(tk2dEditorSkin.SC_ListBoxBG, GUILayout.ExpandWidth(true), GUILayout.ExpandHeight(true));
  383. bool multiSelectKey = (Application.platform == RuntimePlatform.OSXEditor)?Event.current.command:Event.current.control;
  384. bool shiftSelectKey = Event.current.shift;
  385. bool selectionChanged = false;
  386. SpriteCollectionEditorEntry.Type lastType = SpriteCollectionEditorEntry.Type.None;
  387. foreach (var entry in entries)
  388. {
  389. if (lastType != entry.type)
  390. {
  391. if (lastType != SpriteCollectionEditorEntry.Type.None)
  392. GUILayout.Space(8);
  393. else
  394. GUI.SetNextControlName("firstLabel");
  395. GUILayout.Label(GetEntryTypeString(entry.type), tk2dEditorSkin.SC_ListBoxSectionHeader, GUILayout.ExpandWidth(true));
  396. lastType = entry.type;
  397. }
  398. bool newSelected = GUILayout.Toggle(entry.selected, entry.name, tk2dEditorSkin.SC_ListBoxItem, GUILayout.ExpandWidth(true));
  399. if (newSelected != entry.selected)
  400. {
  401. GUI.FocusControl("firstLabel");
  402. entry.selectionKey = spriteListSelectionKey++;
  403. if (multiSelectKey)
  404. {
  405. // Only allow multiselection with sprites
  406. bool selectionAllowed = entry.type == SpriteCollectionEditorEntry.Type.Sprite;
  407. foreach (var e in entries)
  408. {
  409. if (e != entry && e.selected && e.type != entry.type)
  410. {
  411. selectionAllowed = false;
  412. break;
  413. }
  414. }
  415. if (selectionAllowed)
  416. {
  417. entry.selected = newSelected;
  418. selectionChanged = true;
  419. }
  420. else
  421. {
  422. foreach (var e in entries)
  423. {
  424. e.selected = false;
  425. }
  426. entry.selected = true;
  427. selectionChanged = true;
  428. }
  429. }
  430. else if (shiftSelectKey)
  431. {
  432. // find first selected entry in list
  433. int firstSelection = int.MaxValue;
  434. foreach (var e in entries)
  435. {
  436. if (e.selected && e.listIndex < firstSelection)
  437. {
  438. firstSelection = e.listIndex;
  439. }
  440. }
  441. int lastSelection = entry.listIndex;
  442. if (lastSelection < firstSelection)
  443. {
  444. lastSelection = firstSelection;
  445. firstSelection = entry.listIndex;
  446. }
  447. // Filter for multiselection
  448. if (entry.type == SpriteCollectionEditorEntry.Type.Sprite)
  449. {
  450. for (int i = firstSelection; i <= lastSelection; ++i)
  451. {
  452. if (entries[i].type != entry.type)
  453. {
  454. firstSelection = entry.listIndex;
  455. lastSelection = entry.listIndex;
  456. }
  457. }
  458. }
  459. else
  460. {
  461. firstSelection = lastSelection = entry.listIndex;
  462. }
  463. foreach (var e in entries)
  464. {
  465. e.selected = (e.listIndex >= firstSelection && e.listIndex <= lastSelection);
  466. }
  467. selectionChanged = true;
  468. }
  469. else
  470. {
  471. foreach (var e in entries)
  472. {
  473. e.selected = false;
  474. }
  475. entry.selected = true;
  476. selectionChanged = true;
  477. }
  478. }
  479. }
  480. if (selectionChanged)
  481. {
  482. UpdateSelection();
  483. Repaint();
  484. }
  485. GUILayout.EndVertical();
  486. GUILayout.EndScrollView();
  487. Rect viewRect = GUILayoutUtility.GetLastRect();
  488. tk2dPreferences.inst.spriteCollectionListWidth = (int)tk2dGuiUtility.DragableHandle(4819283,
  489. viewRect, tk2dPreferences.inst.spriteCollectionListWidth,
  490. tk2dGuiUtility.DragDirection.Horizontal);
  491. }
  492. bool IsValidDragPayload()
  493. {
  494. int idx = 0;
  495. foreach (var v in DragAndDrop.objectReferences)
  496. {
  497. var type = v.GetType();
  498. if (type == typeof(Texture2D))
  499. return true;
  500. else if (type == typeof(Object) && System.IO.Directory.Exists(DragAndDrop.paths[idx]))
  501. return true;
  502. ++idx;
  503. }
  504. return false;
  505. }
  506. string GetEntryTypeString(SpriteCollectionEditorEntry.Type kind)
  507. {
  508. switch (kind)
  509. {
  510. case SpriteCollectionEditorEntry.Type.Sprite: return "Sprites";
  511. case SpriteCollectionEditorEntry.Type.SpriteSheet: return "Sprite Sheets";
  512. case SpriteCollectionEditorEntry.Type.Font: return "Fonts";
  513. }
  514. Debug.LogError("Unhandled type");
  515. return "";
  516. }
  517. void HandleDroppedPayload(Object[] objects)
  518. {
  519. List<int> addedIndices = new List<int>();
  520. foreach (var obj in objects)
  521. {
  522. Texture2D tex = obj as Texture2D;
  523. string name = spriteCollectionProxy.FindUniqueTextureName(tex.name);
  524. int slot = spriteCollectionProxy.FindOrCreateEmptySpriteSlot();
  525. spriteCollectionProxy.textureParams[slot].name = name;
  526. spriteCollectionProxy.textureParams[slot].colliderType = tk2dSpriteCollectionDefinition.ColliderType.None;
  527. spriteCollectionProxy.textureRefs[slot] = (Texture2D)obj;
  528. addedIndices.Add(slot);
  529. }
  530. // And now select them
  531. searchFilter = "";
  532. PopulateEntries();
  533. foreach (var entry in entries)
  534. {
  535. if (entry.type == SpriteCollectionEditorEntry.Type.Sprite &&
  536. addedIndices.IndexOf(entry.index) != -1)
  537. entry.selected = true;
  538. }
  539. UpdateSelection();
  540. }
  541. // recursively find textures in path
  542. List<Object> AddTexturesInPath(string path)
  543. {
  544. List<Object> localObjects = new List<Object>();
  545. foreach (var q in System.IO.Directory.GetFiles(path))
  546. {
  547. string f = q.Replace('\\', '/');
  548. System.IO.FileInfo fi = new System.IO.FileInfo(f);
  549. if (fi.Extension.ToLower() == ".meta")
  550. continue;
  551. Object obj = AssetDatabase.LoadAssetAtPath(f, typeof(Texture2D));
  552. if (obj != null) localObjects.Add(obj);
  553. }
  554. foreach (var q in System.IO.Directory.GetDirectories(path))
  555. {
  556. string d = q.Replace('\\', '/');
  557. localObjects.AddRange(AddTexturesInPath(d));
  558. }
  559. return localObjects;
  560. }
  561. int leftBarWidth { get { return tk2dPreferences.inst.spriteCollectionListWidth; } }
  562. Object[] deferredDroppedObjects;
  563. void DrawDropZone()
  564. {
  565. GUILayout.BeginVertical(tk2dEditorSkin.SC_ListBoxBG, GUILayout.Width(leftBarWidth), GUILayout.ExpandHeight(true));
  566. GUILayout.FlexibleSpace();
  567. GUILayout.BeginHorizontal();
  568. GUILayout.FlexibleSpace();
  569. if (DragAndDrop.objectReferences.Length == 0 && !SpriteCollection.Empty)
  570. GUILayout.Label("Drop sprite here", tk2dEditorSkin.SC_DropBox);
  571. else
  572. GUILayout.Label("Drop sprites here", tk2dEditorSkin.SC_DropBox);
  573. GUILayout.FlexibleSpace();
  574. GUILayout.EndHorizontal();
  575. GUILayout.FlexibleSpace();
  576. GUILayout.EndVertical();
  577. Rect rect = new Rect(0, 0, leftBarWidth, Screen.height);
  578. if (rect.Contains(Event.current.mousePosition))
  579. {
  580. switch (Event.current.type)
  581. {
  582. case EventType.DragUpdated:
  583. if (IsValidDragPayload())
  584. DragAndDrop.visualMode = DragAndDropVisualMode.Copy;
  585. else
  586. DragAndDrop.visualMode = DragAndDropVisualMode.None;
  587. break;
  588. case EventType.DragPerform:
  589. var droppedObjectsList = new List<Object>();
  590. for (int i = 0; i < DragAndDrop.objectReferences.Length; ++i)
  591. {
  592. var type = DragAndDrop.objectReferences[i].GetType();
  593. if (type == typeof(Texture2D))
  594. droppedObjectsList.Add(DragAndDrop.objectReferences[i]);
  595. else if (type == typeof(Object) && System.IO.Directory.Exists(DragAndDrop.paths[i]))
  596. droppedObjectsList.AddRange(AddTexturesInPath(DragAndDrop.paths[i]));
  597. }
  598. deferredDroppedObjects = droppedObjectsList.ToArray();
  599. Repaint();
  600. break;
  601. }
  602. }
  603. }
  604. bool dragging = false;
  605. bool currentDraggingValue = false;
  606. void OnGUI()
  607. {
  608. if (Event.current.type == EventType.DragUpdated)
  609. {
  610. if (IsValidDragPayload())
  611. dragging = true;
  612. }
  613. else if (Event.current.type == EventType.DragExited)
  614. {
  615. dragging = false;
  616. Repaint();
  617. }
  618. else
  619. {
  620. if (currentDraggingValue != dragging)
  621. {
  622. currentDraggingValue = dragging;
  623. }
  624. }
  625. if (Event.current.type == EventType.Layout && deferredDroppedObjects != null)
  626. {
  627. HandleDroppedPayload(deferredDroppedObjects);
  628. deferredDroppedObjects = null;
  629. }
  630. GUILayout.BeginVertical();
  631. DrawToolbar();
  632. GUILayout.BeginHorizontal();
  633. if (currentDraggingValue)
  634. DrawDropZone();
  635. else
  636. DrawSpriteList();
  637. if (settingsView.show || (spriteCollectionProxy != null && spriteCollectionProxy.Empty)) settingsView.Draw();
  638. else if (fontView.Draw(selectedEntries)) { }
  639. else if (spriteSheetView.Draw(selectedEntries)) { }
  640. else spriteView.Draw(selectedEntries);
  641. GUILayout.EndHorizontal();
  642. GUILayout.EndVertical();
  643. }
  644. }