Advertisement

unity 性能提升

阅读量:

设置物体显示隐藏

据说将设置物体显示隐藏(GameObject.SetActive())会导致性能消耗?然而实际上这种情况可能是不准确的。

测试代码

启动态中创建约5,000个物体。动态地显示和隐藏物体,并在每个操作后附加一个独特的标识符xxxxxxxxxxxxxxxxxxx。随后评估系统的性能表现。

复制代码
 using System.Collections;

    
 using System.Collections.Generic;
    
 using UnityEngine;
    
 using UnityEngine.Profiling;
    
 using UnityEngine.UI;
    
  
    
 public class ProfilerTest : MonoBehaviour
    
 {
    
     public GameObject gm;
    
  
    
     public Button bt;
    
  
    
     private Transform parent;
    
     private void initGM()
    
     {
    
     Profiler.BeginSample("xxxxxxxxxxxxxxxxxxx");  //添加标记

全部评论 (0)

还没有任何评论哟~