画布UI对象的OnBecomeVisible [英] OnBecomeVisible for Canvas UI Objects

查看:100
本文介绍了画布UI对象的OnBecomeVisible的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为Canvas UI搜索类似于OnBecameVisible的方法. MonoBehaviour.OnBecameVisible()

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

以便我可以根据需求加载和卸载图像资源.但是我找不到任何有用的东西. 我有一个这样的页面,其中包含250多个花的信息,因此我必须为此管理我的纹理资源.

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.

如果我禁用了图像组件,则该页面将正确地加载到游戏中,否则由于过多的图形内存需求,当我加载该页面时,游戏会在iPhone设备中崩溃.

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.

推荐答案

Unity目前没有提供直接解决方案.但是由于可见区域是矩形的并且与屏幕空间有关,所以您可以轻松地检查元素是否包含在其中.

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.

这里有一些论坛上的帖子,有关帮助脚本及其在这种情况下的用法,这些应该可以解决您的问题: https://forum.unity.com/threads/test-if-ui-element-is-visible-on-screen.276549/#post-2978773

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

这篇关于画布UI对象的OnBecomeVisible的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆