static List <ClipInfo> GetAnimationClips() { List <ClipInfo> clips = new List <ClipInfo>(); string[] guids = Selection.assetGUIDs; foreach (var guid in guids) { string path = AssetDatabase.GUIDToAssetPath(guid); Object[] objs = AssetDatabase.LoadAllAssetsAtPath(path); foreach (Object obj in objs) { AnimationClip clip = obj as AnimationClip; if (clip != null && clip.name != "__preview__Take 001") { ClipInfo info = new ClipInfo() { path = path, clip = Object.Instantiate(clip), }; clips.Add(info); } } } return(clips); }
public void PlayClip(string clipName, DefAction OnFinish = null, ClipFinishCondtion condtion = null) { GameTools.Log("PlayClip : " + clipName); ClipInfo clip = GetClipInfoByName(clipName); GameTools.Log("PlayClip Flag : " + clip.ConFlag); string clipFlag = clip.ConFlag; animator.SetBool(clipFlag, true); curClipName = clip.Name; WaitForSec(clip.Duration, () => { if (OnFinish != null) { if (condtion != null) { if (condtion()) { OnFinish(); } } else { OnFinish(); } } }); }
public ClipInfo GetClipInfoByName(string clipFlag) { ClipInfo clip = null; allClipDict.TryGetValue(clipFlag, out clip); return(clip); }
protected void AdjustMixDuration(SpineAnimationStateClip targetClip, ClipInfo timelineClipInfo) { if (timelineClipInfo == null) { return; } var timelineClip = timelineClipInfo.timelineClip; if (timelineClip == null) { return; } float blendInDur = System.Math.Max((float)timelineClip.blendInDuration, (float)timelineClip.easeInDuration); bool isBlendingNow = blendInDur > 0; bool wasBlendingBefore = timelineClipInfo.previousBlendInDuration > 0; if (isBlendingNow) { if (!wasBlendingBefore) { timelineClipInfo.unblendedMixDuration = targetClip.template.mixDuration; } targetClip.template.mixDuration = blendInDur; EditorUtility.SetDirty(targetClip); } else if (wasBlendingBefore) { targetClip.template.mixDuration = timelineClipInfo.unblendedMixDuration; EditorUtility.SetDirty(targetClip); } timelineClipInfo.previousBlendInDuration = blendInDur; }
static List <ClipInfo> GetAllAnimationClips() { List <string> fs = new List <string>(Directory.GetFiles(CLIPS_PATH, "*.fbx", SearchOption.AllDirectories)); List <ClipInfo> clips = new List <ClipInfo>(); for (int i = 0; i < fs.Count; i++) { string path = AMTool.GetUnityPath(fs[i]); Object[] objs = AssetDatabase.LoadAllAssetsAtPath(path); foreach (Object obj in objs) { AnimationClip clip = obj as AnimationClip; if (clip != null && clip.name != PREVIEW_CLIP) { ClipInfo info = new ClipInfo() { path = path, clip = Object.Instantiate(clip), }; clips.Add(info); } } } return(clips); }
/// <summary> /// Embed creator to build a better Message /// </summary> /// <param name="clip"></param> /// <returns></returns> private Embed CreateEmbed(ClipInfo clip) { EmbedBuilder clipInfo = new EmbedBuilder() { Description = clip.title }; string creatorName = "Name is missing"; if (clip.creator_name != "") { creatorName = clip.creator_name; } EmbedFieldBuilder field1 = new EmbedFieldBuilder() { Name = "Creator", Value = creatorName, IsInline = true }; EmbedFieldBuilder field2 = new EmbedFieldBuilder() { Name = "Created at", Value = clip.created_at.ToString("dd.MM.yyyy"), IsInline = true }; clipInfo.AddField(field1); clipInfo.AddField(field2); Embed finished = clipInfo.Build(); return(finished); }
/// <summary> /// Coroutine for music playback. /// </summary> IEnumerator MusicLoop() { while (true) { audioSourceToPlay = 1 - audioSourceToPlay; var audioSource = audioSources[audioSourceToPlay]; audioSource.volume = volume * volumeScale; if (!playing) { currentClip = clips.GetRandom(); audioSource.clip = currentClip.Clip; audioSource.volume = volume * volumeScale; audioSource.Play(); playing = true; } else { currentClip = nextClip; } nextClip = clips.GetRandom(); double dt = 60f / bpm * currentClip.Beats; //Debug.Log (dt); var otherAudioSource = audioSources[1 - audioSourceToPlay]; otherAudioSource.clip = nextClip.Clip; otherAudioSource.volume = volumeScale * volume; otherAudioSource.PlayScheduled(AudioSettings.dspTime + dt); yield return(new WaitForSecondsRealtime((float)dt)); } }
private PlayerAnimatorMgr addClip(ClipInfo clipInfo) { if (UITools.isValidString(clipInfo.Name)) { allClipDict.Add(clipInfo.Name, clipInfo); } return(this); }
/// <summary> /// Показывает результат работы над клипом /// </summary> public void Show(ClipInfo clip) { _clipInfo = clip; clipAnalyzer.Analyze(clip); DisplayResult(clip); Open(); }
/// <summary> /// Выводит результат работы /// </summary> private void DisplayResult(ClipInfo clip) { header.text = $"Завершена работа над клипом трека \"{ProductionManager.GetTrackName(clip.TrackId)}\""; viewsAmount.text = $"ПРОСМОТРЫ: {clip.Views}"; likesAndDislikes.text = $"{clip.Likes} лайков / {clip.Dislikes} дизлайков"; fansIncome.text = $"ФАНАТЫ: +{clip.FansIncome}"; moneyIncome.text = $"ДЕНЬГИ: +{clip.MoneyIncome}$"; }
protected override void BeforePageClose() { base.BeforePageClose(); directorPoints.text = "0"; operatorPoints.text = "0"; _clip = null; }
void TimerCallBack(float remainTime) { if (remainTime <= 0) { timer.Pause = true; audioSource.clip = null; playingInfo = null; PlayNext(); } }
public void OnEnable() { templateProp = serializedObject.FindProperty("template"); System.Array.Resize(ref clipInfo, targets.Length); for (int i = 0; i < targets.Length; ++i) { var clip = (SpineAnimationStateClip)targets[i]; clipInfo[i] = new ClipInfo(); clipInfo[i].timelineClip = FindTimelineClip(clip); } }
private void SetPosition() { RectTransform rt = GetComponent <RectTransform>(); var pos = ClipInfo.SecToPixel(Time); rt.anchorMin = new Vector2(pos, 0.0f); rt.anchorMax = new Vector2(pos, 1.0f); rt.anchoredPosition = new Vector2(0, 0); rt.offsetMin = new Vector2(0, 0); rt.offsetMax = new Vector2(30, 0); rt.localScale = Vector3.one; }
// 参数:clipName,僵尸声音类型,僵尸Transform,延迟,声音大小,音调 public static void Play(string clipName, ZombieAudioType type, Transform zombieTrans, float delay, float volMul, float pitch) { if (Profile.soundEnable) { int index = (int)type; string key = clipName + index; if (!clipInfoDict.ContainsKey(key)) { TypeInfo info = typeInfoArray[index]; if ((info.current < info.max) && (Time.realtimeSinceStartup >= (info.lastCallTime + info.interval))) { AudioClip clip = AudioClipManager.GetClip(clipName); if (clip == null) { Debug.Log("no clip" + clipName); } else { ClipInfo clipInfo = new ClipInfo { zombieTrans = zombieTrans, name = clipName, type = type, playTime = Time.realtimeSinceStartup, delay = delay, volMul = volMul, pitch = pitch }; info.current++; info.lastCallTime = Time.realtimeSinceStartup; // 如果没有延迟,直接播放,有延迟在update中处理 if (clipInfo.delay <= 0f) { AudioSource source = new GameObject("Audio:" + clipName) { transform = { parent = root } }.AddComponent <AudioSource>(); source.clip = clip; source.volume = clipInfo.volMul * info.volumeMul; source.loop = false; float num2 = Mathf.Clamp(Time.timeScale, 0.75f, 1f); source.pitch = clipInfo.pitch * num2; clipInfo.length = clip.length / source.pitch; clipInfo.audioSource = source; source.Play(); SpecialDeal(clipInfo); } clipInfoDict.Add(key, clipInfo); } } } } }
public bool Equals(ClipInfo _other) { if (clipped != _other.clipped || top != _other.top || bottom != _other.bottom || left != _other.left || right != _other.right) { return(false); } return(true); }
public override void ProcessFrame(Playable playable, FrameData info, object playerData) { base.ProcessFrame(playable, info, playerData); int activeInputs = 0; ClipInfo clipA = new ClipInfo(); ClipInfo clipB = new ClipInfo(); for (int i = 0; i < playable.GetInputCount(); i++) { float weight = playable.GetInputWeight(i); var clip = (ScriptPlayable <TimeScaleBehaviour>)playable.GetInput(i); var behaviour = clip.GetBehaviour(); if (behaviour != null && playable.GetPlayState() == PlayState.Playing && weight > 0 ) { clipA = clipB; clipB.scale = behaviour.scale; clipB.weight = weight; clipB.time = clip.GetTime(); if (++activeInputs == 2) { break; } } } if (activeInputs == 0) { if (Time.timeScale < 1f) { Time.timeScale = 1f; } return; } if (activeInputs < 2) { Time.timeScale = clipB.scale; } else { if (clipA.time > clipB.time) { Time.timeScale = Mathf.Lerp(clipA.scale, clipB.scale, clipB.weight); } else { Time.timeScale = Mathf.Lerp(clipA.scale, clipB.scale, clipA.weight); } } }
public static void StopSound(AudioSource _toStop) { try { ClipInfo clip = s_activeAudio.Find(s => s.audioSource == _toStop); s_activeAudio.Remove(clip); _toStop.Stop(); } catch { Debug.Log("Error trying to stop audio source " + _toStop); } }
public void PlayClip(string clipID) { ClipInfo clip = GetClip(clipID); if (clip.music) { PlayMusic(clip); } else { PlaySFX(clip); } }
public void SetCursorPosition() { //TextCurrentTime.text = string.Format("{0:000.00}", CursorPosition); var newTime = ClipInfo.SecToPixel(_cursorTime); _cursor.anchorMin = new Vector2(newTime, 0); _cursor.anchorMax = new Vector2(newTime, 1); _cursor.anchoredPosition = Vector2.zero; _videoManager.SetTime(_cursorTime); _audioManager.UpdatePlayTime(_cursorTime); }
// 如果该僵尸在接近中,所有声音音量减半 private static void SpecialDeal(ClipInfo clipInfo) { if (clipInfo.type == ZombieAudioType.APPROACH) { foreach (ClipInfo info in clipInfoDict.Values) { info.volMul *= 0.5f; if (info.audioSource != null) { info.audioSource.volume *= 0.5f; } } } }
void Awake() { skinningData = GetComponent <GPUAnimationPlayer>().skinningData; _bakedRenderers = new List <BakedGPUSkinnedMeshRenderer>(); _fadeOutClipInfo = new ClipInfo(); _fadeOutClipInfo.clipIdx = -1; _currClipInfo = new ClipInfo(); _currClipInfo.clipIdx = -1; _crossFadeInfo = new CrossFadeInfo(); isPlaying = false; isPaused = false; }
public void PlaySound(AudioSource clip, GameObject movingObject, bool loop, int delayInSeconds) { clipInfoObject = new ClipInfo(clip, movingObject, loop); if (delayInSeconds > 0) { StartCoroutine(this, playSoundClip, delayInSeconds); } else { ActuallyPlay(); } }
static void SaveClip(ClipInfo info) { string dirPath = string.Format("{0}/clips", Path.GetDirectoryName(info.path)); if (!Directory.Exists(dirPath)) { Directory.CreateDirectory(dirPath); } string path = string.Format("{0}/{1}.anim", dirPath, info.clip.name.Replace("(Clone)", "")); AssetDatabase.CreateAsset(info.clip, path); AssetDatabase.Refresh(); }
public async Task <string> DownloadClipAsync(ClipInfo Clip, string OutputFolder = null) { string ClipDirect = Clip.thumbnail_url.Replace("-preview-480x272.jpg", ".mp4"); OutputFolder ??= Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); string OutputPath = Path.Combine(OutputFolder, $"{Clip.broadcaster_name} {Clip.title}.mp4".RemoveInvalidChars()); using (var Client = new WebClient()) { var Data = await Client.DownloadDataTaskAsync(ClipDirect); File.WriteAllBytes(OutputPath, Data); } return(OutputPath); }
private ClipInfo GetClip(string clipID) { ClipInfo clip = new ClipInfo(); foreach (ClipInfo ci in m_clips) { if (ci.clipID.Equals(clipID)) { clip = ci; break; } } return(clip); }
/// <summary> /// Gets an AviSynth clip information by running a script that outputs the frame count to a file. /// </summary> /// <param name="source">The AviSynth script to get information for.</param> /// <param name="silent">If true, the x264 window will be hidden.</param> /// <returns>The clip information.</returns> public static ClipInfo GetClipInfo(MediaEncoderSettings settings, string scriptFile, bool silent) { string TempScript = settings.TempFile + ".avs"; string TempResult = settings.TempFile + ".txt"; string TempOut = settings.TempFile + ".y4m"; // Read source script and remove MT. Also remove Deshaker if present. string FileContent = File.ReadAllText(scriptFile); FileContent.Replace(Environment.NewLine + "Deshaker", Environment.NewLine + "#Deshaker"); AviSynthScriptBuilder Script = new AviSynthScriptBuilder(FileContent); Script.RemoveMT(); //Script.DitherOut(false); // Get frame count. Script.AppendLine(); Script.AppendLine(@"WriteFileStart(""{0}"", ""FrameRate""{1}""Framecount"")", TempResult, @", """""" "","" """""", "); Script.AppendLine("Trim(0,-1)"); Script.WriteToFile(TempScript); // Run script. Run(@"Encoder\avs2yuv.exe", String.Format(@"""{0}"" -o {1}", TempScript, TempOut), true); // Read frame count ClipInfo Result = null; if (File.Exists(TempResult)) { string FileString = File.ReadAllText(TempResult); string[] FileValues = FileString.Split(','); Result = new ClipInfo(); try { Result.FrameRate = float.Parse(FileValues[0], CultureInfo.InvariantCulture); Result.FrameCount = int.Parse(FileValues[1]); } catch { Result = null; } } // Delete temp files. File.Delete(TempScript); File.Delete(TempResult); File.Delete(TempOut); // Dummy file that received avs2yuv output. return(Result); }
private void PlayMusic(ClipInfo clip) { foreach (AudioSource audioSource in m_musicChannels) { if (!audioSource.isPlaying) { audioSource.Stop(); audioSource.clip = clip.audioClip; audioSource.pitch = clip.pitch; audioSource.volume = clip.volume; audioSource.outputAudioMixerGroup = clip.output; audioSource.Play(); break; } } }
private void Update() { foreach (string str in clipInfoDict.Keys) { ClipInfo clipInfo = clipInfoDict[str]; int type = (int)clipInfo.type; TypeInfo info2 = typeInfoArray[type]; // 处理延迟播放 if ((clipInfo.delay > 0f) && ((Time.realtimeSinceStartup - clipInfo.playTime) >= clipInfo.delay)) { clipInfo.delay = 0f; clipInfo.playTime = Time.realtimeSinceStartup; AudioClip clip = AudioClipManager.GetClip(clipInfo.name); AudioSource source = new GameObject("Audio:" + clipInfo.name) { transform = { parent = root } }.AddComponent <AudioSource>(); source.clip = clip; source.volume = clipInfo.volMul * info2.volumeMul; source.loop = false; float num2 = Mathf.Clamp(Time.timeScale, 0.75f, 1f); source.pitch = clipInfo.pitch * num2; clipInfo.length = clip.length / source.pitch; clipInfo.audioSource = source; source.Play(); SpecialDeal(clipInfo); } else if (Time.realtimeSinceStartup >= (clipInfo.playTime + clipInfo.length)) { clipInfoDeleteList.Add(str); info2.current--; if (clipInfo.audioSource != null) { Destroy(clipInfo.audioSource.gameObject); } } } if (clipInfoDeleteList.Count > 0) { for (int i = 0; i < clipInfoDeleteList.Count; i++) { clipInfoDict.Remove(clipInfoDeleteList[i]); } clipInfoDeleteList.Clear(); } }
public void ChangeGridOffset(float offset) { float clipTimeSizeInMinutes = ClipInfo.ClipTimeSize / 60; _offset = offset; float width = BarsParent.GetComponent <RectTransform> ().rect.width; for (int i = 0; i < _gridLines.Count; i++) { float time = ClipInfo.ClipTimeSize / _gridLines.Count * i + offset; time = (float)Math.Round(time, 2); float pos = ClipInfo.SecToPixel(time); _gridLines[i].name = time.ToString("F2"); SetPosition(_gridLines[i], pos); } }
/// <summary> /// Called by the application when a sound sample for a specific note & octave is requested. /// </summary> /// <param name="note">The note to request the data for</param> /// <param name="octave">The octave to request the data for</param> /// <param name="channel">The channel on which this sample will be active</param> /// <param name="velocity">The velocity of the key press for this sample</param> /// <returns>a new ClipInfo instance containing the correct data or null</returns> public ClipInfo GetSampleData(int note, int octave, int channel, float velocity) { if (SampleData[note].Length <= octave) { Debug.Log("Octave out of range '" + octave + "' for note '" + note + "'."); return null; } ClipInfo info = new ClipInfo(); info.Data = SampleData[note][octave]; info.Index = 0; info.Channel = channel; info.Velocity = velocity; info.Damping = 1.0f; info.StopIndex = SampleStopIndex[note][octave]; return info; }
private ToolStripMenuItem CreateClipMenuItem(int clipNum, ClipInfo? info) { string dur = ToolStripPlayModeDropDownButton.UnknownTime; string begin = ToolStripPlayModeDropDownButton.UnknownTime; string end = ToolStripPlayModeDropDownButton.UnknownTime; if (info.HasValue && info.Value.Duration.HasValue) { dur = ToolStripPlayModeDropDownButton.FormatTimespan(info.Value.Duration.Value); if (info.Value.Begin.HasValue) { begin = ToolStripPlayModeDropDownButton.FormatTimespan(info.Value.Begin.Value); end = ToolStripPlayModeDropDownButton.FormatTimespan(info.Value.Begin.Value + info.Value.Duration.Value); } } ToolStripMenuItem tsmi = new ToolStripMenuItem( string.Format("クリップ{0} {1} ({2}-{3})", clipNum, dur, begin, end)); tsmi.Tag = clipNum; tsmi.Click += delegate(object sender, EventArgs e) { ToolStripMenuItem sender2 = sender as ToolStripMenuItem; this.OnPlayModeSelect((int)sender2.Tag); }; if (this.currentMode.HasValue && this.currentMode.Value.Equals(clipNum)) { tsmi.Checked = true; tsmi.Enabled = false; } else if (!this.currentMode.HasValue && this.currentClipNo.HasValue && this.currentClipNo.Equals(clipNum)) { tsmi.Checked = true; } return tsmi; }
public bool Equals ( ClipInfo _other ) { if ( clipped != _other.clipped || top != _other.top || bottom != _other.bottom || left != _other.left || right != _other.right ) { return false; } return true; }
void ProcessAudioOcclusion(ClipInfo _audioClip) { //Get the audioListener in the scene Vector3 listenerPos = m_listener.transform.position; Vector3 sourcePos = _audioClip.audioSource.transform.position; int ignoreMask = 3 << 10; ignoreMask = ~ignoreMask; RaycastHit hit; if(Physics.Linecast(sourcePos, listenerPos, out hit, ignoreMask)) { Debug.DrawLine( sourcePos, listenerPos); if(hit.collider.tag != "Listener") { //TODO: //For now, get every conduit in existence GameObject[] conduits = GameObject.FindGameObjectsWithTag("AudioConduit"); bool occlude = true; //Before occluding, raycast from audio source to all nearby audio conduits. foreach(GameObject conduit in conduits) { RaycastHit sourceToConduit; if(Physics.Linecast(sourcePos, conduit.transform.position, out sourceToConduit)) { if(sourceToConduit.collider.tag == "AudioConduit") { //If there is a conduit within sight of the audio source, check whether the listener has line of sight with the same conduit. RaycastHit LinstenerToConduit; if(Physics.Linecast(listenerPos, conduit.transform.position, out LinstenerToConduit)) { if(LinstenerToConduit.collider.tag == "AudioConduit") { Debug.DrawLine( sourcePos, conduit.transform.position, Color.red); Debug.DrawLine( conduit.transform.position, listenerPos, Color.blue); occlude = false; _audioClip.audioSource.volume = _audioClip.defaultVolume / 2; if(occludeState != OcclusionState.OCCLUSION_PARTIAL) { occludeState = OcclusionState.OCCLUSION_PARTIAL; //Debug.Log("Partial Occlusion"); } } } } } } AudioLowPassFilter audioFilter = _audioClip.audioSource.gameObject.GetComponent<AudioLowPassFilter>(); if(occlude) { if(audioFilter == null) { AudioLowPassFilter filter =_audioClip.audioSource.gameObject.AddComponent<AudioLowPassFilter>(); filter.cutoffFrequency = 2000; } _audioClip.audioSource.volume = _audioClip.defaultVolume / 10; if(occludeState != OcclusionState.OCCLUSION_FULL) { occludeState = OcclusionState.OCCLUSION_FULL; //Debug.Log("Full Occlusion. " + hit.collider.gameObject.name + " is blocking audio"); } } } else { if(_audioClip.audioSource.gameObject.GetComponent<AudioLowPassFilter>() != null) { Destroy(_audioClip.audioSource.gameObject.GetComponent<AudioLowPassFilter>()); _audioClip.audioSource.volume = _audioClip.defaultVolume; } if(occludeState != OcclusionState.OCCLUSION_FALSE) { occludeState = OcclusionState.OCCLUSION_FALSE; //Debug.Log("No Occlusion"); } } } }