Added audio files to list of loaded assets
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
@@ -25,13 +24,22 @@ public class UISettingsAssets : MonoBehaviour
|
||||
FontSize = 18,
|
||||
OnClick = (container) =>
|
||||
{
|
||||
Process.Start("explorer.exe", "/select," + filePath);
|
||||
System.Diagnostics.Process.Start("explorer.exe", "/select," + filePath);
|
||||
}
|
||||
};
|
||||
LoadedAssetEntries.Add(entry.Name, assetentry);
|
||||
LoadedAssetPageCtrl.AddEntries(assetentry);
|
||||
}
|
||||
|
||||
public void LoadedAssetsRemove(UmaDatabaseEntry entry)
|
||||
{
|
||||
if (!LoadedAssetPageCtrl) return;
|
||||
if (!LoadedAssetEntries.ContainsKey(entry.Name)) return;
|
||||
var pageEntry = LoadedAssetEntries[entry.Name];
|
||||
LoadedAssetEntries.Remove(entry.Name);
|
||||
LoadedAssetPageCtrl.RemoveEntry(pageEntry);
|
||||
}
|
||||
|
||||
public void LoadedAssetsClear()
|
||||
{
|
||||
LoadedAssetEntries.Clear();
|
||||
|
||||
@@ -1,15 +1,7 @@
|
||||
using Gallop;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text.RegularExpressions;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using Debug = UnityEngine.Debug;
|
||||
|
||||
public class PageManager : MonoBehaviour
|
||||
{
|
||||
@@ -61,6 +53,25 @@ public class PageManager : MonoBehaviour
|
||||
}
|
||||
}
|
||||
|
||||
public void RemoveEntry(Entry entry)
|
||||
{
|
||||
if (!ScrollRect) return;
|
||||
|
||||
if (SearchText)
|
||||
SearchText.text = "";
|
||||
Entries.Remove(entry);
|
||||
totalPage = Mathf.CeilToInt(Entries.Count / (float)ShowCount);
|
||||
if (currentPage > totalPage - 1)
|
||||
{
|
||||
currentPage = Mathf.Max(totalPage - 1, 0);
|
||||
LoadPage(currentPage);
|
||||
}
|
||||
else
|
||||
{
|
||||
((Text)PageText.placeholder).text = $"{currentPage + 1} / {totalPage}";
|
||||
}
|
||||
}
|
||||
|
||||
public void ResetCtrl()
|
||||
{
|
||||
totalPage = 0;
|
||||
|
||||
@@ -23,6 +23,7 @@ public class UmaAssetManager : MonoBehaviour
|
||||
BodyBehindAlphaShader;
|
||||
|
||||
public static event Action<UmaDatabaseEntry> OnLoadedBundleUpdate;
|
||||
public static event Action<UmaDatabaseEntry> OnLoadedBundleRemove;
|
||||
public static event Action OnLoadedBundleClear;
|
||||
public static event Action<int, int, string> OnLoadProgressChange;
|
||||
|
||||
@@ -104,6 +105,18 @@ public class UmaAssetManager : MonoBehaviour
|
||||
return Get(entry);
|
||||
}
|
||||
|
||||
public static void UnloadAssetBundle(UmaDatabaseEntry entry, bool unloadAllObjects)
|
||||
{
|
||||
if (instance.NeverUnload.ContainsKey(entry.Name) || !instance.LoadedBundles.ContainsKey(entry.Name)) return;
|
||||
var bundle = instance.LoadedBundles[entry.Name];
|
||||
if(bundle != null)
|
||||
{
|
||||
bundle.Unload(unloadAllObjects);
|
||||
}
|
||||
instance.LoadedBundles.Remove(entry.Name);
|
||||
OnLoadedBundleRemove.Invoke(entry);
|
||||
}
|
||||
|
||||
private static bool LoadAB(UmaDatabaseEntry entry, bool neverUnload = false)
|
||||
{
|
||||
string filePath = entry.FilePath; //downloads the file
|
||||
@@ -113,29 +126,38 @@ public class UmaAssetManager : MonoBehaviour
|
||||
}
|
||||
else if (File.Exists(filePath))
|
||||
{
|
||||
AssetBundle bundle = AssetBundle.LoadFromFile(filePath);
|
||||
if (!bundle)
|
||||
{
|
||||
Debug.Log(filePath + " exists and doesn't work");
|
||||
UmaViewerUI.Instance?.ShowMessage(filePath + " exists and doesn't work", UIMessageType.Error);
|
||||
}
|
||||
if (bundle.name == "shader.a")
|
||||
{
|
||||
neverUnload = true;
|
||||
EyeShader = (Shader)bundle.LoadAsset("assets/_gallop/resources/shader/3d/character/charactertooneyet.shader");
|
||||
FaceShader = (Shader)bundle.LoadAsset("assets/_gallop/resources/shader/3d/character/charactertoonfacetser.shader");
|
||||
HairShader = (Shader)bundle.LoadAsset("assets/_gallop/resources/shader/3d/character/charactertoonhairtser.shader");
|
||||
AlphaShader = (Shader)bundle.LoadAsset("assets/_gallop/resources/shader/3d/character/characteralphanolinetoonhairtser.shader");
|
||||
CheekShader = (Shader)bundle.LoadAsset("assets/_gallop/resources/shader/3d/character/charactermultiplycheek.shader");
|
||||
EyebrowShader = (Shader)bundle.LoadAsset("assets/_gallop/resources/shader/3d/character/charactertoonmayu.shader");
|
||||
BodyAlphaShader = (Shader)bundle.LoadAsset("assets/_gallop/resources/shader/3d/character/characteralphanolinetoontser.shader");
|
||||
BodyBehindAlphaShader = (Shader)bundle.LoadAsset("assets/_gallop/resources/shader/3d/character/characteralphanolinetoonbehindtser.shader");
|
||||
}
|
||||
AddOrUpdate(entry.Name, bundle, neverUnload);
|
||||
if (!neverUnload)
|
||||
if (!entry.IsAssetBundle)
|
||||
{
|
||||
//used for audio files
|
||||
AddOrUpdate(entry.Name, null, neverUnload);
|
||||
OnLoadedBundleUpdate?.Invoke(entry);
|
||||
}
|
||||
else
|
||||
{
|
||||
AssetBundle bundle = AssetBundle.LoadFromFile(filePath);
|
||||
if (!bundle)
|
||||
{
|
||||
Debug.Log(filePath + " exists and doesn't work");
|
||||
UmaViewerUI.Instance?.ShowMessage(filePath + " exists and doesn't work", UIMessageType.Error);
|
||||
}
|
||||
if (bundle.name == "shader.a")
|
||||
{
|
||||
neverUnload = true;
|
||||
EyeShader = (Shader)bundle.LoadAsset("assets/_gallop/resources/shader/3d/character/charactertooneyet.shader");
|
||||
FaceShader = (Shader)bundle.LoadAsset("assets/_gallop/resources/shader/3d/character/charactertoonfacetser.shader");
|
||||
HairShader = (Shader)bundle.LoadAsset("assets/_gallop/resources/shader/3d/character/charactertoonhairtser.shader");
|
||||
AlphaShader = (Shader)bundle.LoadAsset("assets/_gallop/resources/shader/3d/character/characteralphanolinetoonhairtser.shader");
|
||||
CheekShader = (Shader)bundle.LoadAsset("assets/_gallop/resources/shader/3d/character/charactermultiplycheek.shader");
|
||||
EyebrowShader = (Shader)bundle.LoadAsset("assets/_gallop/resources/shader/3d/character/charactertoonmayu.shader");
|
||||
BodyAlphaShader = (Shader)bundle.LoadAsset("assets/_gallop/resources/shader/3d/character/characteralphanolinetoontser.shader");
|
||||
BodyBehindAlphaShader = (Shader)bundle.LoadAsset("assets/_gallop/resources/shader/3d/character/characteralphanolinetoonbehindtser.shader");
|
||||
}
|
||||
AddOrUpdate(entry.Name, bundle, neverUnload);
|
||||
if (!neverUnload)
|
||||
{
|
||||
OnLoadedBundleUpdate?.Invoke(entry);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -191,17 +213,6 @@ public class UmaAssetManager : MonoBehaviour
|
||||
|
||||
public static bool Exist(AssetBundle bundle) => instance.LoadedBundles.ContainsValue(bundle);
|
||||
|
||||
private static void UnloadBundle(AssetBundle bundle, bool unloadAllObjects)
|
||||
{
|
||||
if (instance.NeverUnload.ContainsValue(bundle)) return;
|
||||
var entry = instance.LoadedBundles.FirstOrDefault(b => b.Value == bundle);
|
||||
if (entry.Key != null)
|
||||
{
|
||||
instance.LoadedBundles.Remove(entry.Key);
|
||||
}
|
||||
bundle.Unload(unloadAllObjects);
|
||||
}
|
||||
|
||||
public static void UnloadAllBundle(bool unloadAllObjects = false)
|
||||
{
|
||||
foreach (var bundle in instance.LoadedBundles)
|
||||
|
||||
@@ -21,10 +21,8 @@ public class UmaViewerBuilder : MonoBehaviour
|
||||
static UmaViewerUI UI => UmaViewerUI.Instance;
|
||||
static UISettingsModel ModelSettings => UmaViewerUI.Instance.ModelSettings;
|
||||
|
||||
public List<AssetBundle> Loaded;
|
||||
public List<Shader> ShaderList = new List<Shader>();
|
||||
public Material TransMaterialCharas;
|
||||
public Material TransMaterialProps;
|
||||
public UmaContainerCharacter CurrentUMAContainer;
|
||||
public UmaContainer CurrentOtherContainer;
|
||||
|
||||
@@ -761,12 +759,12 @@ public class UmaViewerBuilder : MonoBehaviour
|
||||
public void LoadLiveSound(int songid, UmaDatabaseEntry SongAwb, bool needLyrics = true)
|
||||
{
|
||||
CurrentLiveSoundAWBIndex = -1; // mix awb together
|
||||
CurrentLiveSoundAWB.Clear();
|
||||
ClearLiveSounds();
|
||||
//load character voice
|
||||
if (SongAwb != null)
|
||||
{
|
||||
PlaySound(SongAwb);
|
||||
CurrentLiveSoundAWB.Add(SongAwb);
|
||||
AddLiveSound(SongAwb);
|
||||
}
|
||||
|
||||
//load BG
|
||||
@@ -778,7 +776,7 @@ public class UmaViewerBuilder : MonoBehaviour
|
||||
if (BGclip.Count > 0)
|
||||
{
|
||||
AddAudioSource(BGclip[0]);
|
||||
CurrentLiveSoundAWB.Add(BGawb);
|
||||
AddLiveSound(BGawb);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -824,8 +822,8 @@ public class UmaViewerBuilder : MonoBehaviour
|
||||
|
||||
public void SetLastAudio(UmaDatabaseEntry AudioAwb, int index)
|
||||
{
|
||||
CurrentLiveSoundAWB.Clear();
|
||||
CurrentLiveSoundAWB.Add(AudioAwb);
|
||||
ClearLiveSounds();
|
||||
AddLiveSound(AudioAwb);
|
||||
CurrentLiveSoundAWBIndex = index;
|
||||
}
|
||||
|
||||
@@ -1086,4 +1084,19 @@ public class UmaViewerBuilder : MonoBehaviour
|
||||
AnimationCamera.fieldOfView = fov;
|
||||
}
|
||||
}
|
||||
|
||||
private void AddLiveSound(UmaDatabaseEntry entry)
|
||||
{
|
||||
UmaAssetManager.LoadAssetBundle(entry, false, false);
|
||||
CurrentLiveSoundAWB.Add(entry);
|
||||
}
|
||||
|
||||
private void ClearLiveSounds()
|
||||
{
|
||||
foreach (var liveSound in CurrentLiveSoundAWB)
|
||||
{
|
||||
UmaAssetManager.UnloadAssetBundle(liveSound, true);
|
||||
}
|
||||
CurrentLiveSoundAWB.Clear();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -118,6 +118,7 @@ public class UmaViewerUI : MonoBehaviour
|
||||
CameraSettings.AAModeDropdown.SetValueWithoutNotify(Config.Instance.AntiAliasing);
|
||||
AssetSettings.LoadedAssetsClear();
|
||||
UmaAssetManager.OnLoadedBundleUpdate += AssetSettings.LoadedAssetsAdd;
|
||||
UmaAssetManager.OnLoadedBundleRemove += AssetSettings.LoadedAssetsRemove;
|
||||
UmaAssetManager.OnLoadedBundleClear += AssetSettings.LoadedAssetsClear;
|
||||
|
||||
PoseManager.LoadLocalPoseFiles();
|
||||
@@ -130,6 +131,7 @@ public class UmaViewerUI : MonoBehaviour
|
||||
private void OnDestroy()
|
||||
{
|
||||
UmaAssetManager.OnLoadedBundleUpdate -= AssetSettings.LoadedAssetsAdd;
|
||||
UmaAssetManager.OnLoadedBundleRemove -= AssetSettings.LoadedAssetsRemove;
|
||||
UmaAssetManager.OnLoadedBundleClear -= AssetSettings.LoadedAssetsClear;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user