From 98b151830609a9903c33089bf8d6d524186ffbc6 Mon Sep 17 00:00:00 2001 From: gaoxin Date: Wed, 16 Jun 2021 17:29:17 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E6=B7=BB=E5=8A=A0stream=E9=85=8D?= =?UTF-8?q?=E7=BD=AE=E3=80=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BGNC/loading_xipu_2.jpg.meta | 110 ------------------ .../BGNC/login_xipu_2.jpg.meta | 110 ------------------ .../~Lua/Framework/Manager/PackageManager.lua | 26 +++++ .../Framework/Manager/ServerConfigManager.lua | 2 +- Assets/ManagedResources/~Lua/Logic/Game.lua | 7 +- .../ManagedResources/~Lua/misc/functions.lua | 2 +- Assets/Scripts/Bridge/ResourcesManager.cs | 5 + .../ResourcesMgr/Manager/ResourcesManager.cs | 31 ++++- Assets/Scripts/GameInit/UpdatePanel.cs | 57 +++++---- .../GameLogic_ResourcesManagerWrap.cs | 19 +++ Assets/StreamingAssets/Res/PackConfig.txt | 7 ++ .../StreamingAssets/Res/PackConfig.txt.meta | 7 ++ .../Res/loading_xipu.png} | Bin .../StreamingAssets/Res/loading_xipu.png.meta | 7 ++ .../Res/login_xipu.png} | Bin .../StreamingAssets/Res/login_xipu.png.meta | 7 ++ 16 files changed, 149 insertions(+), 248 deletions(-) delete mode 100644 Assets/ManagedResources/BGNC/loading_xipu_2.jpg.meta delete mode 100644 Assets/ManagedResources/BGNC/login_xipu_2.jpg.meta create mode 100644 Assets/StreamingAssets/Res/PackConfig.txt create mode 100644 Assets/StreamingAssets/Res/PackConfig.txt.meta rename Assets/{ManagedResources/BGNC/loading_xipu_2.jpg => StreamingAssets/Res/loading_xipu.png} (100%) create mode 100644 Assets/StreamingAssets/Res/loading_xipu.png.meta rename Assets/{ManagedResources/BGNC/login_xipu_2.jpg => StreamingAssets/Res/login_xipu.png} (100%) create mode 100644 Assets/StreamingAssets/Res/login_xipu.png.meta diff --git a/Assets/ManagedResources/BGNC/loading_xipu_2.jpg.meta b/Assets/ManagedResources/BGNC/loading_xipu_2.jpg.meta deleted file mode 100644 index 7e16254c73..0000000000 --- a/Assets/ManagedResources/BGNC/loading_xipu_2.jpg.meta +++ /dev/null @@ -1,110 +0,0 @@ -fileFormatVersion: 2 -guid: 42305eec223abab478aefd6f970de194 -TextureImporter: - fileIDToRecycleName: {} - externalObjects: {} - serializedVersion: 9 - mipmaps: - mipMapMode: 0 - enableMipMap: 0 - sRGBTexture: 1 - linearTexture: 0 - fadeOut: 0 - borderMipMap: 0 - mipMapsPreserveCoverage: 0 - alphaTestReferenceValue: 0.5 - mipMapFadeDistanceStart: 1 - mipMapFadeDistanceEnd: 3 - bumpmap: - convertToNormalMap: 0 - externalNormalMap: 0 - heightScale: 0.25 - normalMapFilter: 0 - isReadable: 0 - streamingMipmaps: 0 - streamingMipmapsPriority: 0 - grayScaleToAlpha: 0 - generateCubemap: 6 - cubemapConvolution: 0 - seamlessCubemap: 0 - textureFormat: 1 - maxTextureSize: 2048 - textureSettings: - serializedVersion: 2 - filterMode: -1 - aniso: -1 - mipBias: -100 - wrapU: 1 - wrapV: 1 - wrapW: 1 - nPOTScale: 0 - lightmap: 0 - compressionQuality: 50 - spriteMode: 1 - spriteExtrude: 1 - spriteMeshType: 1 - alignment: 0 - spritePivot: {x: 0.5, y: 0.5} - spritePixelsToUnits: 100 - spriteBorder: {x: 0, y: 0, z: 0, w: 0} - spriteGenerateFallbackPhysicsShape: 1 - alphaUsage: 1 - alphaIsTransparency: 1 - spriteTessellationDetail: -1 - textureType: 8 - textureShape: 1 - singleChannelComponent: 0 - maxTextureSizeSet: 0 - compressionQualitySet: 0 - textureFormatSet: 0 - platformSettings: - - serializedVersion: 2 - buildTarget: DefaultTexturePlatform - maxTextureSize: 2048 - resizeAlgorithm: 0 - textureFormat: -1 - textureCompression: 1 - compressionQuality: 50 - crunchedCompression: 0 - allowsAlphaSplitting: 0 - overridden: 0 - androidETC2FallbackOverride: 0 - - serializedVersion: 2 - buildTarget: Standalone - maxTextureSize: 2048 - resizeAlgorithm: 0 - textureFormat: -1 - textureCompression: 1 - compressionQuality: 50 - crunchedCompression: 0 - allowsAlphaSplitting: 0 - overridden: 0 - androidETC2FallbackOverride: 0 - - serializedVersion: 2 - buildTarget: Android - maxTextureSize: 2048 - resizeAlgorithm: 0 - textureFormat: 65 - textureCompression: 1 - compressionQuality: 100 - crunchedCompression: 0 - allowsAlphaSplitting: 0 - overridden: 1 - androidETC2FallbackOverride: 0 - spriteSheet: - serializedVersion: 2 - sprites: [] - outline: [] - physicsShape: [] - bones: [] - spriteID: 4712a1414ca412d4482e2b542dd85783 - vertices: [] - indices: - edges: [] - weights: [] - spritePackingTag: - pSDRemoveMatte: 0 - pSDShowRemoveMatteOption: 0 - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/ManagedResources/BGNC/login_xipu_2.jpg.meta b/Assets/ManagedResources/BGNC/login_xipu_2.jpg.meta deleted file mode 100644 index 268c19565f..0000000000 --- a/Assets/ManagedResources/BGNC/login_xipu_2.jpg.meta +++ /dev/null @@ -1,110 +0,0 @@ -fileFormatVersion: 2 -guid: ee7fd5016d6302543a04615e45f802c6 -TextureImporter: - fileIDToRecycleName: {} - externalObjects: {} - serializedVersion: 9 - mipmaps: - mipMapMode: 0 - enableMipMap: 0 - sRGBTexture: 1 - linearTexture: 0 - fadeOut: 0 - borderMipMap: 0 - mipMapsPreserveCoverage: 0 - alphaTestReferenceValue: 0.5 - mipMapFadeDistanceStart: 1 - mipMapFadeDistanceEnd: 3 - bumpmap: - convertToNormalMap: 0 - externalNormalMap: 0 - heightScale: 0.25 - normalMapFilter: 0 - isReadable: 0 - streamingMipmaps: 0 - streamingMipmapsPriority: 0 - grayScaleToAlpha: 0 - generateCubemap: 6 - cubemapConvolution: 0 - seamlessCubemap: 0 - textureFormat: 1 - maxTextureSize: 2048 - textureSettings: - serializedVersion: 2 - filterMode: -1 - aniso: -1 - mipBias: -100 - wrapU: 1 - wrapV: 1 - wrapW: 1 - nPOTScale: 0 - lightmap: 0 - compressionQuality: 50 - spriteMode: 1 - spriteExtrude: 1 - spriteMeshType: 1 - alignment: 0 - spritePivot: {x: 0.5, y: 0.5} - spritePixelsToUnits: 100 - spriteBorder: {x: 0, y: 0, z: 0, w: 0} - spriteGenerateFallbackPhysicsShape: 1 - alphaUsage: 1 - alphaIsTransparency: 1 - spriteTessellationDetail: -1 - textureType: 8 - textureShape: 1 - singleChannelComponent: 0 - maxTextureSizeSet: 0 - compressionQualitySet: 0 - textureFormatSet: 0 - platformSettings: - - serializedVersion: 2 - buildTarget: DefaultTexturePlatform - maxTextureSize: 2048 - resizeAlgorithm: 0 - textureFormat: -1 - textureCompression: 1 - compressionQuality: 50 - crunchedCompression: 0 - allowsAlphaSplitting: 0 - overridden: 0 - androidETC2FallbackOverride: 0 - - serializedVersion: 2 - buildTarget: Standalone - maxTextureSize: 2048 - resizeAlgorithm: 0 - textureFormat: -1 - textureCompression: 1 - compressionQuality: 50 - crunchedCompression: 0 - allowsAlphaSplitting: 0 - overridden: 0 - androidETC2FallbackOverride: 0 - - serializedVersion: 2 - buildTarget: Android - maxTextureSize: 2048 - resizeAlgorithm: 0 - textureFormat: 65 - textureCompression: 1 - compressionQuality: 100 - crunchedCompression: 0 - allowsAlphaSplitting: 0 - overridden: 1 - androidETC2FallbackOverride: 0 - spriteSheet: - serializedVersion: 2 - sprites: [] - outline: [] - physicsShape: [] - bones: [] - spriteID: 263f5516c18d76546823718924314c55 - vertices: [] - indices: - edges: [] - weights: [] - spritePackingTag: - pSDRemoveMatte: 0 - pSDShowRemoveMatteOption: 0 - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/ManagedResources/~Lua/Framework/Manager/PackageManager.lua b/Assets/ManagedResources/~Lua/Framework/Manager/PackageManager.lua index f7afa8af8e..ece74b67d8 100644 --- a/Assets/ManagedResources/~Lua/Framework/Manager/PackageManager.lua +++ b/Assets/ManagedResources/~Lua/Framework/Manager/PackageManager.lua @@ -23,8 +23,24 @@ function PackageManager.Initialize() break end end + + -- 获取stream设置 + if ServerConfigManager.IsSettingActive(ServerConfigManager.SettingConfig.IS_LOAD_STREAMING) then + resMgr:LoadStreamingText("PackConfig", function(config) + local json = require 'cjson' + local data = json.decode(config) + this.StreamConfig = data + LogError("Load text done!!!") + end) + end end +-- 获取包名 +function PackageManager.GetPackageID() + if this.StreamConfig then + return this.StreamConfig.PackID + end +end -- 获取包名 function PackageManager.GetPackageName() return this.PackageName @@ -37,12 +53,18 @@ function PackageManager.GetRechargeField() end -- 获取登录背景图 function PackageManager.GetLoginPanelBg() + if this.StreamConfig then + return this.StreamConfig.LoginPanelBG + end if this.config then return this.config.LoginPanelBg end end -- 获取登录Logo function PackageManager.GetLoginPanelLogo() + if this.StreamConfig then + return this.StreamConfig.LoginPanelLogo + end if this.config then return this.config.LoginLogo end @@ -55,6 +77,10 @@ function PackageManager.GetCustomEventField() end -- 获取loading图list function PackageManager.GetLoadingList() + if this.StreamConfig then + local list = string.split(this.StreamConfig.LoadingPanelBG, "#") + return list + end if this.config then local list = string.split(this.config.LoadingImgList, "#") return list diff --git a/Assets/ManagedResources/~Lua/Framework/Manager/ServerConfigManager.lua b/Assets/ManagedResources/~Lua/Framework/Manager/ServerConfigManager.lua index bf4a765cf9..fe38ed7dcd 100644 --- a/Assets/ManagedResources/~Lua/Framework/Manager/ServerConfigManager.lua +++ b/Assets/ManagedResources/~Lua/Framework/Manager/ServerConfigManager.lua @@ -17,7 +17,7 @@ ServerConfigManager.SettingConfig = { IS_PLAY_LOGIN_VIDEO = "IS_PLAY_LOGIN_VIDEO", -- 判断是否可以播放登录视频 PACKAGE_CONFIG = "PACKAGE_CONFIG", -- 包配置 IS_NO_TALKING = "IS_NO_TALKING", -- 禁言 - IS_LOAD_STREAMING_TEXTURE = "IS_LOAD_STREAMING_TEXTURE", -- 是否加载外部资源 + IS_LOAD_STREAMING = "IS_LOAD_STREAMING", -- 是否加载外部资源 } diff --git a/Assets/ManagedResources/~Lua/Logic/Game.lua b/Assets/ManagedResources/~Lua/Logic/Game.lua index 57f43ebdb7..15efdc4c21 100644 --- a/Assets/ManagedResources/~Lua/Logic/Game.lua +++ b/Assets/ManagedResources/~Lua/Logic/Game.lua @@ -14,8 +14,11 @@ function Game.Initialize() Screen.sleepTimeout = U3d.SleepTimeout.NeverSleep this.GlobalEvent = EventManager.New() this.InitManagers() - UIManager.OpenPanel(UIName.LoginPanel) - UIManager.OpenPanel(UIName.HorseRaceLampView) + -- 延迟 + Timer.New(function() + UIManager.OpenPanel(UIName.LoginPanel) + UIManager.OpenPanel(UIName.HorseRaceLampView) + end, 0.5):Start() end --初始化管理器 diff --git a/Assets/ManagedResources/~Lua/misc/functions.lua b/Assets/ManagedResources/~Lua/misc/functions.lua index 136082dc97..4e411fcb28 100644 --- a/Assets/ManagedResources/~Lua/misc/functions.lua +++ b/Assets/ManagedResources/~Lua/misc/functions.lua @@ -79,7 +79,7 @@ end function LoadStreamingTexture(spLoader, name, func) if name and name ~= "" and func then - if ServerConfigManager.IsSettingActive(ServerConfigManager.SettingConfig.IS_LOAD_STREAMING_TEXTURE) then + if ServerConfigManager.IsSettingActive(ServerConfigManager.SettingConfig.IS_LOAD_STREAMING) then resMgr:LoadStreamingTexture(name, function(sp) if sp then func(sp) diff --git a/Assets/Scripts/Bridge/ResourcesManager.cs b/Assets/Scripts/Bridge/ResourcesManager.cs index 7fbe68b8e5..8b9861d3be 100644 --- a/Assets/Scripts/Bridge/ResourcesManager.cs +++ b/Assets/Scripts/Bridge/ResourcesManager.cs @@ -191,6 +191,11 @@ namespace GameLogic { { resMgr.LoadStreamingTexture(name, luaFunction); } + + public void LoadStreamingText(string name, LuaFunction luaFunction) + { + resMgr.LoadStreamingText(name, luaFunction); + } } } diff --git a/Assets/Scripts/Core/ResMgr/ResourcesMgr/Manager/ResourcesManager.cs b/Assets/Scripts/Core/ResMgr/ResourcesMgr/Manager/ResourcesManager.cs index 36efb496be..bfc90fea50 100644 --- a/Assets/Scripts/Core/ResMgr/ResourcesMgr/Manager/ResourcesManager.cs +++ b/Assets/Scripts/Core/ResMgr/ResourcesMgr/Manager/ResourcesManager.cs @@ -127,10 +127,11 @@ namespace ResMgr { public void LoadStreamingTexture(string name, LuaFunction luaFunction) { - StartCoroutine(LoadFromStream(name, luaFunction)); + StartCoroutine(LoadTextureFromStream(name, luaFunction)); } - public IEnumerator LoadFromStream(string name, LuaFunction luaFunction) + public IEnumerator LoadTextureFromStream(string name, LuaFunction luaFunction) { + Debug.Log(Application.streamingAssetsPath + "/Res/" + name + ".png"); UnityWebRequest www = UnityWebRequestTexture.GetTexture(Application.streamingAssetsPath + "/Res/"+ name + ".png"); yield return www.SendWebRequest(); if (www.isNetworkError || www.isHttpError) @@ -151,6 +152,32 @@ namespace ResMgr { } } + public void LoadStreamingText(string name, LuaFunction luaFunction) + { + StartCoroutine(LoadTextFromStream(name, luaFunction)); + } + public IEnumerator LoadTextFromStream(string name, LuaFunction luaFunction) + { + Debug.Log(Application.streamingAssetsPath + "/Res/" + name + ".txt"); + UnityWebRequest www = UnityWebRequest.Get(Application.streamingAssetsPath + "/Res/" + name + ".txt"); + yield return www.SendWebRequest(); + if (www.isNetworkError || www.isHttpError) + { + Debug.Log(www.error); + if (luaFunction != null) + { + luaFunction.Call(false); + } + } + else + { + string tex = www.downloadHandler.text; + if (luaFunction != null) + { + luaFunction.Call(tex); + } + } + } } } diff --git a/Assets/Scripts/GameInit/UpdatePanel.cs b/Assets/Scripts/GameInit/UpdatePanel.cs index 0e58471774..de922be8dd 100644 --- a/Assets/Scripts/GameInit/UpdatePanel.cs +++ b/Assets/Scripts/GameInit/UpdatePanel.cs @@ -37,13 +37,14 @@ namespace GameLogic BeginUpdatePlatform(); } - public IEnumerator LoadFromStream(string name, Action act) + public IEnumerator LoadFromStream(Action act) { - UnityWebRequest www = UnityWebRequestTexture.GetTexture(Application.streamingAssetsPath + "/Res/" + name + ".png"); - yield return www.SendWebRequest(); - if (www.isNetworkError || www.isHttpError) + Debug.Log(Application.streamingAssetsPath + "/Res/PackConfig.txt"); + UnityWebRequest uwr = UnityWebRequest.Get(Application.streamingAssetsPath + "/Res/PackConfig.txt"); + yield return uwr.SendWebRequest(); + if (uwr.isNetworkError || uwr.isHttpError) { - Debug.Log(www.error); + Debug.Log(uwr.error); if (act != null) { act(null); @@ -51,12 +52,28 @@ namespace GameLogic } else { - Debug.Log("load success"); - Texture2D tex = ((DownloadHandlerTexture)www.downloadHandler).texture; - Sprite sp = Sprite.Create(tex, new Rect(0, 0, tex.width, tex.height), new Vector2(0, 0)); - if (act != null) + Hashtable table = MiniJSON.jsonDecode(uwr.downloadHandler.text) as Hashtable; + string bgName = table["UpdatePanelBG"] as string; + + UnityWebRequest www = UnityWebRequestTexture.GetTexture(Application.streamingAssetsPath + "/Res/" + bgName + ".png"); + yield return www.SendWebRequest(); + if (www.isNetworkError || www.isHttpError) { - act(sp); + Debug.Log(www.error); + if (act != null) + { + act(null); + } + } + else + { + Debug.Log("load success"); + Texture2D tex = ((DownloadHandlerTexture)www.downloadHandler).texture; + Sprite sp = Sprite.Create(tex, new Rect(0, 0, tex.width, tex.height), new Vector2(0, 0)); + if (act != null) + { + act(sp); + } } } } @@ -64,20 +81,16 @@ namespace GameLogic private void OnEnable() { - string updatePanelBg = ConfigManager.Instance.GetConfigInfo("Setting.UPDATE_PANEL_BG.value"); - if(updatePanelBg != null && updatePanelBg != "") + Image img = this.transform.Find("Canvas/LoadingScreen/bg1").GetComponent(); + img.color = new Color(1f, 1f, 1f, 0f); + StartCoroutine(LoadFromStream((Sprite sp) => { - Image img = this.transform.Find("Canvas/LoadingScreen/bg1").GetComponent(); - img.color = new Color(1f, 1f, 1f, 0f); - StartCoroutine(LoadFromStream(updatePanelBg, (Sprite sp) => + if (sp != null) { - if (sp != null) - { - img.sprite = sp; - } - img.color = new Color(1f, 1f, 1f, 1f); - })); - } + img.sprite = sp; + } + img.color = new Color(1f, 1f, 1f, 1f); + })); } private void OnDestroy() { diff --git a/Assets/Source/Generate/GameLogic_ResourcesManagerWrap.cs b/Assets/Source/Generate/GameLogic_ResourcesManagerWrap.cs index 04283b09ad..da32e68c53 100644 --- a/Assets/Source/Generate/GameLogic_ResourcesManagerWrap.cs +++ b/Assets/Source/Generate/GameLogic_ResourcesManagerWrap.cs @@ -19,6 +19,7 @@ public class GameLogic_ResourcesManagerWrap L.RegFunction("UnLoadAll", UnLoadAll); L.RegFunction("Reset", Reset); L.RegFunction("LoadStreamingTexture", LoadStreamingTexture); + L.RegFunction("LoadStreamingText", LoadStreamingText); L.RegFunction("New", _CreateGameLogic_ResourcesManager); L.RegFunction("__tostring", ToLua.op_ToString); L.RegVar("isLoading", get_isLoading, set_isLoading); @@ -271,6 +272,24 @@ public class GameLogic_ResourcesManagerWrap } } + [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))] + static int LoadStreamingText(IntPtr L) + { + try + { + ToLua.CheckArgsCount(L, 3); + GameLogic.ResourcesManager obj = (GameLogic.ResourcesManager)ToLua.CheckObject(L, 1); + string arg0 = ToLua.CheckString(L, 2); + LuaFunction arg1 = ToLua.CheckLuaFunction(L, 3); + obj.LoadStreamingText(arg0, arg1); + return 0; + } + catch (Exception e) + { + return LuaDLL.toluaL_exception(L, e); + } + } + [MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))] static int get_isLoading(IntPtr L) { diff --git a/Assets/StreamingAssets/Res/PackConfig.txt b/Assets/StreamingAssets/Res/PackConfig.txt new file mode 100644 index 0000000000..4b8fe42074 --- /dev/null +++ b/Assets/StreamingAssets/Res/PackConfig.txt @@ -0,0 +1,7 @@ +{ + "PackID":"XIPU_2", + "UpdatePanelBG":"loading_xipu", + "LoginPanelBG":"login_xipu", + "LoginPanelLogo":"", + "LoadingPanelBG":"loading_xipu" +} \ No newline at end of file diff --git a/Assets/StreamingAssets/Res/PackConfig.txt.meta b/Assets/StreamingAssets/Res/PackConfig.txt.meta new file mode 100644 index 0000000000..2c0bf72170 --- /dev/null +++ b/Assets/StreamingAssets/Res/PackConfig.txt.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: e0329a008458aa34fb72f1b0b6235956 +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/ManagedResources/BGNC/loading_xipu_2.jpg b/Assets/StreamingAssets/Res/loading_xipu.png similarity index 100% rename from Assets/ManagedResources/BGNC/loading_xipu_2.jpg rename to Assets/StreamingAssets/Res/loading_xipu.png diff --git a/Assets/StreamingAssets/Res/loading_xipu.png.meta b/Assets/StreamingAssets/Res/loading_xipu.png.meta new file mode 100644 index 0000000000..2e0648db66 --- /dev/null +++ b/Assets/StreamingAssets/Res/loading_xipu.png.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 1240de5e6b99f7c449f4863c5e61b133 +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/ManagedResources/BGNC/login_xipu_2.jpg b/Assets/StreamingAssets/Res/login_xipu.png similarity index 100% rename from Assets/ManagedResources/BGNC/login_xipu_2.jpg rename to Assets/StreamingAssets/Res/login_xipu.png diff --git a/Assets/StreamingAssets/Res/login_xipu.png.meta b/Assets/StreamingAssets/Res/login_xipu.png.meta new file mode 100644 index 0000000000..08ea312ff6 --- /dev/null +++ b/Assets/StreamingAssets/Res/login_xipu.png.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 7934cb466aa1a26478fd4e4cc0481567 +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: