Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Jul 11, 2023. It is now read-only.

Commit c396590

Browse files
author
wanderer
committed
默认不开启图集请求
1 parent 64cb2c4 commit c396590

File tree

2 files changed

+67
-26
lines changed

2 files changed

+67
-26
lines changed

‎GameFramework/Runtime/Resource/ResourceManager.cs‎

Lines changed: 66 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -103,18 +103,19 @@ public string LocalPath
103103
#region 构造函数
104104
public ResourceManager()
105105
{
106-
//自动监听图集请求,并异步加载图集资源
107-
SpriteAtlasManager.atlasRequested += (tag, callback) => {
108-
string assetPath = Asset.AllAssetPaths.Find(x =>x.EndsWith($"{tag.ToLower()}.spriteatlas"));
109-
if (!string.IsNullOrEmpty(assetPath))
110-
{
111-
Asset.LoadAsset<SpriteAtlas>(assetPath, callback);
112-
}
113-
else
114-
{
115-
throw new GameException($"The path to the SpriteAtlas file could not be found. {tag}");
116-
}
117-
};
106+
////自动监听图集请求,并异步加载图集资源
107+
//SpriteAtlasManager.atlasRequested += (tag, callback) =>
108+
//{
109+
// string assetPath = Resource.Asset.AllAssetPaths.Find(x => x.EndsWith($"{tag.ToLower()}.spriteatlas"));
110+
// if (!string.IsNullOrEmpty(assetPath))
111+
// {
112+
// Resource.Asset.LoadAsset<SpriteAtlas>(assetPath, callback);
113+
// }
114+
// else
115+
// {
116+
// throw new GameException($"The path to the SpriteAtlas file could not be found. {tag}");
117+
// }
118+
//};
118119

119120
//获取事件管理器
120121
_event = GameFrameworkMode.GetModule<EventManager>();
@@ -126,12 +127,6 @@ public ResourceManager()
126127
_sceneLoadingEventArgs = new SceneLoadingEventArgs();
127128
_sceneLoadedEventArgs = new SceneLoadedEventArgs();
128129
_sceneAsyncOperations = new Dictionary<string, AsyncOperation>();
129-
130-
//BundleResourceHelper
131-
GameObject bundleBehaviourHelper = new GameObject("AssetBundleBehaviourHelper");
132-
Asset = bundleBehaviourHelper.AddComponent<BundleAssetsHelper>();
133-
bundleBehaviourHelper.hideFlags = HideFlags.HideAndDontSave;
134-
GameObject.DontDestroyOnLoad(bundleBehaviourHelper);
135130
}
136131
#endregion
137132

@@ -157,7 +152,34 @@ public override void OnInit()
157152
_remoteUpdatePath = Path.Combine(_remoteUpdatePath, Utility.GetRuntimePlatformName());
158153
//资源版本
159154
Version = new ResourceVersion(_remoteUpdatePath,LocalPath);
160-
}
155+
156+
//选择更新 | 读取本地 | 编辑器
157+
switch (ResUpdateType)
158+
{
159+
case ResourceUpdateType.None:
160+
break;
161+
case ResourceUpdateType.Update:
162+
//BundleResourceHelper
163+
GameObject bundleBehaviourHelper = new GameObject("AssetBundleBehaviourHelper");
164+
Asset = bundleBehaviourHelper.AddComponent<BundleAssetsHelper>();
165+
bundleBehaviourHelper.hideFlags = HideFlags.HideAndDontSave;
166+
GameObject.DontDestroyOnLoad(bundleBehaviourHelper);
167+
break;
168+
case ResourceUpdateType.Local:
169+
break;
170+
case ResourceUpdateType.Editor:
171+
#if UNITY_EDITOR
172+
Asset = new EditorAssetsHelper();
173+
#else
174+
//如果在非编辑器模式下选择了Editor,使用本地文件
175+
throw new GameException("Please select the correct resource type, not ResourceUpdateType.Editor!");
176+
#endif
177+
break;
178+
}
179+
180+
181+
182+
}
161183

162184

163185
#region 外部接口
@@ -169,15 +191,34 @@ public void SetResourceHelper(IAssetsHelper resourceHelper)
169191
{
170192
Asset?.Clear();
171193
Asset = resourceHelper;
172-
173194
}
174195

196+
/// <summary>
197+
/// 图集请求
198+
/// </summary>
199+
/// <param name="tag"></param>
200+
/// <param name="callback"></param>
201+
public void OnAtlasRequested(string operation, Action<string,Action<SpriteAtlas>> callback)
202+
{
203+
if (string.IsNullOrEmpty(operation))
204+
{
205+
return;
206+
}
207+
if (operation.Equals("+"))
208+
{
209+
SpriteAtlasManager.atlasRequested += callback;
210+
}
211+
else if(operation.Equals("-"))
212+
{
213+
SpriteAtlasManager.atlasRequested -= callback;
214+
}
215+
}
175216

176-
/// <summary>
177-
/// 设置对象池管理器的
178-
/// </summary>
179-
/// <param name="helper"></param>
180-
public void SetGameObjectPoolHelper(IGameObjectPoolHelper helper)
217+
/// <summary>
218+
/// 设置对象池管理器的
219+
/// </summary>
220+
/// <param name="helper"></param>
221+
public void SetGameObjectPoolHelper(IGameObjectPoolHelper helper)
181222
{
182223
_gameObjectPoolHelper = helper;
183224
}

‎GameFramework/Runtime/Resource/ResourceVersion.cs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ public Task<AssetBundleVersionInfo> RequestLocalVersion()
115115
public void RequestRemoteVersion(Action<AssetBundleVersionInfo> callback)
116116
{
117117
RemoteVersion = null;
118-
string versionAssetPath = Path.Combine(_remoteUpdatePath, _assetVersionTxt);
118+
string versionAssetPath = string.Format("{0}/{1}",_remoteUpdatePath,_assetVersionTxt);// Path.Combine(_remoteUpdatePath, _assetVersionTxt);
119119
_webRequest.RequestText(versionAssetPath, null,(result, content) =>
120120
{
121121
if (result && !string.IsNullOrEmpty(content))

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /