OnBecomeVisible for Canvas UI Objects

南笙酒味 提交于 2019-12-12 05:41:12

问题


I was searching for method similar to OnBecameVisible for Canvas UI. MonoBehaviour.OnBecameVisible()

So that I can load and unload image resources based on requirements. But I can't able to find anything useful in this. I have this kind of page exist which contains 250+ flowers information so I have to manage my texture resources for this.

If I disable Image component then page loaded correctly in game otherwise game get crashed in iPhone device when I load this page because of too much graphics memory requirements.

So for managing resources loading and unloading, I need some way.


回答1:


There is no direct solution provided by Unity at the moment. But since the visible area is rectangular and related to screen space, you can easily check if your element contained in it.

Here is some post from forums about a helper script and its usage about this situation which should be able to solve your problem: https://forum.unity.com/threads/test-if-ui-element-is-visible-on-screen.276549/#post-2978773



来源:https://stackoverflow.com/questions/47314314/onbecomevisible-for-canvas-ui-objects

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!