Git Product home page Git Product logo

Comments (3)

IcePower avatar IcePower commented on August 14, 2024

这个参数我是从字母哥的EUI里抄过来的。ShowPanelData 里只有一个参数 Entity ContextData,我猜测它的用法是向打开的界面传递参数。也可以根据需要往 ShowPanelData 里加入其他的字段,比如控制界面的弹出方式、释放策略等。
比如我现在要向 LobbyPanel 传个参数 LobbyPanelContext

[ChildOf(typeof(ShowPanelData))]
public class LobbyPanelContext: Entity, IAwake
{
    public string Name { get; set; }
}

在打开界面的地方这样使用:

ShowPanelData showPanelData = fuiComponent.AddChild<ShowPanelData>();
LobbyPanelContext lobbyPanelContext = showPanelData.AddChild<LobbyPanelContext>();
lobbyPanelContext.Name = "参数";
showPanelData.ContextData = lobbyPanelContext;
await fuiComponent.ShowPanelAsync(PanelId.LobbyPanel, showPanelData);

这样在 LobbyPanelSystem.OShow 里就可以打印出 lobbyPanelContext.Name 了:

LobbyPanelContext lobbyPanelContext = contextData as LobbyPanelContext;
Log.Info(lobbyPanelContext.Name);

其他地方可能还需要根据你的需求做一些修改。
不过我们项目里这块的代码有了一些改动,之后我可以提交一下。

from x-et7.

sosloop avatar sosloop commented on August 14, 2024

那 ShowPanelData 在哪销毁呢,每次打开都会创建

from x-et7.

IcePower avatar IcePower commented on August 14, 2024

fuiComponent.ShowPanelAsync 函数里会把 ShowPanelData 挂到界面上,界面销毁的时候 ShowPanelData 跟着销毁。

from x-et7.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.