ARCore Unity 将新游戏对象添加到导入的预制件

ARCore Unity adding a new gameobject to an imported prefabs

我在 https://www.youtube.com/watch?v=1cwm6sCcV_o&list=PLKIKuXdn4ZMhwJmPnYI0e7Ixv94ZFPvEP

使用本教程构建了一个 AR 门户

AR 门户运行良好。 但是现在,我想添加一个新的游戏对象(比如 Quad),它将充当横幅屏幕。我希望此横幅位于门户内。 我想将 WWW.LoadImagesintoTexture 脚本 (https://docs.unity3d.com/ScriptReference/WWW.LoadImageIntoTexture.html) 添加到此横幅并在其上渲染在线图像。

现在,我可以将在线图像放到横幅上,但是,一旦我进入门户,横幅就会消失。会是什么原因呢?我应该如何找到解决方案?

请注意:我们使用了 Unity 资产商店中的公园资产。

检查我正在使用的 OnlineIMage 脚本:

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

第一个猜测是 material/shader 被使用。 本教程要求每个 material 都有一个带有“_StencilTest”属性 的特殊着色器,它将根据设备是否在 'other world' 内进行切换。 如果对象通过测试,这将只允许绘制对象的像素。 还要确保门户脚本知道应该在转换时更改的 material。