Skip to content

Commit

Permalink
UIMgr
Browse files Browse the repository at this point in the history
  • Loading branch information
chasinghope committed Dec 13, 2024
1 parent 9c9746a commit dbab263
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 1 deletion.
26 changes: 26 additions & 0 deletions Runtime/Core/UIMgr.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading;
using Cysharp.Threading.Tasks;
using UnityEngine;
Expand Down Expand Up @@ -296,6 +297,11 @@ public void RemovePanel<T>()
mPanleStack.RemoveIndex(index);
}
}

public void InsertPanel(int rIndex, Type rUIBaseType, UIData rUIData)
{
mPanleStack.Insert(rIndex, (rUIBaseType, rUIData));
}

private bool IsOpened(Type rType)
{
Expand Down Expand Up @@ -455,6 +461,7 @@ private async UniTask BackAsync(bool rForceDestroy = false)
instance.transform.SetAsLastSibling();
DoBind(newPanel);
DoShow(newPanel);
Debug.LogWarning($"返回到界面: {prePanelType.Name}");
}
else
{
Expand Down Expand Up @@ -639,6 +646,25 @@ private void Destroy(GameObject instance)
}

#endregion



#region Debug

public void Test_PrintUIStack()
{
StringBuilder sb = new StringBuilder();
sb.Append("UIStack: Root");
foreach (var item in mPanleStack)
{
sb.Append("->");
sb.Append(item.type.Name);

}
Debug.Log(sb.ToString());
}

#endregion
}
}

22 changes: 21 additions & 1 deletion Runtime/Core/UIStack.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@

using System;
using System.Collections;
using System.Collections.Generic;

namespace Congroo.UI
{


public class UIStack<T>
public class UIStack<T> :IEnumerable<T>
{
private List<T> items = new List<T>();

Expand Down Expand Up @@ -40,6 +41,12 @@ public T Peek()
return items[items.Count - 1];
}


public void Insert(int index, T item)
{
items.Insert(index, item);
}

// IsEmpty 方法用于检查栈是否为空
public bool IsEmpty()
{
Expand Down Expand Up @@ -72,6 +79,19 @@ public T GetIndex(int index)
{
return items[index];
}

public IEnumerator<T> GetEnumerator()
{
for (int i = 0; i < items.Count; i++)
{
yield return items[i];
}
}

IEnumerator IEnumerable.GetEnumerator()
{
return GetEnumerator();
}
}

}

0 comments on commit dbab263

Please sign in to comment.