-2

我写了一个代码,当播放器没有在相机中渲染时,它应该被销毁,但即使在相机中渲染它也会被破坏,请参阅我的下面的代码;



using UnityEngine;

public class IfnotvisibleDestroy : MonoBehaviour
{
    public SpriteRenderer re;
   
    // Start is called before the first frame update
    void Start()
    {
        
    }

    // Update is called once per frame
    public void Update()

    {
       
        if (re.isVisible)
        {
            Debug.Log(re.isVisible);
        }
        if(!re.isVisible)
        {
            Destroy(gameObject);
        }
    }
}
4

1 回答 1

-1

在 FixedUpdate 函数中执行销毁游戏对象部分

于 2021-01-06T03:59:21.420 回答