1.问题描述
Assets\Battlehub\RTCommon\Scripts\RTEBase.cs(690,20): error CS0619: ‘XRDevice.isPresent’ is obsolete: ‘This is obsolete, and should no longer be used. Instead, find the active XRDisplaySubsystem and check that the running property is true (for details, see XRDevice.isPresent documentation).’
这个报错是我在使用Unity的RuntimesEditor插件的时候出现的,大概就是说API过期了需要修改一下。
2.解决办法
在网上查了查没找到相关的,于是就根据报错提示直接去Unity的Api文档查看。看了一下才知道是之前的接口不能用了,重写一下就行。XRDevice.isPresent文档。按照文档中说的重写一个内部类再调用就行。
在代码中添加下面这部分,然后修改一下调用的代码就行。
internal static class ExampleUtil
{
public static bool isPresent()
{
var xrDisplaySubsystems = new List<XRDisplaySubsystem>();
SubsystemManager.GetInstances<XRDisplaySubsystem>(xrDisplaySubsystems);
foreach (var xrDisplay in xrDisplaySubsystems)
{
if (xrDisplay.running)
{
return true;
}
}
return false;
}
}