[当我在Unity Editor中运行以下代码时,或者如果我构建并运行它(不是在无头模式下运行),GetNativeTexturePtr()
将返回纹理ID的值>0
,等等
但是,在构建启用了[[Server Build]选项的应用程序时,GetNativeTexturePtr()
始终返回0
。即使IsCreated()
返回true。
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class test : MonoBehaviour
{
private RenderTexture m_RenderTexture;
// Start is called before the first frame update
void Start()
{
m_RenderTexture = new RenderTexture(256, 256, 24, RenderTextureFormat.ARGB32);
m_RenderTexture.Create();
if (!m_RenderTexture.IsCreated())
{
Debug.LogError("RenderTexture could not be created");
}
Debug.Log("texture id = " + m_RenderTexture.GetNativeTexturePtr().ToString());
}
}
统一版本2019.1.9f1