Skip to content

Commit

Permalink
Merge pull request #887 from wechat-miniprogram/fix/apiv2-detailsDestroy
Browse files Browse the repository at this point in the history
fix: 提前Details销毁时机
  • Loading branch information
0oQiaoo0 authored Oct 14, 2024
2 parents ce70102 + 5fca7d6 commit 2424b54
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Demo/API_V2/Assets/Scripts/DetailsController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ private void Start()
}

// 清除详情信息
private void ClearDetails()
public void ClearDetails()
{
// 销毁详情信息
Destroy(_details);
Expand All @@ -105,7 +105,7 @@ private void ClearDetails()
// 初始化详情信息
public void Init(EntrySO so)
{
ClearDetails();
// ClearDetails();
entrySO = so;

titleText.text = so.entryName;
Expand Down
5 changes: 5 additions & 0 deletions Demo/API_V2/Assets/Scripts/GameManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,11 @@ private void Start()
// 切换 MainCanvas 和 DetailsCanvas 的显示状态
public void SwitchCanvas()
{
if (!_isMainCanvasActive)
{
// 提前销毁时机 防止预期外的行为发生
detailsController.ClearDetails();
}
_isMainCanvasActive = !_isMainCanvasActive;
mainCanvas.SetActive(_isMainCanvasActive);
detailsCanvas.SetActive(!_isMainCanvasActive);
Expand Down

0 comments on commit 2424b54

Please sign in to comment.