[Unity3D学习]NGUI UIScrollView UIGrid性能优化

之前用UIGrid 发现如果数据量大了。NGUI就会创建大量的GameObject. 这样肯定对性能消耗影响巨大,所以我自己优化了一下。这样效率可以提高很多。当然,优化过后UIGrid还是有一些不足,可惜暂时没有思路,以后有思路了。再接着继续。直接贴代码。

Demo : game.gamerisker.com/grid/

DownLoad : GridDemo 访问密码: o7bf

 

 

 

 

17 Comments

  1. prince says:

    Hi,

    I’m interested in this article but I can’t read Chinese, so could you explain the main point that you optimized the UIScrollView?

    Thank you.

  2. gakaki says:

    大哥源码消失了 能不能上传到github或者oschina呢 还可以给你改进 qq 82506111

  3. says:

    我想请教下,如果grid一行多列的特性怎么实现数据的更新,例如:1行4列

  4. argen says:

    你好,我用了你的这个优化的grid,但有个问题是如果grid的item比较复杂的话在滑动后就会显示不出来了,第一屏是可以显示的,因为是测试,所以滑动的时候也没有去改变item的值,只是验证性能,但滑动后就是显示不了,这是什么原因呢,能给个思路吗?
    非常感谢

    • YangDan says:

      谢谢,感谢你的使用!

      item 最终的渲染 是在Validate这个方法里面,如果不显示,有可能是Item的坐标计算不对,处于可视范围以外造成的,你可以看看item的坐标。item的显示与它复杂没关系。

      如果有还是出现问题,可以直接联系我:QQ:133523686(注明来意 3Q)

  5. says:

    已搞定,很不错的优化,3Q

  6. 大众 says:

    你好 请问这个有打unity包吗?初学者 很感兴趣,想学习一下,谢谢!

  7. kason says:

    Assets/Grid/CustomScrollView.cs(202,32): error CS1061: Type UIPanel' does not contain a definition for onChange’ and no extension method onChange' of type UIPanel’ could be found (are you missing a using directive or an assembly reference?)

    ngui3.5.8版本 不知道哪个方法可以替代这个

    • GameRisker says:

      你好,因为我手里没有3.5.8版本,无法明确告诉你用哪个方法替代,我只能给你一些建议,请你详细的看一下CustomGrid.cs类的头注释,CustomScrollView类,你应该可以直接使用3.5.8版本的 只需要把bounds改为外部赋值,其他的依然用原来的类代码。慢慢的改一下 相信你也能运行起来的,祝你成功!

Leave a Reply to YangDan Cancel reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.