public GameObject GetPrefab(int _type, int _nom) { string path = "Assets/Content/"; GameObject prefab = null; BaseU bu = GetObjConfig(_type, _nom); if (bu == null) { Debug.LogError("SettingsContainer.GetPrefab not find in settings Tip=" + _type + " Obj=" + _nom); return(null); } else { if (bu.pref == "Reb" && Application.platform == RuntimePlatform.WindowsEditor) { return(null); //TODO: убрать- просто надоела } switch (_type) { case 5: path = path + "Bots/"; break; case 0: case 1: case 2: path = path + "Buildings/"; break; case 3: path = path + "Thing/"; break; case 4: path = path + "Terrain/"; break; } #if UNITY_EDITOR prefab = (GameObject)AssetDatabase.LoadAssetAtPath(path + bu.pref + ".prefab", typeof(GameObject)); #endif if (!prefab) { AssetBundle bundle = gameControll.GetAssetBundle(bu.bundle); prefab = (GameObject)bundle.LoadAsset(bu.pref); } return(prefab); } }
/* * public AssetBundle GetAssetBundle(string _name) * { * try{ * return settings.AssetBundleIndex[_name].bundle; * }catch * { * Debug.LogError("SettingsCfg.GetAssetBundle not defined name "+_name); * } * return null; * } */ public void ImportOldJSON(HashRequist _HashRequist, DehashRequist _DehashRequist) { int i = 0; Hashtable obj; AssetBundleU[] abs = new AssetBundleU[] {}; TerrainU[] terrains = new TerrainU[] {}; TowerU[] towers = new TowerU[] {}; BotU[] bots = new BotU[] {}; ResourceU[] resources = new ResourceU[] {}; WallU[] walls = new WallU[] {}; ThingU[] things = new ThingU[] {}; BulletU[] bullets = new BulletU[] {}; BaseU[] menus = new BaseU[] {}; BaseU bs; base.ImportOldJSON(_HashRequist, _DehashRequist); if (jsonText != "") { _HashRequist(jsonText, delegate(Hashtable SettingsOld){ int count = 0; //Заполним список AssetBundle obj = (Hashtable)SettingsOld["AssetBundle"]; Hashtable ab = (Hashtable)obj["" + count]; while (ab != null) { AssetBundleU au = new AssetBundleU(); au.name = (string)ab["name"]; // au.downloaded=false; System.Array.Resize(ref abs, abs.Length + 1); abs[abs.Length - 1] = au; count++; ab = (Hashtable)obj["" + count]; } //Заполним настройки string[] prefixs = new string[] { "4-", "0-", "5-", "1-", "2-", "3-", "6-", "10-" }; for (i = 0; i < prefixs.Length; i++) { count = 0; string prefix = prefixs[i]; try{ obj = (Hashtable)SettingsOld[prefix + count]; while (obj != null) { switch (i) { case 0: //if (PlayerPrefs.GetInt("debug")==1) Debug.Log("SettingsCfg.MapSettings terrains="+obj); _DehashRequist(obj, delegate(string _str){ TerrainU tn = (TerrainU)JsonUtility.FromJson(_str, typeof(TerrainU)); System.Array.Resize(ref terrains, terrains.Length + 1); terrains[terrains.Length - 1] = tn; }); break; case 1: //if (PlayerPrefs.GetInt("debug")==1) Debug.Log("SettingsCfg.MapSettings towers="+obj); _DehashRequist(obj, delegate(string _str){ TowerU tr = (TowerU)JsonUtility.FromJson(_str, typeof(TowerU)); System.Array.Resize(ref towers, towers.Length + 1); towers[towers.Length - 1] = tr; }); break; case 2: //if (PlayerPrefs.GetInt("debug")==1) Debug.Log("SettingsCfg.MapSettings bots="+obj); _DehashRequist(obj, delegate(string _str){ BotU bt = (BotU)JsonUtility.FromJson(_str, typeof(BotU)); System.Array.Resize(ref bots, bots.Length + 1); bots[bots.Length - 1] = bt; }); break; case 3: //if (PlayerPrefs.GetInt("debug")==1) Debug.Log("SettingsCfg.MapSettings bots="+obj); _DehashRequist(obj, delegate(string _str){ ResourceU re = (ResourceU)JsonUtility.FromJson(_str, typeof(ResourceU)); System.Array.Resize(ref resources, resources.Length + 1); resources[resources.Length - 1] = re; }); break; case 4: //if (PlayerPrefs.GetInt("debug")==1) Debug.Log("SettingsCfg.MapSettings bots="+obj); _DehashRequist(obj, delegate(string _str){ WallU wl = (WallU)JsonUtility.FromJson(_str, typeof(WallU)); System.Array.Resize(ref walls, walls.Length + 1); walls[walls.Length - 1] = wl; }); break; case 5: _DehashRequist(obj, delegate(string _str){ //if (PlayerPrefs.GetInt("debug")==1) Debug.Log("SettingsCfg.MapSettings bots="+obj); ThingU tg = (ThingU)JsonUtility.FromJson(_str, typeof(ThingU)); System.Array.Resize(ref things, things.Length + 1); things[things.Length - 1] = tg; }); break; case 6: _DehashRequist(obj, delegate(string _str){ //if (PlayerPrefs.GetInt("debug")==1) Debug.Log("SettingsCfg.MapSettings bots="+obj); BulletU bu = (BulletU)JsonUtility.FromJson(_str, typeof(BulletU)); System.Array.Resize(ref bullets, bullets.Length + 1); bullets[bullets.Length - 1] = bu; }); break; case 7: _DehashRequist(obj, delegate(string _str){ bs = (BaseU)JsonUtility.FromJson(_str, typeof(BaseU)); System.Array.Resize(ref menus, menus.Length + 1); menus[menus.Length - 1] = bs; }); break; } count++; obj = (Hashtable)SettingsOld[prefix + count]; } }catch { } } }); } jsonText = ""; settings.AssetBundles = abs; settings.terrains = terrains; settings.towers = towers; settings.bots = bots; settings.resources = resources; settings.walls = walls; settings.things = things; settings.bullets = bullets; settings.menus = menus; for (i = 0; i < settings.towers.Length; i++) { settings.towers[i].bulletInd = BulletIndex(settings.towers[i].bullet); settings.towers[i].bullet = ""; } for (i = 0; i < settings.bots.Length; i++) { settings.bots[i].bulletInd = BulletIndex(settings.bots[i].bullet); settings.bots[i].bullet = ""; } }