简体   繁体   中英

what's the best structure when use many keys and one value?

I'm making an assetbundle loader. now I'm using Resources.Load(path) but it will be changed to MyResources.Load(path) .

MyResources.Load(path) will work same Resources.Load(path) when i develop and will find assetbundle name from path and return an object when it release.

so, now I'm using following.

hashAssetBundle.Add("Sword/red_sword.prefab", "weapon");
hashAssetBundle.Add("Sword/blue_sword.prefab", "weapon");
hashAssetBundle.Add("Gun/red_gun.prefab", "weapon");
hashAssetBundle.Add("Gun/blue_gun.prefab", "weapon");

and use like following and the reason why I use like it is compatibility and convinience of development.

goSword = MyResources.Load<GameObject>("Sword/red_sword");

problem is the 4000 keys. I want a better data structure. help me!

ps. sorry for English.

Small suggestion on resource loading. Cant you load the asset folder instead of individual asset itself.

Add("Sword", "weapon");

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM