vuforia ARCamera 视频背景为黑色
vuforia ARCamera videobackground is black
我已经使用 vuforia ARCamera 和 imagetarget 创建了 assetbundle 场景。现在加载 assetbundle 场景后,场景可以黑屏启动。我注意到 ARCamera -> Camera -> BackgroundPlane->VideoMaterial(Instance) -> "Custom/VideoBackground" 未启用。但是当我手动启用它时,摄像头已启用并实时显示。无论如何在场景加载后启用该着色器。
图一:
Before enabling and scene was opened from assetbundle
图二:After enabling shader option
这里有一个更完整的答案供以后参考:
您可以通过将脚本附加到在唤醒时启用着色器的所述 GameObject 来解决此问题,它看起来像这样:
void Awake()
{
//get your video material component
VideoMaterial myVideoMaterial = getComponent<VideoMaterial>();
//Look for a shader called "VideoBackground" and apply it to the shader material of the component
myVideoMaterial.material.shader = Shader.find("Custom/VideoBackground");
Destroy(this);//this will remove this script after executing it, just looks a bit cleaner in my opinion but no necessary
}
这是假设您已经从场景中某处的 material 引用了着色器。如果你不这样做,你可以按照 Gowthy 的评论将着色器添加到 "always included shaders" 列表中。这可以通过转到项目设置下的 Graphics
菜单找到,然后向下滚动到 "Always Included Shaders" 部分。或者您可以将着色器添加到播放器构建中包含的 "Resources" 文件夹中
- 从资产目录中删除 Vuforia 文件夹。
- 打开播放器设置并取消选中 XR 设置中的 Vuforia 支持。
- 选择删除文件选项。
- 然后再次检查 Vuforia 支持。
- 在场景中选择 Vuforia 相机。
- 添加许可证密钥。
- 就是这样。
我已经使用 vuforia ARCamera 和 imagetarget 创建了 assetbundle 场景。现在加载 assetbundle 场景后,场景可以黑屏启动。我注意到 ARCamera -> Camera -> BackgroundPlane->VideoMaterial(Instance) -> "Custom/VideoBackground" 未启用。但是当我手动启用它时,摄像头已启用并实时显示。无论如何在场景加载后启用该着色器。
图一: Before enabling and scene was opened from assetbundle
图二:After enabling shader option
这里有一个更完整的答案供以后参考:
您可以通过将脚本附加到在唤醒时启用着色器的所述 GameObject 来解决此问题,它看起来像这样:
void Awake()
{
//get your video material component
VideoMaterial myVideoMaterial = getComponent<VideoMaterial>();
//Look for a shader called "VideoBackground" and apply it to the shader material of the component
myVideoMaterial.material.shader = Shader.find("Custom/VideoBackground");
Destroy(this);//this will remove this script after executing it, just looks a bit cleaner in my opinion but no necessary
}
这是假设您已经从场景中某处的 material 引用了着色器。如果你不这样做,你可以按照 Gowthy 的评论将着色器添加到 "always included shaders" 列表中。这可以通过转到项目设置下的 Graphics
菜单找到,然后向下滚动到 "Always Included Shaders" 部分。或者您可以将着色器添加到播放器构建中包含的 "Resources" 文件夹中
- 从资产目录中删除 Vuforia 文件夹。
- 打开播放器设置并取消选中 XR 设置中的 Vuforia 支持。
- 选择删除文件选项。
- 然后再次检查 Vuforia 支持。
- 在场景中选择 Vuforia 相机。
- 添加许可证密钥。
- 就是这样。