/// <summary> /// 相应更新远程资源事件的处理函数 /// </summary> public virtual void UpdateRemoteAssetHandler() { HotFixSubgroup hotFixSubgroup = GameComponent.HotFixSubgroup; if (hotFixSubgroup.applyILRuntime && !string.IsNullOrEmpty(hotFixSubgroup.initerNameInResource)) { #if ILRUNTIME StartILRuntime(); #endif GameObject mainBridge = Resources.Load <GameObject>(hotFixSubgroup.initerNameInResource); mainBridge = Instantiate(mainBridge); HotFixerComponent hotfixer = mainBridge.GetComponent <HotFixerComponent>(); ILRuntimeUtils.InvokeMethodILR(hotfixer.ShellBridge, hotFixSubgroup.initerClassName, hotFixSubgroup.initerGameCompSetter, 1, GameComponent); } else { mClientVersions = GameComponent.DevelopSetting.remoteAssetVersions; if (mClientVersions != default) { UIManager uis = ShipDockApp.Instance.UIs; mStartingUpdatePopup = (IStartingUpdatePopup)uis.OpenResourceUI <MonoBehaviour>(GameComponent.DevelopSetting.resUpdatePopupPath); mClientVersions.LoadRemoteVersion(OnLoadComplete, OnVersionInvalid, out _);//加载远端服务器的资源版本 } else { AfterStartingLoadComplete(); } } }
/// <summary> /// 创建资源版本 /// </summary> /// <param name="remoteVers"></param> private void BuildVersionConfig(ref ResDataVersion remoteVers) { string versions = default; ResDataVersion resDataVersion = default; GetVersionDataFromRemote(ref remoteVers, ref versions, ref resDataVersion); string[] abNamesValue = ABNamesWillBuild != default ? ABNamesWillBuild.ToArray() : new string[0]; resDataVersion.CreateNewResVersion(ref resRemoteGateWay, isUpdateVersion, isUpdateResVersion, isSyncAppVersion, ref remoteVers, ref abNamesValue); resDataVersion.Refresh(); bool applyClientGateway = false; if (isSyncClientVersions) { List <ScriptableObject> list = default; ShipDockEditorUtils.FindAssetInEditorProject(ref list, "t:ScriptableObject", @"Assets\Prefabs"); ClientResVersion clientRes = default;// = (ClientResVersion)list[0]; foreach (ScriptableObject i in list) { if (i.name == ClientVersionFileName) { clientRes = (ClientResVersion)i; break; } else { } } applyClientGateway = clientRes.ApplyCurrentResGateway; if (applyClientGateway) { resDataVersion.res_gateway = clientRes.ClientResVersionGateway(); } clientRes.Versions.CloneVersionsFrom(ref resDataVersion); clientRes.SetChanges(resDataVersion.ResChanges); UnityEditor.EditorUtility.SetDirty(clientRes); } versions = JsonUtility.ToJson(resDataVersion); string stamp = "_".Append(System.DateTime.Now.ToShortDateString().Replace("/", "_")); FileOperater.WriteUTF8Text(versions, Application.dataPath.Append("/Prefabs/ClientResVersions_Previews/", ResDataVersion.FILE_RES_DATA_VERSIONS_NAME, stamp, ".json")); //仅用于查看 FileOperater.WriteBytes(versions, AppPaths.ABBuildOutputRoot.Append(ResDataVersion.FILE_RES_DATA_VERSIONS_NAME)); //位于资源主目录里的正式文件 resDataVersion.Clean(); remoteVers?.Clean(); }
protected virtual void OnDestroy() { GameComponent = default; mClientVersions = default; mStartingUpdatePopup = default; }