Example #1
0
        //-----------------------------------------------------------------
        protected void OnDestroy()
        {
            ClearClick();
#if ASYNC_MODE
            string abName = name.ToLower().Replace("panel", "");
            ResManager.UnloadAssetBundle(abName + AppConst.ExtName);
#endif
            QUtil.ClearMemory();
            Debug.Log("~" + name + " was destroy!");
        }
        IEnumerator OnExtractResource()
        {
            string dataPath = QUtil.DataPath;         //数据目录
            string resPath  = QUtil.AppContentPath(); //游戏包资源目录

            if (Directory.Exists(dataPath))
            {
                Directory.Delete(dataPath, true);
            }
            Directory.CreateDirectory(dataPath);

            string infile  = resPath + "files.txt";
            string outfile = dataPath + "files.txt";

            if (File.Exists(outfile))
            {
                File.Delete(outfile);
            }

            string message = "正在解包文件:>files.txt";

            Debug.Log(infile);
            Debug.Log(outfile);
            if (Application.platform == RuntimePlatform.Android)
            {
                WWW www = new WWW(infile);
                yield return(www);

                if (www.isDone)
                {
                    File.WriteAllBytes(outfile, www.bytes);
                }
                yield return(0);
            }
            else
            {
                File.Copy(infile, outfile, true);
            }
            yield return(new WaitForEndOfFrame());

            //释放所有文件到数据目录
            string[] files = File.ReadAllLines(outfile);
            foreach (var file in files)
            {
                string[] fs = file.Split('|');
                infile  = resPath + fs[0]; //
                outfile = dataPath + fs[0];

                message = "正在解包文件:>" + fs[0];
                Debug.Log("正在解包文件:>" + infile);

                string dir = Path.GetDirectoryName(outfile);
                if (!Directory.Exists(dir))
                {
                    Directory.CreateDirectory(dir);
                }

                if (Application.platform == RuntimePlatform.Android)
                {
                    WWW www = new WWW(infile);
                    yield return(www);

                    if (www.isDone)
                    {
                        File.WriteAllBytes(outfile, www.bytes);
                    }
                    yield return(0);
                }
                else
                {
                    if (File.Exists(outfile))
                    {
                        File.Delete(outfile);
                    }
                    File.Copy(infile, outfile, true);
                }
            }
            message = "解包完成!!!";
            Debug.Log(message);
            yield return(new WaitForSeconds(0.1f));

            message = string.Empty;
            //释放完成,开始启动更新资源
            OnResourceInited();
        }
Example #3
0
 protected void OnClickEvent(GameObject go)
 {
     QUtil.CallMethod(name, "OnClick", go);
 }
Example #4
0
 protected void OnClick()
 {
     QUtil.CallMethod(name, "OnClick");
 }
Example #5
0
 protected void Start()
 {
     QUtil.CallMethod(name, "Start");
 }
Example #6
0
 protected void Awake()
 {
     QUtil.CallMethod(name, "Awake", gameObject);
 }