Improve resource loading logic and performance
This commit is contained in:
@@ -1,12 +0,0 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class DeepCopy
|
||||
{
|
||||
public static void CopyValues<T>(T from, T to)
|
||||
{
|
||||
var json = JsonUtility.ToJson(from);
|
||||
JsonUtility.FromJsonOverwrite(json, to);
|
||||
}
|
||||
}
|
||||
@@ -104,25 +104,22 @@ public class UmaContainer : MonoBehaviour
|
||||
public void MergeModel()
|
||||
{
|
||||
if (!Body) return;
|
||||
|
||||
List<Transform> bodybones = new List<Transform>(Body.GetComponentInChildren<SkinnedMeshRenderer>().bones);
|
||||
var bodyBones = Body.GetComponentInChildren<SkinnedMeshRenderer>().bones.ToDictionary(bone => bone.name, bone => bone.transform);
|
||||
List<Transform> emptyBones = new List<Transform>();
|
||||
emptyBones.Add(Body.GetComponentInChildren<SkinnedMeshRenderer>().rootBone.Find("Tail_Ctrl"));
|
||||
emptyBones.Add(Body.transform.Find("Position/Hip/Tail_Ctrl"));
|
||||
while (Body.transform.childCount > 0)
|
||||
{
|
||||
var child = Body.transform.GetChild(0);
|
||||
child.SetParent(transform);
|
||||
Body.transform.GetChild(0).SetParent(transform);
|
||||
}
|
||||
Body.SetActive(false); //for debugging
|
||||
|
||||
|
||||
//MergeHead
|
||||
if (Head)
|
||||
{
|
||||
var headskins = Head.GetComponentsInChildren<SkinnedMeshRenderer>();
|
||||
foreach (SkinnedMeshRenderer headskin in headskins)
|
||||
{
|
||||
emptyBones.AddRange(MergeBone(headskin, bodybones));
|
||||
MergeBone(headskin, bodyBones,ref emptyBones);
|
||||
}
|
||||
var eyes = new GameObject("Eyes");
|
||||
eyes.transform.SetParent(transform);
|
||||
@@ -139,7 +136,7 @@ public class UmaContainer : MonoBehaviour
|
||||
if (Tail)
|
||||
{
|
||||
var tailskin = Tail.GetComponentInChildren<SkinnedMeshRenderer>();
|
||||
emptyBones.AddRange(MergeBone(tailskin, bodybones));
|
||||
MergeBone(tailskin, bodyBones, ref emptyBones);
|
||||
while (Tail.transform.childCount > 0)
|
||||
{
|
||||
var child = Tail.transform.GetChild(0);
|
||||
@@ -194,7 +191,7 @@ public class UmaContainer : MonoBehaviour
|
||||
{
|
||||
if (!Head || !Hair) return;
|
||||
|
||||
List<Transform> bodybones = new List<Transform>(Head.GetComponentsInChildren<Transform>());
|
||||
var bodyBones = Head.GetComponentInChildren<SkinnedMeshRenderer>().bones.ToDictionary(bone => bone.name, bone => bone.transform);
|
||||
List<Transform> emptyBones = new List<Transform>();
|
||||
|
||||
var headHolder = Head.GetComponent<AssetHolder>();
|
||||
@@ -208,7 +205,7 @@ public class UmaContainer : MonoBehaviour
|
||||
foreach (SkinnedMeshRenderer hairskin in hairskins)
|
||||
{
|
||||
hairskin.gameObject.transform.SetParent(Head.transform);
|
||||
emptyBones.AddRange(MergeBone(hairskin, bodybones));
|
||||
MergeBone(hairskin, bodyBones ,ref emptyBones);
|
||||
}
|
||||
Hair.gameObject.SetActive(false);
|
||||
|
||||
@@ -232,17 +229,15 @@ public class UmaContainer : MonoBehaviour
|
||||
transform.Find("Position").localScale = new Vector3(BodyScale, BodyScale, BodyScale);
|
||||
}
|
||||
|
||||
public Transform[] MergeBone(SkinnedMeshRenderer from, List<Transform> targetBones)
|
||||
public void MergeBone(SkinnedMeshRenderer from, Dictionary<string, Transform> targetBones,ref List<Transform> emptyBones)
|
||||
{
|
||||
var rootbone = targetBones.FindLast(a => a.name.Equals(from.rootBone.name));
|
||||
var rootbone = targetBones[from.rootBone.name];
|
||||
if (rootbone) from.rootBone = rootbone;
|
||||
|
||||
List<Transform> emptyBones = new List<Transform>();
|
||||
Transform[] tmpBone = new Transform[from.bones.Length];
|
||||
for (int i = 0; i < tmpBone.Length; i++)
|
||||
{
|
||||
var targetbone = targetBones.FindLast(a => a.name.Equals(from.bones[i].name));
|
||||
if (targetbone)
|
||||
if (targetBones.TryGetValue(from.bones[i].name, out Transform targetbone))
|
||||
{
|
||||
tmpBone[i] = targetbone;
|
||||
from.bones[i].position = targetbone.position;
|
||||
@@ -258,22 +253,28 @@ public class UmaContainer : MonoBehaviour
|
||||
}
|
||||
}
|
||||
from.bones = tmpBone;
|
||||
return emptyBones.ToArray();
|
||||
}
|
||||
|
||||
public void LoadPhysics()
|
||||
{
|
||||
cySpringDataContainers = new List<CySpringDataContainer>(PhysicsContainer.GetComponentsInChildren<CySpringDataContainer>());
|
||||
var bones = new List<Transform>(GetComponentsInChildren<Transform>());
|
||||
var colliders = new List<GameObject>();
|
||||
|
||||
foreach (CySpringDataContainer spring in cySpringDataContainers)
|
||||
var bones = new Dictionary<string,Transform>();
|
||||
foreach (var bone in GetComponentsInChildren<Transform>())
|
||||
{
|
||||
colliders.AddRange(spring.InitiallizeCollider(bones));
|
||||
if (!bones.ContainsKey(bone.name))
|
||||
bones.Add(bone.name, bone);
|
||||
}
|
||||
foreach (CySpringDataContainer spring in cySpringDataContainers)
|
||||
|
||||
var colliders = new Dictionary<string, Transform>();
|
||||
|
||||
for (int i = 0; i < cySpringDataContainers.Count; i++)
|
||||
{
|
||||
spring.InitializePhysics(bones, colliders);
|
||||
colliders = UmaUtility.MergeDictionaries(colliders,cySpringDataContainers[i].InitiallizeCollider(bones));
|
||||
}
|
||||
|
||||
for (int i = 0; i < cySpringDataContainers.Count; i++)
|
||||
{
|
||||
cySpringDataContainers[i].InitializePhysics(bones, colliders);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -397,35 +398,6 @@ public class UmaContainer : MonoBehaviour
|
||||
|
||||
}
|
||||
}
|
||||
public MeshRenderer debug;
|
||||
private void Update()
|
||||
{
|
||||
//if (Input.GetMouseButtonDown(1))
|
||||
//{
|
||||
// var cam = Camera.main;
|
||||
// var distance = Mathf.Clamp(cam.transform.InverseTransformPoint(HeadBone.transform.position).magnitude - 0.1f, 0, 2);
|
||||
// var mousePos = new Vector3(Input.mousePosition.x, Input.mousePosition.y, distance);
|
||||
// var worldPos = cam.ScreenToWorldPoint(mousePos);
|
||||
// if (Physics.Raycast(Camera.main.ScreenPointToRay(mousePos), out RaycastHit hit))
|
||||
// {
|
||||
// hit.rigidbody.AddForce(Camera.main.transform.forward * 50, ForceMode.Impulse);
|
||||
|
||||
// FaceDrivenKeyTarget.ChangeMorphWeight(FaceDrivenKeyTarget.OtherMorphs[2].BindProperties[0], 2, FaceDrivenKeyTarget.OtherMorphs[2]);
|
||||
// FaceDrivenKeyTarget.ChangeMorphWeight(FaceDrivenKeyTarget.OtherMorphs[2].BindProperties[1], 1, FaceDrivenKeyTarget.OtherMorphs[2]);
|
||||
// Invoke(nameof(Test), 0.3f);
|
||||
// }
|
||||
//}
|
||||
}
|
||||
|
||||
//public void Test()
|
||||
//{
|
||||
// FaceDrivenKeyTarget.ChangeMorphWeight(FaceDrivenKeyTarget.OtherMorphs[2].BindProperties[0], 0, FaceDrivenKeyTarget.OtherMorphs[2]);
|
||||
// FaceDrivenKeyTarget.ChangeMorphWeight(FaceDrivenKeyTarget.OtherMorphs[2].BindProperties[1], 0, FaceDrivenKeyTarget.OtherMorphs[2]);
|
||||
// FaceEmotionKeyTarget.FaceEmotionKey.ForEach(e => { if (e.target) e.Weight = 0; });
|
||||
// var tmp = FaceEmotionKeyTarget.FaceEmotionKey[Random.Range(22, 26)];
|
||||
// tmp.Weight = 1;
|
||||
// FaceDrivenKeyTarget.ChangeMorph();
|
||||
//}
|
||||
|
||||
public void SetNextAnimationCut(string cutName)
|
||||
{
|
||||
@@ -491,7 +463,6 @@ public class UmaContainer : MonoBehaviour
|
||||
PuppetMaster.FlattenHierarchy();
|
||||
}
|
||||
|
||||
|
||||
public class MaterialHelper
|
||||
{
|
||||
public Material Mat;
|
||||
|
||||
@@ -10,7 +10,6 @@ public class UmaDatabaseEntry
|
||||
public UmaFileType Type;
|
||||
public string Name;
|
||||
public string Url;
|
||||
public string Checksum;
|
||||
public string Prerequisites;
|
||||
public string FilePath
|
||||
{
|
||||
|
||||
@@ -5,6 +5,8 @@ using Mono.Data.Sqlite;
|
||||
using System.Data;
|
||||
using Assets.Scripts;
|
||||
using System.IO;
|
||||
using System.Diagnostics;
|
||||
using Debug = UnityEngine.Debug;
|
||||
|
||||
public class UmaDatabaseController
|
||||
{
|
||||
@@ -51,7 +53,7 @@ public class UmaDatabaseController
|
||||
public List<DataRow> DressData;
|
||||
|
||||
/// <summary> Meta Database Connection </summary>
|
||||
private SqliteConnection metaDb;
|
||||
public SqliteConnection metaDb;
|
||||
/// <summary> Master Database Connection </summary>
|
||||
private SqliteConnection masterDb;
|
||||
/// <summary> Loads the file database </summary>
|
||||
@@ -72,7 +74,6 @@ public class UmaDatabaseController
|
||||
masterDb = new SqliteConnection($@"Data Source={Config.Instance.MainPath}\master\master.mdb;");
|
||||
}
|
||||
|
||||
|
||||
metaDb.Open();
|
||||
MetaEntries = ReadMeta(metaDb);
|
||||
|
||||
@@ -82,8 +83,9 @@ public class UmaDatabaseController
|
||||
FaceTypeData = ReadFaceTypeData(masterDb);
|
||||
LiveData = ReadAllLiveData(masterDb);
|
||||
DressData = ReadAllDressData(masterDb);
|
||||
|
||||
}
|
||||
catch
|
||||
catch
|
||||
{
|
||||
CloseAllConnection();
|
||||
var msg = $"Database not found at: {Config.Instance.MainPath}";
|
||||
@@ -102,7 +104,7 @@ public class UmaDatabaseController
|
||||
static Dictionary<string,UmaDatabaseEntry> ReadMeta(SqliteConnection conn)
|
||||
{
|
||||
SqliteCommand sqlite_cmd = conn.CreateCommand();
|
||||
sqlite_cmd.CommandText = "SELECT m,n,h,c,d FROM a";
|
||||
sqlite_cmd.CommandText = "SELECT m,n,h,d FROM a WHERE d IS NOT NULL";
|
||||
SqliteDataReader sqlite_datareader = sqlite_cmd.ExecuteReader();
|
||||
Dictionary<string, UmaDatabaseEntry> meta = new Dictionary<string, UmaDatabaseEntry>();
|
||||
while (sqlite_datareader.Read())
|
||||
@@ -110,18 +112,19 @@ public class UmaDatabaseController
|
||||
UmaDatabaseEntry entry = null;
|
||||
try
|
||||
{
|
||||
entry = new UmaDatabaseEntry()
|
||||
entry = new UmaDatabaseEntry
|
||||
{
|
||||
Type = (UmaFileType)Enum.Parse(typeof(UmaFileType), sqlite_datareader["m"] as string),
|
||||
Name = sqlite_datareader["n"] as string,
|
||||
Url = sqlite_datareader["h"] as string,
|
||||
Checksum = sqlite_datareader["c"].ToString(),
|
||||
Prerequisites = sqlite_datareader["d"] as string
|
||||
Type = (UmaFileType)Enum.Parse(typeof(UmaFileType), sqlite_datareader.GetString(0)),
|
||||
Name = sqlite_datareader.GetString(1),
|
||||
Url = sqlite_datareader.GetString(2),
|
||||
Prerequisites = sqlite_datareader.GetString(3)
|
||||
};
|
||||
}
|
||||
catch(Exception e) { Debug.LogError("Error caught: " + e); }
|
||||
catch(Exception e) { Debug.LogError("Error caught: " + e + entry.Name); }
|
||||
if (entry != null) {
|
||||
|
||||
if (entry != null) meta.Add(entry.Name, entry);
|
||||
meta.Add(entry.Name, entry);
|
||||
}
|
||||
}
|
||||
return meta;
|
||||
}
|
||||
@@ -136,20 +139,21 @@ public class UmaDatabaseController
|
||||
return ReadMaster(conn, "SELECT * FROM mob_data");
|
||||
}
|
||||
|
||||
static List<DataRow> ReadMaster(SqliteConnection conn,string sql)
|
||||
static List<DataRow> ReadMaster(SqliteConnection conn, string sql)
|
||||
{
|
||||
List<DataRow> dr = new List<DataRow>();
|
||||
SqliteCommand sqlite_cmd = conn.CreateCommand();
|
||||
sqlite_cmd.CommandText = sql;
|
||||
SqliteDataReader sqlite_datareader = sqlite_cmd.ExecuteReader();
|
||||
var result = new DataTable();
|
||||
result.Load(sqlite_datareader);
|
||||
var temp = result.Rows.GetEnumerator();
|
||||
while (temp.MoveNext())
|
||||
|
||||
using (var sqlite_cmd = conn.CreateCommand())
|
||||
{
|
||||
dr.Add((DataRow)temp.Current);
|
||||
sqlite_cmd.CommandText = sql;
|
||||
using var sqlite_datareader = sqlite_cmd.ExecuteReader();
|
||||
var result = new DataTable();
|
||||
result.Load(sqlite_datareader);
|
||||
foreach (DataRow row in result.Rows)
|
||||
{
|
||||
dr.Add(row);
|
||||
}
|
||||
}
|
||||
sqlite_cmd.Dispose();
|
||||
return dr;
|
||||
}
|
||||
|
||||
@@ -200,11 +204,8 @@ public class UmaDatabaseController
|
||||
public static DataRow ReadMobDressColor(string mobid)
|
||||
{
|
||||
var results= ReadMaster(instance.masterDb, $"SELECT * FROM mob_dress_color_set WHERE id LIKE {mobid}");
|
||||
foreach(var data in results)
|
||||
{
|
||||
return data;
|
||||
}
|
||||
return null;
|
||||
|
||||
return results.Count > 0 ? results[0] : null;
|
||||
}
|
||||
|
||||
public static DataRow ReadMobHairColor(string colorid)
|
||||
|
||||
@@ -20,7 +20,7 @@ public class UmaViewerAudio
|
||||
{
|
||||
Debug.Log(name);
|
||||
UmaSoundInfo info;
|
||||
info.acbPath = Main.AbSounds.FirstOrDefault(a => a.Name.Contains(name) && a.Name.EndsWith("acb")).FilePath;
|
||||
info.acbPath = null;
|
||||
info.awbPath = Main.AbSounds.FirstOrDefault(a => a.Name.Contains(name) && a.Name.EndsWith("awb")).FilePath;
|
||||
return info;
|
||||
}
|
||||
|
||||
+113
-113
@@ -5,11 +5,13 @@ using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using UmaMusumeAudio;
|
||||
using UnityEngine;
|
||||
using UnityEngine.SceneManagement;
|
||||
using Debug = UnityEngine.Debug;
|
||||
|
||||
public class UmaViewerBuilder : MonoBehaviour
|
||||
{
|
||||
@@ -44,8 +46,8 @@ public class UmaViewerBuilder : MonoBehaviour
|
||||
public Animator AnimationCameraAnimator;
|
||||
public Camera AnimationCamera;
|
||||
|
||||
|
||||
private bool ShadersLoaded = false;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
Instance = this;
|
||||
@@ -65,17 +67,17 @@ public class UmaViewerBuilder : MonoBehaviour
|
||||
else if (chara.IsMob)
|
||||
{
|
||||
CurrentUMAContainer.CharaData = UmaDatabaseController.ReadCharaData(chara);
|
||||
LoadMobUma(chara, costumeId);
|
||||
LoadMobUma(chara, costumeId, loadMotion: true);
|
||||
}
|
||||
else if (UI.isHeadFix && CurrentHead != null && CurrentHead.chara.IsMob)
|
||||
{
|
||||
CurrentUMAContainer.CharaData = UmaDatabaseController.ReadCharaData(CurrentHead.chara);
|
||||
LoadMobUma(CurrentHead.chara, costumeId, chara.Id);
|
||||
LoadMobUma(CurrentHead.chara, costumeId, chara.Id, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
CurrentUMAContainer.CharaData = UmaDatabaseController.ReadCharaData(chara);
|
||||
LoadNormalUma(chara, costumeId);
|
||||
LoadNormalUma(chara, costumeId, true);
|
||||
}
|
||||
|
||||
yield break;
|
||||
@@ -108,7 +110,7 @@ public class UmaViewerBuilder : MonoBehaviour
|
||||
}
|
||||
}
|
||||
|
||||
private void LoadNormalUma(CharaEntry chara, string costumeId)
|
||||
private void LoadNormalUma(CharaEntry chara, string costumeId, bool loadMotion = false)
|
||||
{
|
||||
int id = chara.Id;
|
||||
DataRow charaData = CurrentUMAContainer.CharaData;
|
||||
@@ -141,20 +143,16 @@ public class UmaViewerBuilder : MonoBehaviour
|
||||
//
|
||||
// Some models will naturally be missing due to how this system is designed.
|
||||
|
||||
string body = "";
|
||||
body = UmaDatabaseController.BodyPath + $"bdy{costumeIdShort}/pfb_bdy{costumeId}_{height}_{shape}_{bust}";
|
||||
|
||||
Debug.Log("Looking for " + body);
|
||||
asset = UmaViewerMain.Instance.AbChara.FirstOrDefault(a => a.Name == body);
|
||||
string body = UmaDatabaseController.BodyPath + $"bdy{costumeIdShort}/pfb_bdy{costumeId}_{height}_{shape}_{bust}";
|
||||
UmaViewerMain.Instance.AbList.TryGetValue(body, out asset);
|
||||
}
|
||||
else asset = UmaViewerMain.Instance.AbChara.FirstOrDefault(a => a.Name == UmaDatabaseController.BodyPath + $"bdy{id}_{costumeId}/pfb_bdy{id}_{costumeId}");
|
||||
else UmaViewerMain.Instance.AbList.TryGetValue(UmaDatabaseController.BodyPath + $"bdy{id}_{costumeId}/pfb_bdy{id}_{costumeId}", out asset);
|
||||
|
||||
if (asset == null)
|
||||
{
|
||||
Debug.LogError("No body, can't load!");
|
||||
return;
|
||||
}
|
||||
|
||||
else if (genericCostume)
|
||||
{
|
||||
string texPattern1 = "", texPattern2 = "", texPattern3 = "", texPattern4 = "", texPattern5 = "";
|
||||
@@ -194,32 +192,23 @@ public class UmaViewerBuilder : MonoBehaviour
|
||||
//Load Body
|
||||
RecursiveLoadAsset(asset);
|
||||
|
||||
bool physicsloaded = false, physicsloaded2 = false;
|
||||
//Load Physics
|
||||
foreach (var asset1 in UmaViewerMain.Instance.AbChara.Where(a => a.Name.StartsWith(UmaDatabaseController.BodyPath + $"bdy{costumeIdShort}/clothes")))
|
||||
if (Main.AbList.TryGetValue(UmaDatabaseController.BodyPath + $"bdy{costumeIdShort}/clothes/pfb_bdy{costumeIdShort}_cloth00", out _))
|
||||
{
|
||||
if (asset1.Name.Contains("cloth00") && asset1.Name.Contains("bust" + bust) && !physicsloaded)
|
||||
{
|
||||
RecursiveLoadAsset(asset1);
|
||||
physicsloaded = true;
|
||||
}
|
||||
else if (asset1.Name.Contains("cloth00") && !asset1.Name.Contains("bust") && !physicsloaded2)
|
||||
{
|
||||
RecursiveLoadAsset(asset1);
|
||||
physicsloaded2 = true;
|
||||
}
|
||||
var asset1 = Main.AbList[UmaDatabaseController.BodyPath + $"bdy{costumeIdShort}/clothes/pfb_bdy{costumeIdShort}_cloth00"];
|
||||
RecursiveLoadAsset(asset1);
|
||||
asset1 = Main.AbList[UmaDatabaseController.BodyPath + $"bdy{costumeIdShort}/clothes/pfb_bdy{costumeIdShort}_bust{bust}_cloth00"];
|
||||
RecursiveLoadAsset(asset1);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
RecursiveLoadAsset(asset);
|
||||
|
||||
//Load Physics
|
||||
foreach (var asset1 in UmaViewerMain.Instance.AbChara.Where(a => a.Name.StartsWith(UmaDatabaseController.BodyPath + $"bdy{id}_{costumeId}/clothes")))
|
||||
{
|
||||
if (asset1.Name.Contains("cloth00"))
|
||||
RecursiveLoadAsset(asset1);
|
||||
}
|
||||
var asset1 = Main.AbList[UmaDatabaseController.BodyPath + $"bdy{id}_{costumeId}/clothes/pfb_bdy{id}_{costumeId}_cloth00"];
|
||||
RecursiveLoadAsset(asset1);
|
||||
asset1 = Main.AbList[UmaDatabaseController.BodyPath + $"bdy{id}_{costumeId}/clothes/pfb_bdy{id}_{costumeId}_bust_cloth00"];
|
||||
RecursiveLoadAsset(asset1);
|
||||
}
|
||||
|
||||
// Record Head Data
|
||||
@@ -248,12 +237,14 @@ public class UmaViewerBuilder : MonoBehaviour
|
||||
}
|
||||
|
||||
string head = UmaDatabaseController.HeadPath + $"chr{head_id}_{head_costumeId}/pfb_chr{head_id}_{head_costumeId}";
|
||||
asset = UmaViewerMain.Instance.AbChara.FirstOrDefault(a => a.Name == head);
|
||||
asset = null;
|
||||
Main.AbList.TryGetValue(head, out asset);
|
||||
|
||||
bool isDefaultHead = false;
|
||||
//Some costumes don't have custom heads
|
||||
if (head_costumeId != "00" && asset == null)
|
||||
{
|
||||
asset = UmaViewerMain.Instance.AbChara.FirstOrDefault(a => a.Name == UmaDatabaseController.HeadPath + $"chr{head_id}_00/pfb_chr{head_id}_00");
|
||||
asset = Main.AbList[UmaDatabaseController.HeadPath + $"chr{head_id}_00/pfb_chr{head_id}_00"];
|
||||
isDefaultHead = true;
|
||||
}
|
||||
|
||||
@@ -264,25 +255,20 @@ public class UmaViewerBuilder : MonoBehaviour
|
||||
{
|
||||
RecursiveLoadAsset(asset1);
|
||||
}
|
||||
|
||||
//Load Head
|
||||
RecursiveLoadAsset(asset);
|
||||
|
||||
//Load Physics
|
||||
if (isDefaultHead)
|
||||
{
|
||||
foreach (var asset1 in UmaViewerMain.Instance.AbChara.Where(a => a.Name.StartsWith($"{UmaDatabaseController.HeadPath}chr{head_id}_00/clothes")))
|
||||
{
|
||||
if (asset1.Name.Contains("cloth00"))
|
||||
RecursiveLoadAsset(asset1);
|
||||
}
|
||||
var asset1 = Main.AbList[UmaDatabaseController.HeadPath + $"chr{id}_00/clothes/pfb_chr{id}_00_cloth00"];
|
||||
RecursiveLoadAsset(asset1);
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (var asset1 in UmaViewerMain.Instance.AbChara.Where(a => a.Name.StartsWith($"{UmaDatabaseController.HeadPath}chr{head_id}_{head_costumeId}/clothes")))
|
||||
{
|
||||
if (asset1.Name.Contains("cloth00"))
|
||||
RecursiveLoadAsset(asset1);
|
||||
}
|
||||
var asset1 = Main.AbList[UmaDatabaseController.HeadPath + $"chr{id}_{costumeId}/clothes/pfb_chr{id}_{costumeId}_cloth00"];
|
||||
RecursiveLoadAsset(asset1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -291,22 +277,20 @@ public class UmaViewerBuilder : MonoBehaviour
|
||||
string tailName = $"tail{tailId.ToString().PadLeft(4, '0')}_00";
|
||||
string tailPath = $"3d/chara/tail/{tailName}/";
|
||||
string tailPfb = tailPath + $"pfb_{tailName}";
|
||||
asset = UmaViewerMain.Instance.AbChara.FirstOrDefault(a => a.Name == tailPfb);
|
||||
asset = null;
|
||||
Main.AbList.TryGetValue(tailPfb, out asset);
|
||||
if (asset != null)
|
||||
{
|
||||
foreach (var asset1 in UmaViewerMain.Instance.AbChara.Where(a => a.Name.StartsWith($"{tailPath}textures/tex_{tailName}_{head_id}") || a.Name.StartsWith($"{tailPath}textures/tex_{tailName}_0000")))
|
||||
foreach (var asset2 in UmaViewerMain.Instance.AbChara.Where(a => a.Name.StartsWith($"{tailPath}textures/tex_{tailName}_{head_id}") || a.Name.StartsWith($"{tailPath}textures/tex_{tailName}_0000")))
|
||||
{
|
||||
RecursiveLoadAsset(asset1);
|
||||
RecursiveLoadAsset(asset2);
|
||||
}
|
||||
|
||||
RecursiveLoadAsset(asset);
|
||||
|
||||
|
||||
//Load Physics
|
||||
foreach (var asset1 in UmaViewerMain.Instance.AbChara.Where(a => a.Name.StartsWith($"{tailPath}clothes")))
|
||||
{
|
||||
if (asset1.Name.Contains("cloth00"))
|
||||
RecursiveLoadAsset(asset1);
|
||||
}
|
||||
var asset1 = Main.AbList[$"{tailPath}clothes/pfb_{tailName}_cloth00"];
|
||||
RecursiveLoadAsset(asset1);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -314,25 +298,25 @@ public class UmaViewerBuilder : MonoBehaviour
|
||||
}
|
||||
}
|
||||
|
||||
CurrentUMAContainer.LoadPhysics(); //Need to load physics before loading FacialMorph
|
||||
CurrentUMAContainer.LoadPhysics();
|
||||
CurrentUMAContainer.SetDynamicBoneEnable(UI.DynamicBoneEnable);
|
||||
|
||||
//Load FacialMorph
|
||||
LoadFaceMorph(id, costumeId);
|
||||
|
||||
CurrentUMAContainer.TearControllers.ForEach(a => a.SetDir(a.CurrentDir));
|
||||
CurrentUMAContainer.HeadBone = (GameObject)CurrentUMAContainer.Body.GetComponent<AssetHolder>()._assetTable["head"];
|
||||
CurrentUMAContainer.EyeHeight = CurrentUMAContainer.Head.GetComponent<AssetHolder>()._assetTableValue["head_center_offset_y"];
|
||||
CurrentUMAContainer.MergeModel();
|
||||
CurrentUMAContainer.SetHeight(-1);
|
||||
CurrentUMAContainer.Initialize(!UI.isTPose);
|
||||
if (!UI.isTPose)
|
||||
if (!UI.isTPose && loadMotion)
|
||||
{
|
||||
LoadAsset(UmaViewerMain.Instance.AbMotions.FirstOrDefault(a => a.Name.EndsWith($"anm_eve_chr{id}_00_idle01_loop")));
|
||||
if (Main.AbList.TryGetValue($"3d/motion/event/body/chara/chr{id}_00/anm_eve_chr{id}_00_idle01_loop", out UmaDatabaseEntry entry))
|
||||
{
|
||||
LoadAsset(entry);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void LoadMobUma(CharaEntry chara, string costumeId, int bodyid = -1)
|
||||
private void LoadMobUma(CharaEntry chara, string costumeId, int bodyid = -1, bool loadMotion = false)
|
||||
{
|
||||
int id = chara.Id;
|
||||
CurrentUMAContainer.IsMob = chara.IsMob;
|
||||
@@ -378,16 +362,15 @@ public class UmaViewerBuilder : MonoBehaviour
|
||||
body = UmaDatabaseController.BodyPath + $"bdy{costumeIdShort}/pfb_bdy{costumeId}_{height}_{shape}_{bust}";
|
||||
|
||||
Debug.Log("Looking for " + body);
|
||||
asset = UmaViewerMain.Instance.AbChara.FirstOrDefault(a => a.Name == body);
|
||||
Main.AbList.TryGetValue(body, out asset);
|
||||
}
|
||||
else asset = UmaViewerMain.Instance.AbChara.FirstOrDefault(a => a.Name == UmaDatabaseController.BodyPath + $"bdy{bodyid}_{costumeId}/pfb_bdy{bodyid}_{costumeId}");
|
||||
else Main.AbList.TryGetValue($"{UmaDatabaseController.BodyPath}bdy{bodyid}_{costumeId}/pfb_bdy{bodyid}_{costumeId}", out asset);
|
||||
|
||||
if (asset == null)
|
||||
{
|
||||
Debug.LogError("No body, can't load!");
|
||||
return;
|
||||
}
|
||||
|
||||
else if (genericCostume)
|
||||
{
|
||||
string texPattern1 = "", texPattern2 = "", texPattern3 = "", texPattern4 = "", texPattern5 = "";
|
||||
@@ -424,35 +407,27 @@ public class UmaViewerBuilder : MonoBehaviour
|
||||
{
|
||||
RecursiveLoadAsset(asset1);
|
||||
}
|
||||
|
||||
//Load Body
|
||||
RecursiveLoadAsset(asset);
|
||||
|
||||
bool physicsloaded = false, physicsloaded2 = false;
|
||||
//Load Physics
|
||||
foreach (var asset1 in UmaViewerMain.Instance.AbChara.Where(a => a.Name.StartsWith(UmaDatabaseController.BodyPath + $"bdy{costumeIdShort}/clothes")))
|
||||
if (Main.AbList.TryGetValue(UmaDatabaseController.BodyPath + $"bdy{costumeIdShort}/clothes/pfb_bdy{costumeIdShort}_cloth00", out _))
|
||||
{
|
||||
if (asset1.Name.Contains("cloth00") && asset1.Name.Contains("bust" + bust) && !physicsloaded)
|
||||
{
|
||||
RecursiveLoadAsset(asset1);
|
||||
physicsloaded = true;
|
||||
}
|
||||
else if (asset1.Name.Contains("cloth00") && !asset1.Name.Contains("bust") && !physicsloaded2)
|
||||
{
|
||||
RecursiveLoadAsset(asset1);
|
||||
physicsloaded2 = true;
|
||||
}
|
||||
var asset1 = Main.AbList[UmaDatabaseController.BodyPath + $"bdy{costumeIdShort}/clothes/pfb_bdy{costumeIdShort}_cloth00"];
|
||||
RecursiveLoadAsset(asset1);
|
||||
asset1 = Main.AbList[UmaDatabaseController.BodyPath + $"bdy{costumeIdShort}/clothes/pfb_bdy{costumeIdShort}_bust{bust}_cloth00"];
|
||||
RecursiveLoadAsset(asset1);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
RecursiveLoadAsset(asset);
|
||||
|
||||
//Load Physics
|
||||
foreach (var asset1 in UmaViewerMain.Instance.AbChara.Where(a => a.Name.StartsWith(UmaDatabaseController.BodyPath + $"bdy{bodyid}_{costumeId}/clothes")))
|
||||
{
|
||||
if (asset1.Name.Contains("cloth00"))
|
||||
RecursiveLoadAsset(asset1);
|
||||
}
|
||||
var asset1 = Main.AbList[UmaDatabaseController.BodyPath + $"bdy{bodyid}_{costumeId}/clothes/pfb_bdy{bodyid}_{costumeId}_cloth00"];
|
||||
RecursiveLoadAsset(asset1);
|
||||
asset1 = Main.AbList[UmaDatabaseController.BodyPath + $"bdy{bodyid}_{costumeId}/clothes/pfb_bdy{bodyid}_{costumeId}_bust_cloth00"];
|
||||
RecursiveLoadAsset(asset1);
|
||||
}
|
||||
|
||||
// Record Head Data
|
||||
@@ -471,8 +446,8 @@ public class UmaViewerBuilder : MonoBehaviour
|
||||
var head_s = head_id.ToString().PadLeft(4, '0');
|
||||
string head = UmaDatabaseController.HeadPath + $"chr{head_s}_{head_costumeId}/pfb_chr{head_s}_{head_costumeId}_face{faceid.PadLeft(3, '0')}";
|
||||
string hair = UmaDatabaseController.HeadPath + $"chr{head_s}_{head_costumeId}/pfb_chr{head_s}_{head_costumeId}_hair{hairid.PadLeft(3, '0')}";
|
||||
asset = UmaViewerMain.Instance.AbChara.FirstOrDefault(a => a.Name == head);
|
||||
var hairasset = UmaViewerMain.Instance.AbChara.FirstOrDefault(a => a.Name == hair);
|
||||
Main.AbList.TryGetValue(head, out asset);
|
||||
Main.AbList.TryGetValue(hair, out UmaDatabaseEntry hairasset);
|
||||
bool isDefaultHead = true;
|
||||
|
||||
|
||||
@@ -503,13 +478,13 @@ public class UmaViewerBuilder : MonoBehaviour
|
||||
//Load Physics
|
||||
if (isDefaultHead)
|
||||
{
|
||||
foreach (var asset1 in UmaViewerMain.Instance.AbChara.Where(a => a.Name.StartsWith($"{UmaDatabaseController.HeadPath}chr{head_s}_00/clothes")))
|
||||
if (Main.AbList.TryGetValue($"{UmaDatabaseController.HeadPath}chr{head_s}_00/clothes/pfb_chr{head_s}_00_hair{hairid.PadLeft(3, '0')}_cloth00", out UmaDatabaseEntry asset1))
|
||||
{
|
||||
if (asset1.Name.Contains($"hair{hairid.PadLeft(3, '0')}_cloth00"))
|
||||
RecursiveLoadAsset(asset1);
|
||||
RecursiveLoadAsset(asset1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (tailId != 0)
|
||||
{
|
||||
string tailName = $"tail{tailId.ToString().PadLeft(4, '0')}_00";
|
||||
@@ -526,10 +501,9 @@ public class UmaViewerBuilder : MonoBehaviour
|
||||
|
||||
|
||||
//Load Physics
|
||||
foreach (var asset1 in UmaViewerMain.Instance.AbChara.Where(a => a.Name.StartsWith($"{tailPath}clothes")))
|
||||
if (Main.AbList.TryGetValue($"{tailPath}clothes/pfb_{tailName}_cloth00", out UmaDatabaseEntry asset2))
|
||||
{
|
||||
if (asset1.Name.Contains("cloth00"))
|
||||
RecursiveLoadAsset(asset1);
|
||||
RecursiveLoadAsset(asset2);
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -550,9 +524,13 @@ public class UmaViewerBuilder : MonoBehaviour
|
||||
CurrentUMAContainer.MergeModel();
|
||||
CurrentUMAContainer.SetHeight(-1);
|
||||
CurrentUMAContainer.Initialize(!UI.isTPose);
|
||||
if (!UI.isTPose)
|
||||
|
||||
if (!UI.isTPose && loadMotion)
|
||||
{
|
||||
LoadAsset(UmaViewerMain.Instance.AbMotions.FirstOrDefault(a => a.Name.EndsWith($"homestand{personality.PadLeft(2, '0')}_loop")));
|
||||
if (Main.AbList.TryGetValue($"3d/motion/event/body/type00/anm_eve_type00_homestand{personality.PadLeft(2, '0')}_loop", out UmaDatabaseEntry entry))
|
||||
{
|
||||
LoadAsset(entry);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -575,9 +553,9 @@ public class UmaViewerBuilder : MonoBehaviour
|
||||
{
|
||||
costumeIdShort = costumeId.Remove(costumeId.LastIndexOf('_'));
|
||||
string body = $"3d/chara/mini/body/mbdy{costumeIdShort}/pfb_mbdy{costumeId}_0";
|
||||
asset = UmaViewerMain.Instance.AbChara.FirstOrDefault(a => a.Name == body);
|
||||
Main.AbList.TryGetValue(body,out asset);
|
||||
}
|
||||
else asset = UmaViewerMain.Instance.AbChara.FirstOrDefault(a => a.Name == $"3d/chara/mini/body/mbdy{id}_{costumeId}/pfb_mbdy{id}_{costumeId}");
|
||||
else Main.AbList.TryGetValue($"3d/chara/mini/body/mbdy{id}_{costumeId}/pfb_mbdy{id}_{costumeId}",out asset);
|
||||
if (asset == null)
|
||||
{
|
||||
Debug.LogError("No body, can't load!");
|
||||
@@ -607,12 +585,13 @@ public class UmaViewerBuilder : MonoBehaviour
|
||||
RecursiveLoadAsset(asset);
|
||||
|
||||
string hair = $"3d/chara/mini/head/mchr{id}_{costumeId}/pfb_mchr{id}_{costumeId}_hair";
|
||||
asset = UmaViewerMain.Instance.AbChara.FirstOrDefault(a => a.Name == hair);
|
||||
Main.AbList.TryGetValue(hair, out asset);
|
||||
if (costumeId != "00" && asset == null)
|
||||
{
|
||||
customHead = false;
|
||||
asset = UmaViewerMain.Instance.AbChara.FirstOrDefault(a => a.Name == $"3d/chara/mini/head/mchr{id}_00/pfb_mchr{id}_00_hair");
|
||||
Main.AbList.TryGetValue($"3d/chara/mini/head/mchr{id}_00/pfb_mchr{id}_00_hair", out asset);
|
||||
}
|
||||
|
||||
if (asset != null)
|
||||
{
|
||||
//Load Hair Textures
|
||||
@@ -636,7 +615,7 @@ public class UmaViewerBuilder : MonoBehaviour
|
||||
}
|
||||
|
||||
string head = $"3d/chara/mini/head/mchr0001_00/pfb_mchr0001_00_face0";
|
||||
asset = UmaViewerMain.Instance.AbChara.FirstOrDefault(a => a.Name == head);
|
||||
Main.AbList.TryGetValue(head,out asset);
|
||||
if (asset != null)
|
||||
{
|
||||
//Load Head Textures
|
||||
@@ -655,7 +634,11 @@ public class UmaViewerBuilder : MonoBehaviour
|
||||
var eyebrowLmat = matList.FirstOrDefault(a => a.gameObject.name.Equals("M_Mayu_L"));
|
||||
var eyebrowRmat = matList.FirstOrDefault(a => a.gameObject.name.Equals("M_Mayu_R"));
|
||||
UI.LoadFacialPanelsMini(eyemat.material, eyebrowLmat.material, eyebrowRmat.material, mouthmat.material);
|
||||
LoadAsset(UmaViewerMain.Instance.AbMotions.FirstOrDefault(a => a.Name.EndsWith($"anm_min_eve_chr{id}_00_idle01_loop")));
|
||||
|
||||
if(Main.AbList.TryGetValue($"3d/motion/mini/event/body/chara/chr{id}_00/anm_min_eve_chr{id}_00_idle01_loop",out asset))
|
||||
{
|
||||
LoadAsset(asset);
|
||||
}
|
||||
}
|
||||
|
||||
public void LoadProp(UmaDatabaseEntry entry)
|
||||
@@ -935,7 +918,7 @@ public class UmaViewerBuilder : MonoBehaviour
|
||||
{
|
||||
foreach (string prerequisite in entry.Prerequisites.Split(';'))
|
||||
{
|
||||
RecursiveLoadAsset(Main.AbList[prerequisite], true, SetParent);
|
||||
RecursiveLoadAsset(Main.AbList[prerequisite], true, SetParent);
|
||||
}
|
||||
}
|
||||
LoadAsset(entry, IsSubAsset, SetParent);
|
||||
@@ -1465,7 +1448,13 @@ public class UmaViewerBuilder : MonoBehaviour
|
||||
var eyeLocator_L = headBone.transform.Find("Eye_target_locator_L");
|
||||
var eyeLocator_R = headBone.transform.Find("Eye_target_locator_R");
|
||||
|
||||
var mangaEntry = Main.AbEffect.FindAll(a => a.Name.StartsWith("3d/effect/charaemotion/pfb_eff_chr_emo_eye"));
|
||||
var mangaEntry = new List<UmaDatabaseEntry>()
|
||||
{
|
||||
Main.AbList["3d/effect/charaemotion/pfb_eff_chr_emo_eye_000"],
|
||||
Main.AbList["3d/effect/charaemotion/pfb_eff_chr_emo_eye_001"],
|
||||
Main.AbList["3d/effect/charaemotion/pfb_eff_chr_emo_eye_002"],
|
||||
Main.AbList["3d/effect/charaemotion/pfb_eff_chr_emo_eye_003"],
|
||||
};
|
||||
var mangaObjects = new List<GameObject>();
|
||||
mangaEntry.ForEach(entry =>
|
||||
{
|
||||
@@ -1487,11 +1476,16 @@ public class UmaViewerBuilder : MonoBehaviour
|
||||
CurrentUMAContainer.RightMangaObject.Add(RightObj);
|
||||
});
|
||||
|
||||
var tearEntry = Main.AbChara.FindAll(a => a.Name.StartsWith("3d/chara/common/tear/") && a.Name.Contains("pfb_chr_tear"));
|
||||
var tearEntry = new List<UmaDatabaseEntry>() {
|
||||
Main.AbList["3d/chara/common/tear/tear000/pfb_chr_tear000"],
|
||||
Main.AbList["3d/chara/common/tear/tear001/pfb_chr_tear001"],
|
||||
};
|
||||
|
||||
if (tearEntry.Count > 0)
|
||||
{
|
||||
tearEntry.ForEach(a => RecursiveLoadAsset(a));
|
||||
}
|
||||
|
||||
if (CurrentUMAContainer.TearPrefab_0 && CurrentUMAContainer.TearPrefab_1)
|
||||
{
|
||||
var p0 = CurrentUMAContainer.TearPrefab_0;
|
||||
@@ -1506,7 +1500,11 @@ public class UmaViewerBuilder : MonoBehaviour
|
||||
var firsehead = CurrentUMAContainer.Head;
|
||||
var origin_faceDriven = firsehead.GetComponent<AssetHolder>()._assetTable["facial_target"] as FaceDrivenKeyTarget;
|
||||
var faceDriven = ScriptableObject.CreateInstance<FaceDrivenKeyTarget>();
|
||||
DeepCopy.CopyValues(origin_faceDriven, faceDriven);
|
||||
faceDriven._eyebrowTarget = origin_faceDriven._eyebrowTarget;
|
||||
faceDriven._eyeTarget = origin_faceDriven._eyeTarget;
|
||||
faceDriven._mouthTarget = origin_faceDriven._mouthTarget;
|
||||
faceDriven.name = $"char{id}_{costumeId}_face_target";
|
||||
|
||||
var earDriven = firsehead.GetComponent<AssetHolder>()._assetTable["ear_target"] as DrivenKeyTarget;
|
||||
var faceOverride = firsehead.GetComponent<AssetHolder>()._assetTable["face_override"] as FaceOverrideData;
|
||||
faceDriven._earTarget = earDriven._targetFaces;
|
||||
@@ -1515,13 +1513,13 @@ public class UmaViewerBuilder : MonoBehaviour
|
||||
CurrentUMAContainer.FaceOverrideData = faceOverride;
|
||||
faceOverride?.SetEnable(UI.EnableFaceOverride);
|
||||
faceDriven.DrivenKeyLocator = locator.transform;
|
||||
faceDriven.Initialize(firsehead.GetComponentsInChildren<Transform>().ToList());
|
||||
faceDriven.Initialize(UmaUtility.ConvertArrayToDictionary(firsehead.GetComponentsInChildren<Transform>()));
|
||||
|
||||
var emotionDriven = ScriptableObject.CreateInstance<FaceEmotionKeyTarget>();
|
||||
emotionDriven.name = $"char{id}_{costumeId}_emotion_target";
|
||||
CurrentUMAContainer.FaceEmotionKeyTarget = emotionDriven;
|
||||
emotionDriven.FaceDrivenKeyTarget = faceDriven;
|
||||
emotionDriven.FaceEmotionKey = UmaDatabaseController.Instance.FaceTypeData.ToList();
|
||||
emotionDriven.FaceEmotionKey = UmaDatabaseController.Instance.FaceTypeData;
|
||||
emotionDriven.Initialize();
|
||||
}
|
||||
|
||||
@@ -1657,16 +1655,16 @@ public class UmaViewerBuilder : MonoBehaviour
|
||||
if (param.Length > 4)
|
||||
{
|
||||
int index = int.Parse(param[4]);
|
||||
if(index == 1)
|
||||
if (index == 1)
|
||||
{
|
||||
foreach(var entry in Main.AbMotions.Where(a => a.Name.Contains($"{param[0]}_{param[1]}_{param[2]}_{param[3]}_")))
|
||||
foreach (var entry in Main.AbMotions.Where(a => a.Name.Contains($"{param[0]}_{param[1]}_{param[2]}_{param[3]}_")))
|
||||
{
|
||||
UmaAssetManager.LoadAssetBundle(entry, isRecursive: false);
|
||||
}
|
||||
}
|
||||
index++;
|
||||
var nextMotion = Main.AbMotions.FirstOrDefault(a => a.Name.EndsWith($"{param[0]}_{param[1]}_{param[2]}_{param[3]}_0{index}"));
|
||||
|
||||
index++;
|
||||
var nextMotion = Main.AbMotions.FirstOrDefault(a => a.Name.EndsWith($"{param[0]}_{param[1]}_{param[2]}_{param[3]}_0{index}"));
|
||||
|
||||
var aevent = new AnimationEvent
|
||||
{
|
||||
time = clip.length * 0.99f,
|
||||
@@ -1818,7 +1816,7 @@ public class UmaViewerBuilder : MonoBehaviour
|
||||
public Sprite LoadCharaIcon(string id)
|
||||
{
|
||||
string value = $"chara/chr{id}/chr_icon_{id}";
|
||||
if (UmaViewerMain.Instance.AbList.TryGetValue(value,out UmaDatabaseEntry entry))
|
||||
if (UmaViewerMain.Instance.AbList.TryGetValue(value, out UmaDatabaseEntry entry))
|
||||
{
|
||||
AssetBundle assetBundle = UmaAssetManager.LoadAssetBundle(entry, true);
|
||||
if (assetBundle.Contains($"chr_icon_{id}"))
|
||||
@@ -1835,7 +1833,8 @@ public class UmaViewerBuilder : MonoBehaviour
|
||||
public Sprite LoadMobCharaIcon(string id)
|
||||
{
|
||||
string value = $"mob/mob_chr_icon_{id}_000001_01";
|
||||
if (UmaViewerMain.Instance.AbList.TryGetValue(value,out UmaDatabaseEntry entry)) {
|
||||
if (UmaViewerMain.Instance.AbList.TryGetValue(value, out UmaDatabaseEntry entry))
|
||||
{
|
||||
string path = entry.FilePath;
|
||||
AssetBundle assetBundle = UmaAssetManager.LoadAssetBundle(entry, true);
|
||||
if (assetBundle.Contains($"mob_chr_icon_{id}_000001_01"))
|
||||
@@ -1862,7 +1861,7 @@ public class UmaViewerBuilder : MonoBehaviour
|
||||
{
|
||||
string value = $"live/jacket/jacket_icon_l_{musicid}";
|
||||
|
||||
if (UmaViewerMain.Instance.AbList.TryGetValue(value, out UmaDatabaseEntry entry))
|
||||
if (UmaViewerMain.Instance.AbList.TryGetValue(value, out UmaDatabaseEntry entry))
|
||||
{
|
||||
AssetBundle assetBundle = UmaAssetManager.LoadAssetBundle(entry, true);
|
||||
if (assetBundle.Contains($"jacket_icon_l_{musicid}"))
|
||||
@@ -1892,10 +1891,11 @@ public class UmaViewerBuilder : MonoBehaviour
|
||||
UmaViewerUI.Instance.currentFaceDrivenKeyTarget = null;
|
||||
UmaViewerUI.Instance.LoadEmotionPanels(null);
|
||||
UmaViewerUI.Instance.LoadFacialPanels(null);
|
||||
foreach (Transform t in UmaViewerUI.Instance.MaterialsList.content)
|
||||
{
|
||||
Destroy(t.gameObject);
|
||||
}
|
||||
if (UmaViewerUI.Instance.MaterialsList)
|
||||
foreach (Transform t in UmaViewerUI.Instance.MaterialsList.content)
|
||||
{
|
||||
Destroy(t.gameObject);
|
||||
}
|
||||
|
||||
if (CurrentUMAContainer.transform.parent && CurrentUMAContainer.transform.parent.name.Contains("Root"))
|
||||
{
|
||||
|
||||
@@ -5,6 +5,8 @@ using UnityEngine;
|
||||
using System;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using System.Collections;
|
||||
using System.Diagnostics;
|
||||
using Debug = UnityEngine.Debug;
|
||||
|
||||
public class UmaViewerMain : MonoBehaviour
|
||||
{
|
||||
@@ -28,12 +30,15 @@ public class UmaViewerMain : MonoBehaviour
|
||||
Instance = this;
|
||||
new Config();
|
||||
Application.targetFrameRate = 120;
|
||||
|
||||
AbList = UmaDatabaseController.Instance.MetaEntries;
|
||||
AbChara = AbList.Where(ab => ab.Key.StartsWith(UmaDatabaseController.CharaPath)).Select(ab=>ab.Value).ToList();
|
||||
AbMotions = AbList.Where(ab => ab.Key.StartsWith(UmaDatabaseController.MotionPath)).Select(ab => ab.Value).ToList();
|
||||
AbEffect = AbList.Where(ab => ab.Key.StartsWith(UmaDatabaseController.EffectPath)).Select(ab => ab.Value).ToList();
|
||||
AbSounds = AbList.Where(ab => ab.Key.EndsWith(".awb") || ab.Key.EndsWith(".acb")).Select(ab => ab.Value).ToList();
|
||||
CostumeList = AbList.Where(ab => ab.Key.StartsWith(UmaDatabaseController.CostumePath)).Select(ab => ab.Value).ToList();
|
||||
var chara_3d = AbList.Where(ab => ab.Value.Type == UmaFileType._3d_cutt).Select(ab => ab.Value).ToList();
|
||||
AbChara = chara_3d.FindAll(ab => ab.Name.StartsWith(UmaDatabaseController.CharaPath));
|
||||
AbMotions = chara_3d.FindAll(ab => ab.Name.StartsWith(UmaDatabaseController.MotionPath));
|
||||
AbEffect = chara_3d.FindAll(ab => ab.Name.StartsWith(UmaDatabaseController.EffectPath));
|
||||
AbSounds = AbList.Where(ab => ab.Value.Type == UmaFileType.sound).Select(ab => ab.Value).ToList();
|
||||
var outgame = AbList.Where(ab => ab.Value.Type == UmaFileType.outgame).Select(ab => ab.Value).ToList();
|
||||
CostumeList = outgame.FindAll(e => e.Name.StartsWith(UmaDatabaseController.CostumePath));
|
||||
}
|
||||
|
||||
private IEnumerator Start()
|
||||
@@ -46,7 +51,6 @@ public class UmaViewerMain : MonoBehaviour
|
||||
if (Config.Instance.Language == Language.En)
|
||||
{
|
||||
loadingUI.LoadingProgressChange(0, 11, "Downloading Character Data");
|
||||
yield return null;
|
||||
yield return UmaViewerDownload.DownloadText("https://www.tracenacademy.com/api/BasicCharaDataInfo", txt =>
|
||||
{
|
||||
if (string.IsNullOrEmpty(txt)) return;
|
||||
@@ -62,7 +66,6 @@ public class UmaViewerMain : MonoBehaviour
|
||||
|
||||
//Mob names (EN & JP)
|
||||
loadingUI.LoadingProgressChange(1, 11, "Downloading Mob Data");
|
||||
yield return null;
|
||||
yield return UmaViewerDownload.DownloadText("https://www.tracenacademy.com/api/BasicMobDataInfo", txt =>
|
||||
{
|
||||
if (string.IsNullOrEmpty(txt)) return;
|
||||
|
||||
@@ -421,7 +421,7 @@ public class UmaViewerUI : MonoBehaviour
|
||||
public void LoadFacialPanels(FaceDrivenKeyTarget target)
|
||||
{
|
||||
currentFaceDrivenKeyTarget = target;
|
||||
|
||||
if(FacialList)
|
||||
foreach (UmaUIContainer ui in FacialList.GetComponentsInChildren<UmaUIContainer>(true))
|
||||
{
|
||||
Destroy(ui.gameObject);
|
||||
@@ -549,6 +549,7 @@ public class UmaViewerUI : MonoBehaviour
|
||||
|
||||
public void LoadEmotionPanels(FaceEmotionKeyTarget target)
|
||||
{
|
||||
if (EmotionList)
|
||||
foreach (UmaUIContainer ui in EmotionList.content.GetComponentsInChildren<UmaUIContainer>())
|
||||
{
|
||||
Destroy(ui.gameObject);
|
||||
@@ -749,7 +750,7 @@ public class UmaViewerUI : MonoBehaviour
|
||||
list.AddRange(Main.AbChara.Where(a => a.Name.StartsWith(UmaDatabaseController.HeadPath) && a.Name.Contains(chara.Id.ToString())));
|
||||
list.AddRange(Main.AbChara.Where(a => a.Name.StartsWith("3d/chara/tail")));
|
||||
list.Add(Main.AbList["3d/animator/drivenkeylocator"]);
|
||||
list.Add(Main.AbMotions.FirstOrDefault(a => a.Name.EndsWith($"anm_eve_chr{chara.Id}_00_idle01_loop")));
|
||||
list.Add(Main.AbList[$"3d/motion/event/body/chara/chr{achara.Id}_00/anm_eve_chr{achara.Id}_00_idle01_loop"]);
|
||||
|
||||
|
||||
Builder.UnloadUma();
|
||||
@@ -802,14 +803,14 @@ public class UmaViewerUI : MonoBehaviour
|
||||
list.AddRange(Main.AbChara.Where(a => a.Name.StartsWith(UmaDatabaseController.HeadPath) && a.Name.Contains(chara.Id.ToString())));
|
||||
list.AddRange(Main.AbChara.Where(a => a.Name.StartsWith("3d/chara/tail")));
|
||||
list.Add(Main.AbList["3d/animator/drivenkeylocator"]);
|
||||
list.Add(Main.AbMotions.FirstOrDefault(a => a.Name.EndsWith($"anm_eve_chr{chara.Id}_00_idle01_loop")));
|
||||
|
||||
if(!chara.IsMob && !isHeadFix)
|
||||
{
|
||||
list.Add(Main.AbList[$"3d/motion/event/body/chara/chr{chara.Id}_00/anm_eve_chr{chara.Id}_00_idle01_loop"]);
|
||||
}
|
||||
|
||||
Builder.UnloadUma();
|
||||
//UmaAssetManager.UnloadAllBundle(true);
|
||||
UmaAssetManager.PreLoadAndRun(list, delegate {
|
||||
StartCoroutine(Builder.LoadUma(chara, costumeId, mini));
|
||||
});
|
||||
UmaAssetManager.PreLoadAndRun(list, delegate { StartCoroutine(Builder.LoadUma(chara, costumeId, mini)); });
|
||||
//StartCoroutine(Builder.LoadUma(achara, costumeId, mini));
|
||||
}
|
||||
});
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: be8344d1cb7c78742abfc99780af4230
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,59 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using UnityEngine;
|
||||
|
||||
public class UmaUtility
|
||||
{
|
||||
public static Dictionary<string, Transform> ConvertListToDictionary(List<Transform> transformList)
|
||||
{
|
||||
Dictionary<string, Transform> dict = new Dictionary<string, Transform>();
|
||||
|
||||
foreach (Transform transform in transformList)
|
||||
{
|
||||
if (!dict.ContainsKey(transform.name))
|
||||
{
|
||||
dict.Add(transform.name, transform);
|
||||
}
|
||||
}
|
||||
return dict;
|
||||
}
|
||||
|
||||
public static Dictionary<string, Transform> ConvertArrayToDictionary(Transform[] transformArray)
|
||||
{
|
||||
Dictionary<string, Transform> dict = new Dictionary<string, Transform>();
|
||||
|
||||
for (int i = 0; i < transformArray.Length; i++)
|
||||
{
|
||||
Transform transform = transformArray[i];
|
||||
if (!dict.ContainsKey(transform.name))
|
||||
{
|
||||
dict.Add(transform.name, transform);
|
||||
}
|
||||
}
|
||||
return dict;
|
||||
}
|
||||
|
||||
public static Dictionary<string, T> MergeDictionaries<T>(Dictionary<string, T> dict1, Dictionary<string, T> dict2)
|
||||
{
|
||||
Dictionary<string, T> mergedDict = new Dictionary<string, T>(dict1);
|
||||
foreach (var kvp in dict2)
|
||||
{
|
||||
if (!mergedDict.ContainsKey(kvp.Key))
|
||||
{
|
||||
mergedDict.Add(kvp.Key, kvp.Value);
|
||||
}
|
||||
}
|
||||
return mergedDict;
|
||||
}
|
||||
|
||||
public static void CopyValues<T>(T from, T to)
|
||||
{
|
||||
var json = JsonUtility.ToJson(from);
|
||||
JsonUtility.FromJsonOverwrite(json, to);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4227c56e1c9f9564591654f0d69ef04a
|
||||
guid: 0504957ce7fa2b6489c066474e0f3ffa
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
@@ -27,14 +27,13 @@ namespace Gallop
|
||||
|
||||
public List<DynamicBone> DynamicBones = new List<DynamicBone>();
|
||||
|
||||
public List<GameObject> InitiallizeCollider(List<Transform> bones)
|
||||
public Dictionary<string, Transform> InitiallizeCollider(Dictionary<string, Transform> bones)
|
||||
{
|
||||
var colliders = new List<GameObject>();
|
||||
var colliders = new Dictionary<string, Transform>();
|
||||
foreach (CySpringCollisionData collider in collisionParam)
|
||||
{
|
||||
if (collider._isInner) continue;
|
||||
var bone = bones.Find(a => { return a.name == collider._targetObjectName; });
|
||||
if (bone)
|
||||
if (bones.TryGetValue(collider._targetObjectName, out Transform bone))
|
||||
{
|
||||
|
||||
var child = new GameObject(collider._collisionName);
|
||||
@@ -42,7 +41,7 @@ namespace Gallop
|
||||
child.transform.localPosition = Vector3.zero;
|
||||
child.transform.localRotation = Quaternion.identity;
|
||||
child.transform.localScale = Vector3.one;
|
||||
colliders.Add(child);
|
||||
colliders.Add(child.name, child.transform);
|
||||
|
||||
switch (collider._type)
|
||||
{
|
||||
@@ -78,13 +77,12 @@ namespace Gallop
|
||||
return colliders;
|
||||
}
|
||||
|
||||
public void InitializePhysics(List<Transform> bones, List<GameObject> colliders)
|
||||
public void InitializePhysics(Dictionary<string, Transform> bones, Dictionary<string, Transform> colliders)
|
||||
{
|
||||
DynamicBones.Clear();
|
||||
foreach (CySpringParamDataElement spring in springParam)
|
||||
{
|
||||
var bone = bones.Find(a => { return a.name == spring._boneName; });
|
||||
if (bone)
|
||||
if (bones.TryGetValue(spring._boneName,out Transform bone))
|
||||
{
|
||||
bool isTail = gameObject.name.Contains("tail");//The tail needs less traction
|
||||
var dynamic = bone.gameObject.AddComponent<DynamicBone>();
|
||||
@@ -113,15 +111,14 @@ namespace Gallop
|
||||
|
||||
foreach (string collisionName in spring._collisionNameList)
|
||||
{
|
||||
var tmp = colliders.Find(a => { return a.gameObject.name == collisionName; });
|
||||
if (tmp)
|
||||
if (colliders.TryGetValue(collisionName,out Transform tmp))
|
||||
{
|
||||
dynamic.Particles[0].m_Colliders.Add(tmp.GetComponent<DynamicBoneColliderBase>());
|
||||
}
|
||||
}
|
||||
|
||||
foreach (CySpringParamDataChildElement Childcollision in spring._childElements)
|
||||
{
|
||||
|
||||
var tempParticle = dynamic.Particles.Find(a => { return a.m_Transform.gameObject.name == Childcollision._boneName; });
|
||||
if (tempParticle != null)
|
||||
{
|
||||
@@ -143,8 +140,7 @@ namespace Gallop
|
||||
tempParticle.m_LimitAngel_Max = Childcollision._limitAngleMax;
|
||||
foreach (string collisionName in Childcollision._collisionNameList)
|
||||
{
|
||||
var tmp = colliders.Find(a => { return a.gameObject.name == collisionName; });
|
||||
if (tmp)
|
||||
if (colliders.TryGetValue(collisionName,out Transform tmp))
|
||||
{
|
||||
tempParticle.m_Colliders.Add(tmp.GetComponent<DynamicBoneColliderBase>());
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ namespace Gallop
|
||||
public List<MouthTarget> _mouthTarget;
|
||||
public List<TargetInfomation> _earTarget;
|
||||
|
||||
public List<Transform> Objs;
|
||||
public Dictionary<string, Transform> Objs;
|
||||
private FacialMorph BaseLEarMorph, BaseREarMorph;
|
||||
private FacialMorph BaseLEyeBrowMorph, BaseREyeBrowMorph;
|
||||
private FacialMorph BaseLEyeMorph, BaseREyeMorph;
|
||||
@@ -45,16 +45,20 @@ namespace Gallop
|
||||
|
||||
List<FacialMorph> leftEarMorph = new List<FacialMorph>();
|
||||
List<FacialMorph> rightEarMorph = new List<FacialMorph>();
|
||||
public void Initialize(List<Transform> objs)
|
||||
public void Initialize(Dictionary<string, Transform> objs)
|
||||
{
|
||||
Objs = objs;
|
||||
|
||||
List<Particle> particles = new List<Particle>();
|
||||
Dictionary<string, Particle> particles = new Dictionary<string, Particle>();
|
||||
foreach (CySpringDataContainer spring in Container.cySpringDataContainers)
|
||||
{
|
||||
foreach (DynamicBone dynamicbone in spring.DynamicBones)
|
||||
{
|
||||
particles.AddRange(dynamicbone.Particles);
|
||||
foreach(var particle in dynamicbone.Particles)
|
||||
{
|
||||
if (!particles.ContainsKey(particle.m_Transform.name))
|
||||
particles.Add(particle.m_Transform.name,particle);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -70,13 +74,12 @@ namespace Gallop
|
||||
morph.trsArray = _earTarget[i]._faceGroupInfo[j]._trsArray;
|
||||
foreach (TrsArray trs in morph.trsArray)
|
||||
{
|
||||
var physicsParticle = particles.Find(a => a.m_Transform.name.Equals(trs._path));
|
||||
if (physicsParticle != null)
|
||||
if (particles.TryGetValue(trs._path, out Particle physicsParticle))
|
||||
{
|
||||
trs.isPhysics = true;
|
||||
trs.physicsParticle = physicsParticle;
|
||||
}
|
||||
trs.transform = Objs.Find(ani => ani.name.Equals(trs._path));
|
||||
Objs.TryGetValue(trs._path,out trs.transform);
|
||||
}
|
||||
if (i == 0)
|
||||
{
|
||||
@@ -105,7 +108,7 @@ namespace Gallop
|
||||
morph.trsArray = _eyebrowTarget[i]._faceGroupInfo[j]._trsArray;
|
||||
foreach (TrsArray trs in morph.trsArray)
|
||||
{
|
||||
trs.transform = Objs.Find(ani => ani.name.Equals(trs._path));
|
||||
Objs.TryGetValue(trs._path, out trs.transform);
|
||||
}
|
||||
if (i == 0)
|
||||
{
|
||||
@@ -134,7 +137,7 @@ namespace Gallop
|
||||
morph.trsArray = _eyeTarget[i]._faceGroupInfo[j]._trsArray;
|
||||
foreach (TrsArray trs in morph.trsArray)
|
||||
{
|
||||
trs.transform = Objs.Find(ani => ani.name.Equals(trs._path));
|
||||
Objs.TryGetValue(trs._path,out trs.transform);
|
||||
}
|
||||
if (i == 0)
|
||||
{
|
||||
@@ -174,7 +177,7 @@ namespace Gallop
|
||||
morph.trsArray = _mouthTarget[i]._faceGroupInfo[j]._trsArray;
|
||||
foreach (TrsArray trs in morph.trsArray)
|
||||
{
|
||||
trs.transform = Objs.Find(ani => ani.name.Equals(trs._path));
|
||||
Objs.TryGetValue(trs._path, out trs.transform);
|
||||
}
|
||||
if (i == 0)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user