当前进展
本周前几天我已经实现了如何把服务器上的资源进行下载解压,接下来还需要让app在解压路径下把图片和视频进行动态的绑定,可以参考第三周的那篇博客的做法:
ImageTargetManager.cs
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using EasyAR;
using System.IO;
public class ImageTargetManager : MonoBehaviour {
public GameObject videoPrefab;
// Use this for initialization
void Awake () {
string sArrangement = File.ReadAllText(UnityEngine.Application.persistentDataPath + "/TempFiles/arrangement.txt");
AssetsArrangementInfo dstInfo = JsonUtility.FromJson<AssetsArrangementInfo>(sArrangement);
for(int i = 0; i < dstInfo.targetList.Count; ++i)
{
GameObject videoPlayer = Instantiate(videoPrefab);
var ITbehaviour = videoPlayer.GetComponent<ImageTargetBehaviour>();
ITbehaviour.Path = UnityEngine.Application.persistentDataPath + "/TempFiles/" + dstInfo.targetList[i];
ITbehaviour.Storage = StorageType.Absolute;
ITbehaviour.Bind(GameObject.Find("ImageTracker").GetComponent<ImageTrackerBehaviour>());
var VPbehaviour = videoPlayer.transform.GetChild(0).GetComponent<VideoPlayerBehaviour>();
VPbehaviour.Path = UnityEngine.Application.persistentDataPath + "/TempFiles/" + dstInfo.srcList[i];
VPbehaviour.Storage = StorageType.Absolute;
VPbehaviour.VideoScaleMode = EasyAR.VideoPlayerBaseBehaviour.ScaleMode.Fill;
VPbehaviour.EnableAutoPlay = true;
VPbehaviour.EnableLoop = true;
VPbehaviour.OpenWhenStart = true;
VPbehaviour.VideoScaleFactorBase = 0.1f;
}
}
}
本文介绍了一种在增强现实(AR)应用中实现资源动态绑定的方法。通过Unity和EasyAR框架,该方案能够将服务器上下载并解压的图片及视频资源绑定到对应的AR目标上,实现了动态内容更新。
1513

被折叠的 条评论
为什么被折叠?



