IEnumerator CreateAudioSource() { yield return(new WaitForSeconds(0.5f)); audioSourceAtom = GetAtomById(AUDIO_SOURCE_NAME); if (audioSourceAtom == null) { SuperController.singleton.StartCoroutine(SuperController.singleton.AddAtomByType("AudioSource", AUDIO_SOURCE_NAME, true)); yield return(new WaitWhile(() => GetAtomById(AUDIO_SOURCE_NAME) != null)); audioSourceAtom = GetAtomById(AUDIO_SOURCE_NAME); } if (audioSourceAtom != null) { audioSource = audioSourceAtom.GetStorableByID("AudioSource") as AudioSourceControl; if (audioSource != null) { FreeControllerV3 hipControl = containingAtom.freeControllers.First((controller) => controller.name == "hipControl"); if (hipControl != null) { FreeControllerV3 sfxControl = audioSourceAtom.mainController; sfxControl.transform.SetPositionAndRotation(hipControl.transform.position, hipControl.transform.rotation); sfxControl.currentPositionState = FreeControllerV3.PositionState.ParentLink; sfxControl.currentRotationState = FreeControllerV3.RotationState.ParentLink; Rigidbody rb = SuperController.singleton.RigidbodyNameToRigidbody("Person:hipControl"); sfxControl.SelectLinkToRigidbody(rb, FreeControllerV3.SelectLinkState.PositionAndRotation); audioSource.volume = 0.5f; } } HideController(audioSourceAtom); } }
/** * Play the assigned audio clip with optional "if clear" param. */ public void Play(AudioSourceControl receiver = null, bool ifClear = false, bool clearQueue = false) { if (SourceClip == null) { return; } if ((UnityEngine.Object)receiver != (UnityEngine.Object)null) { Receiver = receiver; } if (ifClear) { Receiver.PlayIfClear(SourceClip); } else { if (clearQueue) { Receiver.PlayNowClearQueue(SourceClip); } else { Receiver.PlayNow(SourceClip); } } }
public AudioSourceControl GetFreeAudioSourceControl() { AudioSourceControl audioSourceControl = null; int num = -1; for (int i = 0; i < this.m_audioSourceControlList.Count; i++) { if (!this.m_audioSourceControlList[i].isPlaying) { audioSourceControl = this.m_audioSourceControlList[i]; num = i; break; } } if (audioSourceControl == null || audioSourceControl.audioSourceObject == null || audioSourceControl.audioSource == null) { if (num != -1) { this.m_audioSourceControlList.RemoveAt(num); } audioSourceControl = this.AddAudioSourceControl(); } if (audioSourceControl.audioSourceObject.activeSelf) { audioSourceControl.audioSourceObject.SetActive(false); } return(audioSourceControl); }
/// <summary> /// 停止播放背景音乐 /// </summary> public static void stopBGMClip() { AudioSourceControl control = Camera.main.GetComponent <AudioSourceControl>(); if (control != null) { control.stopBGMClip(); } }
private void Awake() { CommonData.GameStatus = 0; gameFinshAnimTime = 3f; uiMasterControl = gameObject.AddComponent <UIMasterControl>(); audioSourceControl = gameObject.AddComponent <AudioSourceControl>(); audioSourceControl.stopBGMClip(); initData(); }
private void Awake() { uiMasterControl = gameObject.AddComponent <UIMasterControl>(); audioSourceControl = gameObject.AddComponent <AudioSourceControl>(); GameObject menuBackGroundObj = MenuBackGroundBuilder.buildMenuBack(new Vector3(0, 0, 0)); menuBackGround = menuBackGroundObj.GetComponent <MenuBackGroundCpt>(); }
public void Destroy() { try { UI.Destroy(); Receiver = null; SourceClip = null; } catch (Exception e) { SuperController.LogError($"AudioMate.{nameof(AudioMateClip)}.{nameof(Destroy)}: {e}"); } }
private AudioSourceControl AddAudioSourceControl() { GameObject gameObject = UnityEngine.Object.Instantiate(this.m_audioSourcePrefab) as GameObject; gameObject.transform.parent = this.m_targetRoot; gameObject.transform.localPosition = Vector3.zero; AudioSourceControl component = gameObject.GetComponent <AudioSourceControl>(); gameObject.SetActive(false); this.m_audioSourceControlList.Add(component); return(component); }
/// <summary> /// 播放音乐片段 /// </summary> /// <param name="onClickEnum"></param> public static void playSoundClip(AudioButtonOnClickEnum onClickEnum) { if (CommonConfigure.IsOpenSound == EnabledEnum.OFF) { return; } AudioSourceControl control = Camera.main.GetComponent <AudioSourceControl>(); if (control != null) { control.playSoundClip(onClickEnum); } }
/** * Add assigned audio clip to audio controller queue list. */ public void Queue(AudioSourceControl receiver = null) { if (SourceClip == null) { return; } if ((UnityEngine.Object)receiver != (UnityEngine.Object)null) { Receiver = receiver; } else { return; } Receiver.QueueClip(SourceClip); }
public void ReleaseUnusedAudioSourceControl() { for (int i = this.m_audioSourceControlList.Count - 1; i >= 0; i--) { AudioSourceControl audioSourceControl = this.m_audioSourceControlList[i]; if (audioSourceControl == null || audioSourceControl.audioSourceObject == null) { this.m_audioSourceControlList.RemoveAt(i); } else if (!audioSourceControl.isPlaying) { audioSourceControl.Clear(); this.m_audioSourceControlList.RemoveAt(i); } } }
public override void HandleAfterOpenView() { base.HandleAfterOpenView(); if (!this.m_isOpen) { this.m_audioSourceControl = AudioMgr.Play(new AudioClipInfo { clipName = "sd_ui_heart", audioSourceType = eAudioSourceType.UI_Loop, fadeInSpeed = 0f, fadeOutSpeed = 1f, audioPriority = 10, volume = 1f }, AudioMgr.Instance.transform); this.m_isOpen = true; } }
/** * Set the audio source controller which plays the clips */ public void SyncAudioReceiver() { if (ReceiverAtom == null || ReceiverNode == null) { return; } try { Receiver = SuperController.singleton.GetAtomByUid(ReceiverAtom)?.GetStorableByID(ReceiverNode) as AudioSourceControl; } catch (Exception e) { SuperController.LogError($"AudioMate.{nameof(AudioMateController)}.{nameof(SyncAudioReceiver)}: {e}"); } }
public List <AudioSourceControl> GetUsingAudioSourceControlList() { List <AudioSourceControl> list = new List <AudioSourceControl>(); for (int i = this.m_audioSourceControlList.Count - 1; i >= 0; i--) { AudioSourceControl audioSourceControl = this.m_audioSourceControlList[i]; if (audioSourceControl == null || audioSourceControl.audioSourceObject == null) { this.m_audioSourceControlList.RemoveAt(i); } else if (audioSourceControl.isPlaying) { list.Add(audioSourceControl); } } return(list); }
public override void Init() { try { AudioSourceControl source = containingAtom.GetStorableByID("AudioSource") as AudioSourceControl; if (source == null) { SuperController.LogError("This plugin only works on AudioSource"); return; } clipCount = new JSONStorableFloat("clipCount", 0, 0, 100, false, false); RegisterFloat(clipCount); JSONStorableAction audioClipAction = new JSONStorableAction("Play Random", () => { if (clips.Count == 0) { return; } source.PlayNow(clips[UnityEngine.Random.Range(0, clips.Count)]); }); CreateButton("Play Random").button.onClick.AddListener(() => { audioClipAction.actionCallback(); }); RegisterAction(audioClipAction); UIDynamicButton addClipButton = CreateButton("Add Clip"); addClipButton.buttonColor = new Color(0, 1, 0); addClipButton.button.onClick.AddListener(() => { BuildClipUI(clips.Count); }); //GetStringParamNames().ForEach((s) => Debug.Log(s)); //Debug.Log(GetStringChooserParamNames().Count); } catch (Exception e) { SuperController.LogError("Exception caught: " + e); } }
public override void Init() { try { LoadFacial(); LoadSharedExpressions(); Dictionary <string, string> personalitiesMap = SuperController.singleton .GetFilesAtPath(Utils.AbsPath("./personalities"), "expression_*.json") .ToList() .Aggregate(new Dictionary <string, string>(), (dict, file) => { string name = FirstLetterToUpper(file.Substring(file.LastIndexOf("\\") + 1).Replace(".json", "").Replace("expression_", "")); dict[name] = file; return(dict); }); JSONStorableStringChooser personalityChooser = new JSONStorableStringChooser("personality", personalitiesMap.Keys.ToList(), personalitiesMap.Keys.ToArray()[0], "personality", (string personality) => { LoadExpressions(personalitiesMap[personality]); }); CreatePopup(personalityChooser).popupPanelHeight = 400; personalityChooser.storeType = JSONStorableParam.StoreType.Full; RegisterStringChooser(personalityChooser); LoadExpressions(personalitiesMap[personalitiesMap.Keys.ToArray()[0]]); nextPlayTime = Time.fixedTime + 1.0f; headAudioSource = containingAtom.GetStorableByID("HeadAudioSource") as AudioSourceControl; jawAdjust = containingAtom.GetStorableByID("JawControl") as AdjustJoints; jawAdjust.driveXRotationFromAudioSourceMultiplier = 115.0f; jawAdjust.driveXRotationFromAudioSourceAdditionalAngle = 0.0f; jawAdjust.driveXRotationFromAudioSourceMaxAngle = -5.0f; eyelidControl = containingAtom.GetStorableByID("EyelidControl") as DAZMeshEyelidControl; eyelidControl.SetBoolParamValue("blinkEnabled", false); } catch (Exception e) { SuperController.LogError("Exception caught: " + e); } }
public override void Init() { try { if (containingAtom.type != "Person") { SuperController.LogError("Please add Doll Master to a Person atom"); return; } lastAtomName = containingAtom.uid; PLUGIN_PATH = GetPluginPath(); ASSETS_PATH = PLUGIN_PATH + "/Assets"; VAMASUTRA_PATH = ASSETS_PATH + "/VAMasutra"; LOAD_PATH = SuperController.singleton.currentLoadDir; headAudioSource = containingAtom.GetStorableByID("HeadAudioSource") as AudioSourceControl; RegisterActions(); ui = new UI(this, 0.001f); ui.canvas.transform.Translate(0, 0.2f, 0); config = new Config(this); personas = new Personas(this); ps = new PluginState(this); arousal = new Arousal(this); expressions = new Expressions(this); expressionController = new ExpressionController(this); sfxController = new SFXController(this); thrustController = new ThrustController(this); thrustAutoController = new ThrustAutoController(this); breathController = new BreathController(this); headController = new HeadController(this); poseController = new PoseController(this); montageController = new MontageController(this, poseController); dressController = new DressController(this); climaxController = new ClimaxController(this); kissController = new KissController(this); new TopButtons(this); //new WorldUI(this); CreateSpacer().height = 200; //SuperController singleton = SuperController.singleton; //singleton.onAtomUIDRenameHandlers = (SuperController.OnAtomUIDRename)Delegate.Combine(singleton.onAtomUIDRenameHandlers, new SuperController.OnAtomUIDRename(HandleRename)); } catch (Exception e) { SuperController.LogError("Exception caught: " + e); } }
//SelectJsonStorable<AudioSource> selector; public override void Init() { #if vamdebug try { #endif audioSource = containingAtom.GetStorableByID("HeadAudioSource") as AudioSourceControl; if (audioSource == null) { audioSource = containingAtom.GetStorableByID("AudioSource") as AudioSourceControl; } if (audioSource == null) { SuperController.LogError($"{this} is not applicable to {containingAtom.name} ({containingAtom.type})"); } playRandom = new JSONStorableAction("Play Random", playRandomClipAction); playNext = new JSONStorableAction("Play Next", playNextClipAction); RegisterAction(playNext); RegisterAction(playRandom); pitchshift = new JSONStorableFloat("pitch shift", 0f, f => playlist.pitchshift = playlist.pitchshift = f, -0.3f, 0.3f, true) { storeType = JSONStorableParam.StoreType.Full }; RegisterFloat(pitchshift); CreateSlider(pitchshift, true); folderpath = new JSONStorableString("loadpath", Application.dataPath + "/../custom/assets/audio") { storeType = JSONStorableParam.StoreType.Full }; RegisterString(folderpath); audioBulk = new AudioBulk(); nacs = new List <NamedAudioClip>(); audioBulk.InitUI(this, nacs, folderpath); playlist = new PlayList(nacs); playIfClear = new JSONStorableBool("Play if clear", true); RegisterBool(playIfClear); playIfClear.storeType = JSONStorableParam.StoreType.Full; CreateToggle(playIfClear, true); delay = new JSONStorableFloat("delay", 0f, 0f, 2f, false); CreateSlider(delay, true); //CreateButton("callback").button.onClick.AddListener(() =>playNext.actionCallback()); CreateButton("Load Audio Folder").button.onClick.AddListener( () => { audioBulk.OpenLoadFolder(nacs, folderpath); Loaded(nacs); }); CreateButton("Load Embeded").button.onClick.AddListener(() => { if (!validInputNameAsEmbedded()) { SuperController.LogError("no valid source"); return; } LoadEmbeddedInput(); Loaded(nacs); }); CreateButton("Play next", true).button.onClick.AddListener(playNextClipAction); CreateButton("Play random", true).button.onClick.AddListener(playRandomClipAction); CreateButton("Stop", false).button.onClick.AddListener(audioSource.Stop); CreateTextField(folderpath, false).height = 10; CreateButton("Reload", false).button.onClick.AddListener(() => { audioBulk.Load(nacs, folderpath.val); Loaded(nacs); } ); clipsLoaded = new JSONStorableString("loaded clips", "No clips loaded"); CreateTextField(clipsLoaded, false).height = 10; #if vamdebug } catch (Exception e) { SuperController.LogError("woops" + e); } #endif }
private void CheckSource() { source_ = Utilities.AtomAudioSource(Atom); }
public override void Init() { try { _headAudioSource = containingAtom.GetStorableByID("HeadAudioSource") as AudioSourceControl; if (_headAudioSource == null) { throw new InvalidOperationException($"Cannot initialize {nameof(Cornwall)} on atom {containingAtom.name} because it does not have a head audio source."); } _clips = new Dictionary <int, List <NamedAudioClip> > { { 0, Clips("FemPixieW1001") }, { 1, Clips("FemPixieW1002") }, { 2, Clips("FemPixieW1003") }, { 3, Clips("FemPixieW1004") }, { 4, Clips("FemPixieW1005") }, { 5, Clips("FemPixieW1006") }, { 6, Clips("FemPixieW1007") }, { 7, Clips("FemPixieW1008") }, { 8, Clips("FemPixieW1009") }, { 9, Clips("FemPixieW1010") }, { 10, Clips("FemPixieW1011") }, { 11, Clips("FemPixieW1012") }, { 12, Clips("FemPixieW1013") }, { 13, Clips("FemPixieW1014") }, { 14, Clips("FemPixieW1015") }, { 15, Clips("FemPixieW1016") }, { 16, Clips("FemPixieW1017") }, { 17, Clips("FemPixieW1018") }, { 18, Clips("FemPixieW1019") }, { 19, Clips("FemPixieW1020") }, { 20, Clips("FemPixieW1021") }, { 21, Clips("FemPixieW1022") }, { 22, Clips("FemPixieW1023") }, { 23, Clips("FemPixieW1024") }, { 24, Clips("FemPixieW1025") }, { 25, Clips("FemPixieW1026") }, { 26, Clips("FemPixieW1027") }, { 27, Clips("FemPixieW1028") }, { 28, Clips("FemPixieW1029") }, { 29, Clips("FemPixieW1030") }, { 30, Clips("FemPixieW1031") }, { 31, Clips("FemPixieW1032") }, { 32, Clips("FemPixieW1033") }, { 33, Clips("FemPixieW1034") }, { 34, Clips("FemPixieW1035") }, { 35, Clips("FemPixieW1036") }, { 36, Clips("FemPixieW1037") }, { 37, Clips("FemPixieW1038") }, { 38, Clips("FemPixieW1039") }, { 39, Clips("FemPixieW1040") }, { 40, Clips("FemPixieW1041") }, { 41, Clips("FemPixieW1042") }, { 42, Clips("FemPixieW1043") }, { 43, Clips("FemPixieW1044") }, { 44, Clips("FemPixieW1045") }, { 45, Clips("FemPixieW1046") }, { 46, Clips("FemPixieW1047") }, { 47, Clips("FemPixieW1048") }, { 48, Clips("FemPixieW1049") }, { 49, Clips("FemPixieW1050") }, { 50, Clips("FemPixieW1051") }, { 51, Clips("FemPixieW1052") }, { 52, Clips("FemPixieW1053") }, { 53, Clips("FemPixieW1054") }, { 54, Clips("FemPixieW1055") }, { 55, Clips("FemPixieW1056") }, { 56, Clips("FemPixieW1057") }, { 57, Clips("FemPixieW1058") }, { 58, Clips("FemPixieW1059") }, { 59, Clips("FemPixieW1060") }, { 60, Clips("FemPixieW1061") }, { 61, Clips("FemPixieW1062") }, { 62, Clips("FemPixieW1063") }, { 63, Clips("FemPixieW1064") }, { 64, Clips("FemPixieW1065") }, { 65, Clips("FemPixieW1066") }, { 66, Clips("FemPixieW1067") }, { 67, Clips("FemPixieW1068") }, { 68, Clips("FemPixieW1069") }, { 69, Clips("FemPixieW1070") }, { 70, Clips("FemPixieW1071") }, { 71, Clips("FemPixieW1072") }, { 72, Clips("FemPixieW1073") }, { 73, Clips("FemPixieW1074") }, { 74, Clips("FemPixieW1075") }, { 75, Clips("FemPixieW1076") }, { 76, Clips("FemPixieW1077") }, { 77, Clips("FemPixieW1078") }, { 78, Clips("FemPixieW1079") }, { 79, Clips("FemPixieW1080") }, { 80, Clips("FemPixieW1081") }, { 81, Clips("FemPixieW1082") }, { 82, Clips("FemPixieW1083") }, { 83, Clips("FemPixieW1084") }, { 84, Clips("FemPixieW1085") }, { 85, Clips("FemPixieW1086") }, { 86, Clips("FemPixieW1087") }, { 87, Clips("FemPixieW1088") }, { 88, Clips("FemPixieW1089") }, { 89, Clips("FemPixieW1090") }, { 90, Clips("FemPixieW1091") }, { 91, Clips("FemPixieW1092") }, { 92, Clips("FemPixieW1093") }, { 93, Clips("FemPixieW1094") }, { 94, Clips("FemPixieW1095") }, { 95, Clips("FemPixieW1096") }, { 96, Clips("FemPixieW1097") }, { 97, Clips("FemPixieW1098") }, { 98, Clips("FemPixieW1099") }, }; int minValue = _clips.Keys.Min(); int maxValue = _clips.Keys.Max(); _intensityJSON = new JSONStorableFloat("Intensity", 0f, minValue, maxValue); RegisterFloat(_intensityJSON); CreateSlider(_intensityJSON); _variabilityJSON = new JSONStorableFloat("Variability", (maxValue - minValue) / 8f, 0f, (maxValue - minValue) / 2f); RegisterFloat(_variabilityJSON); CreateSlider(_variabilityJSON); _paddingJSON = new JSONStorableFloat("Padding", 0.2f, 0f, 5f, false); RegisterFloat(_paddingJSON); CreateSlider(_paddingJSON); } catch (Exception e) { SuperController.LogError($"{nameof(Cornwall)}.{nameof(Init)}: {e}"); } }
private new void Start() { base.Start(); audioSourceControl = CptUtil.getCptFormSceneByName <AudioSourceControl>("Main Camera"); }
public override void Init() { try { lastLoadPath = PATH_WHEN_LOADED = SuperController.singleton.currentLoadDir; sc = SuperController.singleton; DAZCharacterSelector dcs = containingAtom.GetStorableByID("geometry") as DAZCharacterSelector; morphControl = dcs.morphsControlUI; // Fix tongue morph... morphControl.GetMorphByDisplayName("Tongue In-Out").startValue = 0.0f; headAudioSource = containingAtom.GetStorableByID("HeadAudioSource") as AudioSourceControl; JSONStorableAction playRandomAction = new JSONStorableAction("Play Random Expression", () => { if (currentAnimation != null) { currentAnimation.Stop(); } if (animationLookup.Count == 0) { return; } ExpressionAnimation selectedAnimation = currentAnimation; do { int randomIndex = UnityEngine.Random.Range(0, animationLookup.Count); string key = animationLookup.Keys.ToList()[randomIndex]; selectedAnimation = animationLookup[key]; if (animationLookup.Count <= 1) { break; } }while (currentAnimation == selectedAnimation); PlayExpression(selectedAnimation); }); RegisterAction(playRandomAction); JSONStorableAction playRandomWhenReadyAction = new JSONStorableAction("Play Random Expression When Ready", () => { if (currentAnimation != null) { return; } if (animationLookup.Count == 0) { return; } ExpressionAnimation selectedAnimation = currentAnimation; do { int randomIndex = UnityEngine.Random.Range(0, animationLookup.Count); string key = animationLookup.Keys.ToList()[randomIndex]; selectedAnimation = animationLookup[key]; if (animationLookup.Count <= 1) { break; } }while (currentAnimation == selectedAnimation); PlayExpression(selectedAnimation); }); RegisterAction(playRandomWhenReadyAction); CreateButton("Load Expression").button.onClick.AddListener(() => { sc.fileBrowserUI.defaultPath = PATH_WHEN_LOADED; sc.fileBrowserUI.SetTextEntry(false); sc.fileBrowserUI.Show((path) => { if (string.IsNullOrEmpty(path)) { return; } JSONStorableString store = storeList.GetNext(); if (store == null) { return; } CreateUIFromExpressionPath(path, store); lastLoadPath = path; }); }); CreateButton("Load Expression (Folder)").button.onClick.AddListener(() => { sc.GetDirectoryPathDialog((path) => { if (string.IsNullOrEmpty(path)) { return; } sc.GetFilesAtPath(path).ToList().ForEach((filePath) => { if (filePath.ToLower().Contains(".json") == false) { return; } JSONStorableString store = storeList.GetNext(); if (store == null) { return; } Debug.Log("loading " + filePath); CreateUIFromExpressionPath(filePath, store); }); lastLoadPath = path; }, lastLoadPath); }); CreateButton("Secret Button", true); CreateButton("Clear All", true).button.onClick.AddListener(() => { uiList.GetRange(0, uiList.Count).ForEach((ui) => { ui.Remove(); }); }); CreateSpacer(false).height = 50; CreateSpacer(true).height = 50; // do this last so it shows up at the bottom... storeList = new StorableStringList(this, "expression_"); } catch (Exception e) { SuperController.LogError("Exception caught: " + e); } }
private new void Start() { base.Start(); audioSourceControl = Camera.main.GetComponent <AudioSourceControl>(); }