private void DropAreaGUI()
{
Event evt = Event.current;
Rect drop_area = GUILayoutUtility.GetRect(0.0f, 50.0f, GUILayout.ExpandWidth(true));
this.boxStyle.alignment = TextAnchor.MiddleCenter;
GUI.color = SPInstanceEditor.green;
GUI.Box(drop_area, "Add Sprite (Drop Here)", this.boxStyle);
GUI.color = Color.white;
switch (evt.type)
{
case EventType.DragUpdated:
case EventType.DragPerform:
{
if (!drop_area.Contains(evt.mousePosition))
{
return;
}
DragAndDrop.visualMode = DragAndDropVisualMode.Copy;
if (evt.type == EventType.DragPerform)
{
DragAndDrop.AcceptDrag();
Object[] filtered = SPTools.FilterResourcesForAtlasImport(DragAndDrop.objectReferences);
// Disallow miltiple sprites of the same source, if set so
if (!SPTools.GetEditorPrefBool(SPTools.Settings_AllowMuliSpritesOneSource))
{
// Additional filtering specific to the instance
for (int i = 0; i < filtered.Length; i++)
{
if (this.m_SPInstance.sprites.Find(s => s.source == filtered[i]) != null)
{
Debug.LogWarning("A sprite with source \"" +
SimpleSpritePackerEditor.SPTools.GetAssetPath(filtered[i]) +
"\" already exists in the atlas, consider changing the Sprite Packer settings to allow multiple sprites from the same source.");
System.Array.Clear(filtered, i, 1);
}
}
}
// Types are handled internally
this.m_SPInstance.QueueAction_AddSprites(filtered);
}
break;
}
}
}