void Start() { mBackButton.onClick.AddListener(delegate { SceneManager.LoadSceneAsync("Boot"); }); List <Card> cardList = CardHelper.GetCardShuffleList(); // 测试排序; //CardHelper.SortCards(cardList); // Demo 显示牌信息; for (int i = 0; i < cardList.Count; i++) { GameObject ruleItemObj = GameObject.Instantiate(mPrefabObj) as GameObject; if (ruleItemObj != null) { ruleItemObj.SetActive(true); ruleItemObj.transform.parent = mRoot.transform; ruleItemObj.transform.localPosition = Vector3.zero; ruleItemObj.transform.localScale = new Vector3(1.0f, 1.0f, 1.0f); ruleItemObj.name = i.ToString(); Image image = ruleItemObj.GetComponent <Image>(); if (image != null) { image.sprite = ResLoad.GetCardSprite(cardList[i].CardSuits, cardList[i].CardWeight); } } } }
public void Reset() { Log.i("ResMgr Reset!!!", Log.Tag.RES); _shaders.Clear(); ResLoad.clearCach(); ResLoad.init(this); LoadCommonAB(); LuaRoot.dirty = true; }
void createAssetByResLoadAsync(string path) { Caching.ClearCache(); tResLoad = Time.realtimeSinceStartup; for (int i = 0; i < times; ++i) { ResLoad.get(path).asyncLoad(onLoadFinish); } }
protected override void onAwake() { TableMgr.TestModel = true; WindowMgr.SetWindowRes("ActMainWindow", "UI/ActMainWindow"); GameObject go = ResLoad.get("UI/UIRoot").gameObject(); go.GetComponent <GRoot>().mUseLua = false; }
public string path;//动态资源加载路径,不设置则会控制根节点显示隐藏 // Use this for initialization void OnEnable() { if (string.IsNullOrEmpty(path) || transform.childCount > 0) { return; } GameObject go = ResLoad.get(path, ResideType.InScene).gameObject(); go.transform.SetParent(transform, false); }
public bool loadSkill(string skillPath) { TextAsset ta = ResLoad.get(skillPath).asset <TextAsset>(); if (ta == null) { Log.e("Skill not find by ResLoad path=" + skillPath, Log.Tag.Skill); return(false); } return(ta.bytes[0] == 0x73?loadSkills(ta.bytes):loadSkills(ta.text)); }
public void Start() { Instance = this; AssetBundle cubeBundle = GetAssetBundle("cube.myab"); GameObject cube = Instantiate(cubeBundle.LoadAsset("cube")) as GameObject; cube.transform.position = new Vector3(0, 0, 5); t.text = "wan cheng"; }
void createAssetByResLoadSync(string path) { Caching.ClearCache(); float t1 = Time.realtimeSinceStartup; for (int i = 0; i < times; ++i) { float t = Time.realtimeSinceStartup; Object o = ResLoad.get(path, ResideType.InGame).asset <Object>(); Debug.Log("use time=" + (Time.realtimeSinceStartup - t)); } Debug.Log("use time=" + (Time.realtimeSinceStartup - t1)); }
string getFile(int id) { if (skillmap == null) { skillmap = new Dictionary <int, string>(); TextAsset ta = ResLoad.get("Skill/skillmap").asset <TextAsset>(); string[] ss = ta.text.Split(new string[] { "," }, System.StringSplitOptions.RemoveEmptyEntries); for (int i = 0; i < ss.Length; i += 2) { skillmap[int.Parse(ss[i])] = ss[i + 1]; } } return(skillmap[id]); }
void LoadCommonAB() { ResLoad.get("common/font", ResideType.InGame).assetBundle(); AssetBundle ab = ResLoad.get("common/shader", ResideType.InGame).assetBundle(); if (ab != null) { Object[] objs = ab.LoadAllAssets(); for (int i = 0, max = objs.Length; i < max; ++i) { Shader sd = objs [i] as Shader; _shaders [sd.name] = sd; } } }
bool StartUnzip() { Log.i("start unzip res.zip", Log.Tag.RES); do { #if UNITY_ANDROID && !UNITY_EDITOR WWW www = new WWW("jar:file://" + Application.dataPath + "!/assets/resinfo.txt"); while (!www.isDone) { Thread.Sleep(100); continue; } string resinfo = www.text; #else string resinfo = null; string filePath = Application.streamingAssetsPath + "/resinfo.txt"; if (File.Exists(filePath)) { resinfo = File.ReadAllText(filePath); } #endif if (string.IsNullOrEmpty(resinfo)) { break; } string[] ss = resinfo.Split('|'); int resZipVersion = int.Parse(ss [0]); int resZipSize = int.Parse(ss [1]); int[] resPart = ResLoad.str2IntArray(ss[2]); string unzipTagFile = ResLoad.resPath + resZipVersion; if (File.Exists(unzipTagFile)) { break; } if (Directory.Exists(ResLoad.resPath)) { Directory.Delete(ResLoad.resPath, true); } _resZipVersion = resZipVersion; _resZipSize = resZipSize; _resPart = resPart; _unzipTagFile = unzipTagFile; return(true); } while(false); EventMgr.single.SendEvent(GRoot.EventResUnzip, true); return(false); }
void OnUnzipProgress(float progress, int code) { if (code == 0) { progressBar.value = progress; unzipInfo.text = string.Format("正在解压资源...{0:F2}%", 100f * progress); if (progress >= 1) { //unzip ok List <XmlPatch.DFileInfo> fs = null; try { XmlPatch patch = new XmlPatch(Application.persistentDataPath + "/Res/"); bool bcancel = false; fs = patch.listDownFiles(onCheckFileProgress, ref bcancel, _resPart); } catch (Exception e) { Log.e(e); fs = null; } if (fs == null || fs.Count > 0) { Log.e("unzip failed", Log.Tag.RES); unzipInfo.text = "解压资源失败,请确保有足够的存储空间(>" + ToSize(_resZipSize) + ")后重启游戏再试"; quitBtn.gameObject.SetActive(true); return; } File.WriteAllText(_unzipTagFile, "ok"); ResLoad.setVersionPart(_resZipVersion, _resPart); Log.i("^_^ unzip ok", Log.Tag.RES); EventMgr.single.SendEvent(GRoot.EventResUnzip, true); } } else { //unzip failed Log.e("unzip failed", Log.Tag.RES); unzipInfo.text = "解压资源失败,请确保有足够的存储空间(>" + ToSize(_resZipSize) + ")后重启游戏再试"; quitBtn.gameObject.SetActive(true); } }
/// <summary> /// 加载游戏数据 /// </summary> public void LoadJsonData() { FSDataNodeTable <SkillNode> .GetSingleton().LoadJson(ResLoad.LoadJsonRes("skill")); //技能表 FSDataNodeTable <BulletNode> .GetSingleton().LoadJson(ResLoad.LoadJsonRes("bullet")); //子弹表 FSDataNodeTable <ModelNode> .GetSingleton().LoadJson(ResLoad.LoadJsonRes("model")); //模型表 FSDataNodeTable <HeroNode> .GetSingleton().LoadJson(ResLoad.LoadJsonRes("hero")); //英雄表 FSDataNodeTable <HeroSkinNode> .GetSingleton().LoadJson(ResLoad.LoadJsonRes("skin")); //英雄皮肤表 FSDataNodeTable <HeroAttrNode> .GetSingleton().LoadJson(ResLoad.LoadJsonRes("heroAttr")); //英雄属性表 FSDataNodeTable <MonsterAttrNode> .GetSingleton().LoadJson(ResLoad.LoadJsonRes("monsterAttr")); //怪物属性表 FSDataNodeTable <MonsterSkillNode> .GetSingleton().LoadJson(ResLoad.LoadJsonRes("skill_monster")); //怪物技能表 FSDataNodeTable <Moba3v3NaviNode> .GetSingleton().LoadJson(ResLoad.LoadJsonRes("Moba3v3NaviNode")); //地图寻路表 }
public void SendPoker(GameObject rootObj, List <Card> cardList) { // Demo 显示牌信息; for (int i = 0; i < cardList.Count; i++) { GameObject ruleItemObj = GameObject.Instantiate(mPrefabObj) as GameObject; if (ruleItemObj != null) { ruleItemObj.SetActive(true); ruleItemObj.transform.parent = rootObj.transform; ruleItemObj.transform.localPosition = Vector3.zero; ruleItemObj.transform.localScale = new Vector3(1.0f, 1.0f, 1.0f); ruleItemObj.name = i.ToString(); Image image = ruleItemObj.GetComponent <Image>(); if (image != null) { image.sprite = ResLoad.GetCardSprite(cardList[i].CardSuits, cardList[i].CardWeight); } } } }
void OnGUI() { float y = 0; if (GUI.Button(new Rect(200, y, 200, 50), "ClearUnusedAsset")) { Resources.UnloadUnusedAssets(); } if (GUI.Button(new Rect(0, y, 200, 50), "LoadFromMemory")) { Debug.Log("----------------------------LoadFromMemory"); LoadFromMemory(abPath); } if (GUI.Button(new Rect(0, y += 50, 200, 50), "LoadFromMemoryAsync")) { Debug.Log("----------------------------LoadFromMemoryAsync"); StartCoroutine(loadFromMemoryAsync(abPath)); } if (GUI.Button(new Rect(0, y += 50, 200, 50), "loadFromFile")) { Debug.Log("----------------------------loadFromFile"); loadFromFile(abPath); } if (GUI.Button(new Rect(0, y += 50, 200, 50), "loadFromFileAsync")) { Debug.Log("----------------------------loadFromFileAsync"); loadFromFileAsync(abPath); } if (GUI.Button(new Rect(0, y += 50, 200, 50), "LoadFromCacheOrDownload")) { Debug.Log("----------------------------LoadFromCacheOrDownload"); StartCoroutine(createAssetByLoadFromCacheOrDownload(abPath)); } if (GUI.Button(new Rect(0, y += 50, 200, 50), "WWW")) { Debug.Log("----------------------------WWW"); StartCoroutine(createAssetByWWW(abPath)); } if (GUI.Button(new Rect(0, y += 50, 200, 50), "createAssetByResLoadSync")) { Debug.Log("----------------------------createAssetByResLoadSync"); createAssetByResLoadSync(abPath); } if (GUI.Button(new Rect(0, y += 50, 200, 50), "createAssetByResLoadAsync")) { Debug.Log("----------------------------createAssetByResLoadAsync"); createAssetByResLoadAsync(abPath); } if (GUI.Button(new Rect(0, y += 50, 200, 50), "Test Resource Atlas ")) { Object o = Resources.Load("UI/TestRes"); GameObject go = GameObject.Instantiate(o) as GameObject; go.transform.parent = transform; go.transform.localPosition = Vector3.zero; go.transform.localRotation = Quaternion.identity; } if (GUI.Button(new Rect(0, y += 50, 200, 50), "Test Assetbundle Atlas ")) { AssetBundle ab = ResLoad.get("atlas/genera", ResideType.InGame).assetBundle(); GameObject go = ResLoad.get("UI/TestRes").gameObject(); go.transform.parent = transform; go.transform.localPosition = Vector3.zero; go.transform.localRotation = Quaternion.identity; Image[] i = go.GetComponentsInChildren <Image>(true); i [3].sprite = ab.LoadAsset <Sprite> ("Btn_Blue"); ResLoad.clearByPath("atlas/genera"); } }
public void SetMaterial(string matPath) { mEffectMat = ResLoad.get(matPath, ResideType.InScene).asset <Material>(); OnEnable(); }
void Awake() { Single = this; ResLoad.init(this); LoadCommonAB(); }
// 数据存在依赖关系,注意解析顺序 void loadJson() { FSDataNodeTable <SkillNode> .GetSingleton().LoadJson(ResLoad.LoadJsonRes1("skill/skill")); //技能表 FSDataNodeTable <SkillBuffNode> .GetSingleton().LoadJson(ResLoad.LoadJsonRes1("skill/skillBuffs")); //技能buff FSDataNodeTable <ModelNode> .GetSingleton().LoadJson(ResLoad.LoadJsonRes1("model/model")); //模型表 FSDataNodeTable <HeroNode> .GetSingleton().LoadJson(ResLoad.LoadJsonRes1("hero/hero")); //英雄表 FSDataNodeTable <HeroAttrNode> .GetSingleton().LoadJson(ResLoad.LoadJsonRes1("hero/heroAttr")); //英雄属性表 FSDataNodeTable <RoleIconAttrNode> .GetSingleton().LoadJson(ResLoad.LoadJsonRes1("player/headicon")); //修改头像 FSDataNodeTable <MapNode> .GetSingleton().LoadJson(ResLoad.LoadJsonRes1("map/worldMap")); //大关表 FSDataNodeTable <SceneNode> .GetSingleton().LoadJson(ResLoad.LoadJsonRes1("map/dungeons")); //小关表 FSDataNodeTable <UpGradeSkillConsume> .GetSingleton().LoadJson(ResLoad.LoadJsonRes1("skill/upgradeSkillConsume")); //技能消耗表 FSDataNodeTable <MonsterAttrNode> .GetSingleton().LoadJson(ResLoad.LoadJsonRes1("monster/monsterAttr")); // 怪物表 //FSDataNodeTable<ItemNode>.GetSingleton().LoadJson(ResLoad.LoadJsonRes1("item/item")); FSDataNodeTable <StarUpGradeNode> .GetSingleton().LoadJson(ResLoad.LoadJsonRes1("hero/upgradeStarConsume")); FSDataNodeTable <EquipUpgradeNode> .GetSingleton().LoadJson(ResLoad.LoadJsonRes1("hero/upgradeEquipmentConsume")); FSDataNodeTable <HeroUpGradeNode> .GetSingleton().LoadJson(ResLoad.LoadJsonRes1("hero/heroLevelUp")); FSDataNodeTable <CommentsStarNode> .GetSingleton().LoadJson(ResLoad.LoadJsonRes1("scene/CommentsStar")); FSDataNodeTable <LevelConfigsNode> .GetSingleton().LoadJson(ResLoad.LoadJsonRes1("scene/LevelConfigs")); FSDataNodeTable <LevelConfigNode> .GetSingleton().LoadJson(ResLoad.LoadJsonRes1("scene/LevelConfig")); FSDataNodeTable <MobaLevelConfigNode> .GetSingleton().LoadJson(ResLoad.LoadJsonRes1("scene/MobaLevelConfig")); FSDataNodeTable <TPLevelConfigNode> .GetSingleton().LoadJson(ResLoad.LoadJsonRes1("scene/TPLevelConfig")); FSDataNodeTable <TDLevelConfigNode> .GetSingleton().LoadJson(ResLoad.LoadJsonRes1("scene/TDLevelConfig")); FSDataNodeTable <AirWallConfig> .GetSingleton().LoadJson(ResLoad.LoadJsonRes1("scene/AirWallConfig")); FSDataNodeTable <TowerDefenceNode> .GetSingleton().LoadJson(ResLoad.LoadJsonRes1("scene/TowerDefence")); FSDataNodeTable <ActivityPropsNode> .GetSingleton().LoadJson(ResLoad.LoadJsonRes1("scene/ActivityProps")); FSDataNodeTable <MapInfoNode> .GetSingleton().LoadJson(ResLoad.LoadJsonRes1("mapInfo/ScenceConfigureTable")); FSDataNodeTable <ScenceElementFileIndexTableNode> .GetSingleton().LoadJson(ResLoad.LoadJsonRes1("mapInfo/ScenceElementFileIndexTable")); FSDataNodeTable <TaskDataNode> .GetSingleton().LoadJson(ResLoad.LoadJsonRes1("task/taskDetails")); FSDataNodeTable <TaskInstructionsNode> .GetSingleton().LoadJson(ResLoad.LoadJsonRes1("task/taskinstructions")); FSDataNodeTable <TaskPropsNode> .GetSingleton().LoadJson(ResLoad.LoadJsonRes1("task/Useprops")); FSDataNodeTable <CollectNode> .GetSingleton().LoadJson(ResLoad.LoadJsonRes1("task/Collect")); FSDataNodeTable <PlotLinesNode> .GetSingleton().LoadJson(ResLoad.LoadJsonRes1("task/plot_lines")); FSDataNodeTable <DailyTasksNode> .GetSingleton().LoadJson(ResLoad.LoadJsonRes1("task/Daily_tasks")); //日常任务 FSDataNodeTable <DayActiveNode> .GetSingleton().LoadJson(ResLoad.LoadJsonRes1("task/day_active")); //日常箱子状态 FSDataNodeTable <RewardTaskNode> .GetSingleton().LoadJson(ResLoad.LoadJsonRes1("task/Reward_tasks")); //悬赏任务 FSDataNodeTable <TaskRewardNode> .GetSingleton().LoadJson(ResLoad.LoadJsonRes1("task/taskReward")); //任务奖励表 FSDataNodeTable <NPCNode> .GetSingleton().LoadJson(ResLoad.LoadJsonRes1("npc/npc")); FSDataNodeTable <ItemNode> .GetSingleton().LoadJson(ResLoad.LoadJsonRes1("item/item")); //物品 FSDataNodeTable <ItemEquipNode> .GetSingleton().LoadJson(ResLoad.LoadJsonRes1("item/equipment")); //装备 FSDataNodeTable <MaterialNode> .GetSingleton().LoadJson(ResLoad.LoadJsonRes1("item/material")); //材料 FSDataNodeTable <RuneNode> .GetSingleton().LoadJson(ResLoad.LoadJsonRes1("item/rune")); //魂石 FSDataNodeTable <TitleNode> .GetSingleton().LoadJson(ResLoad.LoadJsonRes1("player/title")); //称号表 FSDataNodeTable <ResetLaterNode> .GetSingleton().LoadJson(ResLoad.LoadJsonRes1("player/buyReset")); //购买重置表 FSDataNodeTable <PlayerLevelUpNode> .GetSingleton().LoadJson(ResLoad.LoadJsonRes1("player/playerLevelUp")); //玩家升级表 FSDataNodeTable <UnLockFunctionNode> .GetSingleton().LoadJson(ResLoad.LoadJsonRes1("system/unlockFunction")); //解锁功能表 FSDataNodeTable <LevelRewardNode> .GetSingleton().LoadJson(ResLoad.LoadJsonRes1("welfare/upgradeReward")); //等级奖励表 FSDataNodeTable <OnlineRewardNode> .GetSingleton().LoadJson(ResLoad.LoadJsonRes1("welfare/onlineReward")); //在线奖励表 FSDataNodeTable <UISign_inNode> .GetSingleton().LoadJson(ResLoad.LoadJsonRes1("welfare/signIn")); //签到 FSDataNodeTable <NewPlayerRewardNode> .GetSingleton().LoadJson(ResLoad.LoadJsonRes1("welfare/newbieReward")); //新手15日登录礼包 FSDataNodeTable <MealAttrNode> .GetSingleton().LoadJson(ResLoad.LoadJsonRes1("welfare/meal")); //定时进餐 FSDataNodeTable <GoldDrawNode> .GetSingleton().LoadJson(ResLoad.LoadJsonRes1("activity/goldDraw")); //金币抽奖 FSDataNodeTable <DiamondDrawNode> .GetSingleton().LoadJson(ResLoad.LoadJsonRes1("activity/diamondDraw")); //钻石抽奖 FSDataNodeTable <SoulDrawNode> .GetSingleton().LoadJson(ResLoad.LoadJsonRes1("activity/soulDraw")); //魂匣抽奖 FSDataNodeTable <GoldHandNode> .GetSingleton().LoadJson(ResLoad.LoadJsonRes1("activity/luckyDraw")); //点金手表 FSDataNodeTable <PlayerNameNode> .GetSingleton().LoadJson(ResLoad.LoadJsonRes1("player/playerName")); //改名字库表 FSDataNodeTable <NpcTableNode> .GetSingleton().LoadJson(ResLoad.LoadJsonRes1("mapInfo/NpcTable")); FSDataNodeTable <TransferTableNode> .GetSingleton().LoadJson(ResLoad.LoadJsonRes1("mapInfo/TransferTable")); FSDataNodeTable <RouteNode> .GetSingleton().LoadJson(ResLoad.LoadJsonRes1("mapInfo/RouteTable")); FSDataNodeTable <VipNode> .GetSingleton().LoadJson(ResLoad.LoadJsonRes1("vip/vip"));//vip表 FSDataNodeTable <UIGameAfficheNode> .GetSingleton().LoadJson(ResLoad.LoadJsonRes1("UIGameAffiche/operate_notice")); FSDataNodeTable <GuideNode> .GetSingleton().LoadJson(ResLoad.LoadJsonRes1("guide/guide")); //新手引导表 FSDataNodeTable <UIMountNode> .GetSingleton().LoadJson(ResLoad.LoadJsonRes1("mount/mount")); //坐骑表 FSDataNodeTable <PetNode> .GetSingleton().LoadJson(ResLoad.LoadJsonRes1("pet/pet")); //宠物表 FSDataNodeTable <UIPetNode> .GetSingleton().LoadJson(ResLoad.LoadJsonRes1("Pet/pet")); //宠物表 FSDataNodeTable <Archaeology_rewardNode> .GetSingleton().LoadJson(ResLoad.LoadJsonRes1("activity/Archaeology_reward")); //活动-考古 FSDataNodeTable <ShopNode> .GetSingleton().LoadJson(ResLoad.LoadJsonRes1("shop/shop")); //商店表 FSDataNodeTable <Moba3SceneConfigNode> .GetSingleton().LoadJson(ResLoad.LoadJsonRes1("Moba/Moba3v3ConfigTable")); //moba3v3 FSDataNodeTable <Moba3v3NaviNode> .GetSingleton().LoadJson(ResLoad.LoadJsonRes1("Moba/Moba3v3NaviNode")); //moba3v3 FSDataNodeTable <MobaRobotNode> .GetSingleton().LoadJson(ResLoad.LoadJsonRes1("Moba/arena_robot")); FSDataNodeTable <AfcNode> .GetSingleton().LoadJson(ResLoad.LoadJsonRes1("hero/afc"));//战斗力表 //LevelConfigNode foreach (MapInfoNode tempMIN in FSDataNodeTable <MapInfoNode> .GetSingleton().DataNodeList.Values) { foreach (ScenceElementFileIndexTableNode tempSEFITN in FSDataNodeTable <ScenceElementFileIndexTableNode> .GetSingleton().DataNodeList.Values) { if (tempSEFITN.key == tempMIN.map_info) { string name = tempSEFITN.filename; FSDataNodeTable <SceneMapNode> .GetSingleton().LoadJsons(ResLoad.LoadJsonRes1("mapInfo/" + name), name);//野外地图表 } } } InitItemList(); }
void Awake() { ins = GetComponent <Main>(); ResLoad.Init(); }
void Start() { _grayMat = ResLoad.get("Mat/GrayMat", ResideType.InGame).asset <Material>(); InvokeRepeating("checkSate", 0, 0.1f); }
void Start() { rangeMat = Object.Instantiate(ResLoad.get("Mat/Indicator", ResideType.InScene).asset <Material>()); rectMat = Object.Instantiate(ResLoad.get("Mat/Indicator", ResideType.InScene).asset <Material>()); }
void onLoadFinish(ResLoad resLoad) { Debug.Log("use time=" + (Time.realtimeSinceStartup - tResLoad)); }