毫无头绪!
This commit is contained in:
@@ -16,29 +16,51 @@ namespace Ichni
|
||||
public List<ThemeBundle> loadedThemeBundleList;
|
||||
|
||||
public int waitingBundleAmount;
|
||||
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
instance = this;
|
||||
|
||||
|
||||
loadedThemeBundleList = new List<ThemeBundle>();
|
||||
|
||||
|
||||
AssetBundle.UnloadAllAssetBundles(true);
|
||||
LoadAllThemeBundlesAbstract();
|
||||
//DontDestroyOnLoad(gameObject);
|
||||
LoadThemeBundle("basic");
|
||||
LoadThemeBundle("departure_to_multiverse");
|
||||
LoadThemeBundle("basic");
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
public bool TryGetThemeBundle(string themeBundleName, out ThemeBundle themeBundle)
|
||||
{
|
||||
themeBundle = loadedThemeBundleList.Find(bundle => bundle.themeBundleName == themeBundleName);
|
||||
return themeBundle != null;
|
||||
}
|
||||
|
||||
public T GetObject<T>(string themeBundleName, string objectName) where T : class
|
||||
|
||||
private IEnumerator WaitAndLoad()
|
||||
{
|
||||
return loadedThemeBundleList.Find(bundle => bundle.themeBundleName == themeBundleName)?.GetObject<T>(objectName);
|
||||
while (waitingBundleAmount != 0)
|
||||
{
|
||||
yield return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public T GetObject<T>(string themeBundleName, string objectName) where T : class//?
|
||||
{
|
||||
print(themeBundleName + " " + objectName);
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
public void LoadThemeBundles(List<string> list)
|
||||
@@ -77,22 +99,23 @@ namespace Ichni
|
||||
waitingBundleAmount++;
|
||||
StartCoroutine(LoadThemeBundleCoroutine(themeBundleName));
|
||||
}
|
||||
|
||||
|
||||
IEnumerator LoadThemeBundleCoroutine(string themeBundleName)
|
||||
{
|
||||
string uri = "";
|
||||
|
||||
|
||||
if (Application.platform == RuntimePlatform.WindowsEditor ||
|
||||
Application.platform == RuntimePlatform.WindowsPlayer)
|
||||
{
|
||||
uri = Application.streamingAssetsPath + "/ThemeBundles/Windows64/" + themeBundleName;
|
||||
}else if (Application.platform == RuntimePlatform.OSXEditor ||
|
||||
}
|
||||
else if (Application.platform == RuntimePlatform.OSXEditor ||
|
||||
Application.platform == RuntimePlatform.OSXPlayer)
|
||||
{
|
||||
|
||||
|
||||
uri = Application.streamingAssetsPath + "/ThemeBundles/OSX/" + themeBundleName;
|
||||
}
|
||||
|
||||
|
||||
UnityWebRequest request = UnityWebRequestAssetBundle.GetAssetBundle(uri, 0);
|
||||
yield return request.SendWebRequest();
|
||||
AssetBundle bundle = AssetBundle.LoadFromFile(uri);
|
||||
@@ -120,6 +143,7 @@ namespace Ichni
|
||||
|
||||
yield return new WaitForEndOfFrame();
|
||||
waitingBundleAmount--;
|
||||
print(themeBundleName + " Done!");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -231,7 +255,7 @@ namespace Ichni
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return default(T);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user