Skip to content

Commit

Permalink
1.0.16 优化资产管理变量,优化UI界面传入参数
Browse files Browse the repository at this point in the history
  • Loading branch information
TippingGame committed May 25, 2024
1 parent 922f478 commit 028f969
Show file tree
Hide file tree
Showing 10 changed files with 84 additions and 22 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## [1.0.16] - 2024-05-26
1.优化资产管理代码
2.优化UI界面传入参数

## [1.0.15] - 2024-05-24
1.增加英文文档
2.中文文档图片使用国内地址
Expand Down
55 changes: 47 additions & 8 deletions Runtime/AssetManager/AssetBundleManager/AssetBundleHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,49 @@ namespace F8Framework.Core
/// </summary>
public static class AssetBundleHelper
{
private static string _streamingAssetsPath => Application.streamingAssetsPath + "/" + URLSetting.AssetBundlesName + "/" + URLSetting.GetPlatformName() + "/";
private static string _remoteAddress => GameConfig.LocalGameVersion.AssetRemoteAddress + "/" + URLSetting.AssetBundlesName + "/" + URLSetting.GetPlatformName() + "/";
private static string _hotUpdatePath => Application.persistentDataPath + HotUpdateManager.HotUpdateDirName + "/" + URLSetting.AssetBundlesName + "/" + URLSetting.GetPlatformName() + "/";
private static string _packagePath => Application.persistentDataPath + HotUpdateManager.PackageDirName + "/" + URLSetting.AssetBundlesName + "/" + URLSetting.GetPlatformName() + "/";
private static string _streamingAssetsPath;

private static string GetStreamingAssetsPath()
{
if (_streamingAssetsPath == null)
{
_streamingAssetsPath = Application.streamingAssetsPath + "/" + URLSetting.AssetBundlesName + "/" + URLSetting.GetPlatformName() + "/";
}
return _streamingAssetsPath;
}

private static string _remoteAddress;

private static string GetRemoteAddress()
{
if (_remoteAddress == null)
{
_remoteAddress = GameConfig.LocalGameVersion.AssetRemoteAddress + "/" + URLSetting.AssetBundlesName + "/" + URLSetting.GetPlatformName() + "/";
}
return _remoteAddress;
}

private static string _hotUpdatePath;

private static string GetHotUpdatePath()
{
if (_hotUpdatePath == null)
{
_hotUpdatePath = Application.persistentDataPath + HotUpdateManager.HotUpdateDirName + "/" + URLSetting.AssetBundlesName + "/" + URLSetting.GetPlatformName() + "/";
}
return _hotUpdatePath;
}

private static string _packagePath;

private static string GetPackagePath()
{
if (_packagePath == null)
{
_packagePath = Application.persistentDataPath + HotUpdateManager.PackageDirName + "/" + URLSetting.AssetBundlesName + "/" + URLSetting.GetPlatformName() + "/";
}
return _packagePath;
}

/// <summary>
/// 源类型的枚举。
Expand All @@ -36,20 +75,20 @@ public static string GetAssetBundlePath(SourceType type = SourceType.STREAMING_A
switch (type)
{
case SourceType.STREAMING_ASSETS:
assetBundlePath = _streamingAssetsPath;
assetBundlePath = GetStreamingAssetsPath();
break;
case SourceType.HOT_UPDATE_PATH:
assetBundlePath = _hotUpdatePath;
assetBundlePath = GetHotUpdatePath();
break;
case SourceType.PACKAGE_PATH:
assetBundlePath = _packagePath;
assetBundlePath = GetPackagePath();
break;
case SourceType.REMOTE_ADDRESS:
if (string.IsNullOrEmpty(GameConfig.LocalGameVersion.AssetRemoteAddress))
{
LogF8.LogError("加载远程包需要配置远程地址:AssetRemoteAddress");
}
assetBundlePath = _remoteAddress;
assetBundlePath = GetRemoteAddress();
break;
default:
return null;
Expand Down
14 changes: 11 additions & 3 deletions Runtime/ComponentBind/ComponentBind.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System;
using UnityEngine;

namespace F8Framework.Core
Expand Down Expand Up @@ -163,9 +164,16 @@ private void GenerateAutoBindComponentsCode()
}

UnityEditor.AssetDatabase.Refresh();

SetComponents();


try
{
SetComponents();
}
catch (Exception e)
{
LogF8.LogView(e);
}

UnityEditor.EditorUtility.SetDirty(this);
}
else
Expand Down
3 changes: 2 additions & 1 deletion Runtime/UI/DelegateComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ public void Remove(bool isDestroy)
// 通知外部对象窗口组件上移除之前的事件(关闭窗口前的关闭动画处理)
if (ViewParams.Callbacks != null && ViewParams.Callbacks.OnBeforeRemove != null)
{
ViewParams.Callbacks.OnBeforeRemove(() => Removed(ViewParams, isDestroy));
ViewParams.Callbacks.OnBeforeRemove();
Removed(ViewParams, isDestroy);
}
else
{
Expand Down
5 changes: 0 additions & 5 deletions Runtime/UI/UIManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -142,11 +142,6 @@ public void Open(int uiId, object[] uiArgs = null, UICallbacks callbacks = null)
}
}

public void OpenAsync(int uiId, object[] uiArgs = null, UICallbacks callbacks = null, Action openCallback = null)
{

}

public bool Has(int uiId)
{
if (!_configs.TryGetValue(uiId, out UIConfig config))
Expand Down
4 changes: 2 additions & 2 deletions Runtime/UI/ViewParams.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ public class UICallbacks

public OnAddedEventDelegate OnAdded;
public OnAddedEventDelegate OnRemoved;
public Action<Action> OnBeforeRemove;
public Action OnBeforeRemove;

public UICallbacks(
OnAddedEventDelegate onAdded = null,
OnAddedEventDelegate onRemoved = null,
Action<Action> onBeforeRemove = null)
Action onBeforeRemove = null)
{
OnAdded = onAdded;
OnRemoved = onRemoved;
Expand Down
4 changes: 4 additions & 0 deletions Tests/HotUpdateManager/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ Unity F8 HotUpdate 热更新版本管理,负责打包,分包,热更新资
* 选择打包平台,输出路径,版本号,远程资产加载地址,启用热更新,全量打包,分包,空包。
![image](https://tippinggame-1257018413.cos.ap-guangzhou.myqcloud.com/TippingGame/HotUpdateManager/ui_20240317214323.png)
--------------------------

### 如构建失败:请尝试使用Unity自带的Build一次后再尝试

--------------------------
* 构建后将文件放入CDN服务器
![image](https://tippinggame-1257018413.cos.ap-guangzhou.myqcloud.com/TippingGame/HotUpdateManager/ui_20240323173827.png)
--------------------------
Expand Down
2 changes: 2 additions & 0 deletions Tests/SDKManager/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,3 +95,5 @@ yield return F8DataManager.Instance.LoadLocalizedStringsIEnumerator(); // WebGL
```
* 构建设置。
![image](https://tippinggame-1257018413.cos.ap-guangzhou.myqcloud.com/TippingGame/SDKManager/ui_20240329230924.png)

### 如构建失败:请尝试使用Unity自带的Build一次后再尝试
13 changes: 11 additions & 2 deletions Tests/UI/DemoUIManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,17 @@ void Start()
// 初始化
FF8.UI.Initialize(configs);
// 打开UI,可选参数:data,new UICallbacks()
FF8.UI.Open(1, data, new UICallbacks());
FF8.UI.OpenAsync(1);
FF8.UI.Open(1, data, new UICallbacks(
(parameters, id) => // onAdded
{

}, (parameters, id) => // OnRemoved
{

}, () => // OnBeforeRemove
{

}));
// 打开提示类Notify
FF8.UI.ShowNotify(1, "tip");
// UI是否存在
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "com.tippinggame.f8framework",
"displayName": "F8Framework",
"description": "Unity F8Framework Core",
"version": "1.0.15",
"version": "1.0.16",
"unity": "2021.3",
"license": "MIT",
"keywords": ["Unity", "Framework", "Core"],
Expand Down

0 comments on commit 028f969

Please sign in to comment.