我使用创建了webGL Unity Project。 我有一个使用JSP,HTML和JavaScript的Web项目。
问题是: 如何在我的Web项目中调用我的统一功能?
using UnityEngine;
using System.Collections;
public class sourcedrag : MonoBehaviour {
public static sourcedrag _instance;
public string assetBundleURL;
public GameObject animation_;
// Use this for initialization
void Awake () {
string a = "";
setAssetBundle (a);
}
// Update is called once per frame
void Update () {
}
public void setAssetBundle (string url)
{
assetBundleURL = (url.Equals ("")) ? "put http link": url;
assatbundelcall ();
}
public void assatbundelcall()
{
string url = assetBundleURL;
Debug.Log (url);
WWW www = new WWW (url);
StartCoroutine (WaitForReq (www));
}
IEnumerator WaitForReq (WWW www)
{
yield return www;
AssetBundle bundle = www.assetBundle;
if (www.error == null)
{
animation_ = (GameObject)bundle.LoadAllAssets () [0];
animation_.AddComponent <ReApplyShaders> ();
Instantiate (animation_);
bundle.Unload (false);
}
else {
Debug.Log (www.error);
}
}
}
上面是我的代码,我需要从我的web项目中调用“setAssetBundle”方法。