码迷,mamicode.com
首页 > 其他好文 > 详细

空的OnGUI也会有gc

时间:2018-09-11 21:21:05      阅读:278      评论:0      收藏:0      [点我收藏+]

标签:src   layout   edit   void   http   image   editor   you   内存   

一个空场景,添加如下代码:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class NewBehaviourScript : MonoBehaviour
{
    private void OnGUI()
    {
        
    }
}

技术分享图片

可以看到每帧有一个固定的内存gc,可以用useGUILayout开关来关闭其gc消耗:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class NewBehaviourScript : MonoBehaviour
{
    private void Start()
    {
#if !UNITY_EDITOR
        useGUILayout = false;
#endif
    }

    private void OnGUI()
    {
        
    }
}

 

空的OnGUI也会有gc

标签:src   layout   edit   void   http   image   editor   you   内存   

原文地址:https://www.cnblogs.com/sifenkesi/p/9629713.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!