Refactor: Moved settings panels to their own classes (#89)
This should not affect any functionalities
This commit is contained in:
@@ -0,0 +1,129 @@
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class UISettingsAnimation : MonoBehaviour
|
||||
{
|
||||
static UmaViewerBuilder Builder => UmaViewerBuilder.Instance;
|
||||
|
||||
public TextMeshProUGUI TitleText;
|
||||
public TextMeshProUGUI ProgressText;
|
||||
public Slider ProgressSlider;
|
||||
public Button PlayButton;
|
||||
public TextMeshProUGUI SpeedText;
|
||||
public Slider SpeedSlider;
|
||||
public Button VMDButton;
|
||||
|
||||
internal void UpdateAnimationInfo(UmaContainerCharacter umaContainer)
|
||||
{
|
||||
if (umaContainer.OverrideController["clip_2"].name != "clip_2")
|
||||
{
|
||||
bool isLoop = umaContainer.OverrideController["clip_2"].name.Contains("_loop");
|
||||
var AnimeState = umaContainer.UmaAnimator.GetCurrentAnimatorStateInfo(0);
|
||||
var AnimeClip = umaContainer.OverrideController["clip_2"];
|
||||
if (AnimeClip && umaContainer.UmaAnimator.speed != 0)
|
||||
{
|
||||
var normalizedTime = (isLoop) ? Mathf.Repeat(AnimeState.normalizedTime, 1) : Mathf.Min(AnimeState.normalizedTime, 1);
|
||||
TitleText.text = AnimeClip.name;
|
||||
ProgressText.text = string.Format("{0} / {1}", ToFrameFormat(normalizedTime * AnimeClip.length, AnimeClip.frameRate), ToFrameFormat(AnimeClip.length, AnimeClip.frameRate));
|
||||
ProgressSlider.SetValueWithoutNotify(normalizedTime);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void Pause()
|
||||
{
|
||||
var container = Builder.CurrentUMAContainer;
|
||||
if (!container || !container.UmaAnimator) return;
|
||||
if (Builder.OverrideController.animationClips.Length == 0) return;
|
||||
|
||||
var animator = container.UmaAnimator;
|
||||
var animator_face = container.UmaFaceAnimator;
|
||||
var animator_cam = Builder.AnimationCameraAnimator;
|
||||
var AnimeState = animator.GetCurrentAnimatorStateInfo(0);
|
||||
var state = animator.speed > 0f;
|
||||
if (state)
|
||||
{
|
||||
animator.speed = 0;
|
||||
if (animator_face)
|
||||
animator_face.speed = 0;
|
||||
animator_cam.speed = 0;
|
||||
}
|
||||
else if (AnimeState.normalizedTime < 1f)
|
||||
{
|
||||
animator.speed = SpeedSlider.value;
|
||||
animator_cam.speed = SpeedSlider.value;
|
||||
if (animator_face)
|
||||
animator_face.speed = SpeedSlider.value;
|
||||
}
|
||||
else
|
||||
{
|
||||
animator.speed = SpeedSlider.value;
|
||||
animator.Play(0, 0, 0);
|
||||
animator.Play(0, 2, 0);
|
||||
animator_cam.speed = SpeedSlider.value;
|
||||
animator_cam.Play(0, -1, 0);
|
||||
if (animator_face)
|
||||
{
|
||||
animator_face.speed = SpeedSlider.value;
|
||||
animator_face.Play(0, 0, 0);
|
||||
animator_face.Play(0, 1, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void ChangeProgress(float val)
|
||||
{
|
||||
var container = Builder.CurrentUMAContainer;
|
||||
if (!container) return;
|
||||
var animator = container.UmaAnimator;
|
||||
var animator_face = container.UmaFaceAnimator;
|
||||
var animator_cam = Builder.AnimationCameraAnimator;
|
||||
if (animator != null)
|
||||
{
|
||||
var AnimeClip = container.OverrideController["clip_2"];
|
||||
|
||||
// Pause and Seek;
|
||||
animator.speed = 0;
|
||||
animator.Play(0, 0, val);
|
||||
animator.Play(0, 2, val);
|
||||
if (animator_cam.runtimeAnimatorController)
|
||||
{
|
||||
animator_cam.speed = 0;
|
||||
animator_cam.Play(0, -1, val);
|
||||
}
|
||||
if (animator_face)
|
||||
{
|
||||
animator_face.speed = 0;
|
||||
animator_face.Play(0, 0, val);
|
||||
animator_face.Play(0, 1, val);
|
||||
}
|
||||
|
||||
ProgressText.text = string.Format("{0} / {1}", ToFrameFormat(val * AnimeClip.length, AnimeClip.frameRate), ToFrameFormat(AnimeClip.length, AnimeClip.frameRate));
|
||||
}
|
||||
}
|
||||
|
||||
public void ChangeSpeed(float val)
|
||||
{
|
||||
var container = Builder.CurrentUMAContainer;
|
||||
SpeedText.text = string.Format("Speed: {0:F2}", val);
|
||||
|
||||
if (!container || !container.UmaAnimator) return;
|
||||
|
||||
container.UmaAnimator.speed = val;
|
||||
Builder.AnimationCameraAnimator.speed = val;
|
||||
if (container.UmaFaceAnimator)
|
||||
{
|
||||
container.UmaFaceAnimator.speed = val;
|
||||
}
|
||||
}
|
||||
|
||||
public static string ToFrameFormat(float time, float frameRate)
|
||||
{
|
||||
int frames = Mathf.FloorToInt(time % 1 * frameRate);
|
||||
int seconds = (int)time;
|
||||
int minute = seconds % 3600 / 60;
|
||||
seconds = seconds % 3600 % 60;
|
||||
return string.Format("{0:D2}m:{1:D2}s:{2:D2}f", minute, seconds, frames);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: bb219ac831519664dbea3c160315d0ec
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,58 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using static PageManager;
|
||||
|
||||
public class UISettingsAssets : MonoBehaviour
|
||||
{
|
||||
private Dictionary<string, Entry> LoadedAssetEntries = new Dictionary<string, Entry>();
|
||||
public PageManager LoadedAssetPageCtrl;
|
||||
public ScrollRect LoadedAssetScrollRect;
|
||||
|
||||
public void LoadedAssetsAdd(UmaDatabaseEntry entry)
|
||||
{
|
||||
if (!LoadedAssetPageCtrl) return;
|
||||
if (LoadedAssetEntries.ContainsKey(entry.Name)) return;
|
||||
var file_name = Path.GetFileName(entry.Name);
|
||||
string filePath = entry.FilePath.Replace("/", "\\");
|
||||
var assetentry = new Entry()
|
||||
{
|
||||
Name = file_name,
|
||||
FontSize = 18,
|
||||
OnClick = (container) =>
|
||||
{
|
||||
Process.Start("explorer.exe", "/select," + filePath);
|
||||
}
|
||||
};
|
||||
LoadedAssetEntries.Add(entry.Name, assetentry);
|
||||
LoadedAssetPageCtrl.AddEntries(assetentry);
|
||||
}
|
||||
|
||||
public void LoadedAssetsClear()
|
||||
{
|
||||
LoadedAssetEntries.Clear();
|
||||
if (LoadedAssetPageCtrl)
|
||||
{
|
||||
LoadedAssetPageCtrl.ResetCtrl();
|
||||
LoadedAssetPageCtrl.Initialize(LoadedAssetEntries.Values.ToList(), LoadedAssetScrollRect);
|
||||
}
|
||||
}
|
||||
|
||||
public void CopyAllLoadedAssetsPath()
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
foreach (var entry in LoadedAssetEntries.Keys)
|
||||
{
|
||||
if (UmaViewerMain.Instance.AbList.TryGetValue(entry, out var asset))
|
||||
{
|
||||
sb.AppendLine(asset.FilePath);
|
||||
}
|
||||
}
|
||||
GUIUtility.systemCopyBuffer = sb.ToString();
|
||||
UmaViewerUI.Instance.ShowMessage($"{LoadedAssetEntries.Count} Path copied", UIMessageType.Success);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 01ee252c6096dbc45a4d5bea9fc25274
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,135 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class UISettingsCamera : MonoBehaviour
|
||||
{
|
||||
public TMPro.TMP_Dropdown AAModeDropdown;
|
||||
public TMPro.TMP_Dropdown CameraModeDropdown;
|
||||
|
||||
[Header("Free Camera")]
|
||||
public GameObject FreeCameraSettingsTab;
|
||||
public Slider FOVFree;
|
||||
public Slider CameraRotationFree;
|
||||
public Slider MovementSpeedFree;
|
||||
public Slider RotationSpeedSlider;
|
||||
|
||||
[Header("Orbit Camera")]
|
||||
public GameObject OrbitCameraSettingsTab;
|
||||
public Slider FOVOrbit;
|
||||
public Slider CameraDistance;
|
||||
public Slider CameraHeightSlider;
|
||||
public Slider CameraRotationOrbit;
|
||||
public Slider TargetHeightSlider;
|
||||
public Slider ZoomSpeedSlider;
|
||||
public Slider MovementSpeedOrbit;
|
||||
|
||||
[Space]
|
||||
public Toggle UseAnimationCamera;
|
||||
|
||||
public int CameraMode
|
||||
{
|
||||
get { return CameraModeDropdown.value; }
|
||||
set { CameraModeDropdown.value = value; UpdateSettingsPanel(); }
|
||||
}
|
||||
|
||||
public float FOV
|
||||
{
|
||||
get { return CameraMode == 0 ? FOVOrbit.value : FOVFree.value; }
|
||||
set {
|
||||
if (CameraMode == 0)
|
||||
{
|
||||
FOVOrbit.value = value;
|
||||
}
|
||||
else
|
||||
{
|
||||
FOVFree.value = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public float CameraRotation
|
||||
{
|
||||
get { return CameraMode == 0 ? CameraRotationOrbit.value : CameraRotationFree.value; }
|
||||
set
|
||||
{
|
||||
if (CameraMode == 0)
|
||||
{
|
||||
CameraRotationOrbit.value = value;
|
||||
}
|
||||
else
|
||||
{
|
||||
CameraRotationFree.value = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public float ZoomSpeed
|
||||
{
|
||||
get { return ZoomSpeedSlider.value; }
|
||||
set { ZoomSpeedSlider.value = value; }
|
||||
}
|
||||
|
||||
public float MovementSpeed
|
||||
{
|
||||
get { return CameraMode == 0 ? MovementSpeedOrbit.value : MovementSpeedFree.value; }
|
||||
set
|
||||
{
|
||||
if (CameraMode == 0)
|
||||
{
|
||||
MovementSpeedOrbit.value = value;
|
||||
}
|
||||
else
|
||||
{
|
||||
MovementSpeedFree.value = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public float RotationSpeed
|
||||
{
|
||||
get { return RotationSpeedSlider.value; }
|
||||
set { RotationSpeedSlider.value = value; }
|
||||
}
|
||||
|
||||
public float CameraHeight
|
||||
{
|
||||
get { return CameraHeightSlider.value; }
|
||||
set { CameraHeightSlider.value = value; }
|
||||
}
|
||||
|
||||
public float TargetHeight
|
||||
{
|
||||
get { return TargetHeightSlider.value; }
|
||||
set { TargetHeightSlider.value = value; }
|
||||
}
|
||||
|
||||
public void UpdateSettingsPanel()
|
||||
{
|
||||
if (CameraMode == 0)
|
||||
{
|
||||
OrbitCameraSettingsTab.SetActive(true);
|
||||
FreeCameraSettingsTab.SetActive(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
FreeCameraSettingsTab.SetActive(true);
|
||||
OrbitCameraSettingsTab.SetActive(false);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary> Converts values 1-4 to valid AA values </summary>
|
||||
public void ChangeAntiAliasing(int value)
|
||||
{
|
||||
int[] aaValues = { 0, 2, 4, 8 };
|
||||
|
||||
QualitySettings.antiAliasing = aaValues[value];
|
||||
|
||||
if (Config.Instance.AntiAliasing != value)
|
||||
{
|
||||
Config.Instance.AntiAliasing = value;
|
||||
Config.Instance.UpdateConfig(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0d1f60c359f123945a317ebc3a71d7d3
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,73 @@
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class UISettingsEnvironment : MonoBehaviour
|
||||
{
|
||||
public ScrollRect BackGroundList;
|
||||
public PageManager BackGroundPageCtrl;
|
||||
public GameObject BG_Canvas;
|
||||
public GameObject BG_HSVPickerObj;
|
||||
public Image BG_Image;
|
||||
|
||||
static UmaViewerMain Main => UmaViewerMain.Instance;
|
||||
static UmaViewerBuilder Builder => UmaViewerBuilder.Instance;
|
||||
|
||||
public void ChangeBackground(int index)
|
||||
{
|
||||
BackGroundPageCtrl.ResetCtrl();
|
||||
switch (index)
|
||||
{
|
||||
case 0:
|
||||
Camera.main.clearFlags = CameraClearFlags.Skybox;
|
||||
break;
|
||||
case 1:
|
||||
Camera.main.clearFlags = CameraClearFlags.SolidColor;
|
||||
break;
|
||||
case 2:
|
||||
Camera.main.clearFlags = CameraClearFlags.SolidColor;
|
||||
ListBackgrounds();
|
||||
break;
|
||||
default:
|
||||
Camera.main.clearFlags = CameraClearFlags.Skybox;
|
||||
break;
|
||||
}
|
||||
|
||||
BG_HSVPickerObj.SetActive(index != 2);
|
||||
BG_Canvas.SetActive(index == 2);
|
||||
BackGroundPageCtrl.transform.parent.gameObject.SetActive(index == 2);
|
||||
}
|
||||
|
||||
public void ChangeBackgroundColor(Color color)
|
||||
{
|
||||
Camera.main.backgroundColor = color;
|
||||
}
|
||||
|
||||
void ListBackgrounds()
|
||||
{
|
||||
var pageentrys = new List<PageManager.Entry>();
|
||||
foreach (var entry in Main.AbList.Where(a => a.Key.StartsWith("bg/bg")))
|
||||
{
|
||||
var pageentry = new PageManager.Entry();
|
||||
pageentry.Name = Path.GetFileName(entry.Key);
|
||||
pageentry.Sprite = Builder.LoadSprite(entry.Value);
|
||||
if (pageentry.Sprite == null) continue;
|
||||
pageentry.OnClick = (container) =>
|
||||
{
|
||||
UmaViewerUI.Instance.HighlightChildImage(BackGroundList.content, container);
|
||||
BG_Image.sprite = pageentry.Sprite;
|
||||
BG_Image.SetVerticesDirty();
|
||||
};
|
||||
|
||||
if (BG_Image.sprite == null)
|
||||
{
|
||||
BG_Image.sprite = pageentry.Sprite;
|
||||
BG_Image.SetVerticesDirty();
|
||||
}
|
||||
pageentrys.Add(pageentry);
|
||||
}
|
||||
BackGroundPageCtrl.Initialize(pageentrys, BackGroundList);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 463147a12f484cc4dbe150fb97b22392
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,112 @@
|
||||
using SFB;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class UISettingsModel : MonoBehaviour
|
||||
{
|
||||
static UmaViewerBuilder Builder => UmaViewerBuilder.Instance;
|
||||
|
||||
[SerializeField] private Toggle _lockCharacter;
|
||||
[SerializeField] private Toggle _openWithTPose;
|
||||
[SerializeField] private Toggle _enablePhysics;
|
||||
[SerializeField] private Toggle _lookAtCamera;
|
||||
[SerializeField] private Toggle _faceOverride;
|
||||
[SerializeField] private Slider _outlineWidthSlider;
|
||||
|
||||
public ScrollRect MaterialsList;
|
||||
|
||||
private bool
|
||||
_isHeadFix,
|
||||
_isTPose,
|
||||
_dynamicBoneEnable = true,
|
||||
_enableEyeTracking = true,
|
||||
_enableFaceOverride = true;
|
||||
|
||||
private float _outlineWidth;
|
||||
|
||||
public bool IsHeadFix
|
||||
{
|
||||
get { return _isHeadFix; }
|
||||
set { _lockCharacter.SetIsOnWithoutNotify(value); SetHeadFix(value); }
|
||||
}
|
||||
|
||||
public bool IsTPose
|
||||
{
|
||||
get { return _isTPose; }
|
||||
set { _openWithTPose.SetIsOnWithoutNotify(value); SetTPose(value); }
|
||||
}
|
||||
|
||||
public bool DynamicBoneEnable
|
||||
{
|
||||
get { return _dynamicBoneEnable; }
|
||||
set { _enablePhysics.SetIsOnWithoutNotify(value); SetDynamicBoneEnable(value); }
|
||||
}
|
||||
|
||||
public bool EnableEyeTracking
|
||||
{
|
||||
get { return _enableEyeTracking; }
|
||||
set { _lookAtCamera.SetIsOnWithoutNotify(value); SetEyeTrackingEnable(value); }
|
||||
}
|
||||
|
||||
public bool EnableFaceOverride
|
||||
{
|
||||
get { return _enableFaceOverride; }
|
||||
set { _faceOverride.SetIsOnWithoutNotify(value); SetFaceOverrideEnable(value); }
|
||||
}
|
||||
|
||||
public float OutlineWidth
|
||||
{
|
||||
get { return _outlineWidth; }
|
||||
set { _outlineWidthSlider.value = value; }
|
||||
}
|
||||
|
||||
public void SetHeadFix(bool value)
|
||||
{
|
||||
_isHeadFix = value;
|
||||
}
|
||||
|
||||
public void SetTPose(bool value)
|
||||
{
|
||||
_isTPose = value;
|
||||
}
|
||||
|
||||
public void SetDynamicBoneEnable(bool isOn)
|
||||
{
|
||||
_dynamicBoneEnable = isOn;
|
||||
Builder.CurrentUMAContainer?.SetDynamicBoneEnable(isOn);
|
||||
}
|
||||
|
||||
public void SetEyeTrackingEnable(bool isOn)
|
||||
{
|
||||
_enableEyeTracking = isOn;
|
||||
Builder.CurrentUMAContainer?.SetEyeTracking(isOn);
|
||||
}
|
||||
|
||||
public void SetFaceOverrideEnable(bool isOn)
|
||||
{
|
||||
_enableFaceOverride = isOn;
|
||||
Builder.CurrentUMAContainer?.SetFaceOverrideData(isOn);
|
||||
}
|
||||
|
||||
public void ChangeOutlineWidth(float val)
|
||||
{
|
||||
_outlineWidth = val;
|
||||
Shader.SetGlobalFloat("_GlobalOutlineWidth", val);
|
||||
}
|
||||
|
||||
public void ExportModel()
|
||||
{
|
||||
#if !UNITY_ANDROID || UNITY_EDITOR
|
||||
var container = Builder.CurrentUMAContainer;
|
||||
if (container)
|
||||
{
|
||||
var entry = container.CharaEntry;
|
||||
var path = StandaloneFileBrowser.SaveFilePanel("Save PMX File", Config.Instance.MainPath, $"{entry.Id}_{entry.GetName()}", "pmx");
|
||||
if (!string.IsNullOrEmpty(path))
|
||||
{
|
||||
ModelExporter.ExportModel(container, path);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f61fc8a1e0ca2cf49a9f794b613665f0
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,95 @@
|
||||
#if !UNITY_ANDROID || UNITY_EDITOR
|
||||
using SFB;
|
||||
#endif
|
||||
|
||||
using System.Collections;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class UISettingsOther : MonoBehaviour
|
||||
{
|
||||
public Button UpdateDBButton;
|
||||
public TMP_Dropdown RegionDropdown;
|
||||
public TMP_Dropdown WorkModeDropdown;
|
||||
public TMP_Dropdown LanguageDropdown;
|
||||
private IEnumerator _updateResVerCoroutine;
|
||||
|
||||
public void ApplySettings()
|
||||
{
|
||||
WorkModeDropdown.SetValueWithoutNotify((int)Config.Instance.WorkMode);
|
||||
RegionDropdown.SetValueWithoutNotify((int)Config.Instance.Region);
|
||||
LanguageDropdown.SetValueWithoutNotify((int)Config.Instance.Language);
|
||||
UpdateDBButton.interactable = (Config.Instance.WorkMode == WorkMode.Standalone);
|
||||
}
|
||||
|
||||
public void ChangeLanguage(int lang)
|
||||
{
|
||||
if ((int)Config.Instance.Language != lang)
|
||||
{
|
||||
Config.Instance.Language = (Language)lang;
|
||||
Config.Instance.UpdateConfig(true);
|
||||
}
|
||||
}
|
||||
|
||||
public void ChangeRegion(int region)
|
||||
{
|
||||
if ((int)Config.Instance.Region != region)
|
||||
{
|
||||
Config.Instance.Region = (Region)region;
|
||||
Config.Instance.UpdateConfig(false);
|
||||
StartCoroutine(UmaViewerUI.Instance.ApplyGraphicsSettings());
|
||||
}
|
||||
}
|
||||
|
||||
public void ChangeWorkMode(int mode)
|
||||
{
|
||||
if ((int)Config.Instance.WorkMode != mode)
|
||||
{
|
||||
Config.Instance.WorkMode = (WorkMode)mode;
|
||||
Config.Instance.UpdateConfig(true);
|
||||
}
|
||||
}
|
||||
|
||||
public void UpdateGameDB()
|
||||
{
|
||||
if (_updateResVerCoroutine != null && Config.Instance.WorkMode != WorkMode.Standalone) return;
|
||||
UmaDatabaseController.Instance.CloseAllConnection();
|
||||
ManifestDB dB = new ManifestDB();
|
||||
_updateResVerCoroutine = dB.UpdateResourceVersion(delegate (string msg, UIMessageType type) { UmaViewerUI.Instance.ShowMessage(msg, type); });
|
||||
StartCoroutine(_updateResVerCoroutine);
|
||||
}
|
||||
|
||||
public void ChangeDataPath()
|
||||
{
|
||||
#if !UNITY_ANDROID || UNITY_EDITOR
|
||||
var path = StandaloneFileBrowser.OpenFolderPanel("Select Folder", Config.Instance.MainPath, false);
|
||||
if (path != null && path.Length > 0 && !string.IsNullOrEmpty(path[0]))
|
||||
{
|
||||
if (path[0] != Config.Instance.MainPath)
|
||||
{
|
||||
Config.Instance.MainPath = path[0];
|
||||
Config.Instance.UpdateConfig(true);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
public void OpenConfig()
|
||||
{
|
||||
#if !UNITY_ANDROID || UNITY_EDITOR
|
||||
if (File.Exists(Config.configPath))
|
||||
{
|
||||
Process.Start(new ProcessStartInfo()
|
||||
{
|
||||
FileName = Config.configPath,
|
||||
UseShellExecute = true
|
||||
});
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
public void UnloadAllBundle() => UmaAssetManager.UnloadAllBundle(true);
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 49e773074de12594e9980542be5a673b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,22 @@
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class UISettingsScreenshot : MonoBehaviour
|
||||
{
|
||||
public TMP_InputField _width;
|
||||
public TMP_InputField _height;
|
||||
public Toggle _transparent;
|
||||
public TMP_InputField _gifWidth;
|
||||
public TMP_InputField _gifHeight;
|
||||
public Toggle _gifTransparent;
|
||||
public Button GifButton;
|
||||
|
||||
public int Width => int.Parse(_width.text);
|
||||
public int Height => int.Parse(_height.text);
|
||||
public bool Transparent => _transparent.isOn;
|
||||
|
||||
public int GifWidth => int.Parse(_gifWidth.text);
|
||||
public int GifHeight => int.Parse(_gifHeight.text);
|
||||
public bool GifTransparent => _gifTransparent.isOn;
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0ac07fd922c37624db9cca1147588e2c
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,89 @@
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class UISettingsSound : MonoBehaviour
|
||||
{
|
||||
static UmaViewerBuilder Builder => UmaViewerBuilder.Instance;
|
||||
|
||||
public TextMeshProUGUI TitleText;
|
||||
public TextMeshProUGUI ProgressText;
|
||||
public Slider ProgressSlider;
|
||||
public Button PlayButton;
|
||||
public Text LyricsText;
|
||||
|
||||
internal void UpdateTrack(AudioSource mianSource)
|
||||
{
|
||||
TitleText.text = mianSource.clip.name;
|
||||
ProgressText.text = string.Format("{0} / {1}", ToTimeFormat(mianSource.time), ToTimeFormat(mianSource.clip.length));
|
||||
ProgressSlider.SetValueWithoutNotify(mianSource.time / mianSource.clip.length);
|
||||
LyricsText.text = UmaUtility.GetCurrentLyrics(mianSource.time, UmaViewerBuilder.Instance.CurrentLyrics);
|
||||
LyricsText.text = LyricsText.text;
|
||||
}
|
||||
|
||||
public void PauseAudio()
|
||||
{
|
||||
var sources = Builder.CurrentAudioSources;
|
||||
if (sources.Count > 0)
|
||||
{
|
||||
AudioSource MainSource = sources[0];
|
||||
var state = MainSource.isPlaying;
|
||||
foreach (AudioSource source in sources)
|
||||
{
|
||||
if (state)
|
||||
{
|
||||
source.Pause();
|
||||
}
|
||||
else if (source.clip)
|
||||
{
|
||||
source.Play();
|
||||
}
|
||||
else
|
||||
{
|
||||
source.Stop();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void StopAudio()
|
||||
{
|
||||
var sources = Builder.CurrentAudioSources;
|
||||
foreach (AudioSource source in sources)
|
||||
{
|
||||
source.Stop();
|
||||
}
|
||||
}
|
||||
|
||||
public void ResetPlayer()
|
||||
{
|
||||
TitleText.text = "No Audio";
|
||||
ProgressText.text = "00:00:00 / 00:00:00";
|
||||
ProgressSlider.SetValueWithoutNotify(0);
|
||||
LyricsText.text = "";
|
||||
}
|
||||
|
||||
public void AudioProgressChange(float val)
|
||||
{
|
||||
if (Builder.CurrentAudioSources.Count > 0)
|
||||
{
|
||||
var time = Builder.CurrentAudioSources[0].clip.length * val;
|
||||
foreach (AudioSource source in Builder.CurrentAudioSources)
|
||||
{
|
||||
if (source.clip)
|
||||
{
|
||||
source.time = Mathf.Clamp(time, 0, source.clip.length);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 85575792b20387a409179c22b616f5f2
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user