天天看点

AR本地加载资源

AR本地加载资源

1,首先把之前的脚本复制一份,重新编写此脚本

AR本地加载资源

2,,这里写代码片

//找到  
    private void OnTrackingFound()
    {
        GameObject aixi = Instantiate(aixiPrefab,transform.position-new Vector3(0,-1.6f,0),transform.rotation);          
        aixi.transform.parent = this.transform;

        GameObject e1 = Instantiate(bloodPrefab1, transform.position, Quaternion.identity);
        e1.transform.parent = this.transform;
        Destroy(e1, 5f);
        GameObject e2 = Instantiate(bloodPrefab2, transform.position, Quaternion.identity);
        e2.transform.parent = this.transform;
        Destroy(e2, 5f);

    }
    //丢失识别图
    private void OnTrackingLost()
    {
        Destroy(GameObject.Find("aixi(Clone)"));
        Destroy(GameObject.Find("e1(Clone)"));
        Destroy(GameObject.Find("e2(Clone)"));

    }
           

3,制作阴影,添加一个renderTexture - 赋给相机- 添加一个3DPlane-把renderTexture- 赋给3DPlane-把相机改为SolidColor

AR本地加载资源
AR本地加载资源

4,改变物体的Layer层-使相机只照射到aixi层

AR本地加载资源
AR本地加载资源

继续阅读