Browse Source

1. 修复热更新 showMessage 显示进度偶尔出现报错bug 2. 新增DataRelay文件

gongyan 3 years ago
parent
commit
dc90fbdfc3

+ 50 - 0
LuaDemo/Assets/BundleResource/LuaScripts/Base/DataRelay.lua.txt

@@ -0,0 +1,50 @@
+local DataRelay = {}
+
+DataRelay._cacheTable = {}
+
+DataRelay.KEY_TYPE = {
+    -- CACHE
+    ["SOME_CACHE_KEY"]                  = "SOME_CACHE_KEY",
+
+    -- SAVE
+    ["SOME_SAVE_KEY"]                   = "SOME_SAVE_KEY",
+}
+
+function DataRelay:SetCache(key, value)
+    self._cacheTable[key] = value
+end
+
+function DataRelay:GetCache(key, defaultValue)
+    local result = self._cacheTable[key]
+    if nil == result then return defaultValue end
+    return result
+end
+
+function DataRelay:SaveString(key, value)
+    CS.UnityEngine.PlayerPrefs.SetString(key, value)
+end
+
+function DataRelay:LoadString(key, defaultValue)
+    local result = CS.UnityEngine.PlayerPrefs.GetString(key, defaultValue)
+    return result
+end
+
+function DataRelay:SetInt(key, value)
+    CS.UnityEngine.PlayerPrefs.SetInt(key, value)
+end
+
+function DataRelay:GetInt(key, defaultValue)
+    local result = CS.UnityEngine.PlayerPrefs.GetInt(key, defaultValue)
+    return result
+end
+
+function DataRelay:SetFloat(key, value)
+    CS.UnityEngine.PlayerPrefs.SetFloat(key, value)
+end
+
+function DataRelay:GetFloat(key, defaultValue)
+    local result = CS.UnityEngine.PlayerPrefs.GetFloat(key, defaultValue)
+    return result
+end
+
+return DataRelay

+ 1 - 1
LuaDemo/Assets/BundleResource/LuaScripts/Update/SUpdateManager.lua.txt

@@ -294,7 +294,7 @@ function SUpdateManager.tryDownloadResourceLogic()
         downloadedBytes = downloadedBytes + luaRequest.downloadedBytes
         downloadSpeed = CS.SFramework.SToolFunctionR.GetDownloadSpeed(downloadedBytes, CS.UnityEngine.Time.realtimeSinceStartup - downloadStartTime)
         -- update download speed
-        local stateMessage = string.format("Downloading: %s \nPercent: %d Speed:%s Success", fileName, downloadPercent * 100, downloadSpeed)
+        local stateMessage = string.format("Downloading: %s \nPercent: %.2f Speed:%s Success", fileName, downloadPercent * 100, downloadSpeed)
         eventDispatchCenter:DispatchEvent(eventDispatchCenter.EventType.UPDATE_STATE_INFO, stateMessage)
         require("Base/CoroutineHelper.lua"):Wait(1)