-
-
Notifications
You must be signed in to change notification settings - Fork 7
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
Layout does not refresh it self in Play Mode #1
Comments
UPDATE: possibly OnEnable event would be better to listen for making the "refresh" of SafeArea |
Hi @IvanMurzak, thanks for the report. In my experience, whenever object gets reactivated and Could you try adding a call to protected virtual void OnEnable()
{
_canvas = GetComponentInParent<Canvas>();
RefreshChildrenAnchors();
LayoutRebuilder.MarkLayoutForRebuild(SelfRectTransform); // <-- this line
} Say, do you reparent the object after creating it outside of the Canvas? void OnTransformParentChanged()
{
_canvas = GetComponentInParent<Canvas>();
// RefreshChildrenAnchors(); // no need to refresh children here
LayoutRebuilder.MarkLayoutForRebuild(SelfRectTransform);
} Even if it does not work for you, I'll add it to the script later to handle these reparenting cases. |
It doesn't refresh in builds also. That all what I can say for now. Will test your suggestions. Do you want me to add the code into your class (SafeArea...)? |
My UI never changes parents. It just disabled/enabled. Unity_JfNurYzeI6.mp4 |
@gilzoide I reproduced the error with manual actions. Just need to disable gameObject, scale it to zero, enable it and scale back to 1. Unity_1rH3ac0PEC.mp4 |
Thanks for the insights! protected virtual void OnEnable()
{
_canvas = GetComponentInParent<Canvas>().rootCanvas;
RefreshChildrenAnchors(); // ^ here, get the rootCanvas
}
Yes. If you installed the plugin via UPM, you can find the script at the folder
Hmm, it is possible that scaling won't trigger layout rebuilds. I'll test and fix this case later. Thank you again for the additional information on this issue! |
Hey @IvanMurzak. safe-area.mp4Your case is certainly very strange =/ |
So, something else I just realized is that hovering the Editor button calls |
Hey @IvanMurzak , I've made some changes to the package that might fix your problem. Now every internal call to If it does not, I'll add an option for forcing the layout instead of only marking for rebuild. |
Need to move mouse over the specific area in a layout. That is so annoying thing. Because in the middle of development and debugging need to find a component with the SafeAreaLayout component and move mouse over. Is it possible to force it to work automatically OnAwake or OnStart events (at least as an option)?
Unity_RjdR9pUOmB.mp4
P.S. the package is very cool! Thanks for the work <3
The text was updated successfully, but these errors were encountered: