コード例 #1
0
    private void DropAreaGUI(Rect dropArea)
    {
        var evt = Event.current;

        if (evt.type == EventType.DragUpdated)
        {
            if (dropArea.Contains(evt.mousePosition))
            {
                DragAndDrop.visualMode = DragAndDropVisualMode.Copy;
            }
        }

        if (evt.type == EventType.DragPerform)
        {
            if (dropArea.Contains(evt.mousePosition))
            {
                DragAndDrop.AcceptDrag();
                UnityEngine.Object[] draggedObjects = DragAndDrop.objectReferences as UnityEngine.Object[];
                var clips = new List <AudioClip>();
                foreach (var obj in draggedObjects)
                {
                    var c = obj as AudioClip;
                    if ((c != null) && !clips.Contains(c))
                    {
                        clips.Add(c);
                    }
                }

                clips.Sort((a, b) => a.name.CompareTo(b.name));

                SoundClip clip = (SoundClip)target;
                if (evt.control)
                {
                    clip.InspectorSetClips(clips);
                }
                else
                {
                    clip.InspectorAddClips(clips);
                }
            }
        }
    }