当前位置:   article > 正文

Unity3D的Delegate和SendMessage的性能差测试,以及Delegate在多线程使用要注意的小问题_nativeunitysendmessage 在哪个线程

nativeunitysendmessage 在哪个线程

一、回顾前面写的关于Delegate的消息传送优化文章,http://blog.csdn.net/chiuan/article/details/7883449 

下面的代码是做一个简单的Delegate和SendMessage之间的优化性能差距测试:

  1. using UnityEngine;
  2. using System.Collections;
  3. /// <summary>
  4. /// Delegate basic.
  5. /// just test Delegate && SendMessage ..
  6. ///
  7. /// By Chiuan 2012.8
  8. /// </summary>
  9. public class DelegateBasic : MonoBehaviour {
  10. //define my delegate statement.
  11. public delegate void MyDelegate(string arg1);
  12. //create my delegate object
  13. public MyDelegate myDelegate;
  14. //need some values to debug time spent.
  15. bool isStart;
  16. float timeStart;
  17. int count;
  18. bool isStartSendMessage;
  19. // Use this for initialization
  20. void Start () {
  21. myDelegate += myFunciton1;
  22. //myDelegate += myFunciton2;
  23. }
  24. // Update is called once per frame
  25. void Update () {
  26. if(isStart )
  27. {
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/不正经/article/detail/94744
推荐阅读
相关标签
  

闽ICP备14008679号