using UnityEngine;
using System.Collections;
using System.IO;
using System;
using Object=UnityEngine.Object;
public class LoadABs : MonoBehaviour
{
public string path;
// Use this for initialization
IEnumerator Start ()
{
if(Application.platform == RuntimePlatform.WindowsWebPlayer)
{
path = Application.dataPath + “/ABs”;
}
else
{
path = Application.dataPath + “/…/ABs”;
}
System.Random r = new System.Random();
string[ ] files = Directory.GetFiles(path);
if (files.Length != 0)
{
foreach (string file in files)
{
Debug.Log(file);
WWW www = new WWW(“file://” + file);
yield return www;
if (www.isDone)
{
Object obj = www.assetBundle.mainAsset;
GameObject go = (GameObject)Instantiate(obj);
go.transform.position = new Vector3(r.Next(10), 0, r.Next(10));
Debug.Log(go.name);
}
}
}
}
}
I use the script to test, it works good in editor and exe version, however I build to webplayer, it can not work.
Why? Web need difference way?![]()
Any suggest is very grateful.