read character data form masterDB
This commit is contained in:
@@ -3,11 +3,12 @@ using Newtonsoft.Json.Linq;
|
|||||||
using RootMotion.Dynamics;
|
using RootMotion.Dynamics;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Data;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
public class UmaContainer : MonoBehaviour
|
public class UmaContainer : MonoBehaviour
|
||||||
{
|
{
|
||||||
public JObject CharaData;
|
public DataRow CharaData;
|
||||||
public GameObject Body;
|
public GameObject Body;
|
||||||
public GameObject Tail;
|
public GameObject Tail;
|
||||||
public GameObject Head;
|
public GameObject Head;
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ using System.Threading.Tasks;
|
|||||||
using Mono.Data.Sqlite;
|
using Mono.Data.Sqlite;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using UnityEngine.XR;
|
using UnityEngine.XR;
|
||||||
|
using System.Data;
|
||||||
|
|
||||||
public class UmaDatabaseController
|
public class UmaDatabaseController
|
||||||
{
|
{
|
||||||
@@ -141,6 +142,17 @@ public class UmaDatabaseController
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static DataRow ReadCharaData(int id)
|
||||||
|
{
|
||||||
|
SqliteCommand sqlite_cmd = instance.masterDb.CreateCommand();
|
||||||
|
sqlite_cmd.CommandText = $"SELECT * FROM chara_data WHERE id LIKE {id}";
|
||||||
|
SqliteDataReader sqlite_datareader = sqlite_cmd.ExecuteReader();
|
||||||
|
var result = new DataTable();
|
||||||
|
result.Load(sqlite_datareader);
|
||||||
|
DataRow row = result.Rows[0];
|
||||||
|
return row;
|
||||||
|
}
|
||||||
|
|
||||||
public static string GetABPath(UmaDatabaseEntry entry)
|
public static string GetABPath(UmaDatabaseEntry entry)
|
||||||
{
|
{
|
||||||
if (Application.platform == RuntimePlatform.Android)
|
if (Application.platform == RuntimePlatform.Android)
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ using Newtonsoft.Json.Linq;
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Data;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using UmaMusumeAudio;
|
using UmaMusumeAudio;
|
||||||
@@ -56,31 +57,29 @@ public class UmaViewerBuilder : MonoBehaviour
|
|||||||
|
|
||||||
UnloadAllBundle();
|
UnloadAllBundle();
|
||||||
|
|
||||||
yield return UmaViewerDownload.DownloadText($"https://www.tracenacademy.com/api/CharaData/{id}", txt =>
|
CurrentUMAContainer.CharaData = UmaDatabaseController.ReadCharaData(id);
|
||||||
|
if (mini)
|
||||||
{
|
{
|
||||||
Debug.Log(txt);
|
LoadMiniUma(id, costumeId);
|
||||||
CurrentUMAContainer.CharaData = JObject.Parse(txt);
|
}
|
||||||
if (mini)
|
else
|
||||||
{
|
{
|
||||||
LoadMiniUma(id, costumeId);
|
LoadNormalUma(id, costumeId);
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
yield break;
|
||||||
LoadNormalUma(id, costumeId);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void LoadNormalUma(int id, string costumeId)
|
private void LoadNormalUma(int id, string costumeId)
|
||||||
{
|
{
|
||||||
JObject charaData = CurrentUMAContainer.CharaData;
|
DataRow charaData = CurrentUMAContainer.CharaData;
|
||||||
bool genericCostume = CurrentUMAContainer.IsGeneric = costumeId.Length >= 4;
|
bool genericCostume = CurrentUMAContainer.IsGeneric = costumeId.Length >= 4;
|
||||||
string skin = (string)charaData["skin"],
|
string skin = charaData["skin"].ToString(),
|
||||||
height = (string)charaData["height"],
|
height = charaData["height"].ToString(),
|
||||||
socks = (string)charaData["socks"],
|
socks = charaData["socks"].ToString(),
|
||||||
bust = (string)charaData["bust"],
|
bust = charaData["bust"].ToString(),
|
||||||
sex = (string)charaData["sex"],
|
sex = charaData["sex"].ToString(),
|
||||||
shape = (string)charaData["shape"],
|
shape = charaData["shape"].ToString(),
|
||||||
costumeIdShort = "";
|
costumeIdShort = "";
|
||||||
|
|
||||||
UmaDatabaseEntry asset = null;
|
UmaDatabaseEntry asset = null;
|
||||||
@@ -179,7 +178,7 @@ public class UmaViewerBuilder : MonoBehaviour
|
|||||||
// Record Head Data
|
// Record Head Data
|
||||||
int head_id;
|
int head_id;
|
||||||
string head_costumeId;
|
string head_costumeId;
|
||||||
int tailId = (int)charaData["tailModelId"];
|
int tailId = Convert.ToInt32(charaData["tail_model_id"]);
|
||||||
|
|
||||||
//The tailId of 9006 is 1, but the character has no tail
|
//The tailId of 9006 is 1, but the character has no tail
|
||||||
if (id == 9006) tailId = -1;
|
if (id == 9006) tailId = -1;
|
||||||
@@ -302,14 +301,14 @@ public class UmaViewerBuilder : MonoBehaviour
|
|||||||
|
|
||||||
private void LoadMiniUma(int id, string costumeId)
|
private void LoadMiniUma(int id, string costumeId)
|
||||||
{
|
{
|
||||||
JObject charaData = CurrentUMAContainer.CharaData;
|
DataRow charaData = CurrentUMAContainer.CharaData;
|
||||||
CurrentUMAContainer.IsMini = true;
|
CurrentUMAContainer.IsMini = true;
|
||||||
bool isGeneric = CurrentUMAContainer.IsGeneric = costumeId.Length >= 4;
|
bool isGeneric = CurrentUMAContainer.IsGeneric = costumeId.Length >= 4;
|
||||||
string skin = (string)charaData["skin"],
|
string skin = charaData["skin"].ToString(),
|
||||||
height = (string)charaData["height"],
|
height = charaData["height"].ToString(),
|
||||||
socks = (string)charaData["socks"],
|
socks = charaData["socks"].ToString(),
|
||||||
bust = (string)charaData["bust"],
|
bust = charaData["bust"].ToString(),
|
||||||
sex = (string)charaData["sex"],
|
sex = charaData["sex"].ToString(),
|
||||||
costumeIdShort = "";
|
costumeIdShort = "";
|
||||||
bool customHead = true;
|
bool customHead = true;
|
||||||
|
|
||||||
@@ -971,7 +970,7 @@ public class UmaViewerBuilder : MonoBehaviour
|
|||||||
var currentStateInfo = CurrentUMAContainer.UmaAnimator.GetCurrentAnimatorStateInfo(0);
|
var currentStateInfo = CurrentUMAContainer.UmaAnimator.GetCurrentAnimatorStateInfo(0);
|
||||||
CurrentUMAContainer.UmaAnimator.Rebind();
|
CurrentUMAContainer.UmaAnimator.Rebind();
|
||||||
CurrentUMAContainer.OverrideController["clip_t"] = clip;
|
CurrentUMAContainer.OverrideController["clip_t"] = clip;
|
||||||
CurrentUMAContainer.UmaAnimator.Play("motion_t", 1 ,0);
|
CurrentUMAContainer.UmaAnimator.Play("motion_t", 1, 0);
|
||||||
CurrentUMAContainer.UmaAnimator.Play(currentStateInfo.shortNameHash, 0, currentStateInfo.normalizedTime);
|
CurrentUMAContainer.UmaAnimator.Play(currentStateInfo.shortNameHash, 0, currentStateInfo.normalizedTime);
|
||||||
}
|
}
|
||||||
else if (clip.name.Contains("face"))
|
else if (clip.name.Contains("face"))
|
||||||
@@ -1031,10 +1030,10 @@ public class UmaViewerBuilder : MonoBehaviour
|
|||||||
|
|
||||||
if (posMotion != null)
|
if (posMotion != null)
|
||||||
{
|
{
|
||||||
RecursiveLoadAsset(posMotion);
|
RecursiveLoadAsset(posMotion);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (CurrentUMAContainer.IsMini)
|
if (CurrentUMAContainer.IsMini)
|
||||||
{
|
{
|
||||||
SetPreviewCamera(null);
|
SetPreviewCamera(null);
|
||||||
}
|
}
|
||||||
@@ -1043,7 +1042,7 @@ public class UmaViewerBuilder : MonoBehaviour
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (CurrentUMAContainer.FaceDrivenKeyTarget)
|
if (CurrentUMAContainer.FaceDrivenKeyTarget)
|
||||||
{
|
{
|
||||||
CurrentUMAContainer.FaceDrivenKeyTarget.ResetLocator();
|
CurrentUMAContainer.FaceDrivenKeyTarget.ResetLocator();
|
||||||
}
|
}
|
||||||
@@ -1158,7 +1157,7 @@ public class UmaViewerBuilder : MonoBehaviour
|
|||||||
if (container.Slider != null)
|
if (container.Slider != null)
|
||||||
container.Slider.SetValueWithoutNotify(0);
|
container.Slider.SetValueWithoutNotify(0);
|
||||||
}
|
}
|
||||||
if (CurrentUMAContainer.FaceDrivenKeyTarget)
|
if (CurrentUMAContainer.FaceDrivenKeyTarget)
|
||||||
{
|
{
|
||||||
CurrentUMAContainer.FaceDrivenKeyTarget.ClearMorph();
|
CurrentUMAContainer.FaceDrivenKeyTarget.ClearMorph();
|
||||||
CurrentUMAContainer.FaceDrivenKeyTarget.ChangeMorph();
|
CurrentUMAContainer.FaceDrivenKeyTarget.ChangeMorph();
|
||||||
@@ -1168,7 +1167,7 @@ public class UmaViewerBuilder : MonoBehaviour
|
|||||||
|
|
||||||
private void FixedUpdate()
|
private void FixedUpdate()
|
||||||
{
|
{
|
||||||
if (PreviewCamera&&PreviewCamera.enabled == true)
|
if (PreviewCamera && PreviewCamera.enabled == true)
|
||||||
{
|
{
|
||||||
PreviewCamera.fieldOfView = PreviewCamera.gameObject.transform.parent.transform.localScale.x;
|
PreviewCamera.fieldOfView = PreviewCamera.gameObject.transform.parent.transform.localScale.x;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user