2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

【小ネタ】AudioTrackにボリュームを流し込む方法

Posted at

AudioTrackにボリュームを流し込むコードを備忘でメモしておきます

SetupVolume()の一部
            // タイムライン内のトラック一覧を取得
            var timelineAsset = _director.playableAsset as TimelineAsset;
            if ( timelineAsset == null )
            {
                return;
            }
            
            var tracks = timelineAsset.GetOutputTracks();

            //俺々サウンドマネージャからBGMボリュームを取得
            var bgmVolume = SoundManager.instance.GetVolume(AudioType.Bgm);

            //ボリュームの流し込み
            var audioTrackAsset = tracks.FirstOrDefault(x => x.name == "Audio Track");
            var audioTrack = audioTrackAsset as AudioTrack;
            audioTrack.CreateCurves("nameOfAnimationClip");
            audioTrack.curves.SetCurve(string.Empty,
                typeof(AudioTrack),
                "volume",
                AnimationCurve.Linear(bgmVolume,bgmVolume,bgmVolume,bgmVolume));
            _director.RebuildGraph();

_directorがPlayableDirectorで、音量値はSoundManagerシングルトンから取得しているコードです

2
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?