Support for more costumes.
Shader fixes.
This commit is contained in:
@@ -1,52 +0,0 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class HeadTracker : MonoBehaviour
|
||||
{
|
||||
//bool HorseLoaded = false;
|
||||
//public Transform HeadNeck, HeadHead, HorseNeck, HorseHead;
|
||||
|
||||
//private void Start()
|
||||
//{
|
||||
// HeadHead = FindBoneInChildren(transform, "Head");
|
||||
// HeadNeck = FindBoneInChildren(transform, "Neck");
|
||||
//}
|
||||
|
||||
//private void LateUpdate()
|
||||
//{
|
||||
// if (UmaViewerBuilder.Instance.Body != null)
|
||||
// {
|
||||
// if (HorseHead == null)
|
||||
// {
|
||||
// HorseHead = FindBoneInChildren(UmaViewerBuilder.Instance.Body.transform, "Head");
|
||||
// }
|
||||
// if (HorseNeck == null)
|
||||
// {
|
||||
// HorseNeck = FindBoneInChildren(UmaViewerBuilder.Instance.Body.transform, "Neck");
|
||||
// }
|
||||
|
||||
// HeadNeck.transform.position = HorseNeck.transform.position;
|
||||
// HeadNeck.transform.rotation = HorseNeck.transform.rotation;
|
||||
// HeadHead.transform.position = HorseHead.transform.position;
|
||||
// HeadHead.transform.rotation = HorseHead.transform.rotation;
|
||||
// }
|
||||
//}
|
||||
|
||||
//public Transform FindBoneInChildren(Transform trans, string name)
|
||||
//{
|
||||
// foreach (Transform t in trans)
|
||||
// {
|
||||
// if (t.name == name)
|
||||
// {
|
||||
// return t;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// Transform candidate = FindBoneInChildren(t, name);
|
||||
// if (candidate != null) return candidate;
|
||||
// }
|
||||
// }
|
||||
// return null;
|
||||
//}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1c2f066ae47d0204dbce3393e36aa22f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,31 +1,45 @@
|
||||
using Newtonsoft.Json.Linq;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class UmaContainer : MonoBehaviour
|
||||
{
|
||||
public Transform UmaNeckBone;
|
||||
public Transform UmaHeadBone;
|
||||
public Transform HeadNeckBone;
|
||||
public Transform HeadHeadBone;
|
||||
public JObject CharaData;
|
||||
public GameObject Body;
|
||||
public GameObject Tail;
|
||||
public List<Texture2D> TailTextures = new List<Texture2D>();
|
||||
public GameObject Head;
|
||||
public Animator UmaAnimator;
|
||||
public AnimatorOverrideController OverrideController;
|
||||
|
||||
[Header("Generic")]
|
||||
public bool IsGeneric = false;
|
||||
/// <summary> 0 - costume ID, 1 - ?, 2 - ?, 3 - skin color, 4 - socks, 5 - bust </summary>
|
||||
public string[] GenericVariables;
|
||||
public List<Texture2D> GenericBodyTextures = new List<Texture2D>();
|
||||
|
||||
[Header("Mini")]
|
||||
public bool IsMini = false;
|
||||
public List<Texture2D> MiniHeadTextures = new List<Texture2D>();
|
||||
|
||||
[Header("Head Assembly")]
|
||||
public Transform UmaNeckBone;
|
||||
public Transform UmaHeadBone;
|
||||
public List<GameObject> Heads = new List<GameObject>();
|
||||
public List<Transform> HeadNeckBones = new List<Transform>();
|
||||
public List<Transform> HeadHeadBones = new List<Transform>();
|
||||
|
||||
private void LateUpdate()
|
||||
{
|
||||
if (Body != null && Head != null)
|
||||
if (Body != null && Heads.Count > 0)
|
||||
{
|
||||
if (UmaNeckBone == null) UmaNeckBone = FindBoneInChildren(Body.transform, "Neck");
|
||||
if (UmaHeadBone == null) UmaHeadBone = FindBoneInChildren(Body.transform, "Head");
|
||||
if (HeadNeckBone == null) HeadNeckBone = FindBoneInChildren(Head.transform, "Neck");
|
||||
if (HeadHeadBone == null) HeadHeadBone = FindBoneInChildren(Head.transform, "Head");
|
||||
HeadNeckBone.transform.SetPositionAndRotation(UmaNeckBone.position, UmaNeckBone.rotation);
|
||||
HeadHeadBone.transform.SetPositionAndRotation(UmaHeadBone.position, UmaHeadBone.rotation);
|
||||
for (int i = 0; i < Heads.Count; i++)
|
||||
{
|
||||
HeadNeckBones[i].transform.SetPositionAndRotation(UmaNeckBone.position, UmaNeckBone.rotation);
|
||||
HeadHeadBones[i].transform.SetPositionAndRotation(UmaHeadBone.position, UmaHeadBone.rotation);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -42,7 +42,7 @@ public class UmaDatabaseController
|
||||
/// </summary>
|
||||
public static string HeadPath = "3d/chara/head/";
|
||||
/// <summary>
|
||||
/// 3d/motion/event/body/
|
||||
/// 3d/motion/
|
||||
/// </summary>
|
||||
public static string MotionPath = "3d/motion/";
|
||||
public IEnumerable<UmaDatabaseEntry> MetaEntries;
|
||||
|
||||
@@ -10,6 +10,7 @@ public class UmaViewerBuilder : MonoBehaviour
|
||||
{
|
||||
public static UmaViewerBuilder Instance;
|
||||
UmaViewerMain Main => UmaViewerMain.Instance;
|
||||
UmaViewerUI UI => UmaViewerUI.Instance;
|
||||
|
||||
public List<AssetBundle> Loaded;
|
||||
public List<Shader> ShaderList = new List<Shader>();
|
||||
@@ -23,7 +24,7 @@ public class UmaViewerBuilder : MonoBehaviour
|
||||
Instance = this;
|
||||
}
|
||||
|
||||
public IEnumerator LoadUma(int id, string costumeId)
|
||||
public IEnumerator LoadUma(int id, string costumeId, bool mini)
|
||||
{
|
||||
if(CurrentContainer != null)
|
||||
{
|
||||
@@ -36,54 +37,205 @@ public class UmaViewerBuilder : MonoBehaviour
|
||||
bundle.Value.Unload(true);
|
||||
}
|
||||
Main.LoadedBundles.Clear();
|
||||
UI.LoadedAssetsClear();
|
||||
|
||||
yield return UmaViewerDownload.DownloadText($"https://www.tracenacademy.com/api/CharaData/{id}", txt =>
|
||||
{
|
||||
Debug.Log(txt);
|
||||
|
||||
string body = UmaDatabaseController.BodyPath + $"bdy{id}_{costumeId}/pfb_bdy{id}_{costumeId}";
|
||||
UmaDatabaseEntry asset = UmaViewerMain.Instance.AbList.FirstOrDefault(a => a.Name == body);
|
||||
if (asset == null)
|
||||
CurrentContainer.CharaData = JObject.Parse(txt);
|
||||
if (mini)
|
||||
{
|
||||
Debug.LogError("No body, can't load!");
|
||||
return;
|
||||
LoadMiniUma(id, costumeId);
|
||||
}
|
||||
else
|
||||
{
|
||||
LoadNormalUma(id, costumeId);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void LoadNormalUma(int id, string costumeId)
|
||||
{
|
||||
JObject charaData = CurrentContainer.CharaData;
|
||||
bool genericCostume = CurrentContainer.IsGeneric = costumeId.Length == 4;
|
||||
string[] vars = null;
|
||||
string skin = (string)charaData["skin"],
|
||||
socks = (string)charaData["socks"],
|
||||
bust = (string)charaData["bust"];
|
||||
|
||||
UmaDatabaseEntry asset = null;
|
||||
if (genericCostume)
|
||||
{
|
||||
CurrentContainer.GenericVariables = vars = new string[6] { costumeId, "00", "00", skin, socks, bust };
|
||||
for (int i = 0; i < 3; i++)
|
||||
{
|
||||
string body = UmaDatabaseController.BodyPath + $"bdy{costumeId}_00/pfb_bdy{costumeId}_00_0{i}_{0}_{0}_{bust}";
|
||||
asset = UmaViewerMain.Instance.AbList.FirstOrDefault(a => a.Name == body);
|
||||
if (asset != null) break;
|
||||
}
|
||||
}
|
||||
else asset = UmaViewerMain.Instance.AbList.FirstOrDefault(a => a.Name == UmaDatabaseController.BodyPath + $"bdy{id}_{costumeId}/pfb_bdy{id}_{costumeId}");
|
||||
|
||||
if (asset == null)
|
||||
{
|
||||
Debug.LogError("No body, can't load!");
|
||||
return;
|
||||
}
|
||||
else if (genericCostume)
|
||||
{
|
||||
string texPattern1 = "", texPattern2 = "";
|
||||
switch (costumeId)
|
||||
{
|
||||
case "0001":
|
||||
texPattern1 = $"tex_bdy{costumeId}_00_{"00"}_{skin}_{socks}_0{bust}";
|
||||
texPattern2 = $"tex_bdy{costumeId}_00_00_0_{socks}_00_";
|
||||
break;
|
||||
case "0006": //last var is color?
|
||||
texPattern1 = $"tex_bdy{costumeId}_00_{"00"}_{skin}_{bust}_0{0}";
|
||||
texPattern2 = $"tex_bdy{costumeId}_00_00_0_{bust}_00_";
|
||||
break;
|
||||
default:
|
||||
texPattern1 = $"tex_bdy{costumeId}_00_{"00"}_{skin}_{bust}";
|
||||
texPattern2 = $"tex_bdy{costumeId}_00_00_0_{bust}";
|
||||
break;
|
||||
}
|
||||
Debug.Log(texPattern1 + " " + texPattern2);
|
||||
//Load Body Textures
|
||||
foreach (var asset1 in UmaViewerMain.Instance.AbList.Where(a => a.Name.StartsWith(UmaDatabaseController.BodyPath) && (a.Name.Contains(texPattern1) || a.Name.Contains(texPattern2))))
|
||||
{
|
||||
RecursiveLoadAsset(asset1);
|
||||
}
|
||||
//Load Body
|
||||
RecursiveLoadAsset(asset);
|
||||
}
|
||||
else
|
||||
RecursiveLoadAsset(asset);
|
||||
|
||||
string head = UmaDatabaseController.HeadPath + $"chr{id}_{costumeId}/pfb_chr{id}_{costumeId}";
|
||||
asset = UmaViewerMain.Instance.AbList.FirstOrDefault(a => a.Name == head);
|
||||
string head = UmaDatabaseController.HeadPath + $"chr{id}_{costumeId}/pfb_chr{id}_{costumeId}";
|
||||
asset = UmaViewerMain.Instance.AbList.FirstOrDefault(a => a.Name == head);
|
||||
|
||||
//Some costumes don't have custom heads
|
||||
if (costumeId != "00" && asset == null)
|
||||
{
|
||||
asset = UmaViewerMain.Instance.AbList.FirstOrDefault(a => a.Name == UmaDatabaseController.HeadPath + $"chr{id}_00/pfb_chr{id}_00");
|
||||
}
|
||||
if (asset != null)
|
||||
{
|
||||
//Load Hair Textures
|
||||
foreach (var asset1 in UmaViewerMain.Instance.AbList.Where(a => a.Name.StartsWith($"{UmaDatabaseController.HeadPath}chr{id}_{costumeId}/textures")))
|
||||
{
|
||||
RecursiveLoadAsset(asset1);
|
||||
}
|
||||
//Load Head
|
||||
RecursiveLoadAsset(asset);
|
||||
}
|
||||
|
||||
int tailId = (int)charaData["tailModelId"];
|
||||
if (tailId != 0)
|
||||
{
|
||||
string tailName = $"tail{tailId.ToString().PadLeft(4, '0')}_00";
|
||||
string tailPath = $"3d/chara/tail/{tailName}/";
|
||||
string tailPfb = tailPath + $"pfb_{tailName}";
|
||||
asset = UmaViewerMain.Instance.AbList.FirstOrDefault(a => a.Name == tailPfb);
|
||||
if (asset != null)
|
||||
{
|
||||
//Load Hair Textures
|
||||
foreach (var asset1 in UmaViewerMain.Instance.AbList.Where(a => a.Name.StartsWith($"{UmaDatabaseController.HeadPath}chr{id}_{costumeId}/textures")))
|
||||
foreach (var asset1 in UmaViewerMain.Instance.AbList.Where(a => a.Name.StartsWith($"{tailPath}textures/tex_{tailName}_{id}")))
|
||||
{
|
||||
RecursiveLoadAsset(asset1);
|
||||
}
|
||||
//Load Hair
|
||||
RecursiveLoadAsset(asset);
|
||||
}
|
||||
|
||||
int tailId = (int)JObject.Parse(txt)["tailModelId"];
|
||||
if(tailId != 0)
|
||||
else
|
||||
{
|
||||
string tailName = $"tail{tailId.ToString().PadLeft(4, '0')}_00";
|
||||
string tailPath = $"3d/chara/tail/{tailName}/";
|
||||
string tailPfb = tailPath + $"pfb_{tailName}";
|
||||
asset = UmaViewerMain.Instance.AbList.FirstOrDefault(a => a.Name == tailPfb);
|
||||
if (asset != null)
|
||||
Debug.Log("no tail");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void LoadMiniUma(int id, string costumeId)
|
||||
{
|
||||
JObject charaData = CurrentContainer.CharaData;
|
||||
CurrentContainer.IsMini = true;
|
||||
bool isGeneric = CurrentContainer.IsGeneric = costumeId.Length == 4;
|
||||
bool customHead = true;
|
||||
string[] vars = null;
|
||||
string skin = (string)charaData["skin"],
|
||||
socks = (string)charaData["socks"],
|
||||
bust = (string)charaData["bust"],
|
||||
cos0003 = costumeId == "0003" ? "1" : "0";
|
||||
|
||||
UmaDatabaseEntry asset = null;
|
||||
if (isGeneric)
|
||||
{
|
||||
CurrentContainer.GenericVariables = vars = new string[6] { costumeId, "00", "00", skin, socks, bust };
|
||||
for (int i = 0; i < 3; i++)
|
||||
{
|
||||
string body = $"3d/chara/mini/body/mbdy{costumeId}_0{i}/pfb_mbdy{costumeId}_0{i}_0{cos0003}_0";
|
||||
asset = UmaViewerMain.Instance.AbList.FirstOrDefault(a => a.Name == body);
|
||||
if (asset != null) break;
|
||||
}
|
||||
}
|
||||
else asset = UmaViewerMain.Instance.AbList.FirstOrDefault(a => a.Name == $"3d/chara/mini/body/mbdy{id}_{costumeId}/pfb_mbdy{id}_{costumeId}");
|
||||
if (asset == null)
|
||||
{
|
||||
Debug.LogError("No body, can't load!");
|
||||
return;
|
||||
}
|
||||
else if (isGeneric)
|
||||
{
|
||||
string texPattern1 = $"tex_mbdy{costumeId}_0{cos0003}_{"00"}_{skin}_{0}";
|
||||
//Load Body Textures
|
||||
foreach (var asset1 in UmaViewerMain.Instance.AbList.Where(a => a.Name.StartsWith("3d/chara/mini/body/") && a.Name.Contains(texPattern1)))
|
||||
{
|
||||
RecursiveLoadAsset(asset1);
|
||||
}
|
||||
//Load Body
|
||||
RecursiveLoadAsset(asset);
|
||||
}
|
||||
else
|
||||
RecursiveLoadAsset(asset);
|
||||
|
||||
string hair = $"3d/chara/mini/head/mchr{id}_{costumeId}/pfb_mchr{id}_{costumeId}_hair";
|
||||
asset = UmaViewerMain.Instance.AbList.FirstOrDefault(a => a.Name == hair);
|
||||
if (costumeId != "00" && asset == null)
|
||||
{
|
||||
customHead = false;
|
||||
asset = UmaViewerMain.Instance.AbList.FirstOrDefault(a => a.Name == $"3d/chara/mini/head/mchr{id}_00/pfb_mchr{id}_00_hair");
|
||||
}
|
||||
if (asset != null)
|
||||
{
|
||||
//Load Hair Textures
|
||||
if (customHead)
|
||||
{
|
||||
foreach (var asset1 in UmaViewerMain.Instance.AbList.Where(a => a.Name.StartsWith($"3d/chara/mini/head/mchr{id}_{costumeId}/textures")))
|
||||
{
|
||||
foreach (var asset1 in UmaViewerMain.Instance.AbList.Where(a => a.Name.StartsWith($"{tailPath}textures/tex_{tailName}_{id}")))
|
||||
{
|
||||
RecursiveLoadAsset(asset1);
|
||||
}
|
||||
RecursiveLoadAsset(asset);
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.Log("no tail");
|
||||
RecursiveLoadAsset(asset1);
|
||||
}
|
||||
}
|
||||
});
|
||||
else
|
||||
{
|
||||
foreach (var asset1 in UmaViewerMain.Instance.AbList.Where(a => a.Name.StartsWith($"3d/chara/mini/head/mchr{id}_00/textures")))
|
||||
{
|
||||
RecursiveLoadAsset(asset1);
|
||||
}
|
||||
}
|
||||
|
||||
//Load Hair
|
||||
RecursiveLoadAsset(asset);
|
||||
}
|
||||
|
||||
string head = $"3d/chara/mini/head/mchr0001_00/pfb_mchr0001_00_face0";
|
||||
asset = UmaViewerMain.Instance.AbList.FirstOrDefault(a => a.Name == head);
|
||||
if (asset != null)
|
||||
{
|
||||
//Load Head Textures
|
||||
foreach (var asset1 in UmaViewerMain.Instance.AbList.Where(a => a.Name.StartsWith($"3d/chara/mini/head/mchr0001_00/textures/tex_mchr0001_00_face0_{skin}")))
|
||||
{
|
||||
RecursiveLoadAsset(asset1);
|
||||
}
|
||||
//Load Head
|
||||
RecursiveLoadAsset(asset);
|
||||
}
|
||||
}
|
||||
|
||||
private void RecursiveLoadAsset(UmaDatabaseEntry entry)
|
||||
@@ -114,6 +266,7 @@ public class UmaViewerBuilder : MonoBehaviour
|
||||
return;
|
||||
}
|
||||
Main.LoadedBundles.Add(entry.Name, bundle);
|
||||
UI.LoadedAssetsAdd(Path.GetFileName(entry.Name) + " : " + Path.GetFileName(entry.Url));
|
||||
LoadBundle(bundle);
|
||||
}
|
||||
}
|
||||
@@ -153,7 +306,7 @@ public class UmaViewerBuilder : MonoBehaviour
|
||||
}
|
||||
else if (bundle.name.Contains("/body/"))
|
||||
{
|
||||
LoadBody(bundle.name, asset as GameObject);
|
||||
LoadBody(asset as GameObject);
|
||||
}
|
||||
else if (bundle.name.Contains("/tail/"))
|
||||
{
|
||||
@@ -174,48 +327,131 @@ public class UmaViewerBuilder : MonoBehaviour
|
||||
}
|
||||
else if (asset.GetType() == typeof(Texture2D))
|
||||
{
|
||||
if (bundle.name.Contains("/tail/"))
|
||||
if (bundle.name.Contains("/mini/head"))
|
||||
{
|
||||
CurrentContainer.MiniHeadTextures.Add(asset as Texture2D);
|
||||
}
|
||||
else if (bundle.name.Contains("/tail/"))
|
||||
{
|
||||
CurrentContainer.TailTextures.Add(asset as Texture2D);
|
||||
}
|
||||
else if (bundle.name.Contains("bdy0"))
|
||||
{
|
||||
CurrentContainer.GenericBodyTextures.Add(asset as Texture2D);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void LoadBody(string bundleName, GameObject go)
|
||||
private void LoadBody(GameObject go)
|
||||
{
|
||||
string umaID = "";
|
||||
string[] nameSplit = bundleName.Split(new char[] { '/', '_' });
|
||||
foreach (string s in nameSplit)
|
||||
{
|
||||
if (s.Contains("bdy"))
|
||||
{
|
||||
umaID = s.Substring(s.Length - 4, 4);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
CurrentContainer.Body = Instantiate(go, CurrentContainer.transform);
|
||||
CurrentContainer.UmaAnimator = CurrentContainer.Body.GetComponent<Animator>();
|
||||
CurrentContainer.UmaAnimator.runtimeAnimatorController = CurrentContainer.OverrideController = Instantiate(OverrideController);
|
||||
|
||||
foreach (Renderer r in CurrentContainer.Body.GetComponentsInChildren<Renderer>())
|
||||
if (CurrentContainer.IsGeneric)
|
||||
{
|
||||
foreach (Material m in r.sharedMaterials)
|
||||
List<Texture2D> textures = CurrentContainer.GenericBodyTextures;
|
||||
string costumeId = CurrentContainer.GenericVariables[0],
|
||||
var1 = CurrentContainer.GenericVariables[1],
|
||||
var2 = CurrentContainer.GenericVariables[2],
|
||||
skin = CurrentContainer.GenericVariables[3],
|
||||
socks = CurrentContainer.GenericVariables[4],
|
||||
bust = CurrentContainer.GenericVariables[5];
|
||||
|
||||
foreach (Renderer r in CurrentContainer.Body.GetComponentsInChildren<Renderer>())
|
||||
{
|
||||
m.shader = Shader.Find("Nars/UmaMusume/Body");
|
||||
foreach (Material m in r.sharedMaterials)
|
||||
{
|
||||
string mainTex = "", toonMap = "", tripleMap = "", optionMap = "";
|
||||
if (CurrentContainer.IsMini)
|
||||
{
|
||||
m.SetTexture("_MainTex", textures[0]);
|
||||
}
|
||||
else
|
||||
{
|
||||
m.shader = Shader.Find("Nars/UmaMusume/Body");
|
||||
switch (costumeId) //costume ID
|
||||
{
|
||||
case "0001":
|
||||
mainTex = $"tex_bdy{costumeId}_{var1}_{var2}_{skin}_{socks}_{bust.PadLeft(2, '0')}_diff";
|
||||
toonMap = $"tex_bdy{costumeId}_{var1}_{var2}_{skin}_{socks}_{bust.PadLeft(2, '0')}_shad_c";
|
||||
tripleMap = $"tex_bdy{costumeId}_00_00_0_{socks}_00_base";
|
||||
optionMap = $"tex_bdy{costumeId}_00_00_0_{socks}_00_ctrl";
|
||||
break;
|
||||
case "0006":
|
||||
mainTex = $"tex_bdy{costumeId}_{var1}_{var2}_{skin}_{bust}_{"00"}_diff";
|
||||
toonMap = $"tex_bdy{costumeId}_{var1}_{var2}_{skin}_{bust}_{"00"}_shad_c";
|
||||
tripleMap = $"tex_bdy{costumeId}_00_00_0_{bust}_00_base";
|
||||
optionMap = $"tex_bdy{costumeId}_00_00_0_{bust}_00_ctrl";
|
||||
break;
|
||||
default:
|
||||
mainTex = $"tex_bdy{costumeId}_{var1}_{var2}_{skin}_{bust}_diff";
|
||||
toonMap = $"tex_bdy{costumeId}_{var1}_{var2}_{skin}_{bust}_shad_c";
|
||||
tripleMap = $"tex_bdy{costumeId}_00_00_0_{bust}_base";
|
||||
optionMap = $"tex_bdy{costumeId}_00_00_0_{bust}_ctrl";
|
||||
break;
|
||||
|
||||
}
|
||||
m.SetTexture("_MainTex", textures.FirstOrDefault(t => t.name == mainTex));
|
||||
m.SetTexture("_ToonMap", textures.FirstOrDefault(t => t.name == toonMap));
|
||||
m.SetTexture("_TripleMaskMap", textures.FirstOrDefault(t => t.name == tripleMap));
|
||||
m.SetTexture("_OptionMaskMap", textures.FirstOrDefault(t => t.name == optionMap));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
foreach (Renderer r in CurrentContainer.Body.GetComponentsInChildren<Renderer>())
|
||||
{
|
||||
foreach (Material m in r.sharedMaterials)
|
||||
{
|
||||
if (!m.shader.name.Contains("Mini"))
|
||||
{
|
||||
m.shader = Shader.Find("Nars/UmaMusume/Body");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void LoadHead(GameObject go)
|
||||
{
|
||||
CurrentContainer.Head = Instantiate(go, CurrentContainer.transform);
|
||||
GameObject head = Instantiate(go, CurrentContainer.transform);
|
||||
CurrentContainer.Heads.Add(head);
|
||||
CurrentContainer.HeadNeckBones.Add(UmaContainer.FindBoneInChildren(head.transform, "Neck"));
|
||||
CurrentContainer.HeadHeadBones.Add(UmaContainer.FindBoneInChildren(head.transform, "Head"));
|
||||
|
||||
foreach (Renderer r in CurrentContainer.Head.GetComponentsInChildren<Renderer>())
|
||||
foreach (Renderer r in head.GetComponentsInChildren<Renderer>())
|
||||
{
|
||||
foreach (Material m in r.sharedMaterials)
|
||||
{
|
||||
if (head.name.Contains("mchr"))
|
||||
{
|
||||
if(r.name == "M_Face")
|
||||
{
|
||||
m.SetTexture("_MainTex", CurrentContainer.MiniHeadTextures.First(t => t.name.Contains("face") && t.name.Contains("diff")));
|
||||
}
|
||||
if (r.name == "M_Cheek")
|
||||
{
|
||||
m.CopyPropertiesFromMaterial(InvisibleMaterial);
|
||||
m.SetTexture("_MainTex", CurrentContainer.MiniHeadTextures.First(t => t.name.Contains("cheek")));
|
||||
}
|
||||
if (r.name == "M_Mouth")
|
||||
{
|
||||
m.SetTexture("_MainTex", CurrentContainer.MiniHeadTextures.First(t => t.name.Contains("mouth")));
|
||||
}
|
||||
if (r.name == "M_Eye")
|
||||
{
|
||||
m.SetTexture("_MainTex", CurrentContainer.MiniHeadTextures.First(t => t.name.Contains("eye")));
|
||||
}
|
||||
if (r.name.StartsWith("M_Mayu_"))
|
||||
{
|
||||
m.SetTexture("_MainTex", CurrentContainer.MiniHeadTextures.First(t => t.name.Contains("mayu")));
|
||||
}
|
||||
}
|
||||
switch (m.shader.name)
|
||||
{
|
||||
case "Gallop/3D/Chara/MultiplyCheek":
|
||||
@@ -234,7 +470,7 @@ public class UmaViewerBuilder : MonoBehaviour
|
||||
break;
|
||||
default:
|
||||
Debug.LogError(m.shader.name);
|
||||
// m.shader = Shader.Find("Nars/UmaMusume/Body");
|
||||
// m.shader = Shader.Find("Nars/UmaMusume/Body");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -45,86 +45,15 @@ public class UmaViewerMain : MonoBehaviour
|
||||
}
|
||||
}
|
||||
|
||||
var container = Instantiate(UI.UmaContainerPrefab, UI.AnimationSetList.content).GetComponent<UmaUIContainer>();
|
||||
container.Name.text = container.name = "type00";
|
||||
var imageInstance = container.GetComponent<Image>();
|
||||
container.Button.onClick.AddListener(() => {
|
||||
UI.HighlightChildImage(UI.AnimationSetList.content, imageInstance);
|
||||
ListAnimations(-1);
|
||||
});
|
||||
|
||||
foreach (var chara in Characters.OrderBy(c => c.Id))
|
||||
{
|
||||
var charaInstance = chara;
|
||||
container = Instantiate(UI.UmaContainerPrefab, UI.CharactersList.content).GetComponent<UmaUIContainer>();
|
||||
container.Name.text = container.name = chara.Id + " " + chara.Name;
|
||||
var imageInstance1 = container.GetComponent<Image>();
|
||||
container.Button.onClick.AddListener(() => {
|
||||
UI.HighlightChildImage(UI.CharactersList.content, imageInstance1);
|
||||
ListCostumes(charaInstance.Id);
|
||||
});
|
||||
|
||||
container = Instantiate(UI.UmaContainerPrefab, UI.AnimationSetList.content).GetComponent<UmaUIContainer>();
|
||||
container.Name.text = container.name = chara.Id + " " + chara.Name;
|
||||
var imageInstance2 = container.GetComponent<Image>();
|
||||
container.Button.onClick.AddListener(() => {
|
||||
UI.HighlightChildImage(UI.AnimationSetList.content, imageInstance2);
|
||||
ListAnimations(charaInstance.Id);
|
||||
});
|
||||
}
|
||||
UI.LoadModelPanels();
|
||||
UI.LoadMiniModelPanels();
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
void ListCostumes(int umaId)
|
||||
public void OpenUrl(string url)
|
||||
{
|
||||
for(int i = UI.CostumeList.content.childCount - 1; i >=0; i--)
|
||||
{
|
||||
Destroy(UI.CostumeList.content.GetChild(i).gameObject);
|
||||
}
|
||||
foreach(var entry in AbList.Where(a => !a.Name.Contains("clothes") && a.Name.Contains($"pfb_bdy{umaId}")))
|
||||
{
|
||||
var container = Instantiate(UI.UmaContainerPrefab, UI.CostumeList.content).GetComponent<UmaUIContainer>();
|
||||
string[] split = entry.Name.Split('_');
|
||||
string costumeId = split[split.Length - 1];
|
||||
container.Name.text = container.name = costumeId;
|
||||
container.Button.onClick.AddListener(() => {
|
||||
UI.HighlightChildImage(UI.CostumeList.content, container.GetComponent<Image>());
|
||||
StartCoroutine(Builder.LoadUma(umaId, costumeId));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
void ListAnimations(int umaId)
|
||||
{
|
||||
for (int i = UI.AnimationList.content.childCount - 1; i >= 0; i--)
|
||||
{
|
||||
Destroy(UI.AnimationList.content.GetChild(i).gameObject);
|
||||
}
|
||||
if(umaId == -1)
|
||||
{
|
||||
foreach (var entry in AbList.Where(a => a.Name.StartsWith(UmaDatabaseController.MotionPath) && a.Name.Contains($"/type00") && !a.Name.Contains($"mirror") && !a.Name.Contains($"mini") && !a.Name.Contains($"facial") && !a.Name.Contains($"_cam")))
|
||||
{
|
||||
var entryInstance = entry;
|
||||
var container = Instantiate(UI.UmaContainerPrefab, UI.AnimationList.content).GetComponent<UmaUIContainer>();
|
||||
container.Name.text = container.name = Path.GetFileName(entry.Name);
|
||||
container.Button.onClick.AddListener(() => {
|
||||
UI.HighlightChildImage(UI.AnimationList.content, container.GetComponent<Image>());
|
||||
Builder.LoadAsset(entryInstance);
|
||||
});
|
||||
}
|
||||
}
|
||||
else
|
||||
foreach (var entry in AbList.Where(a => a.Name.StartsWith(UmaDatabaseController.MotionPath) && a.Name.Contains($"chara/chr{umaId}") && !a.Name.Contains($"mirror") && !a.Name.Contains($"mini") && !a.Name.Contains($"facial") && !a.Name.Contains($"_cam")))
|
||||
{
|
||||
var entryInstance = entry;
|
||||
var container = Instantiate(UI.UmaContainerPrefab, UI.AnimationList.content).GetComponent<UmaUIContainer>();
|
||||
container.Name.text = container.name = Path.GetFileName(entry.Name);
|
||||
container.Button.onClick.AddListener(() => {
|
||||
UI.HighlightChildImage(UI.AnimationList.content, container.GetComponent<Image>());
|
||||
Builder.LoadAsset(entryInstance);
|
||||
});
|
||||
}
|
||||
Application.OpenURL(url);
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
|
||||
@@ -1,19 +1,35 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class UmaViewerUI : MonoBehaviour
|
||||
{
|
||||
public static UmaViewerUI Instance;
|
||||
private UmaViewerMain Main => UmaViewerMain.Instance;
|
||||
private UmaViewerBuilder Builder => UmaViewerBuilder.Instance;
|
||||
|
||||
//normal models
|
||||
public ScrollRect CharactersList;
|
||||
public ScrollRect CostumeList;
|
||||
public ScrollRect AnimationSetList;
|
||||
public ScrollRect AnimationList;
|
||||
//mini models
|
||||
public ScrollRect MiniCharactersList;
|
||||
public ScrollRect MiniCostumeList;
|
||||
public ScrollRect MiniAnimationSetList;
|
||||
public ScrollRect MiniAnimationList;
|
||||
|
||||
public List<GameObject> TogglablePanels = new List<GameObject>();
|
||||
|
||||
public GameObject UmaContainerPrefab;
|
||||
|
||||
private int LoadedAssetCount = 0;
|
||||
[SerializeField] private RectTransform LoadedAssetsPanel;
|
||||
[SerializeField] private TMPro.TextMeshProUGUI LoadedAssetsText;
|
||||
|
||||
public Color UIColor1, UIColor2;
|
||||
|
||||
private void Awake()
|
||||
@@ -31,8 +47,173 @@ public class UmaViewerUI : MonoBehaviour
|
||||
}
|
||||
}
|
||||
|
||||
public void ToggleUI(GameObject go)
|
||||
public void LoadedAssetsAdd(string asset)
|
||||
{
|
||||
go.SetActive(!go.activeSelf);
|
||||
LoadedAssetCount++;
|
||||
if (LoadedAssetCount > 1)
|
||||
LoadedAssetsText.text += "\n";
|
||||
LoadedAssetsText.text += asset;
|
||||
LoadedAssetsPanel.sizeDelta = new Vector2(0, LoadedAssetCount * 20);
|
||||
}
|
||||
|
||||
public void LoadedAssetsClear()
|
||||
{
|
||||
LoadedAssetCount = 0;
|
||||
LoadedAssetsText.text = "";
|
||||
LoadedAssetsPanel.sizeDelta = Vector2.zero;
|
||||
}
|
||||
|
||||
public void LoadModelPanels()
|
||||
{
|
||||
var container = Instantiate(UmaContainerPrefab, AnimationSetList.content).GetComponent<UmaUIContainer>();
|
||||
container.Name.text = container.name = "type00";
|
||||
var imageInstance = container.GetComponent<Image>();
|
||||
container.Button.onClick.AddListener(() => {
|
||||
HighlightChildImage(AnimationSetList.content, imageInstance);
|
||||
ListAnimations(-1, false);
|
||||
});
|
||||
|
||||
foreach (var chara in Main.Characters.OrderBy(c => c.Id))
|
||||
{
|
||||
var charaInstance = chara;
|
||||
container = Instantiate(UmaContainerPrefab, CharactersList.content).GetComponent<UmaUIContainer>();
|
||||
container.Name.text = container.name = chara.Id + " " + chara.Name;
|
||||
var imageInstance1 = container.GetComponent<Image>();
|
||||
container.Button.onClick.AddListener(() => {
|
||||
HighlightChildImage(CharactersList.content, imageInstance1);
|
||||
ListCostumes(charaInstance.Id, false);
|
||||
});
|
||||
|
||||
container = Instantiate(UmaContainerPrefab, AnimationSetList.content).GetComponent<UmaUIContainer>();
|
||||
container.Name.text = container.name = chara.Id + " " + chara.Name;
|
||||
var imageInstance2 = container.GetComponent<Image>();
|
||||
container.Button.onClick.AddListener(() => {
|
||||
HighlightChildImage(AnimationSetList.content, imageInstance2);
|
||||
ListAnimations(charaInstance.Id, false);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public void LoadMiniModelPanels()
|
||||
{
|
||||
var container = Instantiate(UmaContainerPrefab, MiniAnimationSetList.content).GetComponent<UmaUIContainer>();
|
||||
container.Name.text = container.name = "type00";
|
||||
var imageInstance = container.GetComponent<Image>();
|
||||
container.Button.onClick.AddListener(() => {
|
||||
HighlightChildImage(MiniAnimationSetList.content, imageInstance);
|
||||
ListAnimations(-1, true);
|
||||
});
|
||||
|
||||
foreach (var chara in Main.Characters.OrderBy(c => c.Id))
|
||||
{
|
||||
var charaInstance = chara;
|
||||
container = Instantiate(UmaContainerPrefab, MiniCharactersList.content).GetComponent<UmaUIContainer>();
|
||||
container.Name.text = container.name = chara.Id + " " + chara.Name;
|
||||
var imageInstance1 = container.GetComponent<Image>();
|
||||
container.Button.onClick.AddListener(() => {
|
||||
HighlightChildImage(MiniCharactersList.content, imageInstance1);
|
||||
ListCostumes(charaInstance.Id, true);
|
||||
});
|
||||
|
||||
container = Instantiate(UmaContainerPrefab, MiniAnimationSetList.content).GetComponent<UmaUIContainer>();
|
||||
container.Name.text = container.name = chara.Id + " " + chara.Name;
|
||||
var imageInstance2 = container.GetComponent<Image>();
|
||||
container.Button.onClick.AddListener(() => {
|
||||
HighlightChildImage(MiniAnimationSetList.content, imageInstance2);
|
||||
ListAnimations(charaInstance.Id, true);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
void ListCostumes(int umaId, bool mini)
|
||||
{
|
||||
ScrollRect costumeList = mini ? MiniCostumeList : CostumeList;
|
||||
for (int i = costumeList.content.childCount - 1; i >= 0; i--)
|
||||
{
|
||||
Destroy(costumeList.content.GetChild(i).gameObject);
|
||||
}
|
||||
string nameVar = mini ? $"pfb_mbdy{umaId}" : $"pfb_bdy{umaId}";
|
||||
foreach (var entry in Main.AbList.Where(a => !a.Name.Contains("clothes") && a.Name.Contains(nameVar)))
|
||||
{
|
||||
var container = Instantiate(UmaContainerPrefab, costumeList.content).GetComponent<UmaUIContainer>();
|
||||
string[] split = entry.Name.Split('_');
|
||||
string costumeId = split[split.Length - 1];
|
||||
container.Name.text = container.name = costumeId;
|
||||
container.Button.onClick.AddListener(() => {
|
||||
HighlightChildImage(costumeList.content, container.GetComponent<Image>());
|
||||
StartCoroutine(Builder.LoadUma(umaId, costumeId, mini));
|
||||
});
|
||||
}
|
||||
//Common costumes
|
||||
List<int> costumes = new List<int>();
|
||||
nameVar = mini ? "pfb_mbdy0" : $"pfb_bdy0";
|
||||
foreach (var entry in Main.AbList.Where(a => a.Name.StartsWith("3d/chara/") && a.Name.Contains("/body/") && !a.Name.Contains("/clothes/") && a.Name.Contains(nameVar)))
|
||||
{
|
||||
int id = int.Parse(Path.GetFileName(entry.Name).Split('_')[1].Substring(mini? 4: 3));
|
||||
if (!costumes.Contains(id))
|
||||
{
|
||||
costumes.Add(id);
|
||||
var container = Instantiate(UmaContainerPrefab, costumeList.content).GetComponent<UmaUIContainer>();
|
||||
string costumeId = container.Name.text = container.name = id.ToString().PadLeft(4,'0');
|
||||
container.Button.onClick.AddListener(() => {
|
||||
HighlightChildImage(costumeList.content, container.GetComponent<Image>());
|
||||
StartCoroutine(Builder.LoadUma(umaId, costumeId, mini));
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ListAnimations(int umaId, bool mini)
|
||||
{
|
||||
ScrollRect animationList = mini ? MiniAnimationList : AnimationList;
|
||||
for (int i = animationList.content.childCount - 1; i >= 0; i--)
|
||||
{
|
||||
Destroy(animationList.content.GetChild(i).gameObject);
|
||||
}
|
||||
|
||||
var filteredList = mini ?
|
||||
Main.AbList.Where(a => a.Name.StartsWith(UmaDatabaseController.MotionPath) && !a.Name.Contains($"mirror") && a.Name.Contains($"mini") && !a.Name.Contains($"facial") && !a.Name.Contains($"_cam"))
|
||||
:
|
||||
Main.AbList.Where(a => a.Name.StartsWith(UmaDatabaseController.MotionPath) && !a.Name.Contains($"mirror") && !a.Name.Contains($"mini") && !a.Name.Contains($"facial") && !a.Name.Contains($"_cam"));
|
||||
|
||||
if (umaId == -1)
|
||||
{
|
||||
foreach (var entry in filteredList.Where(a=> a.Name.Contains($"/type00")))
|
||||
{
|
||||
var entryInstance = entry;
|
||||
var container = Instantiate(UmaContainerPrefab, animationList.content).GetComponent<UmaUIContainer>();
|
||||
container.Name.text = container.name = Path.GetFileName(entry.Name);
|
||||
container.Button.onClick.AddListener(() => {
|
||||
HighlightChildImage(animationList.content, container.GetComponent<Image>());
|
||||
Builder.LoadAsset(entryInstance);
|
||||
});
|
||||
}
|
||||
}
|
||||
else
|
||||
foreach (var entry in filteredList.Where(a => a.Name.Contains($"chara/chr{umaId}")))
|
||||
{
|
||||
var entryInstance = entry;
|
||||
var container = Instantiate(UmaContainerPrefab, animationList.content).GetComponent<UmaUIContainer>();
|
||||
container.Name.text = container.name = Path.GetFileName(entry.Name);
|
||||
container.Button.onClick.AddListener(() => {
|
||||
HighlightChildImage(animationList.content, container.GetComponent<Image>());
|
||||
Builder.LoadAsset(entryInstance);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary> Toggles one object ON and all others from UI.TogglablePanels list OFF </summary>
|
||||
public void ToggleUIPanel(GameObject go)
|
||||
{
|
||||
if (go.activeSelf || !TogglablePanels.Contains(go))
|
||||
{
|
||||
go.SetActive(!go.activeSelf);
|
||||
return;
|
||||
}
|
||||
|
||||
foreach (var panel in TogglablePanels)
|
||||
{
|
||||
panel.SetActive(panel == go);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user