Inheritance: EditorWindow, ISerializationCallbackReceiver
Esempio n. 1
0
        public static void ShowEventBrowser()
        {
            EventBrowser eventBrowser = EditorWindow.GetWindow <EventBrowser>("FMOD Events");

            eventBrowser.minSize = new Vector2(280, 600);
            eventBrowser.Show();
        }
Esempio n. 2
0
        static void OnCacheChange()
        {
            var settings = Settings.Instance;

            settings.MasterBanks.Clear();

            foreach (EditorBankRef bankRef in eventCache.MasterBanks)
            {
                settings.MasterBanks.Add(bankRef.Name);
            }

            settings.Banks.Clear();

            foreach (var bankRef in eventCache.EditorBanks)
            {
                if (!eventCache.MasterBanks.Contains(bankRef) &&
                    !eventCache.StringsBanks.Contains(bankRef))
                {
                    settings.Banks.Add(bankRef.Name);
                }
            }

            settings.Banks.Sort((a, b) => string.Compare(a, b, StringComparison.CurrentCultureIgnoreCase));
            EditorUtility.SetDirty(settings);

            EventBrowser.RepaintEventBrowser();
        }
Esempio n. 3
0
        static void OnCacheChange()
        {
            if (eventCache.MasterBankRef)
            {
                Settings.Instance.MasterBank = eventCache.MasterBankRef.Name;
            }
            else
            {
                Settings.Instance.MasterBank = null;
            }

            Settings.Instance.Banks.Clear();
            foreach (var bankRef in eventCache.EditorBanks)
            {
                if (bankRef != eventCache.MasterBankRef &&
                    bankRef != eventCache.StringsBankRef)
                {
                    Settings.Instance.Banks.Add(bankRef.Name);
                }
            }
            EditorUtility.SetDirty(Settings.Instance);
            EditorUtility.SetDirty(eventCache);

            CopyToStreamingAssets();

            EventBrowser.RepaintEventBrowser();
        }
Esempio n. 4
0
        static void OnCacheChange()
        {
            var settings = Settings.Instance;

            settings.MasterBanks.Clear();

            foreach (EditorBankRef bankRef in eventCache.MasterBanks)
            {
                settings.MasterBanks.Add(bankRef.Name);
            }

            settings.Banks.Clear();

            foreach (var bankRef in eventCache.EditorBanks)
            {
                if (!eventCache.MasterBanks.Contains(bankRef) &&
                    !eventCache.StringsBanks.Contains(bankRef))
                {
                    settings.Banks.Add(bankRef.Name);
                }
            }
            EditorUtility.SetDirty(settings);

            CopyToStreamingAssets();

            EventBrowser.RepaintEventBrowser();
        }
        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            Texture browseIcon = EditorGUIUtility.Load("FMOD/SearchIconBlack.png") as Texture;

            SerializedProperty pathProperty = property;

            EditorGUI.BeginProperty(position, label, property);

            Event e = Event.current;

            if (e.type == EventType.DragPerform && position.Contains(e.mousePosition))
            {
                if (DragAndDrop.objectReferences.Length > 0 &&
                    DragAndDrop.objectReferences[0] != null &&
                    DragAndDrop.objectReferences[0].GetType() == typeof(EditorBankRef))
                {
                    pathProperty.stringValue = ((EditorBankRef)DragAndDrop.objectReferences[0]).Name;

                    e.Use();
                }
            }
            if (e.type == EventType.DragUpdated && position.Contains(e.mousePosition))
            {
                if (DragAndDrop.objectReferences.Length > 0 &&
                    DragAndDrop.objectReferences[0] != null &&
                    DragAndDrop.objectReferences[0].GetType() == typeof(EditorBankRef))
                {
                    DragAndDrop.visualMode = DragAndDropVisualMode.Move;
                    DragAndDrop.AcceptDrag();
                    e.Use();
                }
            }

            float baseHeight = GUI.skin.textField.CalcSize(new GUIContent()).y;

            position = EditorGUI.PrefixLabel(position, GUIUtility.GetControlID(FocusType.Passive), label);

            var buttonStyle = new GUIStyle(GUI.skin.button);

            buttonStyle.padding.top = buttonStyle.padding.bottom = 1;

            Rect searchRect = new Rect(position.x + position.width - browseIcon.width - 15, position.y, browseIcon.width + 10, baseHeight);
            Rect pathRect   = new Rect(position.x, position.y, searchRect.x - position.x - 5, baseHeight);

            EditorGUI.PropertyField(pathRect, pathProperty, GUIContent.none);
            if (GUI.Button(searchRect, new GUIContent(browseIcon, "Select FMOD Bank"), buttonStyle))
            {
                var eventBrowser = EventBrowser.CreateInstance <EventBrowser>();

                eventBrowser.SelectBank(property);
                var windowRect = position;
                windowRect.position = GUIUtility.GUIToScreenPoint(windowRect.position);
                windowRect.height   = searchRect.height + 1;
                eventBrowser.ShowAsDropDown(windowRect, new Vector2(windowRect.width, 400));
            }

            EditorGUI.EndProperty();
        }
        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            position = EditorGUI.PrefixLabel(position, GUIUtility.GetControlID(FocusType.Passive), label);

            EditorGUI.BeginProperty(position, label, property);

            float baseHeight = GUI.skin.textField.CalcSize(new GUIContent()).y;

            Rect rect = new Rect(position.x, position.y, position.width, baseHeight);

            SerializedProperty allProperty   = property.FindPropertyRelative("AllBanks");
            SerializedProperty banksProperty = property.FindPropertyRelative("Banks");

            EditorGUI.PropertyField(rect, allProperty, new GUIContent("All Banks"));

            if (!allProperty.boolValue)
            {
                GUIContent addButtonContent = new GUIContent("Add Bank");
                float      addButtonWidth   = GUI.skin.textField.CalcSize(addButtonContent).x + 20;
                Rect       buttonRect       = new Rect(position.x, position.y + baseHeight + 2, addButtonWidth, baseHeight);
                if (GUI.Button(buttonRect, addButtonContent))
                {
                    banksProperty.InsertArrayElementAtIndex(banksProperty.arraySize);
                    SerializedProperty newBank = banksProperty.GetArrayElementAtIndex(banksProperty.arraySize - 1);
                    newBank.FindPropertyRelative("Name").stringValue = "";

                    var browser = EventBrowser.CreateInstance <EventBrowser>();
                    browser.titleContent = new GUIContent("Select FMOD Bank");
                    browser.SelectBank(newBank);
                    browser.ShowUtility();
                }

                Texture    deleteTexture = EditorGUIUtility.Load("FMOD/Delete.png") as Texture;
                GUIContent deleteContent = new GUIContent(deleteTexture, "Delete Bank");
                float      deleteWidth   = deleteTexture.width + 5;
                Rect       deleteRect    = new Rect(position.x + position.width - deleteWidth - 10, position.y + baseHeight * 2 + 4, deleteWidth, baseHeight);
                Rect       bankRect      = new Rect(position.x, position.y + baseHeight * 2 + 4, position.width - deleteWidth - 10, baseHeight);

                for (int i = 0; i < banksProperty.arraySize; i++)
                {
                    EditorGUI.PropertyField(bankRect, banksProperty.GetArrayElementAtIndex(i), GUIContent.none);

                    if (GUI.Button(deleteRect, deleteContent))
                    {
                        banksProperty.DeleteArrayElementAtIndex(i);
                    }
                    bankRect.y   += baseHeight + 2;
                    deleteRect.y += baseHeight + 2;
                }
            }
            else
            {
                banksProperty.ClearArray();
            }

            EditorGUI.EndProperty();
        }
Esempio n. 7
0
        public static void ShowWindow()
        {
            EventBrowser eventBrowser = GetWindow <EventBrowser>("FMOD Events");

            eventBrowser.minSize = new Vector2(380, 600);

            eventBrowser.BeginStandaloneWindow();
            eventBrowser.Show();
        }
Esempio n. 8
0
        public void OnEnable()
        {
#if UNITY_2019_1_OR_NEWER
            UnityEditor.SceneView.duringSceneGui += SceneUpdate;
            #else
            SceneView.onSceneGUIDelegate += SceneUpdate;
            #endif
            EditorApplication.hierarchyWindowItemOnGUI += HierachachyUpdate;
            instance = this;
        }
Esempio n. 9
0
        static void OnCacheChange()
        {
            List <string> masterBanks = new List <string>();
            List <string> banks       = new List <string>();

            var  settings   = Settings.Instance;
            bool hasChanged = false;

            foreach (EditorBankRef bankRef in eventCache.MasterBanks)
            {
                masterBanks.Add(bankRef.Name);
            }

            if (!CompareLists(masterBanks, settings.MasterBanks))
            {
                settings.MasterBanks.Clear();
                settings.MasterBanks.AddRange(masterBanks);
                hasChanged = true;
            }

            foreach (var bankRef in eventCache.EditorBanks)
            {
                if (!eventCache.MasterBanks.Contains(bankRef) &&
                    !eventCache.StringsBanks.Contains(bankRef))
                {
                    banks.Add(bankRef.Name);
                }
            }
            banks.Sort((a, b) => string.Compare(a, b, StringComparison.CurrentCultureIgnoreCase));

            if (!CompareLists(banks, settings.Banks))
            {
                settings.Banks.Clear();
                settings.Banks.AddRange(banks);
                hasChanged = true;
            }

            if (hasChanged)
            {
                EditorUtility.SetDirty(settings);
                EventBrowser.RepaintEventBrowser();
            }
        }
Esempio n. 10
0
        static void OnCacheChange()
        {
            Settings.Instance.MasterBank = new BankRef(MasterBank.Name);

            Settings.Instance.Banks.Clear();
            foreach (var bankRef in eventCache.EditorBanks)
            {
                if (bankRef != MasterBank)
                {
                    Settings.Instance.Banks.Add(new BankRef(bankRef.Name));
                }
            }
            EditorUtility.SetDirty(Settings.Instance);
            EditorUtility.SetDirty(eventCache);

            EditorUtils.CopyToStreamingAssets();

            EventBrowser eventBrowser = EditorWindow.GetWindow <EventBrowser>("FMOD Events");

            eventBrowser.Repaint();
        }
        static void OnCacheChange()
        {
            Settings.Instance.MasterBanks.Clear();

            foreach (EditorBankRef bankRef in eventCache.MasterBanks)
            {
                Settings.Instance.MasterBanks.Add(bankRef.Name);
            }

            Settings.Instance.Banks.Clear();

            foreach (var bankRef in eventCache.EditorBanks)
            {
                if (!eventCache.MasterBanks.Contains(bankRef) &&
                    !eventCache.StringsBanks.Contains(bankRef))
                {
                    Settings.Instance.Banks.Add(bankRef.Name);
                }
            }

            CopyToStreamingAssets();

            EventBrowser.RepaintEventBrowser();
        }
Esempio n. 12
0
        public override void OnInspectorGUI()
        {
            var load    = serializedObject.FindProperty("LoadEvent");
            var unload  = serializedObject.FindProperty("UnloadEvent");
            var tag     = serializedObject.FindProperty("CollisionTag");
            var banks   = serializedObject.FindProperty("Banks");
            var preload = serializedObject.FindProperty("PreloadSamples");

            EditorGUILayout.PropertyField(load, new GUIContent("Load"));
            EditorGUILayout.PropertyField(unload, new GUIContent("Unload"));

            if ((load.enumValueIndex >= 3 && load.enumValueIndex <= 6) ||
                (unload.enumValueIndex >= 3 && unload.enumValueIndex <= 6))
            {
                tag.stringValue = EditorGUILayout.TagField("Collision Tag", tag.stringValue);
            }

            EditorGUILayout.PropertyField(preload, new GUIContent("Preload Sample Data"));

            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.PrefixLabel("Banks");
            EditorGUILayout.BeginVertical();
            if (GUILayout.Button("Add Bank", GUILayout.ExpandWidth(false)))
            {
                banks.InsertArrayElementAtIndex(banks.arraySize);
                SerializedProperty newBank = banks.GetArrayElementAtIndex(banks.arraySize - 1);
                newBank.stringValue = "";

                EventBrowser browser = CreateInstance <EventBrowser>();

                browser.titleContent = new GUIContent("Select FMOD Bank");

                browser.ChooseBank(newBank);
                browser.ShowUtility();
            }

            Texture    deleteTexture = EditorGUIUtility.Load("FMOD/Delete.png") as Texture;
            GUIContent deleteContent = new GUIContent(deleteTexture, "Delete Bank");

            var buttonStyle = new GUIStyle(GUI.skin.button);

            buttonStyle.padding.top  = buttonStyle.padding.bottom = 1;
            buttonStyle.margin.top   = 2;
            buttonStyle.padding.left = buttonStyle.padding.right = 4;
            buttonStyle.fixedHeight  = GUI.skin.textField.CalcSize(new GUIContent()).y;

            for (int i = 0; i < banks.arraySize; i++)
            {
                EditorGUILayout.BeginHorizontal();
                EditorGUILayout.PropertyField(banks.GetArrayElementAtIndex(i), GUIContent.none);

                if (GUILayout.Button(deleteContent, buttonStyle, GUILayout.ExpandWidth(false)))
                {
                    banks.DeleteArrayElementAtIndex(i);
                }
                EditorGUILayout.EndHorizontal();
            }
            EditorGUILayout.EndVertical();

            EditorGUILayout.EndHorizontal();

            Event e = Event.current;

            if (e.type == EventType.DragPerform)
            {
                if (DragAndDrop.objectReferences.Length > 0 &&
                    DragAndDrop.objectReferences[0] != null &&
                    DragAndDrop.objectReferences[0].GetType() == typeof(EditorBankRef))
                {
                    int pos = banks.arraySize;
                    banks.InsertArrayElementAtIndex(pos);
                    var pathProperty = banks.GetArrayElementAtIndex(pos);

                    pathProperty.stringValue = ((EditorBankRef)DragAndDrop.objectReferences[0]).Name;

                    e.Use();
                }
            }
            if (e.type == EventType.DragUpdated)
            {
                if (DragAndDrop.objectReferences.Length > 0 &&
                    DragAndDrop.objectReferences[0] != null &&
                    DragAndDrop.objectReferences[0].GetType() == typeof(EditorBankRef))
                {
                    DragAndDrop.visualMode = DragAndDropVisualMode.Move;
                    DragAndDrop.AcceptDrag();
                    e.Use();
                }
            }

            serializedObject.ApplyModifiedProperties();
        }
Esempio n. 13
0
        static void ShowEventBrowser()
        {
            EventBrowser eventBrowser = EditorWindow.GetWindow <EventBrowser>("FMOD Events");

            eventBrowser.Show();
        }
        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            Texture browseIcon = EditorGUIUtility.Load("FMOD/SearchIconBlack.png") as Texture;
            Texture openIcon   = EditorGUIUtility.Load("FMOD/StudioIcon.png") as Texture;


            EditorGUI.BeginProperty(position, label, property);
            SerializedProperty pathProperty = property;

            Event e = Event.current;

            if (e.type == EventType.dragPerform && position.Contains(e.mousePosition))
            {
                if (DragAndDrop.objectReferences.Length > 0 &&
                    DragAndDrop.objectReferences[0] != null &&
                    DragAndDrop.objectReferences[0].GetType() == typeof(EditorEventRef))
                {
                    pathProperty.stringValue = ((EditorEventRef)DragAndDrop.objectReferences[0]).Path;
                    GUI.changed = true;
                    e.Use();
                }
            }
            if (e.type == EventType.DragUpdated && position.Contains(e.mousePosition))
            {
                if (DragAndDrop.objectReferences.Length > 0 &&
                    DragAndDrop.objectReferences[0] != null &&
                    DragAndDrop.objectReferences[0].GetType() == typeof(EditorEventRef))
                {
                    DragAndDrop.visualMode = DragAndDropVisualMode.Move;
                    DragAndDrop.AcceptDrag();
                    e.Use();
                }
            }

            float baseHeight = GUI.skin.textField.CalcSize(new GUIContent()).y;

            position = EditorGUI.PrefixLabel(position, GUIUtility.GetControlID(FocusType.Passive), label);

            GUIStyle buttonStyle = GUI.skin.button;

            buttonStyle.padding.top    = 1;
            buttonStyle.padding.bottom = 1;

            Rect openRect   = new Rect(position.x + position.width - openIcon.width - 15, position.y, openIcon.width + 10, baseHeight);
            Rect searchRect = new Rect(openRect.x - browseIcon.width - 15, position.y, browseIcon.width + 10, baseHeight);
            Rect pathRect   = new Rect(position.x, position.y, searchRect.x - position.x - 5, baseHeight);

            EditorGUI.PropertyField(pathRect, pathProperty, GUIContent.none);
            if (GUI.Button(searchRect, new GUIContent(browseIcon, "Search"), buttonStyle))
            {
                var eventBrowser = EventBrowser.CreateInstance <EventBrowser>();
                eventBrowser.titleContent = new GUIContent("Select FMOD Event");
                eventBrowser.SelectEvent(property);
                eventBrowser.ShowUtility();
            }
            if (GUI.Button(openRect, new GUIContent(openIcon, "Open In FMOD Studio"), buttonStyle) &&
                !String.IsNullOrEmpty(pathProperty.stringValue) &&
                EventManager.EventFromPath(pathProperty.stringValue) != null
                )
            {
                EditorEventRef eventRef = EventManager.EventFromPath(pathProperty.stringValue);
                string         cmd      = string.Format("studio.window.navigateTo(studio.project.lookup(\"{0}\"))", eventRef.Guid.ToString("b"));
                EditorUtils.SendScriptCommand(cmd);
            }

            if (!String.IsNullOrEmpty(pathProperty.stringValue) && EventManager.EventFromPath(pathProperty.stringValue) != null)
            {
                Rect foldoutRect = new Rect(position.x + 10, position.y + baseHeight, position.width, baseHeight);
                displayProperties = EditorGUI.Foldout(foldoutRect, displayProperties, "Event Properties");
                if (displayProperties)
                {
                    var style = new GUIStyle(GUI.skin.label);
                    style.richText = true;
                    EditorEventRef eventRef  = EventManager.EventFromPath(pathProperty.stringValue);
                    float          width     = style.CalcSize(new GUIContent("<b>Oneshot</b>")).x;
                    Rect           labelRect = new Rect(position.x, position.y + baseHeight * 2, width, baseHeight);
                    Rect           valueRect = new Rect(position.x + width + 10, position.y + baseHeight * 2, pathRect.width, baseHeight);

                    GUI.Label(labelRect, new GUIContent("<b>GUID</b>"), style);
                    EditorGUI.SelectableLabel(valueRect, eventRef.Guid.ToString("b"));
                    labelRect.y += baseHeight;
                    valueRect.y += baseHeight;

                    GUI.Label(labelRect, new GUIContent("<b>Banks</b>"), style);
                    StringBuilder builder = new StringBuilder();
                    eventRef.Banks.ForEach((x) => { builder.Append(Path.GetFileNameWithoutExtension(x.Path)); builder.Append(", "); });
                    GUI.Label(valueRect, builder.ToString(0, builder.Length - 2));
                    labelRect.y += baseHeight;
                    valueRect.y += baseHeight;

                    GUI.Label(labelRect, new GUIContent("<b>Panning</b>"), style);
                    GUI.Label(valueRect, eventRef.Is3D ? "3D" : "2D");
                    labelRect.y += baseHeight;
                    valueRect.y += baseHeight;

                    GUI.Label(labelRect, new GUIContent("<b>Stream</b>"), style);
                    GUI.Label(valueRect, eventRef.IsStream.ToString());
                    labelRect.y += baseHeight;
                    valueRect.y += baseHeight;

                    GUI.Label(labelRect, new GUIContent("<b>Oneshot</b>"), style);
                    GUI.Label(valueRect, eventRef.IsOneShot.ToString());
                    labelRect.y += baseHeight;
                    valueRect.y += baseHeight;
                }
            }
            else
            {
                Rect labelRect = new Rect(position.x, position.y + baseHeight, position.width, baseHeight);
                GUI.Label(labelRect, new GUIContent("Event Not Found", EditorGUIUtility.Load("FMOD/NotFound.png") as Texture2D));
            }

            EditorGUI.EndProperty();
        }
Esempio n. 15
0
        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            if (buttonStyle == null)
            {
                buttonStyle                = new GUIStyle(GUI.skin.button);
                buttonStyle.padding.top    = 1;
                buttonStyle.padding.bottom = 1;
            }

            Texture browseIcon = EditorUtils.LoadImage("SearchIconBlack.png");
            Texture openIcon   = EditorUtils.LoadImage("BrowserIcon.png");
            Texture addIcon    = EditorUtils.LoadImage("AddIcon.png");
            Texture copyIcon   = EditorUtils.LoadImage("CopyIcon.png");

            using (new EditorGUI.PropertyScope(position, label, property))
            {
                HandleDragEvents(position, property);

                EventReference eventReference = property.GetEventReference();
                EditorEventRef editorEventRef = GetEditorEventRef(eventReference);

                float baseHeight = GetBaseHeight();

                Rect headerRect = position;
                headerRect.width  = EditorGUIUtility.labelWidth;
                headerRect.height = baseHeight;

                if (editorEventRef != null)
                {
                    property.isExpanded = EditorGUI.Foldout(headerRect, property.isExpanded, label, true);
                }
                else
                {
                    EditorGUI.LabelField(headerRect, label);
                }

                Rect addRect    = new Rect(position.xMax - addIcon.width - 7, position.y, addIcon.width + 7, baseHeight);
                Rect openRect   = new Rect(addRect.x - openIcon.width - 7, position.y, openIcon.width + 6, baseHeight);
                Rect searchRect = new Rect(openRect.x - browseIcon.width - 9, position.y, browseIcon.width + 8, baseHeight);
                Rect pathRect   = position;
                pathRect.xMin   = headerRect.xMax;
                pathRect.xMax   = searchRect.x - 3;
                pathRect.height = baseHeight;

                SerializedProperty pathProperty = GetPathProperty(property);

                using (var scope = new EditorGUI.ChangeCheckScope())
                {
                    EditorGUI.PropertyField(pathRect, pathProperty, GUIContent.none);

                    if (scope.changed)
                    {
                        SetEvent(property, pathProperty.stringValue);
                    }
                }

                if (GUI.Button(searchRect, new GUIContent(browseIcon, "Search"), buttonStyle))
                {
                    var eventBrowser = ScriptableObject.CreateInstance <EventBrowser>();

                    eventBrowser.ChooseEvent(property);
                    var windowRect = position;
                    windowRect.xMin     = pathRect.xMin;
                    windowRect.position = GUIUtility.GUIToScreenPoint(windowRect.position);
                    windowRect.height   = openRect.height + 1;
                    eventBrowser.ShowAsDropDown(windowRect, new Vector2(windowRect.width, 400));
                }
                if (GUI.Button(addRect, new GUIContent(addIcon, "Create New Event in Studio"), buttonStyle))
                {
                    var addDropdown = EditorWindow.CreateInstance <CreateEventPopup>();

                    addDropdown.SelectEvent(property);
                    var windowRect = position;
                    windowRect.xMin     = pathRect.xMin;
                    windowRect.position = GUIUtility.GUIToScreenPoint(windowRect.position);
                    windowRect.height   = openRect.height + 1;
                    addDropdown.ShowAsDropDown(windowRect, new Vector2(windowRect.width, 500));
                }
                if (GUI.Button(openRect, new GUIContent(openIcon, "Open In Browser"), buttonStyle) &&
                    !string.IsNullOrEmpty(pathProperty.stringValue) &&
                    EventManager.EventFromPath(pathProperty.stringValue) != null
                    )
                {
                    EventBrowser.ShowWindow();
                    EventBrowser eventBrowser = EditorWindow.GetWindow <EventBrowser>();
                    eventBrowser.FrameEvent(pathProperty.stringValue);
                }

                if (editorEventRef != null)
                {
                    float labelY = headerRect.y + baseHeight;

                    MismatchInfo mismatch = GetMismatch(eventReference, editorEventRef);

                    if (mismatch != null)
                    {
                        Rect warningRect = pathRect;
                        warningRect.xMax   = position.xMax;
                        warningRect.y      = labelY;
                        warningRect.height = WarningSize().y;

                        DrawMismatchUI(warningRect, openRect.x, openRect.width, mismatch, property);

                        labelY = warningRect.yMax;
                    }

                    if (property.isExpanded)
                    {
                        using (new EditorGUI.IndentLevelScope())
                        {
                            Rect labelRect = EditorGUI.IndentedRect(headerRect);
                            labelRect.y = labelY;

                            Rect valueRect = labelRect;
                            valueRect.xMin = labelRect.xMax;
                            valueRect.xMax = position.xMax - copyIcon.width - 7;

                            GUI.Label(labelRect, new GUIContent("GUID"));
                            GUI.Label(valueRect, eventReference.Guid.ToString());

                            Rect copyRect = valueRect;
                            copyRect.xMin = valueRect.xMax;
                            copyRect.xMax = position.xMax;

                            if (GUI.Button(copyRect, new GUIContent(copyIcon, "Copy To Clipboard")))
                            {
                                EditorGUIUtility.systemCopyBuffer = eventReference.Guid.ToString();
                            }

                            valueRect.xMax = position.xMax;

                            labelRect.y += baseHeight;
                            valueRect.y += baseHeight;

                            GUI.Label(labelRect, new GUIContent("Banks"));
                            GUI.Label(valueRect, string.Join(", ", editorEventRef.Banks.Select(x => x.Name).ToArray()));
                            labelRect.y += baseHeight;
                            valueRect.y += baseHeight;

                            GUI.Label(labelRect, new GUIContent("Panning"));
                            GUI.Label(valueRect, editorEventRef.Is3D ? "3D" : "2D");
                            labelRect.y += baseHeight;
                            valueRect.y += baseHeight;

                            GUI.Label(labelRect, new GUIContent("Stream"));
                            GUI.Label(valueRect, editorEventRef.IsStream.ToString());
                            labelRect.y += baseHeight;
                            valueRect.y += baseHeight;

                            GUI.Label(labelRect, new GUIContent("Oneshot"));
                            GUI.Label(valueRect, editorEventRef.IsOneShot.ToString());
                            labelRect.y += baseHeight;
                            valueRect.y += baseHeight;
                        }
                    }
                }
                else
                {
                    EditorEventRef renamedEvent = GetRenamedEventRef(eventReference);

                    if (renamedEvent != null)
                    {
                        MismatchInfo mismatch = new MismatchInfo()
                        {
                            Message  = string.Format("Moved to {0}", renamedEvent.Path),
                            HelpText = string.Format(
                                "This event has been moved in FMOD Studio.\n" +
                                "You can click the repair button to update the path to the new location, or run " +
                                "the <b>{0}</b> command to scan your project for similar issues and fix them all.",
                                EventReferenceUpdater.MenuPath),
                            RepairTooltip = string.Format("Repair: set path to {0}", renamedEvent.Path),
                            RepairAction  = (p) => {
                                p.FindPropertyRelative("Path").stringValue = renamedEvent.Path;
                            },
                        };

                        using (new EditorGUI.IndentLevelScope())
                        {
                            Rect mismatchRect = pathRect;

                            mismatchRect.xMin   = position.xMin;
                            mismatchRect.xMax   = position.xMax;
                            mismatchRect.y     += baseHeight;
                            mismatchRect.height = baseHeight;

                            mismatchRect = EditorGUI.IndentedRect(mismatchRect);

                            DrawMismatchUI(mismatchRect, openRect.x, openRect.width, mismatch, property);
                        }
                    }
                    else
                    {
                        Rect labelRect = pathRect;
                        labelRect.xMax   = position.xMax;
                        labelRect.y     += baseHeight;
                        labelRect.height = WarningSize().y;

                        GUI.Label(labelRect, NotFoundWarning);
                    }
                }
            }
        }
Esempio n. 16
0
 public void OnEnable()
 {
     SceneView.onSceneGUIDelegate += SceneUpdate;
     EditorApplication.hierarchyWindowItemOnGUI += HierachachyUpdate;
     instance = this;
 }
Esempio n. 17
0
        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            Texture browseIcon = EditorGUIUtility.Load("FMOD/SearchIconBlack.png") as Texture;
            Texture openIcon   = EditorGUIUtility.Load("FMOD/BrowserIcon.png") as Texture;
            Texture addIcon    = EditorGUIUtility.Load("FMOD/AddIcon.png") as Texture;

            EditorGUI.BeginProperty(position, label, property);
            SerializedProperty pathProperty = property;

            Event e = Event.current;

            if (e.type == EventType.dragPerform && position.Contains(e.mousePosition))
            {
                if (DragAndDrop.objectReferences.Length > 0 &&
                    DragAndDrop.objectReferences[0] != null &&
                    DragAndDrop.objectReferences[0].GetType() == typeof(EditorEventRef))
                {
                    pathProperty.stringValue = ((EditorEventRef)DragAndDrop.objectReferences[0]).Path;
                    GUI.changed = true;
                    e.Use();
                }
            }
            if (e.type == EventType.DragUpdated && position.Contains(e.mousePosition))
            {
                if (DragAndDrop.objectReferences.Length > 0 &&
                    DragAndDrop.objectReferences[0] != null &&
                    DragAndDrop.objectReferences[0].GetType() == typeof(EditorEventRef))
                {
                    DragAndDrop.visualMode = DragAndDropVisualMode.Move;
                    DragAndDrop.AcceptDrag();
                    e.Use();
                }
            }

            float baseHeight = GUI.skin.textField.CalcSize(new GUIContent()).y;

            position = EditorGUI.PrefixLabel(position, GUIUtility.GetControlID(FocusType.Passive), label);

            GUIStyle buttonStyle = new GUIStyle(GUI.skin.button);

            buttonStyle.padding.top    = 1;
            buttonStyle.padding.bottom = 1;

            Rect addRect    = new Rect(position.x + position.width - addIcon.width - 7, position.y, addIcon.width + 7, baseHeight);
            Rect openRect   = new Rect(addRect.x - openIcon.width - 7, position.y, openIcon.width + 6, baseHeight);
            Rect searchRect = new Rect(openRect.x - browseIcon.width - 9, position.y, browseIcon.width + 8, baseHeight);
            Rect pathRect   = new Rect(position.x, position.y, searchRect.x - position.x - 3, baseHeight);

            EditorGUI.PropertyField(pathRect, pathProperty, GUIContent.none);

            if (GUI.Button(searchRect, new GUIContent(browseIcon, "Search"), buttonStyle))
            {
                var eventBrowser = EventBrowser.CreateInstance <EventBrowser>();

                eventBrowser.SelectEvent(property);
                var windowRect = position;
                windowRect.position = GUIUtility.GUIToScreenPoint(windowRect.position);
                windowRect.height   = openRect.height + 1;
                eventBrowser.ShowAsDropDown(windowRect, new Vector2(windowRect.width, 400));
            }
            if (GUI.Button(addRect, new GUIContent(addIcon, "Create New Event in Studio"), buttonStyle))
            {
                var addDropdown = EditorWindow.CreateInstance <CreateEventPopup>();

                addDropdown.SelectEvent(property);
                var windowRect = position;
                windowRect.position = GUIUtility.GUIToScreenPoint(windowRect.position);
                windowRect.height   = openRect.height + 1;
                addDropdown.ShowAsDropDown(windowRect, new Vector2(windowRect.width, 500));
            }
            if (GUI.Button(openRect, new GUIContent(openIcon, "Open In Browser"), buttonStyle) &&
                !String.IsNullOrEmpty(pathProperty.stringValue) &&
                EventManager.EventFromPath(pathProperty.stringValue) != null
                )
            {
                EventBrowser.ShowEventBrowser();
                var eventBrowser = EditorWindow.GetWindow <EventBrowser>();
                eventBrowser.JumpToEvent(pathProperty.stringValue);
            }

            if (!String.IsNullOrEmpty(pathProperty.stringValue) && EventManager.EventFromPath(pathProperty.stringValue) != null)
            {
                Rect foldoutRect = new Rect(position.x + 10, position.y + baseHeight, position.width, baseHeight);
                property.isExpanded = EditorGUI.Foldout(foldoutRect, property.isExpanded, "Event Properties");
                if (property.isExpanded)
                {
                    var style = new GUIStyle(GUI.skin.label);
                    style.richText = true;
                    EditorEventRef eventRef  = EventManager.EventFromPath(pathProperty.stringValue);
                    float          width     = style.CalcSize(new GUIContent("<b>Oneshot</b>")).x;
                    Rect           labelRect = new Rect(position.x, position.y + baseHeight * 2, width, baseHeight);
                    Rect           valueRect = new Rect(position.x + width + 10, position.y + baseHeight * 2, pathRect.width, baseHeight);

                    GUI.Label(labelRect, new GUIContent("<b>GUID</b>"), style);
                    EditorGUI.SelectableLabel(valueRect, eventRef.Guid.ToString("b"));
                    labelRect.y += baseHeight;
                    valueRect.y += baseHeight;

                    GUI.Label(labelRect, new GUIContent("<b>Banks</b>"), style);
                    StringBuilder builder = new StringBuilder();
                    eventRef.Banks.ForEach((x) => { builder.Append(Path.GetFileNameWithoutExtension(x.Path)); builder.Append(", "); });
                    GUI.Label(valueRect, builder.ToString(0, builder.Length - 2));
                    labelRect.y += baseHeight;
                    valueRect.y += baseHeight;

                    GUI.Label(labelRect, new GUIContent("<b>Panning</b>"), style);
                    GUI.Label(valueRect, eventRef.Is3D ? "3D" : "2D");
                    labelRect.y += baseHeight;
                    valueRect.y += baseHeight;

                    GUI.Label(labelRect, new GUIContent("<b>Stream</b>"), style);
                    GUI.Label(valueRect, eventRef.IsStream.ToString());
                    labelRect.y += baseHeight;
                    valueRect.y += baseHeight;

                    GUI.Label(labelRect, new GUIContent("<b>Oneshot</b>"), style);
                    GUI.Label(valueRect, eventRef.IsOneShot.ToString());
                    labelRect.y += baseHeight;
                    valueRect.y += baseHeight;
                }
            }
            else
            {
                Rect labelRect = new Rect(position.x, position.y + baseHeight, position.width, baseHeight);
                GUI.Label(labelRect, new GUIContent("Event Not Found", EditorGUIUtility.Load("FMOD/NotFound.png") as Texture2D));
            }

            EditorGUI.EndProperty();
        }
Esempio n. 18
0
 public void OnEnable()
 {
     SceneView.onSceneGUIDelegate += SceneUpdate;
     EditorApplication.hierarchyWindowItemOnGUI += HierachachyUpdate;
     instance = this;
 }