在项目开发过程中会发现部分电脑(特别是笔记本)对于unity镜头特效支持的不是很友好,查阅网上资料得出unity镜头特效对显卡类型及显卡内存都有要求,所以需要根据电脑设备型号不同实现不同的效果,上代码:
/// <summary>
/// 设备等级
/// </summary>
public enum DeviceLevel
{
/// <summary>
/// 低等级
/// </summary>
LowLevel,
/// <summary>
/// 中等
/// </summary>
MidLevel,
/// <summary>
/// 高等
/// </summary>
HighLevel
}
/// <summary>
/// 显卡种类
/// </summary>
public enum GraphicsCardType
{
/// <summary>
/// 专业
/// </summary>
Professional,
/// <summary>
/// 游戏
/// </summary>
Game
}
/// <summary>
/// 设备等级
/// </summary>
/// <returns></returns>
private DeviceLevel JudgeDeviceLevel()
{
//Interl(R) HDGraphics系列显卡(集显)
if (SystemInfo.graphicsDeviceVendorID==32902)
{
return DeviceLevel.LowLevel;
}
else//NVIDIA GEFORCE 系列显卡(N卡)and AMD Radeon系列显卡(A卡)
{
if (SystemInfo.processorCount<2)
{
//Cpu核心数<2判定低端
return DeviceLevel.LowLevel;
}
else
{
//显存
int graphicsMemorySize = SystemInfo.graphicsMemorySize;
//内存
int systemMemorySize = SystemInfo.systemMemorySize;
if (graphicsMemorySize >= 6000 && systemMemorySize >= 8000)
return DeviceLevel.HighLevel;
else if (graphicsMemorySize >= 1000 && graphicsMemorySize < 6000 && systemMemorySize >= 4000 || systemMemorySize >= 4000 && systemMemorySize < 8000 && graphicsMemorySize >=1000)
return DeviceLevel.MidLevel;
else
return DeviceLevel.LowLevel;
}
}
}
/// <summary>
/// 设备显卡类别(专业卡或者游戏卡)
/// </summary>
/// <returns></returns>
private GraphicsCardType graphicsCardType()
{
if (SystemInfo.graphicsDeviceName.Contains("Quadro")|| SystemInfo.graphicsDeviceName.Contains("Radeon"))
{
return GraphicsCardType.Professional;
}
else
{
return GraphicsCardType.Game;
}
}
/// <summary>
/// 初始化项目设置
/// </summary>
private void InitGameSet()
{
switch (graphicsCardType())
{
case GraphicsCardType.Professional:
if (Facade.CameraMng.CameraMainTransform != null)
{
CameraMainTransform.GetComponent<PostProcessVolume>().enabled = false;
}
break;
case GraphicsCardType.Game:
switch (JudgeDeviceLevel())
{
case DeviceLevel.LowLevel:
if (Facade.CameraMng.CameraMainTransform != null)
{
CameraMainTransform.GetComponent<PostProcessVolume>().enabled = false;
}
break;
case DeviceLevel.MidLevel:
break;
case DeviceLevel.HighLevel:
break;
default:
break;
}
break;
default:
break;
}
}
查阅资料地址:
https://blog.csdn.net/sky1466181491/article/details/77977977
https://product.pconline.com.cn/itbk/diy/graphics/1802/10846244.html