EventFromPath() 공개 정적인 메소드

public static EventFromPath ( string path ) : EditorEventRef
path string
리턴 EditorEventRef
예제 #1
0
        private void RefreshEventRef()
        {
            if (eventPath != eventPlayable.eventReference.Path)
            {
                eventPath = eventPlayable.eventReference.Path;

                if (!string.IsNullOrEmpty(eventPath))
                {
                    editorEventRef = EventManager.EventFromPath(eventPath);
                }
                else
                {
                    editorEventRef = null;
                }

                if (editorEventRef != null)
                {
                    eventPlayable.UpdateEventDuration(
                        editorEventRef.IsOneShot ? editorEventRef.Length : float.PositiveInfinity);
                }

                ValidateParameterSettings();
                RefreshMissingParameterLists();
            }
        }
        public override void OnInspectorGUI()
        {
            var begin = serializedObject.FindProperty("PlayEvent");
            var end   = serializedObject.FindProperty("StopEvent");
            var tag   = serializedObject.FindProperty("CollisionTag");
            var ev    = serializedObject.FindProperty("Event");
            var param = serializedObject.FindProperty("Params");

            EditorGUILayout.PropertyField(begin, new GUIContent("Play Event"));
            EditorGUILayout.PropertyField(end, new GUIContent("Stop Event"));

            if (begin.enumValueIndex == 3 || begin.enumValueIndex == 4 ||
                end.enumValueIndex == 3 || end.enumValueIndex == 4)
            {
                tag.stringValue = EditorGUILayout.TagField("Collision Tag", tag.stringValue);
            }

            EditorGUI.BeginChangeCheck();

            EditorGUILayout.PropertyField(ev, new GUIContent("Event"));

            if (EditorGUI.EndChangeCheck())
            {
                EditorUtils.UpdateParamsOnEmmitter(serializedObject);
            }

            showParameters = EditorGUILayout.Foldout(showParameters, "Parameters");
            if (showParameters && param.arraySize > 0)
            {
                var eventRef = EventManager.EventFromPath(ev.stringValue);
                for (int i = 0; i < param.arraySize; i++)
                {
                    var parami        = param.GetArrayElementAtIndex(i);
                    var nameProperty  = parami.FindPropertyRelative("Name");
                    var valueProperty = parami.FindPropertyRelative("Value");

                    var paramRef = eventRef.Parameters.Find(x => x.Name == nameProperty.stringValue);
                    if (paramRef == null)
                    {
                        param.DeleteArrayElementAtIndex(i);
                        i--;
                        continue;
                    }

                    EditorGUILayout.Slider(valueProperty, paramRef.Min, paramRef.Max, nameProperty.stringValue);
                }
            }

            showAdvanced = EditorGUILayout.Foldout(showAdvanced, "Advanced Controls");
            if (showAdvanced)
            {
                var fadout = serializedObject.FindProperty("AllowFadeout");
                EditorGUILayout.PropertyField(fadout, new GUIContent("Allow Fadeout When Stopping"));
                var once = serializedObject.FindProperty("TriggerOnce");
                EditorGUILayout.PropertyField(once, new GUIContent("Trigger Once"));
            }

            serializedObject.ApplyModifiedProperties();
        }
 public void OnEnable()
 {
     eventPlayable = target as FMODEventPlayable;
     if (eventPlayable && !string.IsNullOrEmpty(eventPlayable.eventName))
     {
         editorEventRef = EventManager.EventFromPath(eventPlayable.eventName);
         eventPlayable.UpdateEventDuration(editorEventRef.IsOneShot ? editorEventRef.Length : float.PositiveInfinity);
     }
 }
예제 #4
0
        private static bool IsValidEventRef(string reference)
        {
            if (string.IsNullOrEmpty(reference))
            {
                return(true);
            }
            EditorEventRef eventRef = EventManager.EventFromPath(reference);

            return(eventRef != null);
        }
예제 #5
0
 private static EditorEventRef GetEditorEventRef(EventReference eventReference)
 {
     if (EventManager.GetEventLinkage(eventReference) == EventLinkage.Path)
     {
         return(EventManager.EventFromPath(eventReference.Path));
     }
     else // Assume EventLinkage.GUID
     {
         return(EventManager.EventFromGUID(eventReference.Guid));
     }
 }
예제 #6
0
        private static void SetEvent(SerializedProperty property, string path)
        {
            EditorEventRef eventRef = EventManager.EventFromPath(path);

            if (eventRef != null)
            {
                property.SetEventReference(eventRef.Guid, eventRef.Path);
            }
            else
            {
                property.SetEventReference(new FMOD.GUID(), path);
            }
        }
 static void DrawGizmo(StudioEventEmitter studioEmitter, GizmoType gizmoType)
 {
     Gizmos.DrawIcon(studioEmitter.transform.position, "FMODEmitter.tiff", true);
     if ((int)(gizmoType & GizmoType.Selected) != 0 && studioEmitter.Event != null)
     {
         EditorEventRef editorEvent = EventManager.EventFromPath(studioEmitter.Event.Path);
         if (editorEvent != null && editorEvent.Is3D)
         {
             Gizmos.DrawWireSphere(studioEmitter.transform.position, editorEvent.MinDistance);
             Gizmos.DrawWireSphere(studioEmitter.transform.position, editorEvent.MaxDistance);
         }
     }
 }
        public void OnSceneGUI()
        {
            var emitter = target as StudioEventEmitter;

            EditorEventRef editorEvent = EventManager.EventFromPath(emitter.Event);

            if (editorEvent != null && editorEvent.Is3D)
            {
                EditorGUI.BeginChangeCheck();
                float minDistance = emitter.OverrideAttenuation ? emitter.OverrideMinDistance : editorEvent.MinDistance;
                float maxDistance = emitter.OverrideAttenuation ? emitter.OverrideMaxDistance : editorEvent.MaxDistance;
                minDistance = Handles.RadiusHandle(Quaternion.identity, emitter.transform.position, minDistance);
                maxDistance = Handles.RadiusHandle(Quaternion.identity, emitter.transform.position, maxDistance);
                if (EditorGUI.EndChangeCheck() && emitter.OverrideAttenuation)
                {
                    Undo.RecordObject(emitter, "Change Emitter Bounds");
                    emitter.OverrideMinDistance = Mathf.Clamp(minDistance, 0, emitter.OverrideMaxDistance);
                    emitter.OverrideMaxDistance = Mathf.Max(emitter.OverrideMinDistance, maxDistance);
                }
            }
        }
예제 #9
0
        public static void UpdateParamsOnEmitter(SerializedObject serializedObject, string path)
        {
            if (String.IsNullOrEmpty(path) || EventManager.EventFromPath(path) == null)
            {
                return;
            }

            var eventRef = EventManager.EventFromPath(path);

            serializedObject.ApplyModifiedProperties();
            if (serializedObject.isEditingMultipleObjects)
            {
                foreach (var obj in serializedObject.targetObjects)
                {
                    UpdateParamsOnEmitter(obj, eventRef);
                }
            }
            else
            {
                UpdateParamsOnEmitter(serializedObject.targetObject, eventRef);
            }
            serializedObject.Update();
        }
예제 #10
0
        public static void UpdateParamsOnEmmitter(SerializedObject serializedObject)
        {
            var param = serializedObject.FindProperty("Params");
            var path  = serializedObject.FindProperty("Event");

            if (path == null || param == null)
            {
                return;
            }

            param.ClearArray();

            if (!String.IsNullOrEmpty(path.stringValue) && EventManager.EventFromPath(path.stringValue) != null)
            {
                var eventRef = EventManager.EventFromPath(path.stringValue);
                foreach (var paramRef in eventRef.Parameters)
                {
                    param.InsertArrayElementAtIndex(0);
                    var parami = param.GetArrayElementAtIndex(0);
                    parami.FindPropertyRelative("Name").stringValue = paramRef.Name;
                    parami.FindPropertyRelative("Value").floatValue = 0;
                }
            }
        }
예제 #11
0
        public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
        {
            bool  expanded   = property.isExpanded && !String.IsNullOrEmpty(property.stringValue) && EventManager.EventFromPath(property.stringValue) != null;
            float baseHeight = GUI.skin.textField.CalcSize(new GUIContent()).y;

            return(baseHeight * (expanded ? 7 : 2)); // 6 lines of info
        }
예제 #12
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();
        }
        public override void OnInspectorGUI()
        {
            var begin       = serializedObject.FindProperty("PlayEvent");
            var end         = serializedObject.FindProperty("StopEvent");
            var tag         = serializedObject.FindProperty("CollisionTag");
            var ev          = serializedObject.FindProperty("Event");
            var param       = serializedObject.FindProperty("Params");
            var fadeout     = serializedObject.FindProperty("AllowFadeout");
            var once        = serializedObject.FindProperty("TriggerOnce");
            var preload     = serializedObject.FindProperty("Preload");
            var overrideAtt = serializedObject.FindProperty("OverrideAttenuation");
            var minDistance = serializedObject.FindProperty("OverrideMinDistance");
            var maxDistance = serializedObject.FindProperty("OverrideMaxDistance");

            EditorGUILayout.PropertyField(begin, new GUIContent("Play Event"));
            EditorGUILayout.PropertyField(end, new GUIContent("Stop Event"));

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

            EditorGUI.BeginChangeCheck();

            EditorGUILayout.PropertyField(ev, new GUIContent("Event"));

            EditorEventRef editorEvent = EventManager.EventFromPath(ev.stringValue);

            if (EditorGUI.EndChangeCheck())
            {
                EditorUtils.UpdateParamsOnEmitter(serializedObject, ev.stringValue);
                if (editorEvent != null)
                {
                    overrideAtt.boolValue  = false;
                    minDistance.floatValue = editorEvent.MinDistance;
                    maxDistance.floatValue = editorEvent.MaxDistance;
                }
            }

            // Attenuation
            if (editorEvent != null)
            {
                {
                    EditorGUI.BeginDisabledGroup(editorEvent == null || !editorEvent.Is3D);
                    EditorGUILayout.BeginHorizontal();
                    EditorGUILayout.PrefixLabel("Override Attenuation");
                    EditorGUI.BeginChangeCheck();
                    overrideAtt.boolValue = EditorGUILayout.Toggle(overrideAtt.boolValue, GUILayout.Width(20));
                    if (EditorGUI.EndChangeCheck() ||
                        (minDistance.floatValue == -1 && maxDistance.floatValue == -1) // never been initialiased
                        )
                    {
                        minDistance.floatValue = editorEvent.MinDistance;
                        maxDistance.floatValue = editorEvent.MaxDistance;
                    }
                    EditorGUI.BeginDisabledGroup(!overrideAtt.boolValue);
                    EditorGUIUtility.labelWidth = 30;
                    minDistance.floatValue      = EditorGUILayout.FloatField("Min", minDistance.floatValue);
                    minDistance.floatValue      = Mathf.Clamp(minDistance.floatValue, 0, maxDistance.floatValue);
                    maxDistance.floatValue      = EditorGUILayout.FloatField("Max", maxDistance.floatValue);
                    maxDistance.floatValue      = Mathf.Max(minDistance.floatValue, maxDistance.floatValue);
                    EditorGUIUtility.labelWidth = 0;
                    EditorGUI.EndDisabledGroup();
                    EditorGUILayout.EndHorizontal();
                    EditorGUI.EndDisabledGroup();
                }

                param.isExpanded = EditorGUILayout.Foldout(param.isExpanded, "Initial Parameter Values");
                if (ev.hasMultipleDifferentValues)
                {
                    if (param.isExpanded)
                    {
                        GUILayout.Box("Cannot change parameters when different events are selected", GUILayout.ExpandWidth(true));
                    }
                }
                else
                {
                    var eventRef = EventManager.EventFromPath(ev.stringValue);
                    if (param.isExpanded && eventRef != null)
                    {
                        foreach (var paramRef in eventRef.Parameters)
                        {
                            bool  set;
                            float value;
                            bool  matchingSet, matchingValue;
                            CheckParameter(paramRef.Name, out set, out matchingSet, out value, out matchingValue);

                            EditorGUILayout.BeginHorizontal();
                            EditorGUILayout.PrefixLabel(paramRef.Name);
                            EditorGUI.showMixedValue = !matchingSet;
                            EditorGUI.BeginChangeCheck();
                            bool newSet = EditorGUILayout.Toggle(set, GUILayout.Width(20));
                            EditorGUI.showMixedValue = false;

                            if (EditorGUI.EndChangeCheck())
                            {
                                Undo.RecordObjects(serializedObject.isEditingMultipleObjects ? serializedObject.targetObjects : new UnityEngine.Object[] { serializedObject.targetObject }, "Inspector");
                                if (newSet)
                                {
                                    AddParameterValue(paramRef.Name, paramRef.Default);
                                }
                                else
                                {
                                    DeleteParameterValue(paramRef.Name);
                                }
                                set = newSet;
                            }

                            EditorGUI.BeginDisabledGroup(!newSet);
                            if (set)
                            {
                                EditorGUI.showMixedValue = !matchingValue;
                                EditorGUI.BeginChangeCheck();
                                value = EditorGUILayout.Slider(value, paramRef.Min, paramRef.Max);
                                if (EditorGUI.EndChangeCheck())
                                {
                                    Undo.RecordObjects(serializedObject.isEditingMultipleObjects ? serializedObject.targetObjects : new UnityEngine.Object[] { serializedObject.targetObject }, "Inspector");
                                    SetParameterValue(paramRef.Name, value);
                                }
                                EditorGUI.showMixedValue = false;
                            }
                            else
                            {
                                EditorGUI.showMixedValue = !matchingValue;
                                EditorGUILayout.Slider(paramRef.Default, paramRef.Min, paramRef.Max);
                                EditorGUI.showMixedValue = false;
                            }
                            EditorGUI.EndDisabledGroup();
                            EditorGUILayout.EndHorizontal();
                        }
                    }
                }

                fadeout.isExpanded = EditorGUILayout.Foldout(fadeout.isExpanded, "Advanced Controls");
                if (fadeout.isExpanded)
                {
                    EditorGUILayout.PropertyField(preload, new GUIContent("Preload Sample Data"));
                    EditorGUILayout.PropertyField(fadeout, new GUIContent("Allow Fadeout When Stopping"));
                    EditorGUILayout.PropertyField(once, new GUIContent("Trigger Once"));
                }
            }

            serializedObject.ApplyModifiedProperties();
        }
예제 #14
0
        public override void OnInspectorGUI()
        {
            var begin   = serializedObject.FindProperty("PlayEvent");
            var end     = serializedObject.FindProperty("StopEvent");
            var tag     = serializedObject.FindProperty("CollisionTag");
            var ev      = serializedObject.FindProperty("Event");
            var param   = serializedObject.FindProperty("Params");
            var fadeout = serializedObject.FindProperty("AllowFadeout");
            var once    = serializedObject.FindProperty("TriggerOnce");

            EditorGUILayout.PropertyField(begin, new GUIContent("Play Event"));
            EditorGUILayout.PropertyField(end, new GUIContent("Stop Event"));

            if (begin.enumValueIndex == 3 || begin.enumValueIndex == 4 ||
                end.enumValueIndex == 3 || end.enumValueIndex == 4)
            {
                tag.stringValue = EditorGUILayout.TagField("Collision Tag", tag.stringValue);
            }

            EditorGUI.BeginChangeCheck();

            EditorGUILayout.PropertyField(ev, new GUIContent("Event"));

            if (EditorGUI.EndChangeCheck())
            {
                EditorUtils.UpdateParamsOnEmitter(serializedObject, ev.stringValue);
            }

            param.isExpanded = EditorGUILayout.Foldout(param.isExpanded, "Initial Parameter Values");
            if (ev.hasMultipleDifferentValues)
            {
                if (param.isExpanded)
                {
                    GUILayout.Box("Cannot change parameters when different events are selected", GUILayout.ExpandWidth(true));
                }
            }
            else
            {
                var eventRef = EventManager.EventFromPath(ev.stringValue);
                if (param.isExpanded && eventRef != null)
                {
                    foreach (var paramRef in eventRef.Parameters)
                    {
                        bool  set;
                        float value;
                        bool  matchingSet, matchingValue;
                        CheckParameter(paramRef.Name, out set, out matchingSet, out value, out matchingValue);

                        EditorGUILayout.BeginHorizontal();
                        EditorGUILayout.PrefixLabel(paramRef.Name);
                        EditorGUI.showMixedValue = !matchingSet;
                        EditorGUI.BeginChangeCheck();
                        bool newSet = EditorGUILayout.Toggle(set, GUILayout.Width(20));
                        EditorGUI.showMixedValue = false;

                        if (EditorGUI.EndChangeCheck())
                        {
                            Undo.RecordObjects(serializedObject.isEditingMultipleObjects ? serializedObject.targetObjects : new UnityEngine.Object[] { serializedObject.targetObject }, "Inspector");
                            if (newSet)
                            {
                                AddParameterValue(paramRef.Name, paramRef.Default);
                            }
                            else
                            {
                                DeleteParameterValue(paramRef.Name);
                            }
                            set = newSet;
                        }

                        EditorGUI.BeginDisabledGroup(!newSet);
                        if (set)
                        {
                            EditorGUI.showMixedValue = !matchingValue;
                            EditorGUI.BeginChangeCheck();
                            value = EditorGUILayout.Slider(value, paramRef.Min, paramRef.Max);
                            if (EditorGUI.EndChangeCheck())
                            {
                                Undo.RecordObjects(serializedObject.isEditingMultipleObjects ? serializedObject.targetObjects : new UnityEngine.Object[] { serializedObject.targetObject }, "Inspector");
                                SetParameterValue(paramRef.Name, value);
                            }
                            EditorGUI.showMixedValue = false;
                        }
                        else
                        {
                            EditorGUI.showMixedValue = !matchingValue;
                            EditorGUILayout.Slider(paramRef.Default, paramRef.Min, paramRef.Max);
                            EditorGUI.showMixedValue = false;
                        }
                        EditorGUI.EndDisabledGroup();
                        EditorGUILayout.EndHorizontal();
                    }
                }
            }

            fadeout.isExpanded = EditorGUILayout.Foldout(fadeout.isExpanded, "Advanced Controls");
            if (fadeout.isExpanded)
            {
                EditorGUILayout.PropertyField(fadeout, new GUIContent("Allow Fadeout When Stopping"));
                EditorGUILayout.PropertyField(once, new GUIContent("Trigger Once"));
            }

            serializedObject.ApplyModifiedProperties();
        }
예제 #15
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/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();
        }
예제 #16
0
        public override void OnInspectorGUI()
        {
            var begin       = serializedObject.FindProperty("PlayEvent");
            var end         = serializedObject.FindProperty("StopEvent");
            var tag         = serializedObject.FindProperty("CollisionTag");
            var ev          = serializedObject.FindProperty("Event");
            var fadeout     = serializedObject.FindProperty("AllowFadeout");
            var once        = serializedObject.FindProperty("TriggerOnce");
            var preload     = serializedObject.FindProperty("Preload");
            var overrideAtt = serializedObject.FindProperty("OverrideAttenuation");
            var minDistance = serializedObject.FindProperty("OverrideMinDistance");
            var maxDistance = serializedObject.FindProperty("OverrideMaxDistance");

            EditorGUILayout.PropertyField(begin, new GUIContent("Play Event"));
            EditorGUILayout.PropertyField(end, new GUIContent("Stop Event"));

            if ((begin.enumValueIndex >= (int)EmitterGameEvent.TriggerEnter && begin.enumValueIndex <= (int)EmitterGameEvent.TriggerExit2D) ||
                (end.enumValueIndex >= (int)EmitterGameEvent.TriggerEnter && end.enumValueIndex <= (int)EmitterGameEvent.TriggerExit2D))
            {
                tag.stringValue = EditorGUILayout.TagField("Collision Tag", tag.stringValue);
            }

            EditorGUI.BeginChangeCheck();

            EditorGUILayout.PropertyField(ev, new GUIContent("Event"));

            EditorEventRef editorEvent = EventManager.EventFromPath(ev.stringValue);

            if (EditorGUI.EndChangeCheck())
            {
                EditorUtils.UpdateParamsOnEmitter(serializedObject, ev.stringValue);
                if (editorEvent != null)
                {
                    overrideAtt.boolValue  = false;
                    minDistance.floatValue = editorEvent.MinDistance;
                    maxDistance.floatValue = editorEvent.MaxDistance;
                }
            }

            // Attenuation
            if (editorEvent != null)
            {
                {
                    EditorGUI.BeginDisabledGroup(editorEvent == null || !editorEvent.Is3D);
                    EditorGUILayout.BeginHorizontal();
                    EditorGUILayout.PrefixLabel("Override Attenuation");
                    EditorGUI.BeginChangeCheck();
                    overrideAtt.boolValue = EditorGUILayout.Toggle(overrideAtt.boolValue, GUILayout.Width(20));
                    if (EditorGUI.EndChangeCheck() ||
                        (minDistance.floatValue == -1 && maxDistance.floatValue == -1) // never been initialiased
                        )
                    {
                        minDistance.floatValue = editorEvent.MinDistance;
                        maxDistance.floatValue = editorEvent.MaxDistance;
                    }
                    EditorGUI.BeginDisabledGroup(!overrideAtt.boolValue);
                    EditorGUIUtility.labelWidth = 30;
                    minDistance.floatValue      = EditorGUILayout.FloatField("Min", minDistance.floatValue);
                    minDistance.floatValue      = Mathf.Clamp(minDistance.floatValue, 0, maxDistance.floatValue);
                    maxDistance.floatValue      = EditorGUILayout.FloatField("Max", maxDistance.floatValue);
                    maxDistance.floatValue      = Mathf.Max(minDistance.floatValue, maxDistance.floatValue);
                    EditorGUIUtility.labelWidth = 0;
                    EditorGUI.EndDisabledGroup();
                    EditorGUILayout.EndHorizontal();
                    EditorGUI.EndDisabledGroup();
                }

                parameterValueView.OnGUI(editorEvent, !ev.hasMultipleDifferentValues);

                fadeout.isExpanded = EditorGUILayout.Foldout(fadeout.isExpanded, "Advanced Controls");
                if (fadeout.isExpanded)
                {
                    EditorGUILayout.PropertyField(preload, new GUIContent("Preload Sample Data"));
                    EditorGUILayout.PropertyField(fadeout, new GUIContent("Allow Fadeout When Stopping"));
                    EditorGUILayout.PropertyField(once, new GUIContent("Trigger Once"));
                }
            }

            serializedObject.ApplyModifiedProperties();
        }
예제 #17
0
        public override void OnInspectorGUI()
        {
            serializedObject.Update();

            var ev       = serializedObject.FindProperty("eventName");
            var stopType = serializedObject.FindProperty("stopType");

            EditorGUILayout.PropertyField(ev, new GUIContent("Event"));

            var eventRef = EventManager.EventFromPath(ev.stringValue);

            if (eventRef != null && eventRef.Parameters.Count > 0)
            {
                foreach (var paramRef in eventRef.Parameters)
                {
                    bool  set;
                    float value;
                    CheckParameter(paramRef.Name, out set, out value);

                    EditorGUILayout.BeginHorizontal();
                    EditorGUILayout.PrefixLabel(paramRef.Name);
                    EditorGUI.BeginChangeCheck();
                    bool newSet = EditorGUILayout.Toggle(set, GUILayout.Width(20));

                    if (EditorGUI.EndChangeCheck())
                    {
                        Undo.RecordObjects(new UnityEngine.Object[] { serializedObject.targetObject }, "Inspector");
                        if (newSet)
                        {
                            AddParameterValue(serializedObject.targetObject, paramRef.Name, paramRef.Default);
                        }
                        else
                        {
                            DeleteParameterValue(serializedObject.targetObject, paramRef.Name);
                        }
                        set = newSet;
                    }

                    if (set)
                    {
                        EditorGUI.BeginChangeCheck();
                        value = EditorGUILayout.Slider(value, paramRef.Min, paramRef.Max);
                        if (EditorGUI.EndChangeCheck())
                        {
                            Undo.RecordObjects(new UnityEngine.Object[] { serializedObject.targetObject }, "Inspector");
                            SetParameterValue(serializedObject.targetObject, paramRef.Name, value);
                        }
                    }
                    else
                    {
                        EditorGUILayout.Slider(paramRef.Default, paramRef.Min, paramRef.Max);
                    }
                    EditorGUILayout.EndHorizontal();
                }
            }

            EditorGUILayout.PropertyField(stopType, new GUIContent("Stop Mode"));

            if (eventPlayable)
            {
                eventPlayable.OnValidate();
            }
            serializedObject.ApplyModifiedProperties();
        }
예제 #18
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);
                    }
                }
            }
        }
예제 #19
0
        public override void OnInspectorGUI()
        {
            var newTargetEmitter = EditorGUILayout.ObjectField("Target", targetEmitter, typeof(StudioEventEmitter), true) as StudioEventEmitter;

            if (newTargetEmitter != targetEmitter)
            {
                emitters.ClearArray();
                targetEmitter = newTargetEmitter;

                if (targetEmitter == null)
                {
                    serializedObject.ApplyModifiedProperties();
                    return;
                }

                List <StudioEventEmitter> newEmitters = new List <StudioEventEmitter>();
                targetEmitter.GetComponents(newEmitters);
                expanded = new bool[newEmitters.Count];
                foreach (var emitter in newEmitters)
                {
                    emitters.InsertArrayElementAtIndex(0);
                    emitters.GetArrayElementAtIndex(0).FindPropertyRelative("Target").objectReferenceValue = emitter;
                }
            }

            if (targetEmitter == null)
            {
                return;
            }

            EditorGUILayout.PropertyField(trigger, new GUIContent("Trigger"));

            if (trigger.enumValueIndex >= (int)EmitterGameEvent.TriggerEnter && trigger.enumValueIndex <= (int)EmitterGameEvent.TriggerExit2D)
            {
                tag.stringValue = EditorGUILayout.TagField("Collision Tag", tag.stringValue);
            }

            var localEmitters = new List <StudioEventEmitter>();

            targetEmitter.GetComponents(localEmitters);

            int emitterIndex = 0;

            foreach (var emitter in localEmitters)
            {
                SerializedProperty emitterProperty = null;
                for (int i = 0; i < emitters.arraySize; i++)
                {
                    if (emitters.GetArrayElementAtIndex(i).FindPropertyRelative("Target").objectReferenceValue == emitter)
                    {
                        emitterProperty = emitters.GetArrayElementAtIndex(i);
                        break;
                    }
                }

                // New emitter component added to game object since we last looked
                if (emitterProperty == null)
                {
                    emitters.InsertArrayElementAtIndex(0);
                    emitterProperty = emitters.GetArrayElementAtIndex(0);
                    emitterProperty.FindPropertyRelative("Target").objectReferenceValue = emitter;
                }

                if (!string.IsNullOrEmpty(emitter.Event))
                {
                    expanded[emitterIndex] = EditorGUILayout.Foldout(expanded[emitterIndex], emitter.Event);
                    if (expanded[emitterIndex])
                    {
                        var eventRef = EventManager.EventFromPath(emitter.Event);
                        if (emitter.Event.StartsWith("{"))
                        {
                            EditorGUI.BeginDisabledGroup(true);
                            EditorGUILayout.TextField("Path:", eventRef.Path);
                            EditorGUI.EndDisabledGroup();
                        }
                        foreach (var paramRef in eventRef.Parameters)
                        {
                            bool set   = false;
                            int  index = -1;
                            for (int i = 0; i < emitterProperty.FindPropertyRelative("Params").arraySize; i++)
                            {
                                if (emitterProperty.FindPropertyRelative("Params").GetArrayElementAtIndex(i).FindPropertyRelative("Name").stringValue == paramRef.Name)
                                {
                                    index = i;
                                    set   = true;
                                    break;
                                }
                            }
                            EditorGUILayout.BeginHorizontal();
                            EditorGUILayout.PrefixLabel(paramRef.Name);
                            bool newSet = GUILayout.Toggle(set, "");
                            if (!set && newSet)
                            {
                                index = 0;
                                emitterProperty.FindPropertyRelative("Params").InsertArrayElementAtIndex(0);
                                emitterProperty.FindPropertyRelative("Params").GetArrayElementAtIndex(0).FindPropertyRelative("Name").stringValue = paramRef.Name;
                                emitterProperty.FindPropertyRelative("Params").GetArrayElementAtIndex(0).FindPropertyRelative("Value").floatValue = 0;
                            }
                            if (set && !newSet)
                            {
                                emitterProperty.FindPropertyRelative("Params").DeleteArrayElementAtIndex(index);
                            }
                            set = newSet;
                            EditorGUI.BeginDisabledGroup(!set);
                            if (set)
                            {
                                var valueProperty = emitterProperty.FindPropertyRelative("Params").GetArrayElementAtIndex(index).FindPropertyRelative("Value");
                                valueProperty.floatValue = EditorGUILayout.Slider(valueProperty.floatValue, paramRef.Min, paramRef.Max);
                            }
                            else
                            {
                                EditorGUILayout.Slider(0, paramRef.Min, paramRef.Max);
                            }
                            EditorGUI.EndDisabledGroup();
                            EditorGUILayout.EndHorizontal();
                        }
                    }
                }
                emitterIndex++;
            }
            serializedObject.ApplyModifiedProperties();
        }