// Use this for initialization void Start() { if (null == mLvCtrl) { float fw = Screen.width; float fh = Screen.height; float f3 = fh / 3.0f * 2; mLvCtrl = new UIListViewCtrl(); mLvCtrl.mRctWH = new Vector2(fw, f3); mLvCtrl.mViewWH = new Vector2(fw, f3); mLvCtrl.OnClick = GameResMng.TestLoadScene; } GameResMng.ForcePackage = ForceReadFromPackage; GameResMng.CreateResMng(this); }
//-------------------------------------------------------------------------------------------- // szName 带路径但 不需要扩展名 static public void TestLoadScene(LvItm itm, UIListViewCtrl frm) { bool bLoad = false; LvItmBtnEx itx = itm as LvItmBtnEx; if (itx != null) { ResPackge pck = itx.mRefPck; if (pck != null) { string szName = Path.GetFileNameWithoutExtension(pck.mFile); GameResMng pMng = GetResMng(); if (null != pMng) { bLoad = pMng.NtfLoadScene(szName); } if (!bLoad) // 也许没有打包或用Unity打包 { string szNm = Path.GetFileNameWithoutExtension(szName); Application.LoadLevel(szNm.ToLower()); } } } }
void NtfOnResMngGUI() { #if (MY_DEBUG) // 显示出来 UIListViewCtrl LvCtrl = m_lvCtrl; if (LvCtrl == null) { return; } if (LvCtrl.IsEmpty()) { AddReToViewCtrl(); } #endif float fy = 5.0f; float flw = Screen.width - 80; if (GUI.Button(new Rect(flw, fy, 80, 20), @"本地资源")) { mResMng.StartWWW(true); } if (GUI.Button(new Rect(flw - 80, fy, 80, 20), @"网络资源")) { mResMng.StartWWW(false); } fy += 40; //GUI.Label(new Rect( 0, fy, Screen.width, 20), @"调试信息:" + GameResMng.DebugMsg); //fy += 40; //mResTest = GUI.TextField(new Rect( 0, fy, 400, 20), mResTest); if (GUI.Button(new Rect(410, fy, 40, 20), @"查找")) { mMsg = ""; UnityEngine.Object myObj = LoadResource(mResTest); if (myObj == null) { string szMsg = @"加载失败: " + mResTest; Debug.Log(szMsg); } else { Debug.Log("myObj = " + myObj.name); } } if (GUI.Button(new Rect(460, fy, 40, 20), @"清除")) { mMsg = ""; mResTest = ""; } if (GUI.Button(new Rect(510, fy, 40, 20), @"测试")) { if (null != mResDic) { OnTestPack(); } } if (GUI.Button(new Rect(560, fy, 40, 20), @"场景")) { GameResMng pMng = GameResMng.GetResMng(); if (pMng != null) { pMng.LoadSceneCallback(mResTest, null); } } if (GUI.Button(new Rect(610, fy, 40, 20), @"列表")) { OnListPackFiles(); } //fy += 40; //GUI.Label(new Rect( 0, fy, Screen.width, 20), @"提示消息:" + mMsg); }
void AddReToViewCtrl() { #if (MY_DEBUG) // 显示出来 UIListViewCtrl LvCtrl = m_lvCtrl; if (LvCtrl == null) { return; } LvCtrl.ClearLvItems(); LvItm lvHdr = LvCtrl.AddLvLabel(@"调试信息", Color.red); lvHdr.mfont = 24; lvHdr.mAnchor = TextAnchor.MiddleCenter; LvColGrp iGrp = LvCtrl.AddLvColGrp(); //LvColGrp iGrp0 = iGrp.AddLvColGrp(0); string szVer = @"游戏版本:" + GameResMng.mGmVer; iGrp.AddLvLabel(szVer, 200, Color.green); szVer = @"资源版本:" + GameResMng.mReVer; iGrp.AddLvLabel(szVer, 200, Color.blue); //LvColGrp iGrp1 = iGrp.AddLvColGrp(2); //lvHdr = iGrp1.AddLvBtn(@"网络资源", 80, Color.blue); //lvHdr.mAnchor = TextAnchor.MiddleCenter; //lvHdr = iGrp1.AddLvBtn(@"本地资源", 80, Color.blue); //lvHdr.mAnchor = TextAnchor.MiddleCenter; iGrp.UpdateDrawH(); LvCtrl.AddLvEmpty(5); LvCtrl.AddLvLabel(@"运行信息:", Color.green); LvItmGrp itmGrp = LvCtrl.AddLvItmGrp(@"搜索到的资源包:", Color.green); //itmGrp.AddLvLabel("asdf", 0, Color.white); //itmGrp.AddLvLabel("234234asdf", 0, Color.white); if (null != mPackDic) { foreach (ResPackge pck in mPackDic.Values) { Debug.Log("pck.mType = " + pck.mType.ToString()); if (pck.mType == 0) { itmGrp.AddLvLabelEx(pck); } } } itmGrp = LvCtrl.AddLvItmGrp(@"搜索到的场景:", Color.green); //itmGrp.AddLvLabel("asdf", 0, Color.white); //itmGrp.AddLvLabel("234234asdf", 0, Color.white); if (null != mPackDic) { Dictionary <string, ResPackItm> vDic = GetSceneItms(); foreach (ResPackItm itm in vDic.Values) { ResPackge pck = GetPackge(itm.mPack); string sf = Path.GetFileNameWithoutExtension(itm.mFile); itmGrp.AddLvBtnEx(@"Load " + sf, pck); } } #endif }