IEnumerator StartGame() { Services.Get <MenuMain>().StartGame(); var logo = Services.Get <LogoMenu>(); if (logo != null) { logo.Stop(); } yield return(new WaitForSeconds(1.8f)); //if(readyPlayers == null || readyPlayers.Length == 0) // readyPlayers = Object.FindObjectsOfType<PlayerReady>(); //Debug.Log(readyPlayers.Count(p => p.Active)); //for (int i = 0; i < readyPlayers.Length; i++) //{ // if (readyPlayers[i].Active) // { // ActivePlayers.Add(readyPlayers[i].PlayerID); // } //} InAudio.StopAll(gameObject); Application.LoadLevel(2); }
public override void OnInspectorGUI() { base.OnInspectorGUI(); var inAudio = target as InAudio; if (inAudio.GetComponentInChildren <InAudioInstanceFinder>() == null || inAudio.GetComponentInChildren <MusicPlayer>() == null || inAudio.GetComponentInChildren <InCommonDataManager>() == null) { //Checks three of the needed objects if this is indeed a valid prefab //If you read this code, use the "InAudio Manager" prefab stored under InAudio/Prefabs/InAudio Manager EditorGUILayout.HelpBox("You are not using the InAudio Manager prefab.\nPlease use the InAudio prefab placed in \nInAudio/Prefabs/InAudio Manager\ninstead of placing the InAudio script on a random game object.", MessageType.Error); } EditorGUILayout.Separator(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.PrefixLabel("Support"); EditorGUILayout.SelectableLabel("*****@*****.**"); EditorGUILayout.EndHorizontal(); GUI.enabled = Application.isPlaying; if (GUILayout.Button("Stop All Sound Effects")) { InAudio.StopAll(); } if (GUILayout.Button("Stop All Music")) { InAudio.Music.StopAll(); } GUI.enabled = true; EditorGUILayout.Separator(); if (GUILayout.Button("Documentation")) { Application.OpenURL("http://innersystems.net/wiki"); } if (GUILayout.Button("Forum")) { Application.OpenURL("http://forum.unity3d.com/threads/232490-InAudio-Advanced-Audio-for-Unity"); } if (GUILayout.Button("Website")) { Application.OpenURL("http://innersystems.net/"); } }
public void GivePlayerScore(PlayerController controller, int score) { Services.Get <CameraShake>().ApplyShake(0.2f, 0.2f); if (controller == null) { Debug.LogError("Dont try and give null controllers a score"); } var item = Score.Find(s => s.Item1.Id == controller.Id); if (item == null) { item = Score.Add(controller, score); InAudio.Play(gameObject, Point); } else { if (item.Item2 < ScoreLimit) { InAudio.Play(gameObject, Point); } item.Item2 += score; } var scoreUI = FindObjectOfType <PlayerScoreUI>(); if (scoreUI) { scoreUI.GivePoints(controller, item.Item2); } if (item.Item2 > ScoreLimit && !WinnerFound) { WinnerFound = true; InAudio.StopAll(); //WinnerColor = PlayerColor(controller.Id); var hook = Services.Get <WinnerHook>().gameObject; hook.SetActive(true); for (int i = 0; i < hook.transform.childCount; i++) { hook.transform.GetChild(i).gameObject.SetActive(true); } hook.GetComponentInParent <Animator>().enabled = true; StartCoroutine(PlayWin()); } }
public void StopSounds() { InAudio.StopAll(); }
//private static GameObject go; public static void Draw(InAudioNode node) { if (Application.isPlaying) { EditorGUILayout.BeginHorizontal(); if (GUILayout.Button("Play Node")) { if (preview != null) { preview.Stop(); } preview = InAudio.Play(InAudioInstanceFinder.Instance.gameObject, node); preview.SpatialBlend = 0.0f; preview.OnCompleted = (go, audioNode) => preview = null; } if (GUILayout.Button("Stop Playing Node") && preview != null) { InAudio.StopAll(InAudioInstanceFinder.Instance.gameObject); } if (GUILayout.Button("Stop All Instances")) { InAudio.StopAllOfNode(node); } EditorGUILayout.EndHorizontal(); } InAudioNodeData baseData = (InAudioNodeData)node._nodeData; EditorGUILayout.Separator(); DrawSelectedArea(node, baseData); Seperators(2); if (baseData.SelectedArea == 0) { EditorGUIHelper.DrawID(node._guid); #region Volume DataDrawerHelper.DrawVolume(baseData, ref baseData.MinVolume, ref baseData.MaxVolume, ref baseData.RandomVolume); #endregion Seperators(2); #region Parent pitch SetPitch(baseData); #endregion Seperators(2); #region Spatial blend SetSpatialBlend(baseData); #endregion Seperators(2); #region Delay GUILayout.BeginHorizontal(); GUILayout.BeginVertical(); InUndoHelper.GUIUndo(baseData, "Randomize Delay", ref baseData.RandomizeDelay, () => EditorGUILayout.Toggle("Randomize Delay", baseData.RandomizeDelay)); if (baseData.RandomizeDelay) { InUndoHelper.GUIUndo(baseData, "Delay Change", ref baseData.InitialDelayMin, ref baseData.InitialDelayMax, (out float v1, out float v2) => { v1 = Mathf.Clamp(EditorGUILayout.FloatField("Min delay", baseData.InitialDelayMin), 0, baseData.InitialDelayMax); v2 = Mathf.Clamp(EditorGUILayout.FloatField("Max delay", baseData.InitialDelayMax), baseData.InitialDelayMin, float.MaxValue); }); } else { InUndoHelper.GUIUndo(baseData, "Delay", ref baseData.InitialDelayMin, () => { float delay = Mathf.Max(EditorGUILayout.FloatField("Initial delay", baseData.InitialDelayMin), 0); if (delay > baseData.InitialDelayMax) { baseData.InitialDelayMax = baseData.InitialDelayMin + 0.001f; } return(delay); }); } GUILayout.EndVertical(); GUILayout.BeginVertical(); GUILayout.EndVertical(); GUILayout.EndHorizontal(); #endregion Seperators(2); #region Audio bus DataDrawerHelper.DrawMixer(node); #endregion Seperators(2); #region Loops GUI.enabled = true; GUILayout.BeginVertical(); InUndoHelper.GUIUndo(baseData, "Use looping", ref baseData.Loop, () => EditorGUILayout.Toggle("Loop", baseData.Loop)); if (baseData.Loop) { GUI.enabled = baseData.Loop; InUndoHelper.GUIUndo(baseData, "Loop Infinite", ref baseData.LoopInfinite, () => EditorGUILayout.Toggle("Loop Infinite", baseData.LoopInfinite)); if (baseData.Loop) { GUI.enabled = !baseData.LoopInfinite; } InUndoHelper.GUIUndo(baseData, "Loop Randomize", ref baseData.RandomizeLoops, () => EditorGUILayout.Toggle("Randomize Loop Count", baseData.RandomizeLoops)); if (!baseData.RandomizeLoops) { InUndoHelper.GUIUndo(baseData, "Loop Count", ref baseData.MinIterations, () => (byte)Mathf.Clamp(EditorGUILayout.IntField("Loop Count", baseData.MinIterations), 0, 255)); } else { GUILayout.BeginHorizontal(); InUndoHelper.GUIUndo(baseData, "Loop Count", ref baseData.MinIterations, ref baseData.MaxIterations, (out byte v1, out byte v2) => { v1 = (byte)Mathf.Clamp(EditorGUILayout.IntField("Min Loop Count", baseData.MinIterations), 0, 255); v2 = (byte)Mathf.Clamp(EditorGUILayout.IntField("Max Loop Count", baseData.MaxIterations), 0, 255); //Clamp to 0-255 and so that min/max doesn't overlap v2 = (byte)Mathf.Clamp(v2, v1, 255); v1 = (byte)Mathf.Clamp(v1, 0, v2); }); GUILayout.EndHorizontal(); } } GUI.enabled = true; GUILayout.EndVertical(); #endregion Seperators(2); #region Instance limiting InUndoHelper.GUIUndo(baseData, "Limit Instances (Global)", ref baseData.LimitInstances, () => EditorGUILayout.Toggle("Limit Instances", baseData.LimitInstances)); GUI.enabled = baseData.LimitInstances; if (baseData.LimitInstances) { InUndoHelper.GUIUndo(baseData, "Max Instance Cont", ref baseData.MaxInstances, () => Math.Max(EditorGUILayout.IntField("Max Instance Count", baseData.MaxInstances), 0)); InUndoHelper.GUIUndo(baseData, "Stealing Type", ref baseData.InstanceStealingTypes, () => (InstanceStealingTypes)EditorGUILayout.EnumPopup("Stealing Type", baseData.InstanceStealingTypes)); } GUI.enabled = true; #endregion Seperators(2); #region Priority InUndoHelper.GUIUndo(baseData, "Priority", ref baseData.Priority, () => EditorGUILayout.IntSlider("Priority", baseData.Priority, 0, 255)); #endregion Seperators(2); #region Sample offset InUndoHelper.GUIUndo(baseData, "Random Second Offset", ref baseData.RandomSecondsOffset, () => EditorGUILayout.Toggle("Random Second Offset", baseData.RandomSecondsOffset)); if (baseData.RandomSecondsOffset) { InUndoHelper.GUIUndo(baseData, "First item offset", ref baseData.MinSecondsOffset, ref baseData.MaxSecondsOffset, (out float v1, out float v2) => { v1 = Mathf.Clamp(EditorGUILayout.FloatField("Min offset", baseData.MinSecondsOffset), 0, baseData.MaxSecondsOffset); v2 = Mathf.Clamp(EditorGUILayout.FloatField("Max offset", baseData.MaxSecondsOffset), baseData.MinSecondsOffset, float.MaxValue); }); } else { InUndoHelper.GUIUndo(baseData, "Delay", ref baseData.MinSecondsOffset, () => { var delay = Mathf.Max(EditorGUILayout.FloatField("First clip offset", baseData.MinSecondsOffset), 0); if (delay > baseData.MaxSecondsOffset) { baseData.MaxSecondsOffset = baseData.MinSecondsOffset + 1; } return(delay); }); } if (node._type == AudioNodeType.Audio) { var nodeData = node._nodeData as InAudioData; if (nodeData.AudioClip != null) { float length = nodeData.AudioClip.ExactLength(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.PrefixLabel("Clip length"); EditorGUILayout.SelectableLabel(length.ToString(), GUILayout.Height(EditorGUIUtility.singleLineHeight)); EditorGUILayout.EndHorizontal(); if (baseData.RandomSecondsOffset && (baseData.MinSecondsOffset > length || baseData.MaxSecondsOffset > length)) { EditorGUILayout.HelpBox("Offset exceeds sound clip length", MessageType.Warning); } else if (baseData.MinSecondsOffset > length) { EditorGUILayout.HelpBox("Offset exceeds sound clip length", MessageType.Warning); } } } #endregion } else { #region Attenuation if (!node._parent.IsRootOrFolder) { InUndoHelper.GUIUndo(baseData, "Override Parent", ref baseData.OverrideAttenuation, () => GUILayout.Toggle(baseData.OverrideAttenuation, "Override Parent")); } GUI.enabled = baseData.OverrideAttenuation; if (node._parent.IsRootOrFolder) { GUI.enabled = true; } InUndoHelper.GUIUndo(node, "Rolloff Mode", ref baseData.RolloffMode, () => (AudioRolloffMode)EditorGUILayout.EnumPopup("Volume Rolloff", baseData.RolloffMode)); InUndoHelper.GUIUndo(baseData, "Set Rolloff Distance", ref baseData.MinDistance, ref baseData.MaxDistance, (out float v1, out float v2) => { if (baseData.RolloffMode != AudioRolloffMode.Custom) { v1 = EditorGUILayout.FloatField("Min Distance", baseData.MinDistance); } else { v1 = baseData.MinDistance; } v2 = EditorGUILayout.FloatField("Max Distance", baseData.MaxDistance); v1 = Mathf.Max(v1, 0.00001f); v2 = Mathf.Max(v2, v1 + 0.01f); }); if (baseData.RolloffMode == AudioRolloffMode.Custom) { EditorGUILayout.BeginHorizontal(); EditorGUILayout.PrefixLabel("Rolloff"); InUndoHelper.GUIUndo(baseData, "Set Rolloff Curve", ref baseData.FalloffCurve, () => EditorGUILayout.CurveField(baseData.FalloffCurve, GUILayout.Height(200), GUILayout.Width(200))); //baseData.FalloffCurve = EditorGUILayout.CurveField(baseData.FalloffCurve, GUILayout.Height(200), GUILayout.Width(200)); EditorGUILayout.EndHorizontal(); var keys = baseData.FalloffCurve.keys; int keyCount = keys.Length; for (int i = 0; i < keyCount; i++) { Keyframe key = keys[i]; key.time = Mathf.Clamp01(key.time); key.value = Mathf.Clamp01(key.value); try { baseData.FalloffCurve.MoveKey(i, key); } catch (Exception) { } } if (GUILayout.Button("Reset curve", GUILayout.Width(150))) { InUndoHelper.RecordObject(baseData, "Reset Curve"); baseData.FalloffCurve = new AnimationCurve(new Keyframe(0, 1), new Keyframe(0.1f, 1), new Keyframe(1, 0)); } if (Selection.activeObject == null) { EditorGUILayout.HelpBox("Please select any game object in the scene.\nIt fixes a bug in Unity Editor API", MessageType.Info, true); } EditorGUILayout.HelpBox("Unity does not support setting custom rolloff via scripts. This will perform slower than a log/linear rolloff curve", MessageType.Warning, true); GUI.enabled = false; } #endregion GUI.enabled = true; } }
public static bool Draw(InAudioEventNode audioevent) { if (ListAdapter == null) { ListAdapter = new EventActionListAdapter(); ListAdapter.DrawEvent = DrawItem; ListAdapter.ClickedInArea = ClickedInArea; } if (lastEvent != audioevent) { ListAdapter.Event = audioevent; audioEventAction = null; if (audioevent._actionList.Count > 0) { audioEventAction = audioevent._actionList[0]; } } EditorGUILayout.BeginVertical(); lastEvent = audioevent; InUndoHelper.GUIUndo(audioevent, "Name Change", ref audioevent.Name, () => EditorGUILayout.TextField("Name", audioevent.Name)); bool repaint = false; if (audioevent._type == EventNodeType.Event) { EditorGUIHelper.DrawID(audioevent._guid); if (Application.isPlaying) { eventObjectTarget = EditorGUILayout.ObjectField("Event preview target", eventObjectTarget, typeof(GameObject), true) as GameObject; if (eventObjectTarget != null) { bool prefab = PrefabUtility.GetPrefabParent(eventObjectTarget) == null && PrefabUtility.GetPrefabObject(eventObjectTarget) != null; if (!prefab) { EditorGUILayout.BeginHorizontal(); if (GUILayout.Button("Post event")) { InAudio.PostEvent(eventObjectTarget, audioevent); } if (GUILayout.Button("Stop All Sounds/Music in Event")) { InAudio.StopAll(eventObjectTarget); foreach (var eventAction in audioevent._actionList) { var music = eventAction.Target as InMusicGroup; if (music != null) { InAudio.Music.Stop(music); } } } EditorGUILayout.EndHorizontal(); } else { EditorGUILayout.HelpBox("Cannot post events on Prefab", MessageType.Error); } } EditorGUILayout.Separator(); } InUndoHelper.GUIUndo(audioevent, "Delay", ref audioevent.Delay, () => Mathf.Max(EditorGUILayout.FloatField("Delay", audioevent.Delay), 0)); NewEventArea(audioevent); EditorGUILayout.Separator(); EditorGUILayout.Separator(); scrollPos = EditorGUILayout.BeginScrollView(scrollPos); repaint = DrawContent(); EditorGUILayout.EndScrollView(); DrawSelected(audioEventAction); } else if (audioevent._type == EventNodeType.Folder) { if (audioevent.PlacedExternaly) { EditorGUILayout.Separator(); GUI.enabled = false; EditorGUILayout.ObjectField("Placed on", audioevent.gameObject, typeof(GameObject), false); GUI.enabled = true; EditorGUILayout.Separator(); } } EditorGUILayout.EndVertical(); if (toRemove != null) { InUndoHelper.DoInGroup(() => { //Remove the required piece int index = audioevent._actionList.FindIndex(toRemove); AudioEventWorker.DeleteActionAtIndex(audioevent, index); }); toRemove = null; } else //Remove all actions that does not excist. { audioevent._actionList.RemoveAll(p => p == null); } return(repaint); }