add Audio Pannel
This commit is contained in:
+1227
-22
File diff suppressed because it is too large
Load Diff
@@ -26,7 +26,10 @@ public class UmaViewerBuilder : MonoBehaviour
|
|||||||
public UmaContainer CurrentUMAContainer;
|
public UmaContainer CurrentUMAContainer;
|
||||||
public UmaContainer CurrentLiveContainer;
|
public UmaContainer CurrentLiveContainer;
|
||||||
public UmaContainer CurrentOtherContainer;
|
public UmaContainer CurrentOtherContainer;
|
||||||
|
|
||||||
public AudioSource CurrentAudioSource;
|
public AudioSource CurrentAudioSource;
|
||||||
|
public AudioSource CurrentBGAudioSource;
|
||||||
|
|
||||||
public AnimatorOverrideController OverrideController;
|
public AnimatorOverrideController OverrideController;
|
||||||
|
|
||||||
|
|
||||||
@@ -353,12 +356,15 @@ public class UmaViewerBuilder : MonoBehaviour
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void LoadLiveSound(int songid, UmaDatabaseEntry SongAwb)
|
public void LoadLiveSound(int songid,UmaDatabaseEntry SongAwb)
|
||||||
{
|
{
|
||||||
if (CurrentAudioSource)
|
if (CurrentAudioSource)
|
||||||
{
|
{
|
||||||
Destroy(CurrentAudioSource.gameObject);
|
Destroy(CurrentAudioSource.gameObject);
|
||||||
|
UI.ResetPlayer();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
AudioClip clip = LoadAudio(SongAwb);
|
AudioClip clip = LoadAudio(SongAwb);
|
||||||
if (clip != null)
|
if (clip != null)
|
||||||
{
|
{
|
||||||
@@ -366,6 +372,21 @@ public class UmaViewerBuilder : MonoBehaviour
|
|||||||
CurrentAudioSource.clip = clip;
|
CurrentAudioSource.clip = clip;
|
||||||
CurrentAudioSource.Play();
|
CurrentAudioSource.Play();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
string nameVar = $"snd_bgm_live_{songid}_oke";
|
||||||
|
UmaDatabaseEntry BGawb = Main.AbList.FirstOrDefault(a => a.Name.Contains(nameVar) && a.Name.EndsWith("awb"));
|
||||||
|
if (BGawb != null)
|
||||||
|
{
|
||||||
|
AudioClip BGclip = LoadAudio(BGawb);
|
||||||
|
if (BGclip)
|
||||||
|
{
|
||||||
|
CurrentBGAudioSource = CurrentAudioSource.gameObject.AddComponent<AudioSource>();
|
||||||
|
CurrentBGAudioSource.clip = BGclip;
|
||||||
|
CurrentBGAudioSource.Play();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public AudioClip LoadAudio(UmaDatabaseEntry awb)
|
public AudioClip LoadAudio(UmaDatabaseEntry awb)
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ using System.Collections.Generic;
|
|||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using TMPro;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.UI;
|
using UnityEngine.UI;
|
||||||
|
|
||||||
@@ -33,8 +34,14 @@ public class UmaViewerUI : MonoBehaviour,FaceLoadCallBack
|
|||||||
public ScrollRect LiveSoundList;
|
public ScrollRect LiveSoundList;
|
||||||
public ScrollRect LiveCharaSoundList;
|
public ScrollRect LiveCharaSoundList;
|
||||||
|
|
||||||
|
//audios
|
||||||
|
public Slider AudioSlider;
|
||||||
|
public Button AudioPlayButton;
|
||||||
|
public TextMeshProUGUI TitleText;
|
||||||
|
public TextMeshProUGUI ProgressText;
|
||||||
|
|
||||||
//settings
|
//settings
|
||||||
public TMPro.TMP_InputField SSWidth, SSHeight;
|
public TMP_InputField SSWidth, SSHeight;
|
||||||
|
|
||||||
public List<GameObject> TogglablePanels = new List<GameObject>();
|
public List<GameObject> TogglablePanels = new List<GameObject>();
|
||||||
|
|
||||||
@@ -50,6 +57,8 @@ public class UmaViewerUI : MonoBehaviour,FaceLoadCallBack
|
|||||||
private void Awake()
|
private void Awake()
|
||||||
{
|
{
|
||||||
Instance = this;
|
Instance = this;
|
||||||
|
AudioPlayButton.onClick.AddListener(AudioPause);
|
||||||
|
AudioSlider.onValueChanged.AddListener(AudioProgressChange);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void HighlightChildImage(Transform mainObject, Image child)
|
public void HighlightChildImage(Transform mainObject, Image child)
|
||||||
@@ -154,10 +163,7 @@ public class UmaViewerUI : MonoBehaviour,FaceLoadCallBack
|
|||||||
HighlightChildImage(LiveList.content, imageInstance1);
|
HighlightChildImage(LiveList.content, imageInstance1);
|
||||||
ListLiveSounds(live.MusicId);
|
ListLiveSounds(live.MusicId);
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void LoadMiniModelPanels()
|
public void LoadMiniModelPanels()
|
||||||
@@ -279,6 +285,7 @@ public class UmaViewerUI : MonoBehaviour,FaceLoadCallBack
|
|||||||
Builder.LoadLiveSound(songid, entry);
|
Builder.LoadLiveSound(songid, entry);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
string getCharaName(string id)
|
string getCharaName(string id)
|
||||||
@@ -417,4 +424,76 @@ public class UmaViewerUI : MonoBehaviour,FaceLoadCallBack
|
|||||||
PlayerPrefs.DeleteAll();
|
PlayerPrefs.DeleteAll();
|
||||||
Application.Quit();
|
Application.Quit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void AudioPause()
|
||||||
|
{
|
||||||
|
if (Builder.CurrentAudioSource)
|
||||||
|
{
|
||||||
|
AudioSource source = Builder.CurrentAudioSource;
|
||||||
|
if (source.isPlaying)
|
||||||
|
{
|
||||||
|
source.Pause();
|
||||||
|
if (Builder.CurrentBGAudioSource)
|
||||||
|
Builder.CurrentBGAudioSource.Pause();
|
||||||
|
}
|
||||||
|
else if(source.clip)
|
||||||
|
{
|
||||||
|
source.Play();
|
||||||
|
if (Builder.CurrentBGAudioSource)
|
||||||
|
Builder.CurrentBGAudioSource.Play();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
source.Stop();
|
||||||
|
if (Builder.CurrentBGAudioSource)
|
||||||
|
Builder.CurrentBGAudioSource.Stop();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void AudioProgressChange(float val)
|
||||||
|
{
|
||||||
|
if (Builder.CurrentAudioSource)
|
||||||
|
{
|
||||||
|
AudioSource source = Builder.CurrentAudioSource;
|
||||||
|
if (Builder.CurrentAudioSource.clip)
|
||||||
|
{
|
||||||
|
source.time = source.clip.length * val;
|
||||||
|
|
||||||
|
if (Builder.CurrentBGAudioSource)
|
||||||
|
Builder.CurrentBGAudioSource.time = source.clip.length * val;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Update()
|
||||||
|
{
|
||||||
|
if (Builder.CurrentAudioSource)
|
||||||
|
{
|
||||||
|
AudioSource source = Builder.CurrentAudioSource;
|
||||||
|
if (Builder.CurrentAudioSource.clip)
|
||||||
|
{
|
||||||
|
TitleText.text = source.clip.name;
|
||||||
|
ProgressText.text = string.Format("{0} / {1}", ToTimeFormat(source.time), ToTimeFormat(source.clip.length));
|
||||||
|
AudioSlider.SetValueWithoutNotify(source.time/ source.clip.length);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void ResetPlayer()
|
||||||
|
{
|
||||||
|
TitleText.text = "No Audio";
|
||||||
|
ProgressText.text = "00:00:00 / 00:00:00";
|
||||||
|
AudioSlider.SetValueWithoutNotify(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static string ToTimeFormat(float time)
|
||||||
|
{
|
||||||
|
|
||||||
|
int seconds = (int)time;
|
||||||
|
int hour = seconds / 3600;
|
||||||
|
int minute = seconds % 3600 / 60;
|
||||||
|
seconds = seconds % 3600 % 60;
|
||||||
|
return string.Format("{0:D2}:{1:D2}:{2:D2}", hour, minute, seconds);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user