StartMenu!
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using UniRx;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Networking;
|
||||
using UnityEngine.Serialization;
|
||||
@@ -15,19 +16,25 @@ namespace Ichni
|
||||
public List<string> selectedThemeBundleList;
|
||||
public List<ThemeBundle> loadedThemeBundleList;
|
||||
|
||||
public int waitingBundleAmount;
|
||||
public IntReactiveProperty waitingBundleAmount;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
instance = this;
|
||||
if (instance == null)
|
||||
{
|
||||
instance = this;
|
||||
DontDestroyOnLoad(gameObject);
|
||||
}
|
||||
else if (instance != this)
|
||||
{
|
||||
Destroy(gameObject);
|
||||
}
|
||||
|
||||
loadedThemeBundleList = new List<ThemeBundle>();
|
||||
|
||||
AssetBundle.UnloadAllAssetBundles(true);
|
||||
LoadAllThemeBundlesAbstract();
|
||||
//DontDestroyOnLoad(gameObject);
|
||||
LoadThemeBundle("departure_to_multiverse");
|
||||
LoadThemeBundle("basic");
|
||||
//LoadThemeBundle("basic");
|
||||
//LoadThemeBundle("departure_to_multiverse");
|
||||
}
|
||||
|
||||
public bool TryGetThemeBundle(string themeBundleName, out ThemeBundle themeBundle)
|
||||
@@ -36,30 +43,14 @@ namespace Ichni
|
||||
return themeBundle != null;
|
||||
}
|
||||
|
||||
|
||||
private IEnumerator WaitAndLoad()
|
||||
public T GetObject<T>(string themeBundleName, string objectName) where T : class
|
||||
{
|
||||
while (waitingBundleAmount != 0)
|
||||
{
|
||||
yield return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public T GetObject<T>(string themeBundleName, string objectName) where T : class//?
|
||||
{
|
||||
var i = loadedThemeBundleList.Find(bundle => bundle.themeBundleName == themeBundleName)?.GetObject<T>(objectName);
|
||||
if (i == null)
|
||||
{
|
||||
Debug.LogError("Object not found");
|
||||
return loadedThemeBundleList.Find(bundle => bundle.themeBundleName == "basic")?.GetObject<T>("BasicNoteTap3D");
|
||||
}
|
||||
else
|
||||
return i;
|
||||
return loadedThemeBundleList.Find(bundle => bundle.themeBundleName == themeBundleName)?.GetObject<T>(objectName);
|
||||
}
|
||||
|
||||
public void LoadThemeBundles(List<string> list)
|
||||
{
|
||||
waitingBundleAmount = new IntReactiveProperty(list.Count);
|
||||
foreach (var bundle in list)
|
||||
{
|
||||
LoadThemeBundle(bundle);
|
||||
@@ -68,7 +59,8 @@ namespace Ichni
|
||||
|
||||
public void LoadAllThemeBundlesAbstract()
|
||||
{
|
||||
string uri = Application.streamingAssetsPath + "/ThemeBundles";
|
||||
string uri = Application.streamingAssetsPath + "/ThemeBundles/";
|
||||
|
||||
if (ES3.DirectoryExists(uri))
|
||||
{
|
||||
List<string> allFileList = ES3.GetFiles(uri).ToList();
|
||||
@@ -83,15 +75,13 @@ namespace Ichni
|
||||
|
||||
foreach (var abs in absList)
|
||||
{
|
||||
ES3Settings settings = new ES3Settings(uri + "/" + abs, ES3.EncryptionType.None);
|
||||
themeBundleAbstractList.Add(ES3.Load<ThemeBundleAbstract>("ThemeBundleAbstract", settings));
|
||||
themeBundleAbstractList.Add(ES3.Load<ThemeBundleAbstract>("ThemeBundleAbstract", uri + abs));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void LoadThemeBundle(string themeBundleName)
|
||||
{
|
||||
waitingBundleAmount++;
|
||||
StartCoroutine(LoadThemeBundleCoroutine(themeBundleName));
|
||||
}
|
||||
|
||||
@@ -137,7 +127,7 @@ namespace Ichni
|
||||
}
|
||||
|
||||
yield return new WaitForEndOfFrame();
|
||||
waitingBundleAmount--;
|
||||
waitingBundleAmount.Value--;
|
||||
print(themeBundleName + " Done!");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user