database = new WWW(AssetbundleBaseURL + "CharacterElementDatabase.assetbundle");
CharacterElementHolder ceh = (CharacterElementHolder) database.assetBundle.mainAsset;
category:
character:
static Dictionary<string, Dictionary<string, List<CharacterElement>>> sortedElements;
static List<string> availableCharacters = new List<string>();
// This method downloads the CharacterElementDatabase assetbundle and populates
// the sortedElements Dictionary from the contents. This is done at runtime as
// ScriptableObjects do not support Dictionaries.
//ReadyToUse must be true before you create an instance of CharacterGenerator.
public static bool ReadyToUse
{
get
{
if (database == null)
database = new WWW(AssetbundleBaseURL + "CharacterElementDatabase.assetbundle");
if (sortedElements != null)
{
return true;
}
if (!database.isDone)
{
return false;
}
CharacterElementHolder ceh = (CharacterElementHolder) database.assetBundle.mainAsset;
sortedElements = new Dictionary<string, Dictionary<string, List<CharacterElement>>>();
foreach (CharacterElement element in ceh.content)
{
string[] a = element.bundleName.Split('_');
string character = a[0];
string category = a[1].Split('-')[0].Replace(".assetbundle", "");
if (!availableCharacters.Contains(character))
availableCharacters.Add(character);
if (!sortedElements.ContainsKey(character))
sortedElements.Add(character, new Dictionary<string, List<CharacterElement>>());
if (!sortedElements[character].ContainsKey(category))
sortedElements[character].Add(category, new List<CharacterElement>());
sortedElements[character][category].Add(element);
}
return true;
}
}
FR:海涛高软(QQ技术群:386476712)