Improving performance
This commit is contained in:
@@ -56,6 +56,7 @@ public class ManifestDB
|
||||
isError = false;
|
||||
this.callback = callback;
|
||||
callback?.Invoke("Checking Resource Version", UIMessageType.Default);
|
||||
yield return null;
|
||||
yield return UpdateMetaDB();
|
||||
yield return UpdateMasterDB();
|
||||
callback?.Invoke(isError ? "Update aborted." : $"Done. Please restart the application.\n", isError ? UIMessageType.Error : UIMessageType.Success);
|
||||
@@ -70,6 +71,7 @@ public class ManifestDB
|
||||
{
|
||||
string rootHash = null;
|
||||
callback?.Invoke("Getting resource version", UIMessageType.Default);
|
||||
yield return null;
|
||||
yield return UmaViewerDownload.DownloadText("https://www.tracenacademy.com/api/MetaC/root", txt =>
|
||||
{
|
||||
if (string.IsNullOrEmpty(txt)) return;
|
||||
@@ -116,6 +118,7 @@ public class ManifestDB
|
||||
|
||||
//Insert platform
|
||||
callback?.Invoke("Reading Platform Manifest", UIMessageType.Default);
|
||||
yield return null;
|
||||
ManifestEntry[] platformEntrys = null;
|
||||
yield return GetManifest(rootEntry.hname, Kind.PlatformManifest, entrys => { platformEntrys = entrys; });
|
||||
if (platformEntrys == null)
|
||||
@@ -131,6 +134,7 @@ public class ManifestDB
|
||||
|
||||
//Insert AssetManifest
|
||||
callback?.Invoke($"Reading Assets Manifest", UIMessageType.Default);
|
||||
yield return null;
|
||||
ManifestEntry[] assetEntrys = null;
|
||||
yield return GetManifest(platformEntry.hname, Kind.AssetManifest, entrys => { assetEntrys = entrys; });
|
||||
if (assetEntrys == null)
|
||||
@@ -162,6 +166,7 @@ public class ManifestDB
|
||||
continue;
|
||||
}
|
||||
callback?.Invoke($"Reading AssetBundles Manifest : {assetEntry.tname}", UIMessageType.Default);
|
||||
yield return null;
|
||||
using SqliteTransaction tran = MetaDB.BeginTransaction();
|
||||
for (int i = 0; i < assets.Length; i++)
|
||||
{
|
||||
@@ -185,16 +190,19 @@ public class ManifestDB
|
||||
var masterDir = Path.GetDirectoryName(masterPath);
|
||||
|
||||
callback?.Invoke($"Checking master.mdb", UIMessageType.Default);
|
||||
yield return null;
|
||||
SqliteCommand command = new SqliteCommand("SELECT h FROM a WHERE n LIKE 'master.mdb.lz4'", MetaDB);
|
||||
var reader = command.ExecuteReader();
|
||||
|
||||
if (reader.Read())
|
||||
{
|
||||
yield return null;
|
||||
var hash = reader.GetString(0);
|
||||
var path = GetManifestPath(hash);
|
||||
if (!File.Exists(path))
|
||||
{
|
||||
callback?.Invoke($"Downloading master.mdb", UIMessageType.Default);
|
||||
yield return null;
|
||||
UnityWebRequest www = UnityWebRequest.Get(UmaViewerDownload.GetGenericRequestUrl(hash));
|
||||
yield return www.SendWebRequest();
|
||||
if (www.result == UnityWebRequest.Result.Success)
|
||||
@@ -211,6 +219,7 @@ public class ManifestDB
|
||||
}
|
||||
|
||||
callback?.Invoke($"Decompress master.mdb", UIMessageType.Default);
|
||||
yield return null;
|
||||
try
|
||||
{
|
||||
Directory.CreateDirectory(masterDir);
|
||||
@@ -283,10 +292,12 @@ public class ManifestDB
|
||||
if (!File.Exists(path))
|
||||
{
|
||||
this.callback?.Invoke($"Downloading Manifest :{hash}", UIMessageType.Default);
|
||||
yield return null;
|
||||
yield return DownloadManifest(hash);
|
||||
}
|
||||
if (File.Exists(path))
|
||||
{
|
||||
yield return null;
|
||||
callback.Invoke(GetManifest(path, true, kind));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ public class UmaAssetManager : MonoBehaviour
|
||||
|
||||
public static event Action <UmaDatabaseEntry> OnLoadedBundleUpdate;
|
||||
public static event Action OnLoadedBundleClear;
|
||||
public static event Action<int, int> OnLoadProgressChange;
|
||||
public static event Action<int, int, string> OnLoadProgressChange;
|
||||
|
||||
public static Coroutine LoadCoroutine;
|
||||
|
||||
@@ -48,11 +48,11 @@ public class UmaAssetManager : MonoBehaviour
|
||||
for(int i = 0; i < result.Count; i++)
|
||||
{
|
||||
LoadAB(result[i]);
|
||||
OnLoadProgressChange?.Invoke(i, result.Count);
|
||||
OnLoadProgressChange?.Invoke(i, result.Count, null);
|
||||
yield return null;
|
||||
}
|
||||
|
||||
OnLoadProgressChange?.Invoke(-1, result.Count);
|
||||
OnLoadProgressChange?.Invoke(-1, result.Count, null);
|
||||
LoadCoroutine = null;
|
||||
OnDone?.Invoke();
|
||||
}
|
||||
@@ -65,7 +65,7 @@ public class UmaAssetManager : MonoBehaviour
|
||||
SearchAB(Main, entry, ref result);
|
||||
foreach(var e in result)
|
||||
{
|
||||
LoadAB(e, entry.Name.EndsWith("shader") || neverUnload);
|
||||
LoadAB(e, neverUnload);
|
||||
}
|
||||
return Get(entry.Name);
|
||||
}
|
||||
@@ -181,8 +181,10 @@ public class UmaAssetManager : MonoBehaviour
|
||||
var builder = UmaViewerBuilder.Instance;
|
||||
if (builder)
|
||||
{
|
||||
if (builder.CurrentUMAContainer) Destroy(builder.CurrentUMAContainer);
|
||||
if (builder.CurrentOtherContainer) Destroy(builder.CurrentOtherContainer);
|
||||
if (builder.CurrentUMAContainer)
|
||||
builder.UnloadUma();
|
||||
if (builder.CurrentOtherContainer)
|
||||
Destroy(builder.CurrentOtherContainer.gameObject);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -487,6 +487,7 @@ public class UmaContainer : MonoBehaviour
|
||||
|
||||
BipedRagdollCreator.Create(r, options);
|
||||
PuppetMaster = PuppetMaster.SetUp(container.transform, 8, 9);
|
||||
PuppetMaster.solverIterationCount = 3;
|
||||
PuppetMaster.FlattenHierarchy();
|
||||
}
|
||||
|
||||
|
||||
@@ -43,12 +43,12 @@ public class UmaDatabaseController
|
||||
/// <summary> outgame/dress/ </summary>
|
||||
public static string CostumePath = "outgame/dress/";
|
||||
|
||||
public IEnumerable<UmaDatabaseEntry> MetaEntries;
|
||||
public IEnumerable<DataRow> CharaData;
|
||||
public IEnumerable<DataRow> MobCharaData;
|
||||
public IEnumerable<FaceTypeData> FaceTypeData;
|
||||
public IEnumerable<DataRow> LiveData;
|
||||
public IEnumerable<DataRow> DressData;
|
||||
public List<UmaDatabaseEntry> MetaEntries;
|
||||
public List<DataRow> CharaData;
|
||||
public List<DataRow> MobCharaData;
|
||||
public List<FaceTypeData> FaceTypeData;
|
||||
public List<DataRow> LiveData;
|
||||
public List<DataRow> DressData;
|
||||
|
||||
/// <summary> Meta Database Connection </summary>
|
||||
private SqliteConnection metaDb;
|
||||
@@ -99,11 +99,12 @@ public class UmaDatabaseController
|
||||
}
|
||||
}
|
||||
|
||||
static IEnumerable<UmaDatabaseEntry> ReadMeta(SqliteConnection conn)
|
||||
static List<UmaDatabaseEntry> ReadMeta(SqliteConnection conn)
|
||||
{
|
||||
SqliteCommand sqlite_cmd = conn.CreateCommand();
|
||||
sqlite_cmd.CommandText = "SELECT m,n,h,c,d FROM a";
|
||||
SqliteDataReader sqlite_datareader = sqlite_cmd.ExecuteReader();
|
||||
List<UmaDatabaseEntry> meta = new List<UmaDatabaseEntry>();
|
||||
while (sqlite_datareader.Read())
|
||||
{
|
||||
UmaDatabaseEntry entry = null;
|
||||
@@ -121,22 +122,24 @@ public class UmaDatabaseController
|
||||
catch(Exception e) { Debug.LogError("Error caught: " + e); }
|
||||
|
||||
if (entry != null)
|
||||
yield return entry;
|
||||
meta.Add(entry);
|
||||
}
|
||||
return meta;
|
||||
}
|
||||
|
||||
static IEnumerable<DataRow> ReadCharaMaster(SqliteConnection conn)
|
||||
static List<DataRow> ReadCharaMaster(SqliteConnection conn)
|
||||
{
|
||||
return ReadMaster(conn, "SELECT * FROM chara_data C,(SELECT D.'index' charaid,D.'text' charaname FROM text_data D WHERE id like 6) T WHERE C.id like T.charaid");
|
||||
}
|
||||
|
||||
static IEnumerable<DataRow> ReadMobCharaMaster(SqliteConnection conn)
|
||||
static List<DataRow> ReadMobCharaMaster(SqliteConnection conn)
|
||||
{
|
||||
return ReadMaster(conn, "SELECT * FROM mob_data");
|
||||
}
|
||||
|
||||
static IEnumerable<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();
|
||||
@@ -145,13 +148,15 @@ public class UmaDatabaseController
|
||||
var temp = result.Rows.GetEnumerator();
|
||||
while (temp.MoveNext())
|
||||
{
|
||||
yield return (DataRow)temp.Current;
|
||||
dr.Add((DataRow)temp.Current);
|
||||
}
|
||||
sqlite_cmd.Dispose();
|
||||
return dr;
|
||||
}
|
||||
|
||||
static IEnumerable<FaceTypeData> ReadFaceTypeData(SqliteConnection conn)
|
||||
static List<FaceTypeData> ReadFaceTypeData(SqliteConnection conn)
|
||||
{
|
||||
List<FaceTypeData> data = new List<FaceTypeData>();
|
||||
SqliteCommand sqlite_cmd = conn.CreateCommand();
|
||||
sqlite_cmd.CommandText = "SELECT * FROM face_type_data";
|
||||
SqliteDataReader sqlite_datareader = sqlite_cmd.ExecuteReader();
|
||||
@@ -169,30 +174,28 @@ public class UmaDatabaseController
|
||||
inverce_face_type = sqlite_datareader.GetString(7),
|
||||
set_face_group = sqlite_datareader.GetInt32(8),
|
||||
};
|
||||
yield return entry;
|
||||
data.Add(entry);
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
static IEnumerable<DataRow> ReadAllLiveData(SqliteConnection conn)
|
||||
static List<DataRow> ReadAllLiveData(SqliteConnection conn)
|
||||
{
|
||||
return ReadMaster(conn, $"SELECT * FROM live_data L,(SELECT D.'index' songid,D.'text' songname FROM text_data D WHERE id like 16) T WHERE L.music_id like T.songid");
|
||||
}
|
||||
|
||||
static IEnumerable<DataRow> ReadAllDressData(SqliteConnection conn)
|
||||
static List<DataRow> ReadAllDressData(SqliteConnection conn)
|
||||
{
|
||||
return ReadMaster(conn, $"SELECT * FROM dress_data C,(SELECT D.'index' dressid,D.'text' dressname FROM text_data D WHERE id like 14) T WHERE C.id like T.dressid");
|
||||
}
|
||||
|
||||
public static DataRow ReadCharaData(CharaEntry chara)
|
||||
{
|
||||
foreach (var charaentry in chara.IsMob ? instance.MobCharaData : instance.CharaData)
|
||||
if (chara.IsMob)
|
||||
{
|
||||
if (Convert.ToInt32(charaentry[chara.IsMob ? "mob_id" : "id"]) == chara.Id)
|
||||
{
|
||||
return charaentry;
|
||||
}
|
||||
return instance.MobCharaData.Find(e => { return Convert.ToInt32(e["mob_id"]) == chara.Id; });
|
||||
}
|
||||
return null;
|
||||
return instance.CharaData.Find(e => { return Convert.ToInt32(e["id"]) == chara.Id; });
|
||||
}
|
||||
|
||||
public static DataRow ReadMobDressColor(string mobid)
|
||||
|
||||
@@ -71,7 +71,7 @@ public class UmaSceneController:MonoBehaviour
|
||||
Destroy(CavansInstance);
|
||||
}
|
||||
|
||||
public void LoadingProgressChange(int curren, int target)
|
||||
public void LoadingProgressChange(int curren, int target, string message = null)
|
||||
{
|
||||
if(curren == -1)
|
||||
{
|
||||
@@ -80,8 +80,15 @@ public class UmaSceneController:MonoBehaviour
|
||||
else
|
||||
{
|
||||
LoadingProgressPanel.SetActive(true);
|
||||
LoadingProgressText.text = $"Loading...({curren}/{target})";
|
||||
LoadingProgressSlider.value = (float)curren / target;
|
||||
if (string.IsNullOrEmpty(message))
|
||||
{
|
||||
LoadingProgressText.text = $"Loading...({curren}/{target})";
|
||||
}
|
||||
else
|
||||
{
|
||||
LoadingProgressText.text = $"{message}({curren}/{target})";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,15 +40,13 @@ public class UmaViewerMain : MonoBehaviour
|
||||
{
|
||||
Dictionary<int, string> enNames = new Dictionary<int, string>();
|
||||
Dictionary<int, string> mobNames = new Dictionary<int, string>();
|
||||
|
||||
if(Config.Instance.WorkMode == WorkMode.Standalone)
|
||||
{
|
||||
UI.ShowMessage("Initializing...",UIMessageType.Default);
|
||||
}
|
||||
var loadingUI = UmaSceneController.instance;
|
||||
|
||||
//Main chara names (En only)
|
||||
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;
|
||||
@@ -61,8 +59,10 @@ 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;
|
||||
@@ -77,6 +77,8 @@ public class UmaViewerMain : MonoBehaviour
|
||||
|
||||
|
||||
var UmaCharaData = UmaDatabaseController.Instance.CharaData;
|
||||
loadingUI.LoadingProgressChange(2, 11, "Loading Character Data");
|
||||
yield return null;
|
||||
foreach (var item in UmaCharaData)
|
||||
{
|
||||
var id = Convert.ToInt32(item["id"]);
|
||||
@@ -94,6 +96,8 @@ public class UmaViewerMain : MonoBehaviour
|
||||
}
|
||||
|
||||
var MobCharaData = UmaDatabaseController.Instance.MobCharaData;
|
||||
loadingUI.LoadingProgressChange(3, 11, "Loading Mob Data");
|
||||
yield return null;
|
||||
foreach (var item in MobCharaData)
|
||||
{
|
||||
if (Convert.ToInt32(item["use_live"]) == 0)
|
||||
@@ -112,6 +116,8 @@ public class UmaViewerMain : MonoBehaviour
|
||||
});
|
||||
}
|
||||
|
||||
loadingUI.LoadingProgressChange(4, 11, "Loading Costumes Data");
|
||||
yield return null;
|
||||
foreach (var item in CostumeList)
|
||||
{
|
||||
var costume = new CostumeEntry();
|
||||
@@ -134,11 +140,8 @@ public class UmaViewerMain : MonoBehaviour
|
||||
}
|
||||
}
|
||||
|
||||
UI.LoadModelPanels();
|
||||
UI.LoadMiniModelPanels();
|
||||
UI.LoadPropPanel();
|
||||
UI.LoadMapPanel();
|
||||
|
||||
loadingUI.LoadingProgressChange(5, 11, "Loading Live Data");
|
||||
yield return null;
|
||||
var asset = AbList.FirstOrDefault(a => a.Name.Equals("livesettings"));
|
||||
if (asset != null)
|
||||
{
|
||||
@@ -170,14 +173,27 @@ public class UmaViewerMain : MonoBehaviour
|
||||
}
|
||||
}
|
||||
}
|
||||
UI.LoadLivePanels();
|
||||
}
|
||||
}
|
||||
|
||||
if (Config.Instance.WorkMode == WorkMode.Standalone)
|
||||
{
|
||||
UI.ShowMessage("Done.", UIMessageType.Close);
|
||||
}
|
||||
loadingUI.LoadingProgressChange(6, 11, "Loading UI");
|
||||
yield return null;
|
||||
UI.LoadModelPanels();
|
||||
loadingUI.LoadingProgressChange(7, 11, "Loading UI");
|
||||
yield return null;
|
||||
UI.LoadMiniModelPanels();
|
||||
loadingUI.LoadingProgressChange(8, 11, "Loading UI");
|
||||
yield return null;
|
||||
UI.LoadPropPanel();
|
||||
loadingUI.LoadingProgressChange(9, 11, "Loading UI");
|
||||
yield return null;
|
||||
UI.LoadMapPanel();
|
||||
loadingUI.LoadingProgressChange(10, 11, "Loading UI");
|
||||
yield return null;
|
||||
UI.LoadLivePanels();
|
||||
loadingUI.LoadingProgressChange(-1, -1);
|
||||
|
||||
UmaAssetManager.LoadAssetBundle(AbList.FirstOrDefault(e => e.Name.Equals("shader")), true); //Load Shader First
|
||||
}
|
||||
|
||||
public void OpenUrl(string url)
|
||||
|
||||
Reference in New Issue
Block a user