[!tip] 提示
游戏更新模式直接决定了游戏是否可以运行
GameFramework 有四种更新模式
Editor Resource Mode
:编辑器模式Package
: 单机模式Updatable
:运行前更新Updatable While Playing
运行时更新
1. 编辑器模式
不进行更新,直接在编辑器里读取本地工程内资源
开启方法:
勾选:Unity
->Game Framework
->Builtin
->检查器
->Editor Resource Mode
2. 单机模式
读取
Assets/StreamingAssets
文件里资源进行更新- 新建
Assets/StreamingAssets
文件夹 新建
Assets/GameMain/Configs/ResourceCollection.xml
文件<?xml version="1.0" encoding="UTF-8"?> <UnityGameFramework> <ResourceEditor> <Settings> <SourceAssetRootPath>Assets/GameMain</SourceAssetRootPath> <SourceAssetSearchPaths> <SourceAssetSearchPath RelativePath="" /> </SourceAssetSearchPaths> <SourceAssetUnionTypeFilter>t:Scene t:Prefab t:Shader t:Model t:Material t:Texture t:AudioClip t:AnimationClip t:AnimatorController t:Font t:TextAsset t:ScriptableObject</SourceAssetUnionTypeFilter> <SourceAssetUnionLabelFilter>l:ResourceInclusive</SourceAssetUnionLabelFilter> <SourceAssetExceptTypeFilter>t:Script</SourceAssetExceptTypeFilter> <SourceAssetExceptLabelFilter>l:ResourceExclusive</SourceAssetExceptLabelFilter> <AssetSorter>Path</AssetSorter> </Settings> </ResourceEditor> </UnityGameFramework>
新建
Assets/GameMain/Scripts/GameFrameworkConfigs.cs
文件using GameFramework; using System.IO; using UnityEngine; using UnityGameFramework.Editor; using UnityGameFramework.Editor.ResourceTools; namespace StarForce.Editor { public static class GameFrameworkConfigs { [BuildSettingsConfigPath] public static string BuildSettingsConfig = Utility.Path.GetRegularPath(Path.Combine(Application.dataPath, "GameMain/Configs/BuildSettings.xml")); [ResourceCollectionConfigPath] public static string ResourceCollectionConfig = Utility.Path.GetRegularPath(Path.Combine(Application.dataPath, "GameMain/Configs/ResourceCollection.xml")); [ResourceEditorConfigPath] public static string ResourceEditorConfig = Utility.Path.GetRegularPath(Path.Combine(Application.dataPath, "GameMain/Configs/ResourceEditor.xml")); [ResourceBuilderConfigPath] public static string ResourceBuilderConfig = Utility.Path.GetRegularPath(Path.Combine(Application.dataPath, "GameMain/Configs/ResourceBuilder.xml")); }}
- 打开资源编辑器:
unity -> Game Framework -> Resource Tool -> Resource Editor -> 右边资源全部移动到左边 -> save
- 打开资源生成器:
unity -> Game Framework -> Resource Tool -> Resource Builder
Platforms
: 勾选对应平台
Internal Resource Version
: 填写新版本号
Output Directory
: 选择输出目录 (选项目外的)
Save
: 更新ResourceCollection.xml
文件
Start Build Resources
: 生成 复制:
输出目录/Package单机模式或Packed可更新模式/x_x_x/指定平台/
所有文件到StreamingAssets
文件夹[!NOTE]
每个平台上都需要单独导入一次- Unity 中关闭编辑器模式测试效果
3. 运行前更新
联机更新,更新后才可进入游戏
4. 运行时更新
联机更新,游戏中进行更新
常见问题
调试别人项目:直接复制 Assets
文件夹?
更改默认目录: Assets/GameMain/Scripts/Utility/AssetUtility.cs
真好呢
?幽默类评语?
作者以非凡的视角解读平凡,让文字焕发出别样的光彩。
建议补充国内外研究对比,以拓展视野。