unity-game-engineshadervuforiaassetbundlearcamera

vuforia ARCamera videobackground is black


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


Solution

  • 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
    }
    

    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"