コード例 #1
0
 private void Update()
 {
     if (_run == -1)
     {//游戏结束
         Debug.LogWarning("==========游戏结束清理资源开始=============");
         _run = 0;
         StopAllCoroutines();       //结束所有携程
         AssetbundleLoader.Clear(); //释放资源
         EndNetWork();
         method        = null;
         method_update = null;
         method_out    = null;
         appdomain     = null;
         Debug.LogWarning("==========游戏结束清理资源结束=============");
     }
     else if (_run == 100)
     {
         Debug.LogWarning("==========开始加载游戏=============");
         load_game(gamename);
     }
     else if (_run > 0)
     {
         if (network != null)
         {
             network.Update();
         }
         appdomain.Invoke(method_update, null, null);
     }
 }
コード例 #2
0
    private void load_game(string game)
    {
        Screen.orientation = ScreenOrientation.Portrait;
        if (_run == -1)
        {                              //游戏结束
            Debug.LogWarning("==========游戏开始但是上一次没有清理资源=============");
            AssetbundleLoader.Clear(); //释放资源
            EndNetWork();
            method        = null;
            method_update = null;
            method_out    = null;
            appdomain     = null;
        }
        _run = 0;

#if UNITY_EDITOR || UNITY_ANDROID
        data_path = Application.persistentDataPath;
#elif UNITY_IOS
        data_path = Application.temporaryCachePath;
#endif

        epoch = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);

        Debug.Log("开始加载游戏:" + data_path);
        //===ab初始化====
        AssetbundleLoader.Init(data_path, game);
        //===加载热更新代码===
        LoadHotFixAssembly(game);
        Debug.Log("启动完成");
    }