I've built an AR Portal using this tutorial at https://www.youtube.com/watch?v=1cwm6sCcV_o&list=PLKIKuXdn4ZMhwJmPnYI0e7Ixv94ZFPvEP
The AR Portal is working fine. But now, I want to add a new gameObject (say a Quad) which will act as a banner screen. I want this banner to be inside the portal. I want to add WWW.LoadImagesintoTexture script (https://docs.unity3d.com/ScriptReference/WWW.LoadImageIntoTexture.html) to this banner and render online images onto it.
Right now, I am able to get online image onto the banner but, as soon as I enter the portal, the banner disappears. What would be the reason? And how should I find a solution to it?
Please note: We have used Park Assets from the Asset store on Unity.
Check the OnlineIMage Script that I'm using:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Rendering;
public class onlineimage : MonoBehaviour
{
public Material[] materials;
public string url = “https://docs.unity3d.com/uploads/Main/ShadowIntro.png“;
IEnumerator Start()
{
foreach (var mat in materials)
{
mat.SetInt (“_StencilTest”, (int)CompareFunction.NotEqual);
}
Texture2D tex;
tex = new Texture2D(4, 4, TextureFormat.DXT1, false);
using (WWW www = new WWW(url))
{
yield return www;
www.LoadImageIntoTexture(tex);
GetComponent<Renderer>().material.mainTexture = tex;
}
}
}
First guess would be the material/shader being used. This tutorial requires each material to have a special shader with a '_StencilTest' property that will toggle based on whether the device is inside the 'other world'. This will only allow the pixels of the objects to be drawn if they pass the test. also make sure the portal script knows about the material that should be changed on transition.