From b0026ed4e12ffb5672feaf511f74e7aae3ec023c Mon Sep 17 00:00:00 2001
From: client_Wu Xijin <364452445@qq.com>
Date: 星期五, 26 十月 2018 09:37:02 +0800
Subject: [PATCH] 4334 【前端】随包资源支持热更
---
Core/GameEngine/Login/Launch.cs | 45 +++++++++++-----------
Core/ResModule/AssetBundle/AssetBundleUtility.cs | 28 ++++++++++++++
2 files changed, 51 insertions(+), 22 deletions(-)
diff --git a/Core/GameEngine/Login/Launch.cs b/Core/GameEngine/Login/Launch.cs
index 7423ee0..b464d2e 100644
--- a/Core/GameEngine/Login/Launch.cs
+++ b/Core/GameEngine/Login/Launch.cs
@@ -34,6 +34,27 @@
private void Awake()
{
+ ResourcesPath.Instance.Init();
+ SnxxzGame.Instance.gameObject.name = "__SnxxzGame__";
+
+ Application.backgroundLoadingPriority = ThreadPriority.BelowNormal;
+ Screen.sleepTimeout = SleepTimeout.NeverSleep;
+
+ ShaderUtility.InitGlobalParams();
+ SoundPlayer.CreateSoundPlayer();
+
+ SystemSetting.Instance.SetSoundVolume(SystemSetting.Instance.GetSoundVolume());
+ SystemSetting.Instance.SetSoundEffect(SystemSetting.Instance.GetSoundEffect());
+ SystemSetting.Instance.SetGameFps(SystemSetting.Instance.GetGameFps());
+
+ SDKUtility.Instance.Init();
+ GameObjectPoolManager.Instance.gameObject.name = "GameObjectPool";
+ GameObjectPoolManager.Instance.Initialize();
+ ExceptionCatcher.Init();
+ ExceptionCatcher.Catch();
+ DebugUtility.Instance.Init();
+ GlobalTimeEvent.Instance.Begin();
+
#if UNITY_ANDROID && !UNITY_EDITOR
var files = new List<FileInfo>();
FileExtersion.GetAllDirectoryFileInfos(StringUtility.Contact(ResourcesPath.Instance.StreamingAssetPath, "builtin"), files);
@@ -80,32 +101,12 @@
}
#endif
- ResourcesPath.Instance.Init();
- SnxxzGame.Instance.gameObject.name = "__SnxxzGame__";
-
- Application.backgroundLoadingPriority = ThreadPriority.BelowNormal;
- Screen.sleepTimeout = SleepTimeout.NeverSleep;
-
- ShaderUtility.InitGlobalParams();
-
- SoundPlayer.CreateSoundPlayer();
- SoundPlayer.Instance.PlayLoginMusic();
- SystemSetting.Instance.SetSoundVolume(SystemSetting.Instance.GetSoundVolume());
- SystemSetting.Instance.SetSoundEffect(SystemSetting.Instance.GetSoundEffect());
- SystemSetting.Instance.SetGameFps(SystemSetting.Instance.GetGameFps());
-
- SDKUtility.Instance.Init();
- GameObjectPoolManager.Instance.gameObject.name = "GameObjectPool";
- GameObjectPoolManager.Instance.Initialize();
- ExceptionCatcher.Init();
- ExceptionCatcher.Catch();
- DebugUtility.Instance.Init();
- GlobalTimeEvent.Instance.Begin();
-
+ AssetBundleUtility.Instance.InitBuiltInAsset();
}
void Start()
{
+ SoundPlayer.Instance.PlayLoginMusic();
Config.Instance.PreLoadConfigs();
ServerListCenter.Instance.RequestJumpUrl();
diff --git a/Core/ResModule/AssetBundle/AssetBundleUtility.cs b/Core/ResModule/AssetBundle/AssetBundleUtility.cs
index 9407f90..92f0e3c 100644
--- a/Core/ResModule/AssetBundle/AssetBundleUtility.cs
+++ b/Core/ResModule/AssetBundle/AssetBundleUtility.cs
@@ -14,6 +14,34 @@
public bool initialized { get; private set; }
public bool initializedUIAssetBundle { get; private set; }
+ public void InitBuiltInAsset()
+ {
+ var path = AssetVersionUtility.GetAssetFilePath("builtin_assetbundle");
+ var assetBundle = AssetBundle.LoadFromFile(path);
+ if (assetBundle == null)
+ {
+ DebugEx.LogError("AssetBundleManifest鐨勫寘鏂囦欢涓虹┖鎴栬�呭姞杞藉嚭閿�.");
+ }
+
+ var manifest = assetBundle.LoadAsset<AssetBundleManifest>(ResourcesPath.AssetDependentFileAssetName);
+ if (manifest == null)
+ {
+ DebugEx.LogError("AssetBundleManifest鏂囦欢涓虹┖鎴栬�呭姞杞藉嚭閿�.");
+ }
+
+ var bundles = manifest.GetAllAssetBundles();
+ foreach (var bundle in bundles)
+ {
+ var dependenices = manifest.GetAllDependencies(bundle);
+ var hash = manifest.GetAssetBundleHash(bundle);
+ var assetBundleInfo = new AssetBundleInfo(bundle, hash, dependenices);
+ m_AssetBundleInfoList.Add(assetBundleInfo);
+ }
+
+ assetBundle.Unload(true);
+ assetBundle = null;
+ }
+
public IEnumerator Initialize()
{
yield return StartCoroutine(Co_LoadMainfestFile("audio"));
--
Gitblit v1.8.0