PageRenderTime 65ms CodeModel.GetById 39ms RepoModel.GetById 1ms app.codeStats 0ms

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

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