Esempio n. 1
0
 /// <summary>
 /// 初始化Lua代码加载路径
 /// </summary>
 void InitLuaPath()
 {
     if (AppConst.DebugMode)
     {
         string rootPath = PathMod.AppContentPath();
         m_Lua.AddSearchPath(rootPath + "Lua");
         m_Lua.AddSearchPath(rootPath + "View");
         m_Lua.AddSearchPath(rootPath + "ToLua/Lua");
     }
     else
     {
         m_Lua.AddSearchPath(PathMod.DataPath + "lua");
     }
 }
Esempio n. 2
0
        /// <summary>
        /// 加载游戏场景
        /// </summary>
        /// <param name="scenename">场景名</param>
        /// <returns></returns>
        public void LoadGameScene(string scenename, UILoading uiload, VoidDelegate loadfinishdo = null)
        {
            if (_sceneBundle != null)
            {
                LeaveGameScene(() => { LoadGameScene(scenename, uiload, loadfinishdo); });
                return;
            }

            string path = PathMod.AssetPath(string.Format("Scene/{0}.unity3d", scenename));

            uiload.GetProgres = () => { return(progress); };
            GameMain.Instance.StartCoroutine(LoadSceneEnumerator(path, scenename, () =>
            {
                if (loadfinishdo != null)
                {
                    loadfinishdo();
                }
                //EventManager.Instance.Trigger<EventLoadScaneFinish>(new EventLoadScaneFinish(scenename));
            }));
        }
Esempio n. 3
0
        IEnumerator OnExtractResource()
        {
            string dataPath = PathMod.DataPath;         //数据目录
            string resPath  = PathMod.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(message);
            ////facade.SendMessageCommand(NotiConst.UPDATE_MESSAGE, message);
            //MainBehaviour.GlobalObject.SendMessage("OnShowMessage", message);

            //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);
            //    //facade.SendMessageCommand(NotiConst.UPDATE_MESSAGE, message);
            //    GameMain.GlobalObject.SendMessage("OnShowMessage", message);

            //    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);
            //    }
            //    yield return new WaitForEndOfFrame();
            //}
            //message = "解包完成!!!";
            ////facade.SendMessageCommand(NotiConst.UPDATE_MESSAGE, message);
            //GameMain.GlobalObject.SendMessage("OnShowMessage", message);

            yield return(new WaitForSeconds(0.1f));

            message = string.Empty;

            //释放完成,开始启动更新资源
            GameMain.Instance.StartCoroutine(OnUpdateResource());
        }
Esempio n. 4
0
        /// <summary>
        /// 通过 assetbundle 读取单个gameobject
        /// </summary>
        /// <param name="filename"></param>
        /// <param name="sourcename"></param>
        /// <param name="cb"></param>
        /// <param name="forceloadAsyn"></param>


        //public void LoadAudio(string filename, string sourcename, UnityAction<Object> cb, bool forceloadAsyn = false)
        //{
        //    string path = PathMod.AssetPath(string.Format("Audio/{0}", filename));
        //    LoadAsset(path, sourcename, cb, forceloadAsyn);
        //}
        //public void LoadConfig(string filename, string sourcename, UnityAction<Object> cb, bool forceloadAsyn = false)
        //{
        //    string path = PathMod.AssetPath(string.Format("Config/{0}", filename));
        //    LoadAsset(path, sourcename, cb, forceloadAsyn);
        //}
        //public void LoadConfig(string filename,UnityAction<AssetBundle> cb)
        //{
        //    string path = PathMod.AssetPath(string.Format("Config/{0}", filename));
        //    LoadAsset(path,cb, false);
        //}

        public void LoadEffect(string filename, string sourcename)
        {
            string path = PathMod.AssetPath(string.Format("Effect/{0}", filename));

            LoadAsset(path, sourcename);
        }