Skip to main content

C# Assetbundle

using UnityEngine;
using System.Collections;
using System.Collections.Generic;

public class Assetbundle: MonoBehaviour {

public ArrayList mainobjectnames;
//~ public ArrayList mainobjects;
public GameObject gameobject;
public string LastmainAssetNames;
public GameObject astar;
public string wwwdir; //地址
public string lastlevel;
public WWW www;
public int i;
List<GameObject> mainobjects = new List<GameObject>();
// Use this for initialization
IEnumerator Start () {
mainobjectnames=new ArrayList();
mainobjectnames.Add ("bolimen.unity3d");
mainobjectnames.Add ("ChangeNot.unity3d");
mainobjectnames.Add ("ditan.unity3d");
mainobjectnames.Add ("haibao07.unity3d");
mainobjectnames.Add ("haibao7.unity3d");
mainobjectnames.Add ("haibao08.unity3d");
mainobjectnames.Add ("haibao8.unity3d");
mainobjectnames.Add ("haibao09.unity3d");
mainobjectnames.Add ("haibao10.unity3d");
mainobjectnames.Add ("haibao11.unity3d");
mainobjectnames.Add ("haibao12.unity3d");
mainobjectnames.Add ("qiang.unity3d");
mainobjectnames.Add ("shangpin00.unity3d");
mainobjectnames.Add ("shangpin01.unity3d");
mainobjectnames.Add ("shangpin02.unity3d");
mainobjectnames.Add ("shangpin03.unity3d");
mainobjectnames.Add ("shangpin04.unity3d");
mainobjectnames.Add ("shangpin05.unity3d");
mainobjectnames.Add ("shangpin06.unity3d");
mainobjectnames.Add ("shangpin07.unity3d");
mainobjectnames.Add ("shangpin08.unity3d");
mainobjectnames.Add ("shangpin09.unity3d");
mainobjectnames.Add ("shangpin10.unity3d");
mainobjectnames.Add ("shangpin11.unity3d");
mainobjectnames.Add ("shangpin12.unity3d");
mainobjectnames.Add ("shangpin13.unity3d");
mainobjectnames.Add ("shangpin14.unity3d");
mainobjectnames.Add ("shangpin15.unity3d");
mainobjectnames.Add ("shangpin16.unity3d");
mainobjectnames.Add ("shangpin17.unity3d");
mainobjectnames.Add ("shangpin18.unity3d");
mainobjectnames.Add ("shangpin19.unity3d");
mainobjectnames.Add ("shangpin20.unity3d");
mainobjectnames.Add ("yuandimian.unity3d");
mainobjectnames.Add ("zhongxinyuan.unity3d");

//~ mainobjects=new ArrayList();

for (i=0; i<mainobjectnames.Count; i++)
{
www=new WWW(wwwdir+mainobjectnames[i]);
yield return www;
gameobject=(GameObject)Instantiate(www.assetBundle.mainAsset);
//~ gameobject.AddComponent<Transform>();

mainobjects.Add(gameobject);
LastmainAssetNames=www.assetBundle.mainAsset.name;
// GameObject.Find("assetbundleloaded").GetComponent("assetbundleloaded").assetbundles.Push(www.assetBundle);
// mainobjects.Add(www.assetBundle);
};

GameObject pos = new GameObject ("pos");
pos.transform.position=new Vector3(0,0,0);
for (i=0; i<mainobjectnames.Count; i++)
{
mainobjects[i].transform.parent=pos.transform;
};
//pos.transform.localScale=Vector3(15,15,15);
pos.transform.position=transform.position;
pos.transform.rotation=transform.rotation;

}
// Update is called once per frame
void Update () {

}
~Assetbundle()
{
mainobjectnames.Clear();
}
}

本条目发布于2010年4月14日。属于Unity脚本分类。