Added audio files to list of loaded assets
This commit is contained in:
@@ -1,5 +1,4 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Diagnostics;
|
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
@@ -25,13 +24,22 @@ public class UISettingsAssets : MonoBehaviour
|
|||||||
FontSize = 18,
|
FontSize = 18,
|
||||||
OnClick = (container) =>
|
OnClick = (container) =>
|
||||||
{
|
{
|
||||||
Process.Start("explorer.exe", "/select," + filePath);
|
System.Diagnostics.Process.Start("explorer.exe", "/select," + filePath);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
LoadedAssetEntries.Add(entry.Name, assetentry);
|
LoadedAssetEntries.Add(entry.Name, assetentry);
|
||||||
LoadedAssetPageCtrl.AddEntries(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()
|
public void LoadedAssetsClear()
|
||||||
{
|
{
|
||||||
LoadedAssetEntries.Clear();
|
LoadedAssetEntries.Clear();
|
||||||
|
|||||||
@@ -1,15 +1,7 @@
|
|||||||
using Gallop;
|
using System.Collections.Generic;
|
||||||
using System;
|
|
||||||
using System.Collections;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Diagnostics;
|
|
||||||
using System.IO;
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text.RegularExpressions;
|
|
||||||
using TMPro;
|
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.UI;
|
using UnityEngine.UI;
|
||||||
using Debug = UnityEngine.Debug;
|
|
||||||
|
|
||||||
public class PageManager : MonoBehaviour
|
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()
|
public void ResetCtrl()
|
||||||
{
|
{
|
||||||
totalPage = 0;
|
totalPage = 0;
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ public class UmaAssetManager : MonoBehaviour
|
|||||||
BodyBehindAlphaShader;
|
BodyBehindAlphaShader;
|
||||||
|
|
||||||
public static event Action<UmaDatabaseEntry> OnLoadedBundleUpdate;
|
public static event Action<UmaDatabaseEntry> OnLoadedBundleUpdate;
|
||||||
|
public static event Action<UmaDatabaseEntry> OnLoadedBundleRemove;
|
||||||
public static event Action OnLoadedBundleClear;
|
public static event Action OnLoadedBundleClear;
|
||||||
public static event Action<int, int, string> OnLoadProgressChange;
|
public static event Action<int, int, string> OnLoadProgressChange;
|
||||||
|
|
||||||
@@ -104,6 +105,18 @@ public class UmaAssetManager : MonoBehaviour
|
|||||||
return Get(entry);
|
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)
|
private static bool LoadAB(UmaDatabaseEntry entry, bool neverUnload = false)
|
||||||
{
|
{
|
||||||
string filePath = entry.FilePath; //downloads the file
|
string filePath = entry.FilePath; //downloads the file
|
||||||
@@ -113,29 +126,38 @@ public class UmaAssetManager : MonoBehaviour
|
|||||||
}
|
}
|
||||||
else if (File.Exists(filePath))
|
else if (File.Exists(filePath))
|
||||||
{
|
{
|
||||||
AssetBundle bundle = AssetBundle.LoadFromFile(filePath);
|
if (!entry.IsAssetBundle)
|
||||||
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)
|
|
||||||
{
|
{
|
||||||
|
//used for audio files
|
||||||
|
AddOrUpdate(entry.Name, null, neverUnload);
|
||||||
OnLoadedBundleUpdate?.Invoke(entry);
|
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
|
else
|
||||||
{
|
{
|
||||||
@@ -191,17 +213,6 @@ public class UmaAssetManager : MonoBehaviour
|
|||||||
|
|
||||||
public static bool Exist(AssetBundle bundle) => instance.LoadedBundles.ContainsValue(bundle);
|
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)
|
public static void UnloadAllBundle(bool unloadAllObjects = false)
|
||||||
{
|
{
|
||||||
foreach (var bundle in instance.LoadedBundles)
|
foreach (var bundle in instance.LoadedBundles)
|
||||||
|
|||||||
@@ -21,10 +21,8 @@ public class UmaViewerBuilder : MonoBehaviour
|
|||||||
static UmaViewerUI UI => UmaViewerUI.Instance;
|
static UmaViewerUI UI => UmaViewerUI.Instance;
|
||||||
static UISettingsModel ModelSettings => UmaViewerUI.Instance.ModelSettings;
|
static UISettingsModel ModelSettings => UmaViewerUI.Instance.ModelSettings;
|
||||||
|
|
||||||
public List<AssetBundle> Loaded;
|
|
||||||
public List<Shader> ShaderList = new List<Shader>();
|
public List<Shader> ShaderList = new List<Shader>();
|
||||||
public Material TransMaterialCharas;
|
public Material TransMaterialCharas;
|
||||||
public Material TransMaterialProps;
|
|
||||||
public UmaContainerCharacter CurrentUMAContainer;
|
public UmaContainerCharacter CurrentUMAContainer;
|
||||||
public UmaContainer CurrentOtherContainer;
|
public UmaContainer CurrentOtherContainer;
|
||||||
|
|
||||||
@@ -761,12 +759,12 @@ public class UmaViewerBuilder : MonoBehaviour
|
|||||||
public void LoadLiveSound(int songid, UmaDatabaseEntry SongAwb, bool needLyrics = true)
|
public void LoadLiveSound(int songid, UmaDatabaseEntry SongAwb, bool needLyrics = true)
|
||||||
{
|
{
|
||||||
CurrentLiveSoundAWBIndex = -1; // mix awb together
|
CurrentLiveSoundAWBIndex = -1; // mix awb together
|
||||||
CurrentLiveSoundAWB.Clear();
|
ClearLiveSounds();
|
||||||
//load character voice
|
//load character voice
|
||||||
if (SongAwb != null)
|
if (SongAwb != null)
|
||||||
{
|
{
|
||||||
PlaySound(SongAwb);
|
PlaySound(SongAwb);
|
||||||
CurrentLiveSoundAWB.Add(SongAwb);
|
AddLiveSound(SongAwb);
|
||||||
}
|
}
|
||||||
|
|
||||||
//load BG
|
//load BG
|
||||||
@@ -778,7 +776,7 @@ public class UmaViewerBuilder : MonoBehaviour
|
|||||||
if (BGclip.Count > 0)
|
if (BGclip.Count > 0)
|
||||||
{
|
{
|
||||||
AddAudioSource(BGclip[0]);
|
AddAudioSource(BGclip[0]);
|
||||||
CurrentLiveSoundAWB.Add(BGawb);
|
AddLiveSound(BGawb);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -824,8 +822,8 @@ public class UmaViewerBuilder : MonoBehaviour
|
|||||||
|
|
||||||
public void SetLastAudio(UmaDatabaseEntry AudioAwb, int index)
|
public void SetLastAudio(UmaDatabaseEntry AudioAwb, int index)
|
||||||
{
|
{
|
||||||
CurrentLiveSoundAWB.Clear();
|
ClearLiveSounds();
|
||||||
CurrentLiveSoundAWB.Add(AudioAwb);
|
AddLiveSound(AudioAwb);
|
||||||
CurrentLiveSoundAWBIndex = index;
|
CurrentLiveSoundAWBIndex = index;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1086,4 +1084,19 @@ public class UmaViewerBuilder : MonoBehaviour
|
|||||||
AnimationCamera.fieldOfView = fov;
|
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);
|
CameraSettings.AAModeDropdown.SetValueWithoutNotify(Config.Instance.AntiAliasing);
|
||||||
AssetSettings.LoadedAssetsClear();
|
AssetSettings.LoadedAssetsClear();
|
||||||
UmaAssetManager.OnLoadedBundleUpdate += AssetSettings.LoadedAssetsAdd;
|
UmaAssetManager.OnLoadedBundleUpdate += AssetSettings.LoadedAssetsAdd;
|
||||||
|
UmaAssetManager.OnLoadedBundleRemove += AssetSettings.LoadedAssetsRemove;
|
||||||
UmaAssetManager.OnLoadedBundleClear += AssetSettings.LoadedAssetsClear;
|
UmaAssetManager.OnLoadedBundleClear += AssetSettings.LoadedAssetsClear;
|
||||||
|
|
||||||
PoseManager.LoadLocalPoseFiles();
|
PoseManager.LoadLocalPoseFiles();
|
||||||
@@ -130,6 +131,7 @@ public class UmaViewerUI : MonoBehaviour
|
|||||||
private void OnDestroy()
|
private void OnDestroy()
|
||||||
{
|
{
|
||||||
UmaAssetManager.OnLoadedBundleUpdate -= AssetSettings.LoadedAssetsAdd;
|
UmaAssetManager.OnLoadedBundleUpdate -= AssetSettings.LoadedAssetsAdd;
|
||||||
|
UmaAssetManager.OnLoadedBundleRemove -= AssetSettings.LoadedAssetsRemove;
|
||||||
UmaAssetManager.OnLoadedBundleClear -= AssetSettings.LoadedAssetsClear;
|
UmaAssetManager.OnLoadedBundleClear -= AssetSettings.LoadedAssetsClear;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user