vuforia ARCamera videobackground is black

3k views Asked by At

I have create assetbundle scene with vuforia ARCamera and an imagetarget. Now after loading the assetbundle scene, the scene is able to start with black screen. I have noticed that the ARCamera -> Camera -> BackgroundPlane->VideoMaterial(Instance) -> "Custom/VideoBackground" is not enabled. But when i enabled that manually, then the camera has enabled and showing live. Is there anyway to make that shader enabled after scene loads.

Picture-1: Before enabling and scene was opened from assetbundle

Picture-2: After enabling shader option

2

There are 2 answers

0
Remy On BEST ANSWER

Here is a more complete answer for future reference:

You can solve this issue by attaching to script to said GameObject that enables the shader upon awake, it would look something like this:

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
}
  • More information about material shaders can be found in the unity docs here.
  • More information about Shader.find can be found in the docs here

This is assuming that you have a reference to the shader from a material already somewhere in your scene. If you do not you can as per Gowthy's comment add the shader to the "always included shaders" list. This can be found by going to the Graphics menu under Project Settings, and then scroll down to the "Always Included Shaders" section. Or you can add the shader to a "Resources" folder that gets included in the player build"

0
Codemaker2015 On
  1. Delete the Vuforia folder from the assets directory.
  2. Open player settings and uncheck Vuforia support from XR settings.
  3. Choose the remove files options.
  4. Then check the Vuforia support again.
  5. Choose Vuforia camera in your scene.
  6. Add the license key.
  7. That's it.