Unity - 虽然只有简单的网格,但性能很慢?

时间:2018-06-04 03:59:19

标签: c# performance unity3d 3d assets

好吧,这个问题只是DEVICE(iPhone)而我正在拼命寻找突然低FPS的原因。

我使用ARKit如果有所不同 - 当我第一次运行游戏时,一切都很好而且快速,只有一层(游戏对象由两个简单的立方体组成)在场景中。

这是引发慢速FPS的原因 - 一个由箱式对撞机和多个等级组成的游戏对象" (只是立方体..):

enter image description here

产生于:

GameController gameController = GameObject.FindObjectOfType<GameController> ();
        if (!hasItsTiers && gameController.tiersSpawned.Length <= gameController.tierLimit) {
            //based on determined enum..

            //need to add anchor for container
            //These: 1. do not change size, do not change rotation EVER
            //ENSURE that does not exceed bounds of container? something with overlap


            //float sphereRadius = 
            //print(Physics.CheckSphere(this.GetComponent<BoxCollider>().bounds.center, this.GetComponent<BoxCollider>().bounds.size.x/2, 1 << 10));
            if (!(Physics.CheckSphere(this.GetComponent<BoxCollider>().bounds.center, this.GetComponent<BoxCollider>().bounds.size.x/2, 1 << 10)) )
            {
                chosenContainer = Instantiate (chosenContainer, gameObject.GetComponent<BoxCollider> ().bounds.center, Quaternion.identity);
                chosenContainer.transform.localScale = new Vector3 (0.5f, 0.5f, 0.5f);
                hasItsTiers = true;
            }

我确认每次ARPlane只调用一次(我看不到无限循环),因为我在场景中不断存储ArPlanes的数组,并且只有当数组计数发生变化时才触发上述功能用:

public Dictionary<GameObject, float> planesFilled = new Dictionary<GameObject, float>(); //plane, distance
if (planesFilled.Count != oldPlaneCount) {

            hasTriedSpawn = false;
            print ("PLANE ARRAY CHANGED");
            CheckToSpawnOnPlane ();

        }
        oldPlaneCount = planesFilled.Count;

(它必须是字典,因为我用它来计算到对象的距离)

我看了https://ralphbarbagallo.com/2012/07/23/how-to-prevent-performance-spikes-in-unity3d-when-a-model-is-first-visible/,它在第一次加载资产时引用了性能峰值,但我认为这不是问题所在。

在我生成这些立方体集合之一后,FPS会永久减速。我没有解决方案 - 这里有什么问题?

0 个答案:

没有答案