Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[UI Window] - common usage of OnOpen,OnClose,OnRefresh .. #15

Closed
takaaptech opened this issue Jan 5, 2018 · 6 comments
Closed

[UI Window] - common usage of OnOpen,OnClose,OnRefresh .. #15

takaaptech opened this issue Jan 5, 2018 · 6 comments

Comments

@takaaptech
Copy link
Contributor

takaaptech commented Jan 5, 2018

Hi!
I can see we have a lot of function to write the logic each window UI, it is really awesome! Can you tell more about the lifecycle of those methods and common usage pattern?
OnInit()
OnOpen()
OnClose()
OnHide()
OnShow()
OnRefresh() . -- This usage pattern example? What kind of UI event will active this method?
Why we usually using OnOpen and OnClose but not OnShow and OnHide?

And one more thing I am very confused is why we using AddOnClickListener on OnOpen but do not have to remove it on OnClose (and why don't use it in OnInit ), So maybe we have an issue that duplicated events somewhere?

Thank you so much! I am learning it day by day!

@kisence-mian
Copy link
Owner

kisence-mian commented Jan 5, 2018

AddOnClickListener will be automatically removed in the OnClose.
The reason for this is

  1. Simplify the code.
  2. Avoid clicking on the UI when close animation

ps: OpenUI by IApplicationStatus also the same

@takaaptech
Copy link
Contributor Author

Hi @GaoKaiHaHa
Aha i understand now. How about OnRefresh? Is this method for updating, refresh data or logic when user come back to ui window from other window? Can you give me an example how to use it?
Thank so much!

@takaaptech
Copy link
Contributor Author

@GaoKaiHaHa Can you explain more about OnRefesh and how to use it (some example when to use it) in the real game?

@kisence-mian
Copy link
Owner

If you use UIBase.AddEventListener, then OnRefesh will be called when this event is called, and you can also put UI update logic in this method and initiative call it.:)

@kisence-mian
Copy link
Owner

OnInit () is called when the UI is created. This method is called only once during the life of the UI
OnOpen () is called when the UI is opened, for performance reasons, we can create a UI and wait until the right time to open it,
OnClose (), called when the UI is closed
OnHide () is called when the UI is hidden,
OnShow () Called when the UI is redisplaying, as opposed to OnHide ()
We can override the Show() method and Hide() method of UIBase, the default is to change the active

@takaaptech
Copy link
Contributor Author

Hi @GaoKaiHaHa
Now I completely understand it! Thank so much!
Going to ask another question about Popup he he

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants