示例#1
0
        private static void NewEventArea(InAudioEventNode audioevent)
        {
            var defaultAlignment = GUI.skin.label.alignment;

            EditorGUILayout.BeginHorizontal();

            GUI.skin.label.alignment = TextAnchor.MiddleLeft;

            EditorGUILayout.LabelField("");

            EditorGUILayout.EndHorizontal();
            Rect lastArea = GUILayoutUtility.GetLastRect();

            lastArea.height *= 1.5f;

            if (GUI.Button(lastArea, "Click or drag here to add event action"))
            {
                ShowCreationContext(audioevent);
            }

            var dragging = DragAndDrop.objectReferences;

            OnDragging.OnDraggingObject(dragging, lastArea,
                                        objects => AudioEventWorker.CanDropObjects(audioevent, dragging),
                                        objects => AudioEventWorker.OnDrop(audioevent, dragging));

            GUI.skin.label.alignment = defaultAlignment;
        }
示例#2
0
        private static void HandleDragging(AudioEventAction currentAction, Rect dragArea)
        {
            if (currentAction != null)
            {
                if (currentAction is InEventAudioAction)
                {
                    InAudioNode dragged = OnDragging.DraggingObject <InAudioNode>(dragArea, node => node.IsPlayable);
                    if (dragged != null)
                    {
                        InUndoHelper.RecordObject(currentAction, "Change Action Type");
                        currentAction.Target = dragged;
                    }
                }
                else if (currentAction is InEventBankLoadingAction)
                {
                    InAudioBankLink dragged = OnDragging.DraggingObject <InAudioBankLink>(dragArea,
                                                                                          bank => bank._type == AudioBankTypes.Bank);

                    if (dragged != null)
                    {
                        InUndoHelper.RecordObject(currentAction, "Change Action Type");
                        currentAction.Target = dragged;
                    }
                }
                else if (currentAction is InEventMixerValueAction)
                {
                    AudioMixer dragged = OnDragging.DraggingObject <AudioMixer>(dragArea);
                    if (dragged != null)
                    {
                        InUndoHelper.RecordObject(currentAction, "Change Action Type");
                        currentAction.Target = dragged;
                    }
                }
                else if (currentAction is InEventMusicControl || currentAction is InEventMusicFade || currentAction is InEventSoloMuteMusic)
                {
                    InMusicGroup dragged = OnDragging.DraggingObject <InMusicGroup>(dragArea);
                    if (dragged != null)
                    {
                        InUndoHelper.RecordObject(currentAction, "Change Action Type");
                        currentAction.Target = dragged;
                    }
                }
            }
        }
        public static void Draw(InMusicFolder node)
        {
            node.ScrollPosition = EditorGUILayout.BeginScrollView(node.ScrollPosition);
            var prop = new SerializedObject(node);

            prop.Update();
            EditorGUILayout.BeginVertical();

            #region Bank

            InUndoHelper.GUIUndo(node, "Name Change", ref node._name, () =>
                                 EditorGUILayout.TextField("Name", node._name));


            if (!node.IsRoot)
            {
                bool overrideparent = EditorGUILayout.Toggle("Override Parent Bank", node._overrideParentBank);
                if (overrideparent != node._overrideParentBank)
                {
                    AudioBankWorker.ChangeBankOverride(node);
                }
            }
            else
            {
                EditorGUILayout.Separator();
            }

            if (node._overrideParentBank == false && !node.IsRoot)
            {
                GUI.enabled = false;
            }

            EditorGUILayout.BeginHorizontal();

            var parentLink = node.GetBank();
            if (node._overrideParentBank)
            {
                if (node._bankLink != null)
                {
                    EditorGUILayout.LabelField("Bank", node._bankLink.GetName);
                }
                else
                {
                    if (parentLink != null)
                    {
                        EditorGUILayout.LabelField("Bank", "Missing Bank, using parent bank" + parentLink.GetName);
                    }
                    else
                    {
                        EditorGUILayout.LabelField("Bank", "Missing Banks, no bank found");
                    }
                }
            }
            else
            {
                if (parentLink != null)
                {
                    EditorGUILayout.LabelField("Using Bank", parentLink.GetName);
                }
                else
                {
                    EditorGUILayout.LabelField("Using Bank", "Missing");
                }
            }

            bool wasEnabled = GUI.enabled;
            GUI.enabled = true;
            if (GUILayout.Button("Find", GUILayout.Width(50)))
            {
                EditorWindow.GetWindow <AuxWindow>().FindBank(parentLink);
            }

            Rect findArea = GUILayoutUtility.GetLastRect();
            findArea.y += 20;
            if (GUI.Button(findArea, "Find"))
            {
                EditorWindow.GetWindow <AuxWindow>().FindBank(node._bankLink);
            }

            GUI.enabled = wasEnabled;

            GUILayout.Button("Drag new bank here", GUILayout.Width(140));

            var newBank = OnDragging.BusDragging(GUILayoutUtility.GetLastRect());
            if (newBank != null)
            {
                AudioBankWorker.ChangeMusicNodeBank(node, newBank);
            }
            GUI.enabled = true;
            EditorGUILayout.EndHorizontal();
            GUI.enabled = false;
            if (node._bankLink != null)
            {
                EditorGUILayout.LabelField("Node Bank", node._bankLink.GetName);
            }
            else
            {
                EditorGUILayout.LabelField("Node Bank", "Missing Bank");
            }
            GUI.enabled = true;
            if (Application.isPlaying)
            {
                EditorGUILayout.Toggle("Is Loaded", BankLoader.IsLoaded(parentLink));
            }

            #endregion

            EditorGUILayout.Separator();
            EditorGUILayout.Separator();

            #region Mixer

            DataDrawerHelper.DrawMixer(node, prop.FindProperty("_mixerGroup"));

            #endregion
            EditorGUILayout.Separator();
            #region Volume & Pitch
            if (!Application.isPlaying)
            {
                InUndoHelper.GUIUndo(node, "Volume", ref node._minVolume, () => EditorGUILayout.Slider("Initial Volume", node._minVolume, 0f, 1f));
            }
            else
            {
                InUndoHelper.GUIUndo(node, "Volume", ref node.runtimeVolume, () => EditorGUILayout.Slider("Current Volume", node.runtimeVolume, 0f, 1f));
            }

            if (!Application.isPlaying)
            {
                InUndoHelper.GUIUndo(node, "Pitch", ref node._minPitch, () => EditorGUILayout.Slider("Initial Pitch", node._minPitch, 0f, 3f));
            }
            else
            {
                InUndoHelper.GUIUndo(node, "Pitch", ref node.runtimePitch, () => EditorGUILayout.Slider("Current Pitch", node.runtimePitch, 0f, 3f));
            }
            #endregion

            EditorGUILayout.EndVertical();
            prop.ApplyModifiedProperties();

            EditorGUILayout.EndScrollView();
        }
        public static void Draw(InAudioNode node)
        {
            var nodeData = node._nodeData;

            EditorGUILayout.BeginVertical();
            var data = node._nodeData as InFolderData;

            #region Bank

            InUndoHelper.GUIUndo(node, "Name Change", ref node.Name, () =>
                                 EditorGUILayout.TextField("Name", node.Name));

            if (node._type == AudioNodeType.Folder)
            {
                bool overrideparent = EditorGUILayout.Toggle("Override Parent Bank", data.OverrideParentBank);
                if (overrideparent != data.OverrideParentBank)
                {
                    AudioBankWorker.ChangeBankOverride(node);
                }
            }
            else
            {
                EditorGUILayout.LabelField(""); //To fill out the area from the toggle
            }
            if (data.OverrideParentBank == false && node._type != AudioNodeType.Root)
            {
                GUI.enabled = false;
            }

            EditorGUILayout.BeginHorizontal();

            var parentLink = FindParentBank(node);
            if (data.OverrideParentBank)
            {
                if (data.BankLink != null)
                {
                    EditorGUILayout.LabelField("Bank", data.BankLink.GetName);
                }
                else
                {
                    if (parentLink != null)
                    {
                        EditorGUILayout.LabelField("Bank", "Missing Bank, using parent bank" + parentLink.GetName);
                    }
                    else
                    {
                        EditorGUILayout.LabelField("Bank", "Missing Banks, no bank found");
                    }
                }
            }
            else
            {
                if (parentLink != null)
                {
                    EditorGUILayout.LabelField("Using Bank", parentLink.GetName);
                }
                else
                {
                    EditorGUILayout.LabelField("Using Bank", "Missing");
                }
            }

            bool wasEnabled = GUI.enabled;
            GUI.enabled = true;
            if (GUILayout.Button("Find", GUILayout.Width(50)))
            {
                EditorWindow.GetWindow <AuxWindow>().FindBank(parentLink);
            }

            Rect findArea = GUILayoutUtility.GetLastRect();
            findArea.y += 20;
            if (GUI.Button(findArea, "Find"))
            {
                EditorWindow.GetWindow <AuxWindow>().FindBank(data.BankLink);
            }

            GUI.enabled = wasEnabled;

            GUILayout.Button("Drag new bank here", GUILayout.Width(140));

            var newBank = OnDragging.BusDragging(GUILayoutUtility.GetLastRect());
            if (newBank != null)
            {
                AudioBankWorker.ChangeAudioNodeBank(node, newBank);
            }
            GUI.enabled = true;
            EditorGUILayout.EndHorizontal();
            GUI.enabled = false;
            if (data.BankLink != null)
            {
                EditorGUILayout.LabelField("Node Bank", data.BankLink.GetName);
            }
            else
            {
                EditorGUILayout.LabelField("Node Bank", "Missing Bank");
            }

            GUI.enabled = true;
            if (Application.isPlaying)
            {
                EditorGUILayout.Toggle("Is Loaded", BankLoader.IsLoaded(parentLink));
            }
            #endregion

            if (data.ExternalPlacement)
            {
                EditorGUILayout.Separator();

                GUI.enabled = false;
                EditorGUILayout.ObjectField("Placed on", node.gameObject, typeof(GameObject), false);
                GUI.enabled = true;

                EditorGUILayout.Separator();
            }

            #region Mixer
            DataDrawerHelper.DrawMixer(node);
            #endregion
            EditorGUILayout.Separator();
            #region Volume
            if (Application.isPlaying)
            {
                InUndoHelper.GUIUndo(nodeData, "Folder volume", ref data.runtimeVolume, () => EditorGUILayout.Slider("Runtime Volume", data.runtimeVolume, 0, 1));
            }
            else
            {
                InUndoHelper.GUIUndo(nodeData, "Folder volume", ref data.VolumeMin, () => EditorGUILayout.Slider("Initial Volume", data.VolumeMin, 0, 1));
            }
            #endregion

            EditorGUILayout.EndVertical();
        }
        public override void OnInspectorGUI()
        {
            if (!InAudioInstanceFinder.IsValid)
            {
                EditorGUILayout.HelpBox("Please add the InAudio Manager to the scene", MessageType.Info);
                if (GUILayout.Button("Add manager to scene"))
                {
                    ErrorDrawer.AddManagerToScene();
                }
            }


            serializedObject.Update();
            EditorGUI.BeginChangeCheck();
            if (serializedObject.FindProperty("SplineController").hasMultipleDifferentValues)
            {
                EditorGUILayout.HelpBox("Different spline controllers", MessageType.Warning);
                return;
            }
            if (SplineNode.SplineController == null)
            {
                EditorGUILayout.HelpBox("Missing spline controller, please assign one", MessageType.Warning);
            }

            if (InAudioInstanceFinder.IsValid)
            {
                InAudioInstanceFinder.InAudioGuiUserPrefs.SelectedSplineController = SplineNode.SplineController;
            }

            bool add       = GUILayout.Button("Add Node");
            bool selectNew = false;

            if (GUILayout.Button("Add and Select"))
            {
                add       = true;
                selectNew = true;
            }
            EditorGUILayout.Separator();


            var objectField = EditorGUILayout.ObjectField("Controlling Spline", serializedObject.FindProperty("SplineController").objectReferenceValue, typeof(InSpline), true);

            if (serializedObject.FindProperty("SplineController").objectReferenceValue == null)
            {
                serializedObject.FindProperty("SplineController").objectReferenceValue = objectField;
            }

            if (Selection.objects.Length == 1)
            {
                GUILayout.Button("Drag node here to connect");
                OnDragging.DraggingObject <Object>(GUILayoutUtility.GetLastRect(), o =>
                {
                    GameObject go = o as GameObject;
                    if (go != null)
                    {
                        var node = go.GetComponent <InSplineNode>();
                        if (node != SplineNode && !SplineNode.SplineController.ContainsConnection(SplineNode, node))
                        {
                            return(true);
                        }
                    }
                    return(false);
                }, o =>
                {
                    InUndoHelper.RecordObject(SplineNode.SplineController, "Connect nodes");
                    (o as GameObject).GetComponent <InSplineNode>().ConnectTo(SplineNode);
                });

                //var a = new SerializedObject(SplineNode.SplineController)
                if (SplineNode.SplineController != null)
                {
                    expandedConnections = EditorGUILayout.Foldout(expandedConnections, "Connected to");

                    for (int i = 0; i < SplineNode.SplineController.Connections.Count; i++)
                    {
                        EditorGUILayout.BeginHorizontal();
                        GUI.enabled = false;
                        var conc = SplineNode.SplineController.Connections[i];
                        if (conc.NodeA == SplineNode)
                        {
                            EditorGUILayout.ObjectField(conc.NodeB, typeof(InSplineNode), true);
                            GUI.enabled = true;
                            if (GUILayout.Button("X", GUILayout.Width(20)))
                            {
                                InUndoHelper.RecordObject(SplineNode.SplineController, "Remove spline connection");
                                SplineNode.SplineController.RemoveConnections(conc);
                            }
                            EditorUtility.SetDirty(SplineNode.SplineController);
                        }
                        else if (conc.NodeB == SplineNode)
                        {
                            EditorGUILayout.ObjectField(conc.NodeA, typeof(InSplineNode), true);
                            GUI.enabled = true;
                            if (GUILayout.Button("X", GUILayout.Width(20)))
                            {
                                InUndoHelper.RecordObject(SplineNode.SplineController, "Remove spline connection");
                                SplineNode.SplineController.RemoveConnections(conc);
                            }
                            EditorUtility.SetDirty(SplineNode.SplineController);
                        }


                        EditorGUILayout.EndHorizontal();
                    }
                }
            }



            EditorGUILayout.Separator();
            bool delete = true;

            if (GUILayout.Button("Delete"))
            {
                InUndoHelper.DoInGroup(() =>
                {
            #if UNITY_4_1 || UNITY_4_2
                    Undo.RegisterSceneUndo("Combine nodes");
            #else
                    UndoAll("Delete node");
            #endif
                    foreach (var gameObject in Selection.gameObjects)
                    {
                        InUndoHelper.Destroy(gameObject);
                    }

                    delete = true;
                });
            }


            if (add)
            {
                InUndoHelper.DoInGroup(() =>
                {
                #if UNITY_4_1 || UNITY_4_2
                    Undo.RegisterSceneUndo("Delete element in spline");
                #else
                    UndoAll("Add new spline node");
                #endif

                    GameObject go         = InUndoHelper.CreateGO(SplineNode.SplineController.gameObject.name + " Node");
                    go.transform.parent   = SplineNode.SplineController.transform;
                    go.transform.position = SplineNode.transform.position + SplineNode.transform.forward;
                    go.transform.position = SplineNode.transform.position;

                    var newNode = go.AddComponent <InSplineNode>();
                    newNode.SplineController = SplineNode.SplineController;
                    newNode.ConnectTo(SplineNode);
                    SplineNode.SplineController.Nodes.Add(newNode);

                    if (selectNew)
                    {
                        Selection.activeGameObject = go;
                    }
                });
            }

            if (EditorGUI.EndChangeCheck() && delete == false)
            {
                serializedObject.ApplyModifiedProperties();
            }
        }
示例#6
0
        public static void Draw(InAudioBus bus)
        {
            EditorGUILayout.BeginVertical();

            UndoHelper.GUIUndo(bus, "Name Change", ref bus.Name, () =>
                               EditorGUILayout.TextField("Name", bus.Name));

            EditorGUIHelper.DrawID(bus.GUID);

            EditorGUILayout.Separator();

            if (!Application.isPlaying)
            {
                UndoHelper.GUIUndo(bus, "Mute Bus", ref bus.Mute, () =>
                                   EditorGUILayout.Toggle("Initial Mute", bus.Mute));
            }
            else
            {
                UndoHelper.GUIUndo(bus, "Mute Bus (Runtime)", ref bus.RuntimeMute, () =>
                                   EditorGUILayout.Toggle("Mute (Runtime)", bus.RuntimeMute));
            }

            EditorGUILayout.Separator();

            UndoHelper.GUIUndo(bus, "Volume Change", ref bus.Volume, () =>
                               EditorGUILayout.Slider("Master Volume", bus.Volume, 0.0f, 1.0f));

            if (!Application.isPlaying)
            {
                UndoHelper.GUIUndo(bus, "Runtime Volume Change", ref bus.SelfVolume, () =>
                                   EditorGUILayout.Slider("Initial Runtime Volume", bus.SelfVolume, 0.0f, 1.0f));
            }
            else
            {
                UndoHelper.GUIUndo(bus, "Runtime Volume Change", ref bus.RuntimeSelfVolume, () =>
                                   EditorGUILayout.Slider("Runtime Volume", bus.RuntimeSelfVolume, 0.0f, 1.0f));
            }

            EditorGUILayout.Separator();

            GUI.enabled = false;
            if (Application.isPlaying)
            {
                EditorGUILayout.Slider("Ducking", bus.LastDuckedVolume, -1.0f, 0.0f);
                EditorGUILayout.Separator();

                EditorGUILayout.Slider("Final Hierarchy Volume", Mathf.Clamp(bus.FinalVolume, 0, 1), 0, 1.0f);
            }
            else
            {
                float volume = bus.CombinedVolume;
                if (bus.RuntimeMute)
                {
                    volume = 0;
                }
                EditorGUILayout.Slider("Final Hierarchy Volume", volume, 0, 1.0f);
            }

            GUI.enabled = true;

            EditorGUILayout.Separator();
            EditorGUILayout.Separator();

            //Not implemented yet
            #region Ducking



            EditorGUILayout.Separator(); EditorGUILayout.Separator();
            EditorGUILayout.LabelField("Hold Control down and drag a bus here.");
            EditorGUILayout.LabelField("Cannot add parents or children.");

            GUILayout.Button("Drag bus here", GUILayout.Width(200));

            var dragging = DragAndDrop.objectReferences;
            OnDragging.OnDraggingObject <InAudioBus>(dragging, GUILayoutUtility.GetLastRect(),
                                                     buses => AudioBusWorker.CanBeDuckedBy(bus, buses[0]),
                                                     buses =>
            {
                UndoHelper.RecordObject(bus, "Add");
                for (int i = 0; i < buses.Length; i++)
                {
                    DuckingData data = new DuckingData();
                    data.DuckedBy    = buses[i];
                    bus.DuckedBy.Add(data);
                }
            }
                                                     );

            EditorGUILayout.LabelField("");
            Rect labelArea = GUILayoutUtility.GetLastRect();

            labelArea.width = labelArea.width / 4.0f - 5;
            Rect workArea = labelArea;

            for (int i = 0; i < bus.DuckedBy.Count; i++)
            {
                workArea.width = labelArea.width;
                workArea.y    += workArea.height + 4;
                workArea.x     = labelArea.x;

                DuckingData data = bus.DuckedBy[i];

                EditorGUI.SelectableLabel(workArea, data.DuckedBy.Name);
                Rect area1 = workArea;
                workArea.x += workArea.width;

                UndoHelper.GUIUndo(bus, "Duck Amount Change", () =>
                                   EditorGUI.Slider(workArea, data.VolumeDucking, -1.0f, 0.0f),
                                   v => data.VolumeDucking = v);
                Rect area2 = workArea;
                workArea.x += workArea.width;

                UndoHelper.GUIUndo(bus, "Attack Time", () =>
                                   EditorGUI.Slider(workArea, data.AttackTime, 0.0f, 10.0f),
                                   v => data.AttackTime = v);
                Rect area3 = workArea;
                workArea.x += workArea.width;

                UndoHelper.GUIUndo(bus, "Release Time", () =>
                                   EditorGUI.Slider(workArea, data.ReleaseTime, 0.0f, 10.0f),
                                   v => data.ReleaseTime = v);
                Rect area4 = workArea;
                workArea.x    += workArea.width;
                workArea.width = 20;
                if (GUI.Button(workArea, "X"))
                {
                    UndoHelper.RecordObjectFull(bus, "X");
                    bus.DuckedBy.RemoveAt(i);
                    i--;
                }

                if (i == 0) //Workaround to avoid a gui layout mismatch
                {
                    area1.y -= 20;
                    area2.y -= 20;
                    area3.y -= 20;
                    area4.y -= 20;
                    EditorGUI.LabelField(area1, "Ducked By");
                    EditorGUI.LabelField(area2, "Volume Duck Amount");
                    EditorGUI.LabelField(area3, "Attack Time");
                    EditorGUI.LabelField(area4, "Release Time");
                }
            }

            #endregion


            /*   GUILayout.Label("Nodes Playing In This Specific Bus");
             *
             *  lastArea.x += 20;
             *  lastArea.y = lastArea.y + lastArea.height + 2;
             *  lastArea.height = 17;
             *  List<RuntimePlayer> players = node.GetRuntimePlayers();
             *  for (int i = 0; i < players.Count; i++)
             *  {
             *      GUI.Label(lastArea, players[i].NodePlaying.Name);
             *
             *      lastArea.y += 20;
             *  }
             */
            EditorGUILayout.EndVertical();
        }