Exemplo n.º 1
0
        /// <summary> Main GUI function </summary>
        public override void OnInspectorGUI()
        {
            serializedObject.Update();

            m_editorUtils.Initialize(); // Do not remove this!

            m_editorUtils.Panel("GeneralPanel", GeneralPanel, true);
            m_editorUtils.Panel("GlobalSequencesPanel", GlobalSequencesPanel, true);
            m_editorUtils.Panel("OutputPanel", OutputPanel, true);

            if (EditorApplication.isPlaying)
            {
                AmbienceManager.GetSequences(ref GlobalSequences, ref AreaSequences);
                AllTracks     = AmbienceManager.GetTracks();
                GlobalBlocked = AmbienceManager.GetBlocked();
                if (AreaSequences.Count > 0)
                {
                    m_editorUtils.Panel("AreaAudioPanel", AreaAudioPanel, true);
                }
                if (GlobalSequences.Count > 0)
                {
                    m_editorUtils.Panel("AddedSequencesPanel", AddedSequencesPanel, true);
                }
                if (AllTracks.Count > 0)
                {
                    m_editorUtils.Panel("CurrentlyPlayingPanel", CurrentlyPlayingPanel, true);
                }
                if (GlobalBlocked.Count > 0)
                {
                    m_editorUtils.Panel("CurrentlyBlockedPanel", CurrentlyBlockedPanel, true);
                }
                m_editorUtils.Panel("ValuesPanel", ValuesPanel, true);
                m_editorUtils.Panel("EventsPanel", EventsPanel, true);
                EditorUtility.SetDirty(target);
            }

            Event currentEvent = Event.current;

            if (currentEvent.type == EventType.DragUpdated && DragAndDrop.objectReferences.Length > 0)
            {
                for (int x = 0; x < DragAndDrop.objectReferences.Length; ++x)
                {
                    if (DragAndDrop.objectReferences[x] is Sequence && string.IsNullOrEmpty((DragAndDrop.objectReferences[x] as Sequence).m_syncGroup))
                    {
                        DragAndDrop.visualMode = DragAndDropVisualMode.Link;
                        break;
                    }
                }
            }
            else if (currentEvent.type == EventType.DragPerform && DragAndDrop.objectReferences.Length > 0)
            {
                bool foundOne = false;
                for (int x = 0; x < DragAndDrop.objectReferences.Length; ++x)
                {
                    if (DragAndDrop.objectReferences[x] is Sequence)
                    {
                        Sequence seq = DragAndDrop.objectReferences[x] as Sequence;
                        m_globalSequences.InsertArrayElementAtIndex(m_globalSequences.arraySize);
                        m_globalSequences.GetArrayElementAtIndex(m_globalSequences.arraySize - 1).objectReferenceValue = seq;
                        foundOne = true;
                    }
                }
                if (foundOne)
                {
                    DragAndDrop.AcceptDrag();
                    currentEvent.Use();
                }
            }

            serializedObject.ApplyModifiedProperties();
        }