Loaded assets can now be copied to a selected folder
This commit is contained in:
@@ -1,7 +1,9 @@
|
|||||||
|
#if !UNITY_ANDROID || UNITY_EDITOR
|
||||||
|
using SFB;
|
||||||
|
#endif
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.UI;
|
using UnityEngine.UI;
|
||||||
using static PageManager;
|
using static PageManager;
|
||||||
@@ -50,17 +52,57 @@ public class UISettingsAssets : MonoBehaviour
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void CopyAllLoadedAssetsPath()
|
public void CopyAllLoadedAssets()
|
||||||
{
|
{
|
||||||
StringBuilder sb = new StringBuilder();
|
#if !UNITY_ANDROID || UNITY_EDITOR
|
||||||
foreach (var entry in LoadedAssetEntries.Keys)
|
var path = StandaloneFileBrowser.OpenFolderPanel("Select Folder", Config.Instance.MainPath, false);
|
||||||
|
if (path != null && path.Length > 0 && !string.IsNullOrEmpty(path[0]))
|
||||||
{
|
{
|
||||||
if (UmaViewerMain.Instance.AbList.TryGetValue(entry, out var asset))
|
foreach (var entry in LoadedAssetEntries.Keys)
|
||||||
{
|
{
|
||||||
sb.AppendLine(asset.FilePath);
|
if (!UmaViewerMain.Instance.AbList.TryGetValue(entry, out var asset)) continue;
|
||||||
|
|
||||||
|
var outName = Path.Combine(path[0], asset.Name);
|
||||||
|
if (File.Exists(asset.FilePath) && !File.Exists(outName))
|
||||||
|
{
|
||||||
|
Directory.CreateDirectory(Path.GetDirectoryName(outName));
|
||||||
|
File.Copy(asset.FilePath, outName);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
UmaViewerUI.Instance.ShowMessage($"{LoadedAssetEntries.Count} files copied", UIMessageType.Success);
|
||||||
}
|
}
|
||||||
GUIUtility.systemCopyBuffer = sb.ToString();
|
#else
|
||||||
UmaViewerUI.Instance.ShowMessage($"{LoadedAssetEntries.Count} Path copied", UIMessageType.Success);
|
UmaViewerUI.Instance.ShowMessage("Not supported on this platform", UIMessageType.Warning);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
public void CopyCurrentUmaAssets()
|
||||||
|
{
|
||||||
|
#if !UNITY_ANDROID || UNITY_EDITOR
|
||||||
|
if(UmaViewerBuilder.Instance.CurrentUMAContainer == null)
|
||||||
|
{
|
||||||
|
UmaViewerUI.Instance.ShowMessage("No Umamusume loaded", UIMessageType.Warning);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var assets = UmaViewerBuilder.Instance.CurrentUMAContainer.GetAssetsList();
|
||||||
|
|
||||||
|
var path = StandaloneFileBrowser.OpenFolderPanel("Select Folder", Config.Instance.MainPath, false);
|
||||||
|
if (path != null && path.Length > 0 && !string.IsNullOrEmpty(path[0]))
|
||||||
|
{
|
||||||
|
foreach (var asset in assets)
|
||||||
|
{
|
||||||
|
var outName = Path.Combine(path[0], asset.Name);
|
||||||
|
if (File.Exists(asset.FilePath) && !File.Exists(outName))
|
||||||
|
{
|
||||||
|
Directory.CreateDirectory(Path.GetDirectoryName(outName));
|
||||||
|
File.Copy(asset.FilePath, outName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
UmaViewerUI.Instance.ShowMessage($"{assets.Count} files copied", UIMessageType.Success);
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
UmaViewerUI.Instance.ShowMessage("Not supported on this platform", UIMessageType.Warning);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -110,6 +110,8 @@ public class UISettingsModel : MonoBehaviour
|
|||||||
ModelExporter.ExportModel(container, path);
|
ModelExporter.ExportModel(container, path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
UmaViewerUI.Instance.ShowMessage("Not supported on this platform", UIMessageType.Warning);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -74,6 +74,8 @@ public class UISettingsOther : MonoBehaviour
|
|||||||
Config.Instance.UpdateConfig(true);
|
Config.Instance.UpdateConfig(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
UmaViewerUI.Instance.ShowMessage("Not supported on this platform", UIMessageType.Warning);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -88,6 +90,8 @@ public class UISettingsOther : MonoBehaviour
|
|||||||
UseShellExecute = true
|
UseShellExecute = true
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
UmaViewerUI.Instance.ShowMessage("Not supported on this platform", UIMessageType.Warning);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -91,6 +91,8 @@ public class UISettingsSound : MonoBehaviour
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
UmaViewerUI.Instance.ShowMessage("Not supported on this platform", UIMessageType.Warning);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ public class UmaAssetManager : MonoBehaviour
|
|||||||
List<UmaDatabaseEntry> result = new List<UmaDatabaseEntry>();
|
List<UmaDatabaseEntry> result = new List<UmaDatabaseEntry>();
|
||||||
foreach (var entry in entries)
|
foreach (var entry in entries)
|
||||||
{
|
{
|
||||||
SearchAB(Main, entry, ref result);
|
result.AddRange(SearchAB(Main, entry));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Config.Instance.WorkMode == WorkMode.Standalone)
|
if (Config.Instance.WorkMode == WorkMode.Standalone)
|
||||||
@@ -92,13 +92,11 @@ public class UmaAssetManager : MonoBehaviour
|
|||||||
if (isRecursive)
|
if (isRecursive)
|
||||||
{
|
{
|
||||||
var Main = UmaViewerMain.Instance;
|
var Main = UmaViewerMain.Instance;
|
||||||
List<UmaDatabaseEntry> result = new List<UmaDatabaseEntry>();
|
foreach (var e in SearchAB(Main, entry))
|
||||||
SearchAB(Main, entry, ref result);
|
|
||||||
foreach (var e in result)
|
|
||||||
{
|
{
|
||||||
LoadAB(e, neverUnload);
|
LoadAB(e, neverUnload);
|
||||||
}
|
}
|
||||||
return Get(entry.Name);
|
return Get(entry);
|
||||||
}
|
}
|
||||||
|
|
||||||
LoadAB(entry, neverUnload);
|
LoadAB(entry, neverUnload);
|
||||||
@@ -167,16 +165,26 @@ public class UmaAssetManager : MonoBehaviour
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void SearchAB(UmaViewerMain Main, UmaDatabaseEntry entry, ref List<UmaDatabaseEntry> result)
|
/// <summary> Returns entry with all dependencies </summary>
|
||||||
|
public static List<UmaDatabaseEntry> SearchAB(UmaViewerMain Main, UmaDatabaseEntry entry)
|
||||||
{
|
{
|
||||||
if (!string.IsNullOrEmpty(entry.Prerequisites))
|
if (!string.IsNullOrEmpty(entry.Prerequisites))
|
||||||
{
|
{
|
||||||
foreach (string prerequisite in entry.Prerequisites.Split(';'))
|
if (entry.CachedPrerequisites != null) {
|
||||||
|
return new List<UmaDatabaseEntry>() { entry }.Concat(entry.CachedPrerequisites).ToList();
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
SearchAB(Main, Main.AbList[prerequisite], ref result);
|
var prerequisites = new List<UmaDatabaseEntry>();
|
||||||
|
foreach (string prerequisite in entry.Prerequisites.Split(';'))
|
||||||
|
{
|
||||||
|
prerequisites.AddRange(SearchAB(Main, Main.AbList[prerequisite]));
|
||||||
|
}
|
||||||
|
entry.CachedPrerequisites = prerequisites;
|
||||||
|
return new List<UmaDatabaseEntry>() { entry }.Concat(entry.CachedPrerequisites).ToList();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
result.Add(entry);
|
return new List<UmaDatabaseEntry>() { entry };
|
||||||
}
|
}
|
||||||
|
|
||||||
public static AssetBundle Get(string name) => instance.LoadedBundles[name];
|
public static AssetBundle Get(string name) => instance.LoadedBundles[name];
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ public class UmaContainerCharacter : UmaContainer
|
|||||||
public GameObject Head;
|
public GameObject Head;
|
||||||
public GameObject Hair;
|
public GameObject Hair;
|
||||||
|
|
||||||
public List<Texture2D> TailTextures = new List<Texture2D>();
|
public TextureList TailTextures = new TextureList();
|
||||||
|
|
||||||
[Header("Animator")]
|
[Header("Animator")]
|
||||||
public Animator UmaAnimator;
|
public Animator UmaAnimator;
|
||||||
@@ -63,17 +63,17 @@ public class UmaContainerCharacter : UmaContainer
|
|||||||
[Header("Generic")]
|
[Header("Generic")]
|
||||||
public bool IsGeneric = false;
|
public bool IsGeneric = false;
|
||||||
public string VarCostumeIdShort, VarCostumeIdLong, VarSkin, VarHeight, VarSocks, VarBust;
|
public string VarCostumeIdShort, VarCostumeIdLong, VarSkin, VarHeight, VarSocks, VarBust;
|
||||||
public List<Texture2D> GenericBodyTextures = new List<Texture2D>();
|
public TextureList GenericBodyTextures = new TextureList();
|
||||||
|
|
||||||
[Header("Mini")]
|
[Header("Mini")]
|
||||||
public bool IsMini = false;
|
public bool IsMini = false;
|
||||||
public List<Texture2D> MiniHeadTextures = new List<Texture2D>();
|
public TextureList MiniHeadTextures = new TextureList();
|
||||||
|
|
||||||
[Header("Mob")]
|
[Header("Mob")]
|
||||||
public bool IsMob = false;
|
public bool IsMob = false;
|
||||||
public DataRow MobDressColor;
|
public DataRow MobDressColor;
|
||||||
public DataRow MobHeadColor;
|
public DataRow MobHeadColor;
|
||||||
public List<Texture2D> MobHeadTextures = new List<Texture2D>();
|
public TextureList MobHeadTextures = new TextureList();
|
||||||
|
|
||||||
[Header("Physics")]
|
[Header("Physics")]
|
||||||
public bool EnablePhysics = true;
|
public bool EnablePhysics = true;
|
||||||
@@ -85,6 +85,57 @@ public class UmaContainerCharacter : UmaContainer
|
|||||||
private List<Transform> _humanoidBones;
|
private List<Transform> _humanoidBones;
|
||||||
private UIHandleCharacterRoot handleRoot;
|
private UIHandleCharacterRoot handleRoot;
|
||||||
|
|
||||||
|
private List<UmaDatabaseEntry> LoadedAssets = new List<UmaDatabaseEntry>();
|
||||||
|
|
||||||
|
public class TextureList
|
||||||
|
{
|
||||||
|
public class TextureSource
|
||||||
|
{
|
||||||
|
public Texture2D Texture;
|
||||||
|
public UmaDatabaseEntry Entry;
|
||||||
|
public bool Used = false;
|
||||||
|
|
||||||
|
public TextureSource(Texture2D texture, UmaDatabaseEntry entry)
|
||||||
|
{
|
||||||
|
Texture = texture;
|
||||||
|
Entry = entry;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<TextureSource> _list = new List<TextureSource>();
|
||||||
|
|
||||||
|
public Texture2D Load(Func<Texture2D, bool> predicate)
|
||||||
|
{
|
||||||
|
var entry = _list.FirstOrDefault(t => predicate(t.Texture));
|
||||||
|
entry.Used = true;
|
||||||
|
return entry.Texture;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Texture2D LoadLast(Func<Texture2D, bool> predicate)
|
||||||
|
{
|
||||||
|
var entry = _list.LastOrDefault(t => predicate(t.Texture));
|
||||||
|
entry.Used = true;
|
||||||
|
return entry.Texture;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Texture2D Load(int index)
|
||||||
|
{
|
||||||
|
var entry = _list[index];
|
||||||
|
entry.Used = true;
|
||||||
|
return entry.Texture;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Add(Texture2D texture, UmaDatabaseEntry entry)
|
||||||
|
{
|
||||||
|
_list.Add(new TextureSource(texture, entry));
|
||||||
|
}
|
||||||
|
|
||||||
|
public IEnumerable<UmaDatabaseEntry> GetLoadedAssets()
|
||||||
|
{
|
||||||
|
return _list.Select(t=>t.Entry).Distinct();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void Initialize(bool smile)
|
public void Initialize(bool smile)
|
||||||
{
|
{
|
||||||
TrackTarget = new GameObject("TrackTarget").transform;
|
TrackTarget = new GameObject("TrackTarget").transform;
|
||||||
@@ -486,28 +537,27 @@ public class UmaContainerCharacter : UmaContainer
|
|||||||
{
|
{
|
||||||
if (entry.Name.Contains("/mini/head"))
|
if (entry.Name.Contains("/mini/head"))
|
||||||
{
|
{
|
||||||
MiniHeadTextures.Add(tex2D);
|
MiniHeadTextures.Add(tex2D, entry);
|
||||||
}
|
}
|
||||||
else if (entry.Name.Contains("/tail/"))
|
else if (entry.Name.Contains("/tail/"))
|
||||||
{
|
{
|
||||||
TailTextures.Add(tex2D);
|
TailTextures.Add(tex2D, entry);
|
||||||
}
|
}
|
||||||
else if (entry.Name.Contains("bdy0"))
|
else if (entry.Name.Contains("bdy0"))
|
||||||
{
|
{
|
||||||
GenericBodyTextures.Add(tex2D);
|
GenericBodyTextures.Add(tex2D, entry);
|
||||||
}
|
}
|
||||||
else if (entry.Name.Contains("_face") || entry.Name.Contains("_hair"))
|
else if (entry.Name.Contains("_face") || entry.Name.Contains("_hair"))
|
||||||
{
|
{
|
||||||
if (IsMob)
|
if (IsMob)
|
||||||
MobHeadTextures.Add(tex2D);
|
MobHeadTextures.Add(tex2D, entry);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void LoadBody(UmaDatabaseEntry entry)
|
public void LoadBody(UmaDatabaseEntry entry)
|
||||||
{
|
{
|
||||||
GameObject go = entry.Get<GameObject>();
|
Body = InstantiateEntry(entry, transform);
|
||||||
Body = Instantiate(go, transform);
|
|
||||||
UmaAnimator = Body.GetComponent<Animator>();
|
UmaAnimator = Body.GetComponent<Animator>();
|
||||||
|
|
||||||
if (IsMini)
|
if (IsMini)
|
||||||
@@ -521,7 +571,7 @@ public class UmaContainerCharacter : UmaContainer
|
|||||||
|
|
||||||
if (IsGeneric)
|
if (IsGeneric)
|
||||||
{
|
{
|
||||||
List<Texture2D> textures = GenericBodyTextures;
|
TextureList textures = GenericBodyTextures;
|
||||||
string costumeIdShort = VarCostumeIdShort,
|
string costumeIdShort = VarCostumeIdShort,
|
||||||
costumeIdLong = VarCostumeIdLong,
|
costumeIdLong = VarCostumeIdLong,
|
||||||
height = VarHeight,
|
height = VarHeight,
|
||||||
@@ -538,7 +588,7 @@ public class UmaContainerCharacter : UmaContainer
|
|||||||
|
|
||||||
if (IsMini)
|
if (IsMini)
|
||||||
{
|
{
|
||||||
m.SetTexture("_MainTex", textures[0]);
|
m.SetTexture("_MainTex", textures.Load(0));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -566,7 +616,7 @@ public class UmaContainerCharacter : UmaContainer
|
|||||||
if (areaTex != null)
|
if (areaTex != null)
|
||||||
{
|
{
|
||||||
LoadTextures(areaTex);
|
LoadTextures(areaTex);
|
||||||
m.SetTexture("_MaskColorTex", textures.FirstOrDefault(t => t.name.Contains(costumeIdShort) && t.name.EndsWith("area")));
|
m.SetTexture("_MaskColorTex", textures.Load(t => t.name.Contains(costumeIdShort) && t.name.EndsWith("area")));
|
||||||
SetMaskColor(m, IsMob ? MobDressColor : CharaData, IsMob);
|
SetMaskColor(m, IsMob ? MobDressColor : CharaData, IsMob);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -620,13 +670,13 @@ public class UmaContainerCharacter : UmaContainer
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
Debug.Log("Looking for texture " + mainTex);
|
Debug.Log("Looking for texture " + mainTex);
|
||||||
m.SetTexture("_MainTex", textures.FirstOrDefault(t => t.name == mainTex));
|
m.SetTexture("_MainTex", textures.Load(t => t.name == mainTex));
|
||||||
m.SetTexture("_ToonMap", textures.FirstOrDefault(t => t.name == toonMap));
|
m.SetTexture("_ToonMap", textures.Load(t => t.name == toonMap));
|
||||||
m.SetTexture("_TripleMaskMap", textures.FirstOrDefault(t => t.name == tripleMap));
|
m.SetTexture("_TripleMaskMap", textures.Load(t => t.name == tripleMap));
|
||||||
m.SetTexture("_OptionMaskMap", textures.FirstOrDefault(t => t.name == optionMap));
|
m.SetTexture("_OptionMaskMap", textures.Load(t => t.name == optionMap));
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(zekkenNumberTex))
|
if (!string.IsNullOrEmpty(zekkenNumberTex))
|
||||||
m.SetTexture("_ZekkenNumberTex", textures.FirstOrDefault(t => t.name == zekkenNumberTex));
|
m.SetTexture("_ZekkenNumberTex", textures.Load(t => t.name == zekkenNumberTex));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -659,9 +709,8 @@ public class UmaContainerCharacter : UmaContainer
|
|||||||
|
|
||||||
public void LoadHead(UmaDatabaseEntry entry)
|
public void LoadHead(UmaDatabaseEntry entry)
|
||||||
{
|
{
|
||||||
GameObject go = entry.Get<GameObject>();
|
|
||||||
var textures = MobHeadTextures;
|
var textures = MobHeadTextures;
|
||||||
GameObject head = Instantiate(go, transform);
|
GameObject head = InstantiateEntry(entry, transform);
|
||||||
Head = head;
|
Head = head;
|
||||||
|
|
||||||
AssetTable table = null;
|
AssetTable table = null;
|
||||||
@@ -687,24 +736,24 @@ public class UmaContainerCharacter : UmaContainer
|
|||||||
}
|
}
|
||||||
if (r.name == "M_Face")
|
if (r.name == "M_Face")
|
||||||
{
|
{
|
||||||
m.SetTexture("_MainTex", MiniHeadTextures.First(t => t.name.Contains("face") && t.name.Contains("diff")));
|
m.SetTexture("_MainTex", MiniHeadTextures.Load(t => t.name.Contains("face") && t.name.Contains("diff")));
|
||||||
}
|
}
|
||||||
if (r.name == "M_Cheek")
|
if (r.name == "M_Cheek")
|
||||||
{
|
{
|
||||||
m.CopyPropertiesFromMaterial(Builder.TransMaterialCharas);
|
m.CopyPropertiesFromMaterial(Builder.TransMaterialCharas);
|
||||||
m.SetTexture("_MainTex", MiniHeadTextures.First(t => t.name.Contains("cheek")));
|
m.SetTexture("_MainTex", MiniHeadTextures.Load(t => t.name.Contains("cheek")));
|
||||||
}
|
}
|
||||||
if (r.name == "M_Mouth")
|
if (r.name == "M_Mouth")
|
||||||
{
|
{
|
||||||
m.SetTexture("_MainTex", MiniHeadTextures.First(t => t.name.Contains("mouth")));
|
m.SetTexture("_MainTex", MiniHeadTextures.Load(t => t.name.Contains("mouth")));
|
||||||
}
|
}
|
||||||
if (r.name == "M_Eye")
|
if (r.name == "M_Eye")
|
||||||
{
|
{
|
||||||
m.SetTexture("_MainTex", MiniHeadTextures.First(t => t.name.Contains("eye")));
|
m.SetTexture("_MainTex", MiniHeadTextures.Load(t => t.name.Contains("eye")));
|
||||||
}
|
}
|
||||||
if (r.name.StartsWith("M_Mayu_"))
|
if (r.name.StartsWith("M_Mayu_"))
|
||||||
{
|
{
|
||||||
m.SetTexture("_MainTex", MiniHeadTextures.First(t => t.name.Contains("mayu")));
|
m.SetTexture("_MainTex", MiniHeadTextures.Load(t => t.name.Contains("mayu")));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -713,26 +762,26 @@ public class UmaContainerCharacter : UmaContainer
|
|||||||
{
|
{
|
||||||
if (m.name.EndsWith("eye"))
|
if (m.name.EndsWith("eye"))
|
||||||
{
|
{
|
||||||
m.SetTexture("_MainTex", textures.LastOrDefault(t => t.name.Contains("_eye") && t.name.EndsWith("eye0")));
|
m.SetTexture("_MainTex", textures.LoadLast(t => t.name.Contains("_eye") && t.name.EndsWith("eye0")));
|
||||||
m.SetTexture("_High0Tex", textures.LastOrDefault(t => t.name.Contains("_eye") && t.name.EndsWith("hi00")));
|
m.SetTexture("_High0Tex", textures.LoadLast(t => t.name.Contains("_eye") && t.name.EndsWith("hi00")));
|
||||||
m.SetTexture("_High1Tex", textures.LastOrDefault(t => t.name.Contains("_eye") && t.name.EndsWith("hi01")));
|
m.SetTexture("_High1Tex", textures.LoadLast(t => t.name.Contains("_eye") && t.name.EndsWith("hi01")));
|
||||||
m.SetTexture("_High2Tex", textures.LastOrDefault(t => t.name.Contains("_eye") && t.name.EndsWith("hi02")));
|
m.SetTexture("_High2Tex", textures.LoadLast(t => t.name.Contains("_eye") && t.name.EndsWith("hi02")));
|
||||||
m.SetTexture("_MaskColorTex", textures.LastOrDefault(t => t.name.Contains("_eye") && t.name.EndsWith("area")));
|
m.SetTexture("_MaskColorTex", textures.LoadLast(t => t.name.Contains("_eye") && t.name.EndsWith("area")));
|
||||||
SetMaskColor(m, MobHeadColor, "eye", false);
|
SetMaskColor(m, MobHeadColor, "eye", false);
|
||||||
}
|
}
|
||||||
if (m.name.EndsWith("face"))
|
if (m.name.EndsWith("face"))
|
||||||
{
|
{
|
||||||
m.SetTexture("_MainTex", textures.LastOrDefault(t => t.name.Contains("_face") && t.name.EndsWith("diff")));
|
m.SetTexture("_MainTex", textures.LoadLast(t => t.name.Contains("_face") && t.name.EndsWith("diff")));
|
||||||
m.SetTexture("_ToonMap", textures.LastOrDefault(t => t.name.Contains("_face") && t.name.EndsWith("shad_c")));
|
m.SetTexture("_ToonMap", textures.LoadLast(t => t.name.Contains("_face") && t.name.EndsWith("shad_c")));
|
||||||
m.SetTexture("_TripleMaskMap", textures.LastOrDefault(t => t.name.Contains("_face") && t.name.EndsWith("base")));
|
m.SetTexture("_TripleMaskMap", textures.LoadLast(t => t.name.Contains("_face") && t.name.EndsWith("base")));
|
||||||
m.SetTexture("_OptionMaskMap", textures.LastOrDefault(t => t.name.Contains("_face") && t.name.EndsWith("ctrl")));
|
m.SetTexture("_OptionMaskMap", textures.LoadLast(t => t.name.Contains("_face") && t.name.EndsWith("ctrl")));
|
||||||
m.SetTexture("_MaskColorTex", textures.LastOrDefault(t => t.name.Contains("_face") && t.name.EndsWith("area") && !t.name.Contains("_eye")));
|
m.SetTexture("_MaskColorTex", textures.LoadLast(t => t.name.Contains("_face") && t.name.EndsWith("area") && !t.name.Contains("_eye")));
|
||||||
SetMaskColor(m, MobHeadColor, "mayu", true);
|
SetMaskColor(m, MobHeadColor, "mayu", true);
|
||||||
}
|
}
|
||||||
if (m.name.EndsWith("mayu"))
|
if (m.name.EndsWith("mayu"))
|
||||||
{
|
{
|
||||||
m.SetTexture("_MainTex", textures.LastOrDefault(t => t.name.Contains("_face") && t.name.EndsWith("diff")));
|
m.SetTexture("_MainTex", textures.LoadLast(t => t.name.Contains("_face") && t.name.EndsWith("diff")));
|
||||||
m.SetTexture("_MaskColorTex", textures.LastOrDefault(t => t.name.Contains("_face") && t.name.EndsWith("area") && !t.name.Contains("_eye")));
|
m.SetTexture("_MaskColorTex", textures.LoadLast(t => t.name.Contains("_face") && t.name.EndsWith("area") && !t.name.Contains("_eye")));
|
||||||
SetMaskColor(m, MobHeadColor, "mayu", true);
|
SetMaskColor(m, MobHeadColor, "mayu", true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -749,8 +798,8 @@ public class UmaContainerCharacter : UmaContainer
|
|||||||
r.gameObject.SetActive(false);
|
r.gameObject.SetActive(false);
|
||||||
if (IsMob)
|
if (IsMob)
|
||||||
{
|
{
|
||||||
CheekTex_0 = MobHeadTextures.FindLast(a => a.name.Contains("cheek0"));
|
CheekTex_0 = MobHeadTextures.LoadLast(a => a.name.Contains("cheek0"));
|
||||||
CheekTex_1 = MobHeadTextures.FindLast(a => a.name.Contains("cheek1"));
|
CheekTex_1 = MobHeadTextures.LoadLast(a => a.name.Contains("cheek1"));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -761,15 +810,16 @@ public class UmaContainerCharacter : UmaContainer
|
|||||||
|
|
||||||
if(Main.AbList.TryGetValue("3d/chara/common/textures/tex_chr_tear00", out var tearEntry))
|
if(Main.AbList.TryGetValue("3d/chara/common/textures/tex_chr_tear00", out var tearEntry))
|
||||||
{
|
{
|
||||||
var ab = UmaAssetManager.LoadAssetBundle(tearEntry, true, false);
|
LoadedAssets.Add(tearEntry);
|
||||||
var tex = ab.LoadAsset<Texture>("tex_chr_tear00");
|
var ab = UmaAssetManager.LoadAssetBundle(tearEntry, true, false);
|
||||||
StaticTear_L = table["tearmesh_l"] as GameObject;
|
var tex = ab.LoadAsset<Texture>("tex_chr_tear00");
|
||||||
StaticTear_R = table["tearmesh_r"] as GameObject;
|
StaticTear_L = table["tearmesh_l"] as GameObject;
|
||||||
if (StaticTear_L && StaticTear_R)
|
StaticTear_R = table["tearmesh_r"] as GameObject;
|
||||||
{
|
if (StaticTear_L && StaticTear_R)
|
||||||
|
{
|
||||||
StaticTear_L.GetComponent<Renderer>().material.mainTexture = tex;
|
StaticTear_L.GetComponent<Renderer>().material.mainTexture = tex;
|
||||||
StaticTear_R.GetComponent<Renderer>().material.mainTexture = tex;
|
StaticTear_R.GetComponent<Renderer>().material.mainTexture = tex;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (m.shader.name)
|
switch (m.shader.name)
|
||||||
@@ -819,8 +869,7 @@ public class UmaContainerCharacter : UmaContainer
|
|||||||
|
|
||||||
public void LoadHair(UmaDatabaseEntry entry)
|
public void LoadHair(UmaDatabaseEntry entry)
|
||||||
{
|
{
|
||||||
GameObject go = entry.Get<GameObject>();
|
GameObject hair = InstantiateEntry(entry, transform);
|
||||||
GameObject hair = Instantiate(go, transform);
|
|
||||||
Hair = hair;
|
Hair = hair;
|
||||||
var textures = MobHeadTextures;
|
var textures = MobHeadTextures;
|
||||||
foreach (Renderer r in hair.GetComponentsInChildren<Renderer>())
|
foreach (Renderer r in hair.GetComponentsInChildren<Renderer>())
|
||||||
@@ -836,20 +885,20 @@ public class UmaContainerCharacter : UmaContainer
|
|||||||
|
|
||||||
if (m.name.EndsWith("_hair"))
|
if (m.name.EndsWith("_hair"))
|
||||||
{
|
{
|
||||||
m.SetTexture("_MainTex", textures.FirstOrDefault(t => t.name.Contains("_hair") && t.name.EndsWith("diff")));
|
m.SetTexture("_MainTex", textures.Load(t => t.name.Contains("_hair") && t.name.EndsWith("diff")));
|
||||||
m.SetTexture("_ToonMap", textures.FirstOrDefault(t => t.name.Contains("_hair") && t.name.EndsWith("shad_c")));
|
m.SetTexture("_ToonMap", textures.Load(t => t.name.Contains("_hair") && t.name.EndsWith("shad_c")));
|
||||||
m.SetTexture("_OptionMaskMap", textures.FirstOrDefault(t => t.name.Contains("_hair") && t.name.EndsWith("ctrl")));
|
m.SetTexture("_OptionMaskMap", textures.Load(t => t.name.Contains("_hair") && t.name.EndsWith("ctrl")));
|
||||||
m.SetTexture("_MaskColorTex", textures.FirstOrDefault(t => t.name.Contains("_hair") && t.name.EndsWith("area")));
|
m.SetTexture("_MaskColorTex", textures.Load(t => t.name.Contains("_hair") && t.name.EndsWith("area")));
|
||||||
SetMaskColor(m, MobHeadColor, "hair", true);
|
SetMaskColor(m, MobHeadColor, "hair", true);
|
||||||
if (IsMob)
|
if (IsMob)
|
||||||
{
|
{
|
||||||
var cutoff = CharaData["hair_cutoff"].ToString();
|
var cutoff = CharaData["hair_cutoff"].ToString();
|
||||||
m.SetFloat("_Cutoff", int.Parse(cutoff) / 10000f); //Not entirely correct, but effective
|
m.SetFloat("_Cutoff", int.Parse(cutoff) / 10000f); //Not entirely correct, but effective
|
||||||
m.SetTexture("_TripleMaskMap", textures.FirstOrDefault(t => t.name.Contains("_hair") && t.name.EndsWith(CharaData["sex"].ToString() + "_base")));
|
m.SetTexture("_TripleMaskMap", textures.Load(t => t.name.Contains("_hair") && t.name.EndsWith(CharaData["sex"].ToString() + "_base")));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m.SetTexture("_TripleMaskMap", textures.FirstOrDefault(t => t.name.Contains("_hair") && t.name.EndsWith("base")));
|
m.SetTexture("_TripleMaskMap", textures.Load(t => t.name.Contains("_hair") && t.name.EndsWith("base")));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -870,18 +919,17 @@ public class UmaContainerCharacter : UmaContainer
|
|||||||
|
|
||||||
public void LoadTail(UmaDatabaseEntry entry)
|
public void LoadTail(UmaDatabaseEntry entry)
|
||||||
{
|
{
|
||||||
GameObject go = entry.Get<GameObject>();
|
Tail = InstantiateEntry(entry, transform);
|
||||||
Tail = Instantiate(go, transform);
|
|
||||||
var textures = TailTextures;
|
var textures = TailTextures;
|
||||||
foreach (Renderer r in Tail.GetComponentsInChildren<Renderer>())
|
foreach (Renderer r in Tail.GetComponentsInChildren<Renderer>())
|
||||||
{
|
{
|
||||||
foreach (Material m in r.materials)
|
foreach (Material m in r.materials)
|
||||||
{
|
{
|
||||||
m.name = m.name.Replace(" (Instance)", "");
|
m.name = m.name.Replace(" (Instance)", "");
|
||||||
m.SetTexture("_MainTex", textures.FirstOrDefault(t => t.name.EndsWith("diff")));
|
m.SetTexture("_MainTex", textures.Load(t => t.name.EndsWith("diff")));
|
||||||
m.SetTexture("_ToonMap", textures.FirstOrDefault(t => t.name.Contains("shad")));
|
m.SetTexture("_ToonMap", textures.Load(t => t.name.Contains("shad")));
|
||||||
m.SetTexture("_TripleMaskMap", textures.FirstOrDefault(t => t.name.Contains("base")));
|
m.SetTexture("_TripleMaskMap", textures.Load(t => t.name.Contains("base")));
|
||||||
m.SetTexture("_OptionMaskMap", textures.FirstOrDefault(t => t.name.Contains("ctrl")));
|
m.SetTexture("_OptionMaskMap", textures.Load(t => t.name.Contains("ctrl")));
|
||||||
if (IsMob)
|
if (IsMob)
|
||||||
{
|
{
|
||||||
SetMaskColor(m, MobHeadColor, "tail", true);
|
SetMaskColor(m, MobHeadColor, "tail", true);
|
||||||
@@ -988,13 +1036,12 @@ public class UmaContainerCharacter : UmaContainer
|
|||||||
|
|
||||||
public void LoadPhysics(UmaDatabaseEntry entry)
|
public void LoadPhysics(UmaDatabaseEntry entry)
|
||||||
{
|
{
|
||||||
GameObject go = entry.Get<GameObject>();
|
|
||||||
if (!PhysicsContainer)
|
if (!PhysicsContainer)
|
||||||
{
|
{
|
||||||
PhysicsContainer = new GameObject("PhysicsController");
|
PhysicsContainer = new GameObject("PhysicsController");
|
||||||
PhysicsContainer.transform.SetParent(transform);
|
PhysicsContainer.transform.SetParent(transform);
|
||||||
}
|
}
|
||||||
Instantiate(go, PhysicsContainer.transform);
|
InstantiateEntry(entry, PhysicsContainer.transform);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void LoadAnimation(UmaDatabaseEntry entry)
|
public void LoadAnimation(UmaDatabaseEntry entry)
|
||||||
@@ -1299,6 +1346,7 @@ public class UmaContainerCharacter : UmaContainer
|
|||||||
{
|
{
|
||||||
if (!Head) return;
|
if (!Head) return;
|
||||||
var locatorEntry = Main.AbList["3d/animator/drivenkeylocator"];
|
var locatorEntry = Main.AbList["3d/animator/drivenkeylocator"];
|
||||||
|
LoadedAssets.Add(locatorEntry);
|
||||||
var bundle = UmaAssetManager.LoadAssetBundle(locatorEntry);
|
var bundle = UmaAssetManager.LoadAssetBundle(locatorEntry);
|
||||||
var locator = Instantiate(bundle.LoadAsset("DrivenKeyLocator"), transform) as GameObject;
|
var locator = Instantiate(bundle.LoadAsset("DrivenKeyLocator"), transform) as GameObject;
|
||||||
locator.name = "DrivenKeyLocator";
|
locator.name = "DrivenKeyLocator";
|
||||||
@@ -1317,6 +1365,7 @@ public class UmaContainerCharacter : UmaContainer
|
|||||||
var mangaObjects = new List<GameObject>();
|
var mangaObjects = new List<GameObject>();
|
||||||
mangaEntry.ForEach(entry =>
|
mangaEntry.ForEach(entry =>
|
||||||
{
|
{
|
||||||
|
LoadedAssets.Add(entry);
|
||||||
AssetBundle ab = UmaAssetManager.LoadAssetBundle(entry);
|
AssetBundle ab = UmaAssetManager.LoadAssetBundle(entry);
|
||||||
var obj = ab.LoadAsset(Path.GetFileNameWithoutExtension(entry.Name)) as GameObject;
|
var obj = ab.LoadAsset(Path.GetFileNameWithoutExtension(entry.Name)) as GameObject;
|
||||||
obj.SetActive(false);
|
obj.SetActive(false);
|
||||||
@@ -1606,4 +1655,29 @@ public class UmaContainerCharacter : UmaContainer
|
|||||||
pair.Key.SetPositionAndRotation(pair.Value.pos, pair.Value.rot);
|
pair.Key.SetPositionAndRotation(pair.Value.pos, pair.Value.rot);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<UmaDatabaseEntry> GetAssetsList()
|
||||||
|
{
|
||||||
|
return LoadedAssets
|
||||||
|
.Concat(TailTextures.GetLoadedAssets())
|
||||||
|
.Concat(GenericBodyTextures.GetLoadedAssets())
|
||||||
|
.Concat(MiniHeadTextures.GetLoadedAssets())
|
||||||
|
.Concat(MobHeadTextures.GetLoadedAssets())
|
||||||
|
.Distinct().ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
private GameObject InstantiateEntry(UmaDatabaseEntry entry, Transform parent)
|
||||||
|
{
|
||||||
|
if (!LoadedAssets.Contains(entry))
|
||||||
|
{
|
||||||
|
foreach (var asset in UmaAssetManager.SearchAB(UmaViewerMain.Instance, entry))
|
||||||
|
{
|
||||||
|
if (!LoadedAssets.Contains(asset))
|
||||||
|
{
|
||||||
|
LoadedAssets.Add(asset);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return Instantiate(entry.Get<GameObject>());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,6 +13,9 @@ public class UmaDatabaseEntry
|
|||||||
public string Checksum;
|
public string Checksum;
|
||||||
public string Prerequisites;
|
public string Prerequisites;
|
||||||
|
|
||||||
|
[NonSerialized]
|
||||||
|
public List<UmaDatabaseEntry> CachedPrerequisites = null;
|
||||||
|
|
||||||
public string FilePath
|
public string FilePath
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
@@ -43,15 +46,15 @@ public class UmaDatabaseEntry
|
|||||||
|
|
||||||
public T Get<T>(bool withDependencies = true)
|
public T Get<T>(bool withDependencies = true)
|
||||||
{
|
{
|
||||||
UmaAssetManager.LoadAssetBundle(this, isRecursive: withDependencies);
|
Object asset = UmaAssetManager.LoadAssetBundle(this, isRecursive: withDependencies)
|
||||||
Object asset = UmaAssetManager.Get(this).LoadAllAssets().FirstOrDefault(a=>a.GetType() == typeof(T));
|
.LoadAllAssets().FirstOrDefault(a=>a.GetType() == typeof(T));
|
||||||
return (T)System.Convert.ChangeType(asset, typeof(T));
|
return (T)System.Convert.ChangeType(asset, typeof(T));
|
||||||
}
|
}
|
||||||
|
|
||||||
public IEnumerable<T> GetAll<T>(bool withDependencies = true)
|
public IEnumerable<T> GetAll<T>(bool withDependencies = true)
|
||||||
{
|
{
|
||||||
UmaAssetManager.LoadAssetBundle(this, isRecursive: withDependencies);
|
IEnumerable<Object> assets = UmaAssetManager.LoadAssetBundle(this, isRecursive: withDependencies)
|
||||||
IEnumerable<Object> assets = UmaAssetManager.Get(this).LoadAllAssets().Where(a => a.GetType() == typeof(T));
|
.LoadAllAssets().Where(a => a.GetType() == typeof(T));
|
||||||
return assets.Select(asset => (T)System.Convert.ChangeType(asset, typeof(T)));
|
return assets.Select(asset => (T)System.Convert.ChangeType(asset, typeof(T)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user