Skip to content

Commit

Permalink
[更新]1. 更新UI代码
Browse files Browse the repository at this point in the history
  • Loading branch information
AlianBlank committed Oct 17, 2024
1 parent 3e57d33 commit 99eb639
Show file tree
Hide file tree
Showing 11 changed files with 243 additions and 89 deletions.
14 changes: 13 additions & 1 deletion Assets/Bundles/UI/UILogin/UILogin_atlas0.png.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 13 additions & 8 deletions Assets/Hotfix/UI/FairyGUI/UILogin/Components/UIAnnouncement.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@
using Cysharp.Threading.Tasks;
using FairyGUI.Utils;
using GameFrameX.Entity.Runtime;
using GameFrameX.UI.Runtime;
using GameFrameX.UI.FairyGUI.Runtime;
using GameFrameX.Runtime;
using UnityEngine;

namespace Hotfix.UI
{
Expand Down Expand Up @@ -34,24 +36,27 @@ private static void CreateGObjectAsync(UIPackage.CreateObjectCallback result)
UIPackage.CreateObjectAsync(UIPackageName, UIResName, result);
}

public static UIAnnouncement CreateInstance(object userData = null)
public static UIAnnouncement CreateInstance()
{
return new UIAnnouncement(CreateGObject(), userData);
return Create(CreateGObject());
}

public static UniTask<UIAnnouncement> CreateInstanceAsync(Entity domain, object userData = null)
public static UniTask<UIAnnouncement> CreateInstanceAsync(Entity domain)
{
UniTaskCompletionSource<UIAnnouncement> tcs = new UniTaskCompletionSource<UIAnnouncement>();
CreateGObjectAsync((go) =>
{
tcs.TrySetResult(new UIAnnouncement(go, userData));
tcs.TrySetResult(Create(go));
});
return tcs.Task;
}

public static UIAnnouncement Create(GObject go, object userData = null)
public static UIAnnouncement Create(GObject go)
{
return new UIAnnouncement(go, userData);
var fui = go.displayObject.gameObject.GetOrAddComponent<UIAnnouncement>();
fui?.SetGObject(go);
fui?.InitView();
return fui;
}

/// <summary>
Expand Down Expand Up @@ -82,7 +87,7 @@ protected override void InitView()
if(com != null)
{
m_MaskLayer = (GGraph)com.GetChild("MaskLayer");
m_TextContent = UIAnnouncementContent.Create(com.GetChild("TextContent"), this);
m_TextContent = UIAnnouncementContent.Create(com.GetChild("TextContent"));
m_TextTitle = (GTextField)com.GetChild("TextTitle");
}
}
Expand All @@ -102,7 +107,7 @@ public override void Dispose()
self = null;
}

private UIAnnouncement(GObject gObject, object userData) : base(gObject, userData)
private UIAnnouncement(GObject gObject) : base(gObject)
{
// Awake(gObject);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@
using Cysharp.Threading.Tasks;
using FairyGUI.Utils;
using GameFrameX.Entity.Runtime;
using GameFrameX.UI.Runtime;
using GameFrameX.UI.FairyGUI.Runtime;
using GameFrameX.Runtime;
using UnityEngine;

namespace Hotfix.UI
{
Expand All @@ -23,9 +25,12 @@ public sealed partial class UIAnnouncementContent : FUI
public GRichTextField m_LabelContent { get; private set; }


public static UIAnnouncementContent Create(GObject go, object userData = null)
public static UIAnnouncementContent Create(GObject go)
{
return new UIAnnouncementContent(go, userData);
var fui = go.displayObject.gameObject.GetOrAddComponent<UIAnnouncementContent>();
fui?.SetGObject(go);
fui?.InitView();
return fui;
}

/// <summary>
Expand Down Expand Up @@ -72,7 +77,7 @@ public override void Dispose()
self = null;
}

private UIAnnouncementContent(GObject gObject, object userData) : base(gObject, userData)
private UIAnnouncementContent(GObject gObject) : base(gObject)
{
// Awake(gObject);
}
Expand Down
80 changes: 62 additions & 18 deletions Assets/Hotfix/UI/FairyGUI/UILogin/Components/UILogin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
using Cysharp.Threading.Tasks;
using FairyGUI.Utils;
using GameFrameX.Entity.Runtime;
using GameFrameX.UI.Runtime;
using GameFrameX.UI.FairyGUI.Runtime;
using GameFrameX.Runtime;
using GameFrameX.UI.UGUI.Runtime;
using UnityEngine;

namespace Hotfix.UI
Expand All @@ -22,31 +22,75 @@ public sealed partial class UILogin : FUI
/// </summary>
public GComponent self { get; private set; }

public GTextField m_ErrorText { get; private set; }
public GButton m_enter { get; private set; }
public GTextInput m_UserName { get; private set; }
public GTextInput m_Password { get; private set; }
public GTextField m_ErrorText { get; private set; }
public GButton m_enter { get; private set; }
public GTextInput m_UserName { get; private set; }
public GTextInput m_Password { get; private set; }

private static GObject CreateGObject()
{
return UIPackage.CreateObject(UIPackageName, UIResName);
}

private static void CreateGObjectAsync(UIPackage.CreateObjectCallback result)
{
UIPackage.CreateObjectAsync(UIPackageName, UIResName, result);
}

public static UILogin CreateInstance()
{
return Create(CreateGObject());
}

public static UniTask<UILogin> CreateInstanceAsync(Entity domain)
{
UniTaskCompletionSource<UILogin> tcs = new UniTaskCompletionSource<UILogin>();
CreateGObjectAsync((go) =>
{
tcs.TrySetResult(Create(go));
});
return tcs.Task;
}

public static UILogin Create(GObject go)
{
var fui = go.displayObject.gameObject.GetOrAddComponent<UILogin>();
fui?.SetGObject(go);
fui?.InitView();
return fui;
}

/// <summary>
/// 通过此方法获取的FUI,在Dispose时不会释放GObject,需要自行管理(一般在配合FGUI的Pool机制时使用)。
/// </summary>
public static UILogin GetFormPool(GObject go)
{
var fui = go.Get<UILogin>();
if(fui == null)
{
fui = Create(go);
}
fui.IsFromPool = true;
return fui;
}

protected override void InitView()
{
if (gameObject == null)
if(GObject == null)
{
return;
}

self = (GComponent)GObject;
self.Add(this);

var com = GObject.asCom;
if (com != null)
if(com != null)
{
m_ErrorText = (GTextField)com.GetChild("ErrorText");
m_enter = (GButton)com.GetChild("enter");
m_UserName = (GTextInput)com.GetChild("UserName");
m_Password = (GTextInput)com.GetChild("Password");
m_ErrorText = (GTextField)com.GetChild("ErrorText");
m_enter = (GButton)com.GetChild("enter");
m_UserName = (GTextInput)com.GetChild("UserName");
m_Password = (GTextInput)com.GetChild("Password");
}
}

Expand All @@ -59,16 +103,16 @@ public override void Dispose()

base.Dispose();
self.Remove();
m_ErrorText = null;
m_enter = null;
m_UserName = null;
m_Password = null;
self = null;
m_ErrorText = null;
m_enter = null;
m_UserName = null;
m_Password = null;
self = null;
}


public UILogin(GObject gObject, object userData = null, bool isRoot = false) : base(gObject, userData, isRoot)
private UILogin(GObject gObject) : base(gObject)
{
// Awake(gObject);
}
}
}
19 changes: 12 additions & 7 deletions Assets/Hotfix/UI/FairyGUI/UILogin/Components/UIPlayerCreate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@
using Cysharp.Threading.Tasks;
using FairyGUI.Utils;
using GameFrameX.Entity.Runtime;
using GameFrameX.UI.Runtime;
using GameFrameX.UI.FairyGUI.Runtime;
using GameFrameX.Runtime;
using UnityEngine;

namespace Hotfix.UI
{
Expand Down Expand Up @@ -34,24 +36,27 @@ private static void CreateGObjectAsync(UIPackage.CreateObjectCallback result)
UIPackage.CreateObjectAsync(UIPackageName, UIResName, result);
}

public static UIPlayerCreate CreateInstance(object userData = null)
public static UIPlayerCreate CreateInstance()
{
return new UIPlayerCreate(CreateGObject(), userData);
return Create(CreateGObject());
}

public static UniTask<UIPlayerCreate> CreateInstanceAsync(Entity domain, object userData = null)
public static UniTask<UIPlayerCreate> CreateInstanceAsync(Entity domain)
{
UniTaskCompletionSource<UIPlayerCreate> tcs = new UniTaskCompletionSource<UIPlayerCreate>();
CreateGObjectAsync((go) =>
{
tcs.TrySetResult(new UIPlayerCreate(go, userData));
tcs.TrySetResult(Create(go));
});
return tcs.Task;
}

public static UIPlayerCreate Create(GObject go, object userData = null)
public static UIPlayerCreate Create(GObject go)
{
return new UIPlayerCreate(go, userData);
var fui = go.displayObject.gameObject.GetOrAddComponent<UIPlayerCreate>();
fui?.SetGObject(go);
fui?.InitView();
return fui;
}

/// <summary>
Expand Down Expand Up @@ -102,7 +107,7 @@ public override void Dispose()
self = null;
}

private UIPlayerCreate(GObject gObject, object userData) : base(gObject, userData)
private UIPlayerCreate(GObject gObject) : base(gObject)
{
// Awake(gObject);
}
Expand Down
19 changes: 12 additions & 7 deletions Assets/Hotfix/UI/FairyGUI/UILogin/Components/UIPlayerList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@
using Cysharp.Threading.Tasks;
using FairyGUI.Utils;
using GameFrameX.Entity.Runtime;
using GameFrameX.UI.Runtime;
using GameFrameX.UI.FairyGUI.Runtime;
using GameFrameX.Runtime;
using UnityEngine;

namespace Hotfix.UI
{
Expand Down Expand Up @@ -37,24 +39,27 @@ private static void CreateGObjectAsync(UIPackage.CreateObjectCallback result)
UIPackage.CreateObjectAsync(UIPackageName, UIResName, result);
}

public static UIPlayerList CreateInstance(object userData = null)
public static UIPlayerList CreateInstance()
{
return new UIPlayerList(CreateGObject(), userData);
return Create(CreateGObject());
}

public static UniTask<UIPlayerList> CreateInstanceAsync(Entity domain, object userData = null)
public static UniTask<UIPlayerList> CreateInstanceAsync(Entity domain)
{
UniTaskCompletionSource<UIPlayerList> tcs = new UniTaskCompletionSource<UIPlayerList>();
CreateGObjectAsync((go) =>
{
tcs.TrySetResult(new UIPlayerList(go, userData));
tcs.TrySetResult(Create(go));
});
return tcs.Task;
}

public static UIPlayerList Create(GObject go, object userData = null)
public static UIPlayerList Create(GObject go)
{
return new UIPlayerList(go, userData);
var fui = go.displayObject.gameObject.GetOrAddComponent<UIPlayerList>();
fui?.SetGObject(go);
fui?.InitView();
return fui;
}

/// <summary>
Expand Down Expand Up @@ -111,7 +116,7 @@ public override void Dispose()
self = null;
}

private UIPlayerList(GObject gObject, object userData) : base(gObject, userData)
private UIPlayerList(GObject gObject) : base(gObject)
{
// Awake(gObject);
}
Expand Down
Loading

0 comments on commit 99eb639

Please sign in to comment.