0

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

gowthy
  • 3
  • 2
  • 5
  • in your VuforiaConfiguration settings is "Disable Vuforia Play Mode" disabled and set to your desired Webcam? – Senbazuru Aug 07 '18 at 12:21
  • Yes, the option was disabled and set to my webcam but no luck... – gowthy Aug 07 '18 at 12:24
  • Do you get any errors from Unity? Is it able to aquire and start the camera? maybe some other process is currently accessing and blocking the camera? – Senbazuru Aug 07 '18 at 12:45
  • Thanks for your reply @Senbazuru , I'm not getting any errors. The scene loading is clean and no other process is accessing the camera. – gowthy Aug 07 '18 at 12:51
  • Just for my clarity, "custom/VideoBackground is not enabled" is this a gameobject, component or a property? Maybe you could provide a screenshot of the gameobject you're having trouble with? – Remy Aug 08 '18 at 06:51
  • Yes @remy_rm, I have added the pictures. Please see – gowthy Aug 08 '18 at 09:36
  • I see, you should be able to fix this by attaching a script to that gameobject that searches for the VideoMaterial component and sets the shader using `yourVideoMaterial.material.shader = Shader.find("Custom/VideoBackground")` more info you can find in the docs here https://docs.unity3d.com/ScriptReference/Material-shader.html . I currently don't have to time to write an elaborate/complete answer, but hope this will help you. – Remy Aug 08 '18 at 09:54
  • Thank you @remy_rm, that worked...In addition to that I found that we should add the shader in Edit->Project Settings->Graphics->Always Included Shaders->Add the shader – gowthy Aug 09 '18 at 09:29

2 Answers2

0

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"

Remy
  • 4,843
  • 5
  • 30
  • 60
0
  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.
Codemaker2015
  • 12,190
  • 6
  • 97
  • 81