private void PlayAudioAutomaticEnableStart() { PYPlayer audio = GetDefaultAudio("Default"); if (audio is PYPlayerClip) { PYPlayerClip audioClip = (PYPlayerClip)audio; if (PYBundleManager.Instance != null) { if (audioClip.UpdateData.UpdateFromBundle && PYBundleManager.Instance.IsReady) { Invoke("Play", DelayStartEnable); } else { PYBundleManager.Instance.onLoadCompleted.AddListener(PlayDefaultAudioWhenBundleLoads); } } else if (audioClip.Clip != null) { Invoke("Play", DelayStartEnable); } } else { Invoke("Play", DelayStartEnable); } }
public override void UpdateComponent() { if (PYBundleManager.Instance.IsReady) { foreach (PYPlayer player in Audios) { if (player is PYPlayerClip) { PYPlayerClip playerClip = (PYPlayerClip)player; if (!playerClip.UpdateData.UpdateFromBundle) { continue; } playerClip.UpdateData.DefaultComponentValue = playerClip.Clip; AudioClip bundleClip = PYComponentBundle.GetAsset <AudioClip>(playerClip.UpdateData.BundlesToCheck, playerClip.AssetTag.Tag); if (bundleClip != null) { playerClip.Clip = bundleClip; } } } } }
public override void RestoreComponent() { foreach (PYPlayer player in Audios) { if (player is PYPlayerClip) { PYPlayerClip playerClip = (PYPlayerClip)player; if (!playerClip.UpdateData.UpdateFromBundle) { continue; } playerClip.Clip = (AudioClip)playerClip.UpdateData.DefaultComponentValue; } } }
void ShowPYPlayer(PYPlayer elem) { GUILayout.BeginHorizontal(); GUILayout.Space(10); elem.IsShowingElement = EditorGUILayout.Foldout(elem.IsShowingElement, string.Format(AUDIO_ITEM_NAME, elem.Name, elem.GetType().ToString())); if (GUILayout.Button("-", GUILayout.Width(40))) { Undo.RecordObject(target, "Removed Elem"); _target.Audios.Remove(elem); EditorUtility.SetDirty(target); return; } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Space(10); GUILayout.BeginVertical(); if (elem.IsShowingElement) { if (elem is PYPlayerTag) { PYPlayerTag playerTag = (PYPlayerTag)elem; GUILayout.BeginHorizontal(); GUILayout.Label("PYAudio Tag"); if (GUILayout.Button(playerTag.Tag.ToString())) { PYSelectorWindow.Init(_rectButtonTag, playerTag.Tag.ToString(), Enum.GetNames(typeof(PYAudioTags)), (selectedItem) => { playerTag.Tag = (PYAudioTags)Enum.Parse(typeof(PYAudioTags), selectedItem.Value); }); } GUILayout.EndHorizontal(); } else if (elem is PYPlayerClip) { PYPlayerClip playerClip = (PYPlayerClip)elem; GUILayout.BeginHorizontal(); GUILayout.Label("Asset Tag"); string tag = string.IsNullOrEmpty(playerClip.AssetTag.UnprocessedTag) ? "None" : playerClip.AssetTag.UnprocessedTag.Split(':')[0]; if (GUILayout.Button(tag)) { string[] tags = PYBundleManager.GetAssetsTag(); tags = tags.Where(t => t.Contains(": Audio")).ToArray(); PYSelectorWindow.Init(_rectButtonTag, tag, tags, (selectedItem) => { playerClip.AssetTag.UnprocessedTag = selectedItem.Value; }); } GUILayout.EndHorizontal(); } if (Event.current.type == EventType.Repaint) { _rectButtonTag = GUILayoutUtility.GetLastRect(); } elem.DrawInspector(); GUILayout.Space(5); } GUILayout.EndVertical(); GUILayout.EndHorizontal(); }