①重新创建一个工程文件夹,引入带有资源文件的游戏项目。
在unity的工作区间,重新创建一个endlessrunner06文件夹。
双击unity3d软件:
等待进度条完成
等待进度条完成
等待进度条完成
②将之前步骤利用assetbundle已经打包成.unity3d的文件夹和文件进行删除,后期利用云服务器下载即可。
③将一些重名的组件更改一下名字,后期好找到这些组件。
更改完以后记得save scene和save project。
④核心代码:从远程服务器找到用assetbundle打包的.unity3d文件。
在GamePlay文件夹创建c#文件myassets
右键
再按F2键,将c#文件名,改为:myassets
c#文件myassets的内容为:
using UnityEngine;
using System.Collections.Generic;
using System.Collections;
public class myassets : MonoBehaviour
{
void Start()
{
this.StartCoroutine(LoadAssetBundle());
}
IEnumerator LoadAssetBundle()
{
//string url = "http://127.0.0.1:9101/endlessrunnerassets/myassets15android.unity3d";
string url = "http://XX:XXX:XX:XXX:XX/endlessrunner02/endlessrunnerassets/myassets17android.unity3d";
//开始加载WWW
WWW www = WWW.LoadFromCacheOrDownload (url, 4);
Debug.Log ("**************");
//yield return www;
Debug.Log ("**********02");
//加载失败
if(www.error != null)
{
Debug.Log("Load Bundle Faile " + url + " Error Is " + www.error);
yield break;
}
AssetBundle bundle = www.assetBundle;
Object[] objs = bundle.LoadAll();
//Debug.Log(objs.Length);
for(int i =0;i< objs.Length;i++){
/*
if(objs[i].name.Equals("ColliderSpawn")){
Debug.Log("ColliderSpawn的index="+i);
}
if(objs[i].name.Equals("SpawnObj")){
Debug.Log("SpawnObj的index="+i);
}
if(objs[i].name.Equals("coin")){
Debug.Log("coin的index="+i);
}
if(objs[i].name.Equals("slide")){
Debug.Log("slide的index="+i);
}
if(objs[i].name.Equals("hit")){
Debug.Log("hit的index="+i);
}
if(objs[i].name.Equals("getitem")){
Debug.Log("getitem的index="+i);
}
*/
if(objs[i].name.Equals("bgm - Bounce_It")){
Debug.Log("bgm - Bounce_It的index="+i);
}
/*
if(objs[i].name.Equals("Run")){
Debug.Log("Run的index="+i);
}
if(objs[i].name.Equals("TurnLeft")){
Debug.Log("TurnLeft的index="+i);
}
if(objs[i].name.Equals("TurnRight")){
Debug.Log("TurnRight的index="+i);
}
if(objs[i].name.Equals("JumpUp")){
Debug.Log("JumpUp的index="+i);
}
if(objs[i].name.Equals("JumpDown")){
Debug.Log("JumpDown的index="+i);
}
if(objs[i].name.Equals("JumpLoop")){
Debug.Log("JumpLoop的index="+i);
}
if(objs[i].name.Equals("Roll")){
Debug.Log("Roll的index="+i);
}
if(objs[i].name.Equals("Dead")){
Debug.Log("Dead的index="+i);
}
*/
//Debug.Log(objs[i].name);
}
DestroyImmediate (GameObject.Find ("SettingMaterial").GetComponent<SettingMaterial> (), true);
GameObject.Find("SettingMaterial").AddComponent<SettingMaterial>();
Material material0 = bundle.Load("Board" ,typeof (Material)) as Material;
//Instantiate(material0);
GameObject.Find("SettingMaterial").GetComponent<SettingMaterial>().materials[0]=material0;
Material material1 = bundle.Load("Car_Texture" ,typeof (Material)) as Material;
//Instantiate(material1);
GameObject.Find("SettingMaterial").GetComponent<SettingMaterial>().materials[1]=material1;
Material material2 = bundle.Load("CoinTexture" ,typeof (Material)) as Material;
//Instantiate(material2);
GameObject.Find("SettingMaterial").GetComponent<SettingMaterial>().materials[2]=material2;
Material material3 = bundle.Load("Gave" ,typeof (Material)) as Material;
//Instantiate(material3);
GameObject.Find("SettingMaterial").GetComponent<SettingMaterial>().materials[3]=material3;
Material material4 = bundle.Load("Road" ,typeof (Material)) as Material;
Instantiate(material4);
GameObject.Find("SettingMaterial").GetComponent<SettingMaterial>().materials[4]=material4;
Material material5 = bundle.Load("Store" ,typeof (Material)) as Material;
//Instantiate(material5);
GameObject.Find("SettingMaterial").GetComponent<SettingMaterial>().materials[5]=material5;
Material material6 = bundle.Load("TheCube_Jump" ,typeof (Material)) as Material;
//Instantiate(material6);
GameObject.Find("SettingMaterial").GetComponent<SettingMaterial>().materials[6]=material6;
Material material7 = bundle.Load("TheCube_Magnet" ,typeof (Material)) as Material;
//Instantiate(material7);
GameObject.Find("SettingMaterial").GetComponent<SettingMaterial>().materials[7]=material7;
Material material8 = bundle.Load("TheCube_Multiply" ,typeof (Material)) as Material;
//Instantiate(material8);
GameObject.Find("SettingMaterial").GetComponent<SettingMaterial>().materials[8]=material8;
Material material9 = bundle.Load("TheCube_Run" ,typeof (Material)) as Material;
//Instantiate(material9);
GameObject.Find("SettingMaterial").GetComponent<SettingMaterial>().materials[9]=material9;
Material material10 = bundle.Load("Tx_modelB001" ,typeof (Material)) as Material;
//Instantiate(material10);
GameObject.Find("SettingMaterial").GetComponent<SettingMaterial>().materials[10]=material10;
Material material11 = bundle.Load("Tx_modelB001-2" ,typeof (Material)) as Material;
//Instantiate(material11);
GameObject.Find("SettingMaterial").GetComponent<SettingMaterial>().materials[11]=material11;
Material material12 = bundle.Load("Tx_modelB001-3" ,typeof (Material)) as Material;
//Instantiate(material12);
GameObject.Find("SettingMaterial").GetComponent<SettingMaterial>().materials[12]=material12;
Material material13 = bundle.Load("Tx_modelB001-4" ,typeof (Material)) as Material;
//Instantiate(material13);
GameObject.Find("SettingMaterial").GetComponent<SettingMaterial>().materials[13]=material13;
Material material14 = bundle.Load("Tx_modelB001-5" ,typeof (Material)) as Material;
//Instantiate(material14);
GameObject.Find("SettingMaterial").GetComponent<SettingMaterial>().materials[14]=material14;
Material material15 = bundle.Load("Tx_modelB001-6" ,typeof (Material)) as Material;
//Instantiate(material15);
GameObject.Find("SettingMaterial").GetComponent<SettingMaterial>().materials[15]=material15;
Material material16 = bundle.Load("Tx_tunnel_1" ,typeof (Material)) as Material;
//Instantiate(material16);
GameObject.Find("SettingMaterial").GetComponent<SettingMaterial>().materials[16]=material16;
Material material17 = bundle.Load("Tx_tunnel_2" ,typeof (Material)) as Material;
//Instantiate(material17);
GameObject.Find("SettingMaterial").GetComponent<SettingMaterial>().materials[17]=material17;
Material material18 = bundle.Load("Tx_tunnel_Long" ,typeof (Material)) as Material;
//Instantiate(material18);
GameObject.Find("SettingMaterial").GetComponent<SettingMaterial>().materials[18]=material18;
Material material19 = bundle.Load("Tx_BoardUp" ,typeof (Material)) as Material;
//Instantiate(material19);
GameObject.Find("SettingMaterial").GetComponent<SettingMaterial>().materials[19]=material19;
Material material20 = bundle.Load("Tx_Buss" ,typeof (Material)) as Material;
//Instantiate(material20);
GameObject.Find("SettingMaterial").GetComponent<SettingMaterial>().materials[20]=material20;
Material material21 = bundle.Load("Tx_Bridge" ,typeof (Material)) as Material;
//Instantiate(material21);
GameObject.Find("SettingMaterial").GetComponent<SettingMaterial>().materials[21]=material21;
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
GameObject floorPref = bundle.Load("Floor" ,typeof (GameObject)) as GameObject;
//Instantiate(floorPref);
GameObject.Find("PatternSystemManager").GetComponent<PatternSystem>().floor_Pref = floorPref;
GameObject model01 = bundle.Load ("modelB1-1",typeof(GameObject)) as GameObject;
//Instantiate (model01);
//Debug.Log (model01.name);
//GameObject modelB01 = model01.transform.Find("modelB001").gameObject;
//model01.transform.Find ("modelB001").gameObject;
//Instantiate (modelB01);
//Debug.Log (modelB01.name);
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
GameObject gameObject0 = bundle.Load ("Building_1" ,typeof (GameObject)) as GameObject;
Debug.Log ("============"+gameObject0.name);
//Instantiate(gameObject0);
GameObject.Find("PatternSystemManager").GetComponent<PatternSystem>().building_Pref[0]=gameObject0;
DestroyImmediate(gameObject0.GetComponent<Building>(),true);
gameObject0.AddComponent<Building>();
GameObject gameObject1 = bundle.Load("Building_2" ,typeof (GameObject)) as GameObject;
//Instantiate(gameObject1);
GameObject.Find("PatternSystemManager").GetComponent<PatternSystem>().building_Pref[1]=gameObject1;
DestroyImmediate(gameObject1.GetComponent<Building>(),true);
gameObject1.AddComponent<Building>();
GameObject gameObject2 = bundle.Load("Building_3" ,typeof (GameObject)) as GameObject;
//Instantiate(gameObject2);
GameObject.Find("PatternSystemManager").GetComponent<PatternSystem>().building_Pref[2]=gameObject2;
DestroyImmediate(gameObject2.GetComponent<Building>(),true);
gameObject2.AddComponent<Building>();
GameObject gameObject3 = bundle.Load("Building_4" ,typeof (GameObject)) as GameObject;
//Instantiate(gameObject3);
GameObject.Find("PatternSystemManager").GetComponent<PatternSystem>().building_Pref[3]=gameObject3;
DestroyImmediate(gameObject3.GetComponent<Building>(),true);
gameObject3.AddComponent<Building>();
GameObject gameObject4 = bundle.Load("Building_5" ,typeof (GameObject)) as GameObject;
//Instantiate(gameObject4);
GameObject.Find("PatternSystemManager").GetComponent<PatternSystem>().building_Pref[4]=gameObject4;
DestroyImmediate(gameObject4.GetComponent<Building>(),true);
gameObject4.AddComponent<Building>();
GameObject gameObject5 = bundle.Load("Building_6" ,typeof (GameObject)) as GameObject;
//Instantiate(gameObject5);
GameObject.Find("PatternSystemManager").GetComponent<PatternSystem>().building_Pref[5]=gameObject5;
DestroyImmediate(gameObject5.GetComponent<Building>(),true);
gameObject5.AddComponent<Building>();
GameObject gameObject6 = bundle.Load("Building_7" ,typeof (GameObject)) as GameObject;
//Instantiate(gameObject6);
GameObject.Find("PatternSystemManager").GetComponent<PatternSystem>().building_Pref[6]=gameObject6;
DestroyImmediate(gameObject6.GetComponent<Building>(),true);
gameObject6.AddComponent<Building>();
GameObject gameObject7 = bundle.Load("Building_8" ,typeof (GameObject)) as GameObject;
//Instantiate(gameObject7);
GameObject.Find("PatternSystemManager").GetComponent<PatternSystem>().building_Pref[7]=gameObject7;
DestroyImmediate(gameObject7.GetComponent<Building>(),true);
gameObject7.AddComponent<Building>();
GameObject gameObject8 = bundle.Load("Building_9" ,typeof (GameObject)) as GameObject;
//Instantiate(gameObject8);
GameObject.Find("PatternSystemManager").GetComponent<PatternSystem>().building_Pref[8]=gameObject8;
DestroyImmediate(gameObject8.GetComponent<Building>(),true);
gameObject8.AddComponent<Building>();
GameObject gameObject9 = bundle.Load("Building_10" ,typeof (GameObject)) as GameObject;
//Instantiate(gameObject9);
GameObject.Find("PatternSystemManager").GetComponent<PatternSystem>().building_Pref[9]=gameObject9;
DestroyImmediate(gameObject9.GetComponent<Building>(),true);
gameObject9.AddComponent<Building>();
GameObject gameObject10 = bundle.Load("Building_11" ,typeof (GameObject)) as GameObject;
//Instantiate(gameObject10);
GameObject.Find("PatternSystemManager").GetComponent<PatternSystem>().building_Pref[10]=gameObject10;
DestroyImmediate(gameObject10.GetComponent<Building>(),true);
gameObject10.AddComponent<Building>();
GameObject gameObject11 = bundle.Load("Building_12" ,typeof (GameObject)) as GameObject;
//Instantiate(gameObject11);
GameObject.Find("PatternSystemManager").GetComponent<PatternSystem>().building_Pref[11]=gameObject11;
DestroyImmediate(gameObject11.GetComponent<Building>(),true);
gameObject11.AddComponent<Building>();
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
GameObject itemPref0 = bundle.Load("Barrier" ,typeof (GameObject)) as GameObject;
//Instantiate(itemPref0);
GameObject.Find("PatternSystemManager").GetComponent<PatternSystem>().item_Pref[0]=itemPref0;
DestroyImmediate(itemPref0.GetComponent<Item>(),true);
itemPref0.AddComponent<Item>();
itemPref0.GetComponent<Item> ().scoreAdd = 0;
itemPref0.GetComponent<Item> ().decreaseLife = 1;
itemPref0.GetComponent<Item> ().speedMove = 0;
itemPref0.GetComponent<Item> ().duration = 0;
itemPref0.GetComponent<Item> ().itemEffectValue = 0;
itemPref0.GetComponent<Item> ().typeItem = Item.TypeItem.Obstacle;
GameObject itemPref1 = bundle.Load("Car" ,typeof (GameObject)) as GameObject;
//Instantiate(itemPref1);
GameObject.Find("PatternSystemManager").GetComponent<PatternSystem>().item_Pref[1]=itemPref1;
DestroyImmediate(itemPref1.GetComponent<Item>(),true);
itemPref1.AddComponent<Item>();
itemPref1.GetComponent<Item> ().scoreAdd = 0;
itemPref1.GetComponent<Item> ().decreaseLife = 1;
itemPref1.GetComponent<Item> ().speedMove = 0;
itemPref1.GetComponent<Item> ().duration = 0;
itemPref1.GetComponent<Item> ().itemEffectValue = 0;
itemPref1.GetComponent<Item> ().typeItem = Item.TypeItem.Obstacle;
GameObject itemPref2 = bundle.Load("Coin02" ,typeof (GameObject)) as GameObject;
//Instantiate (itemPref2);
GameObject Cylinder = itemPref2.transform.Find ("Cylinder").gameObject;
DestroyImmediate (Cylinder.GetComponent<ItemRotate>(),true);
Cylinder .AddComponent<ItemRotate> ();
GameObject.Find("PatternSystemManager").GetComponent<PatternSystem>().item_Pref[2]=itemPref2;
DestroyImmediate(itemPref2.GetComponent<Item>(),true);
itemPref2.AddComponent<Item>();
itemPref2.GetComponent<Item> ().scoreAdd = 1;
itemPref2.GetComponent<Item> ().decreaseLife = 0;
itemPref2.GetComponent<Item> ().speedMove = 0;
itemPref2.GetComponent<Item> ().duration = 0;
itemPref2.GetComponent<Item> ().itemEffectValue = 0;
itemPref2.GetComponent<Item> ().itemRotate = Cylinder.GetComponent<ItemRotate>();
GameObject coinCollectFlash = bundle.Load ("CoinCollectFlash",typeof (GameObject)) as GameObject;
DestroyImmediate(coinCollectFlash.GetComponent<DestroyEffect>(),true);
coinCollectFlash.AddComponent<DestroyEffect>();
coinCollectFlash.GetComponent<DestroyEffect> ().time = 0.7f;
itemPref2.GetComponent<Item> ().effectHit = coinCollectFlash;
itemPref2.GetComponent<Item> ().typeItem = Item.TypeItem.Coin;
GameObject itemPref3 = bundle.Load("Grave" ,typeof (GameObject)) as GameObject;
//Instantiate(itemPref3);
GameObject.Find("PatternSystemManager").GetComponent<PatternSystem>().item_Pref[3]=itemPref3;
DestroyImmediate(itemPref3.GetComponent<Item>(),true);
itemPref3.AddComponent<Item>();
itemPref3.GetComponent<Item> ().decreaseLife = 1;
itemPref3.GetComponent<Item> ().typeItem = Item.TypeItem.Obstacle;
GameObject itemPref4 = bundle.Load("Item_Jump" ,typeof (GameObject)) as GameObject;
//Instantiate(itemPref4);
GameObject.Find("PatternSystemManager").GetComponent<PatternSystem>().item_Pref[4]=itemPref4;
DestroyImmediate(itemPref4.GetComponent<Item>(),true);
itemPref4.AddComponent<Item>();
itemPref4.GetComponent<Item> ().scoreAdd = 2;
itemPref2.GetComponent<Item> ().decreaseLife = 1;
itemPref2.GetComponent<Item> ().speedMove = 0;
itemPref2.GetComponent<Item> ().duration = 15;
itemPref2.GetComponent<Item> ().itemEffectValue = 0;
GameObject theCube_Shoe = bundle.Load ("TheCube_Shoe",typeof(GameObject)) as GameObject;
DestroyImmediate(theCube_Shoe.GetComponent<DestroyEffect>(),true);
theCube_Shoe.AddComponent<DestroyEffect>();
theCube_Shoe.GetComponent<DestroyEffect> ().time = 0.8f;
itemPref4.GetComponent<Item> ().effectHit = theCube_Shoe;
itemPref4.GetComponent<Item> ().typeItem = Item.TypeItem.ItemJump;
GameObject itemPref5 = bundle.Load("Item_Magnet" ,typeof (GameObject)) as GameObject;
//Instantiate(itemPref5);
GameObject.Find("PatternSystemManager").GetComponent<PatternSystem>().item_Pref[5]=itemPref5;
DestroyImmediate (itemPref5.GetComponent<Item>(),true);
itemPref5.AddComponent<Item>();
itemPref5.GetComponent<Item> ().scoreAdd = 0;
itemPref5.GetComponent<Item> ().decreaseLife = 1;
itemPref5.GetComponent<Item> ().speedMove = 0;
itemPref5.GetComponent<Item> ().duration = 10;
itemPref5.GetComponent<Item> ().itemEffectValue = 0;
GameObject theCube_Magnet = bundle.Load ("TheCube_Magnet",typeof(GameObject)) as GameObject;
DestroyImmediate(theCube_Magnet.GetComponent<DestroyEffect>(),true);
theCube_Magnet.AddComponent<DestroyEffect>();
theCube_Magnet.GetComponent<DestroyEffect> ().time = 0.8f;
itemPref5.GetComponent<Item> ().effectHit = theCube_Magnet;
itemPref5.GetComponent<Item> ().typeItem = Item.TypeItem.ItemMagnet;
GameObject itemPref6 = bundle.Load("Item_Sprint" ,typeof (GameObject)) as GameObject;
//Instantiate(itemPref6);
GameObject.Find("PatternSystemManager").GetComponent<PatternSystem>().item_Pref[6]=itemPref6;
DestroyImmediate (itemPref6.GetComponent<Item>(),true);
itemPref6.AddComponent<Item>();
itemPref6.GetComponent<Item> ().scoreAdd = 0;
itemPref6.GetComponent<Item> ().decreaseLife = 1;
itemPref6.GetComponent<Item> ().speedMove = 0;
itemPref6.GetComponent<Item> ().duration = 5;
itemPref6.GetComponent<Item> ().itemEffectValue = 20;
GameObject theCube_Star = bundle.Load ("TheCube_Star",typeof(GameObject)) as GameObject;
DestroyImmediate(theCube_Star.GetComponent<DestroyEffect>(),true);
theCube_Star.AddComponent<DestroyEffect>();
theCube_Star.GetComponent<DestroyEffect> ().time = 0.8f;
itemPref6.GetComponent<Item> ().effectHit = theCube_Star;
itemPref6.GetComponent<Item> ().typeItem=Item.TypeItem.ItemSprint;
GameObject itemPref7 = bundle.Load("Obstacle_Roll" ,typeof (GameObject)) as GameObject;
//Instantiate(itemPref7);
GameObject.Find("PatternSystemManager").GetComponent<PatternSystem>().item_Pref[7]=itemPref7;
DestroyImmediate (itemPref7.GetComponent<Item>(),true);
itemPref7.AddComponent<Item>();
itemPref7.GetComponent<Item> ().scoreAdd = 0;
itemPref7.GetComponent<Item> ().decreaseLife = 1;
itemPref7.GetComponent<Item> ().speedMove = 0;
itemPref7.GetComponent<Item> ().duration = 0;
itemPref7.GetComponent<Item> ().itemEffectValue = 0;
itemPref7.GetComponent<Item> ().typeItem=Item.TypeItem.Obstacle_Roll;
GameObject itemPref8 = bundle.Load("Item_Multiply" ,typeof (GameObject)) as GameObject;
//Instantiate(itemPref8);
GameObject.Find("PatternSystemManager").GetComponent<PatternSystem>().item_Pref[8]=itemPref8;
DestroyImmediate (itemPref8.GetComponent<Item>(),true);
itemPref8.AddComponent<Item>();
itemPref8.GetComponent<Item> ().scoreAdd = 0;
itemPref8.GetComponent<Item> ().decreaseLife = 1;
itemPref8.GetComponent<Item> ().speedMove = 0;
itemPref8.GetComponent<Item> ().duration = 15;
itemPref8.GetComponent<Item> ().itemEffectValue = 2;
GameObject theCube_Double = bundle.Load ("TheCube_Double",typeof(GameObject)) as GameObject;
DestroyImmediate(theCube_Double.GetComponent<DestroyEffect>(),true);
theCube_Double.AddComponent<DestroyEffect>();
theCube_Double.GetComponent<DestroyEffect> ().time = 0.8f;
itemPref8.GetComponent<Item> ().effectHit = theCube_Double;
itemPref8.GetComponent<Item>().typeItem=Item.TypeItem.ItemMultiply;
GameObject itemPref9 = bundle.Load("Bus" ,typeof (GameObject)) as GameObject;
//Instantiate(itemPref9);
GameObject.Find("PatternSystemManager").GetComponent<PatternSystem>().item_Pref[9]=itemPref9;
DestroyImmediate (itemPref9.GetComponent<Item>(),true);
itemPref9.AddComponent<Item>();
itemPref9.GetComponent<Item> ().scoreAdd = 0;
itemPref9.GetComponent<Item> ().decreaseLife = 1;
itemPref9.GetComponent<Item> ().speedMove = 0;
itemPref9.GetComponent<Item> ().duration = 0;
itemPref9.GetComponent<Item> ().itemEffectValue = 0;
itemPref8.GetComponent<Item>().typeItem=Item.TypeItem.Obstacle;
GameObject itemPref10 = bundle.Load("BoardUp_Short" ,typeof (GameObject)) as GameObject;
//Instantiate(itemPref10);
GameObject.Find("PatternSystemManager").GetComponent<PatternSystem>().item_Pref[10]=itemPref10;
DestroyImmediate (itemPref10.GetComponent<Item>(),true);
itemPref10.AddComponent<Item>();
itemPref10.GetComponent<Item> ().scoreAdd = 0;
itemPref10.GetComponent<Item> ().decreaseLife = 1;
itemPref10.GetComponent<Item> ().speedMove = 0;
itemPref10.GetComponent<Item> ().duration = 0;
itemPref10.GetComponent<Item> ().itemEffectValue = 0;
GameObject itemPref11 = bundle.Load("BoardUp_Long" ,typeof (GameObject)) as GameObject;
//Instantiate(itemPref11);
GameObject.Find("PatternSystemManager").GetComponent<PatternSystem>().item_Pref[11]=itemPref11;
DestroyImmediate (itemPref11.GetComponent<Item>(),true);
itemPref11.AddComponent<Item>();
itemPref11.GetComponent<Item> ().scoreAdd = 0;
itemPref11.GetComponent<Item> ().decreaseLife = 1;
itemPref11.GetComponent<Item> ().speedMove = 0;
itemPref11.GetComponent<Item> ().duration = 0;
itemPref11.GetComponent<Item> ().itemEffectValue = 0;
GameObject itemPref12 = bundle.Load("ItemTest" ,typeof (GameObject)) as GameObject;
//Instantiate(itemPref12);
GameObject.Find("PatternSystemManager").GetComponent<PatternSystem>().item_Pref[12]=itemPref12;
DestroyImmediate (itemPref12.GetComponent<Item>(),true);
itemPref12.AddComponent<Item>();
itemPref12.GetComponent<Item> ().scoreAdd = 0;
itemPref12.GetComponent<Item> ().decreaseLife = 0;
itemPref12.GetComponent<Item> ().speedMove = 0;
itemPref12.GetComponent<Item> ().duration = 0;
itemPref12.GetComponent<Item> ().itemEffectValue = 0;
GameObject itemPref13 = bundle.Load("ItemTest_2" ,typeof (GameObject)) as GameObject;
//Instantiate(itemPref13);
GameObject.Find("PatternSystemManager").GetComponent<PatternSystem>().item_Pref[13]=itemPref13;
DestroyImmediate (itemPref13.GetComponent<Item>(),true);
itemPref13.AddComponent<Item>();
itemPref13.GetComponent<Item> ().scoreAdd = 0;
itemPref13.GetComponent<Item> ().decreaseLife = 0;
itemPref13.GetComponent<Item> ().speedMove = 0;
itemPref13.GetComponent<Item> ().duration = 0;
itemPref13.GetComponent<Item> ().itemEffectValue = 0;
GameObject itemPref14 = bundle.Load("Tunnel_Long" ,typeof (GameObject)) as GameObject;
//Instantiate(itemPref14);
GameObject.Find("PatternSystemManager").GetComponent<PatternSystem>().item_Pref[14]=itemPref14;
DestroyImmediate (itemPref14.GetComponent<Item>(),true);
itemPref14.AddComponent<Item>();
itemPref14.GetComponent<Item> ().scoreAdd = 0;
itemPref14.GetComponent<Item> ().decreaseLife = 1;
itemPref14.GetComponent<Item> ().speedMove = 0;
itemPref14.GetComponent<Item> ().duration = 0;
itemPref14.GetComponent<Item> ().itemEffectValue = 0;
GameObject itemPref15 = bundle.Load("Tunnel_L" ,typeof (GameObject)) as GameObject;
//Instantiate(itemPref15);
GameObject.Find("PatternSystemManager").GetComponent<PatternSystem>().item_Pref[15]=itemPref15;
DestroyImmediate (itemPref15.GetComponent<Item>(),true);
itemPref15.AddComponent<Item>();
itemPref15.GetComponent<Item> ().scoreAdd = 0;
itemPref15.GetComponent<Item> ().decreaseLife = 1;
itemPref15.GetComponent<Item> ().speedMove = 0;
itemPref15.GetComponent<Item> ().duration = 0;
itemPref15.GetComponent<Item> ().itemEffectValue = 0;
itemPref15.GetComponent<Item> ().typeItem = Item.TypeItem.Obstacle;
GameObject itemPref16 = bundle.Load("Bridge" ,typeof (GameObject)) as GameObject;
//Instantiate(itemPref16);
GameObject.Find("PatternSystemManager").GetComponent<PatternSystem>().item_Pref[16]=itemPref16;
DestroyImmediate (itemPref16.GetComponent<Item>(),true);
itemPref16.AddComponent<Item>();
itemPref16.GetComponent<Item> ().scoreAdd = 0;
itemPref16.GetComponent<Item> ().decreaseLife = 0;
itemPref16.GetComponent<Item> ().speedMove = 0;
itemPref16.GetComponent<Item> ().duration = 0;
itemPref16.GetComponent<Item> ().itemEffectValue = 0;
GameObject itemPref17 = bundle.Load("Bus_Moving" ,typeof (GameObject)) as GameObject;
//Instantiate(itemPref17);
GameObject.Find("PatternSystemManager").GetComponent<PatternSystem>().item_Pref[17]=itemPref17;
DestroyImmediate (itemPref17.GetComponent<Item>(),true);
itemPref17.AddComponent<Item>();
itemPref17.GetComponent<Item> ().scoreAdd = 0;
itemPref17.GetComponent<Item> ().decreaseLife = 1;
itemPref17.GetComponent<Item> ().speedMove = 8;
itemPref17.GetComponent<Item> ().duration = 0;
itemPref17.GetComponent<Item> ().itemEffectValue = 0;
itemPref17.GetComponent<Item> ().typeItem = Item.TypeItem.Moving_Obstacle;
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
GameObject spawnobjPref = bundle.Load("SpawnObj" ,typeof (GameObject)) as GameObject;
//Instantiate(spawnobjPref);
GameObject.Find("PatternSystemManager").GetComponent<PatternSystem>().spawnObj_Pref = spawnobjPref;
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
GameObject player01 = bundle.Load("Player" ,typeof (GameObject)) as GameObject;
GameObject.Find("GameController").GetComponent<GameController>().playerPref[0] = player01;
DestroyImmediate(player01.GetComponent<Controller>(),true);
DestroyImmediate(player01.GetComponent<AnimationManager>(),true);
player01.AddComponent<AnimationManager>();
player01.GetComponent<AnimationManager > ().run.animation=(AnimationClip)objs[310];
player01.GetComponent<AnimationManager> ().run.speedAnimation = 1.5f;
player01.GetComponent<AnimationManager> ().turnLeft.animation = (AnimationClip)objs[311];
player01.GetComponent<AnimationManager> ().turnLeft.speedAnimation = 1.25f;
player01.GetComponent<AnimationManager> ().turnRight.animation = (AnimationClip)objs[312];
player01.GetComponent<AnimationManager> ().turnRight.speedAnimation = 1.25f;
player01.GetComponent<AnimationManager> ().jumpUp.animation = (AnimationClip)objs[308];
player01.GetComponent<AnimationManager> ().jumpUp.speedAnimation = 1.0f;
player01.GetComponent<AnimationManager> ().jumpLoop.animation = (AnimationClip)objs[307];
player01.GetComponent<AnimationManager> ().jumpLoop.speedAnimation = 1.0f;
player01.GetComponent<AnimationManager> ().jumpDown.animation = (AnimationClip)objs[306];
player01.GetComponent<AnimationManager> ().jumpDown.speedAnimation = 1.0f;
player01.GetComponent<AnimationManager> ().roll.animation = (AnimationClip)objs[309];
player01.GetComponent<AnimationManager> ().roll.speedAnimation = 1.0f;
player01.GetComponent<AnimationManager> ().dead.animation = (AnimationClip)objs[132];
player01.GetComponent<AnimationManager> ().dead.speedAnimation = 1.0f;
player01.AddComponent<Controller>();
GameObject get_Item_For_Delete = player01.transform.Find ("Get_Item_For_Delete").gameObject;
GameObject magnetCollision = player01.transform.Find ("MagnetCollision").gameObject;
DestroyImmediate(magnetCollision.GetComponent<Magnet>(),true);
magnetCollision.AddComponent<Magnet>();
DestroyImmediate(get_Item_For_Delete.GetComponent<CoinRotation>(),true);
get_Item_For_Delete.AddComponent<CoinRotation>();
player01.GetComponent<Controller>().coinRotate = get_Item_For_Delete.GetComponent<CoinRotation>();
player01.GetComponent<Controller> ().magnet = magnetCollision;
player01.GetComponent<Controller> ().speedMove = 5;
player01.GetComponent<Controller> ().gravity = 20;
player01.GetComponent<Controller> ().jumpValue = 7;
player01.GetComponent<Controller> ().keyInput = true;
player01.GetComponent<Controller> ().touchInput = true;
GameObject colliderSpawn = spawnobjPref.transform.Find ("ColliderSpawn").gameObject;
DestroyImmediate (colliderSpawn.GetComponent<ColliderSpawnCheck> (), true);
colliderSpawn.AddComponent<ColliderSpawnCheck>();
colliderSpawn.GetComponent<ColliderSpawnCheck> ().nameColliderHit = player01.name;
colliderSpawn.GetComponent<ColliderSpawnCheck> ().checkByName = true;
colliderSpawn.GetComponent<ColliderSpawnCheck> ().checkByTag = true;
///////////////////////////////////////////////////////////////////////////////////////////////////////
GameObject player02 = bundle.Load("Player_2" ,typeof (GameObject)) as GameObject;
GameObject.Find("GameController").GetComponent<GameController>().playerPref[1] = player02;
DestroyImmediate(player02.GetComponent<Controller>(),true);
DestroyImmediate(player02.GetComponent<AnimationManager>(),true);
player02.AddComponent<AnimationManager>();
player02.GetComponent<AnimationManager > ().run.animation=(AnimationClip)objs[310];
player02.GetComponent<AnimationManager> ().run.speedAnimation = 1.5f;
player02.GetComponent<AnimationManager> ().turnLeft.animation = (AnimationClip)objs[311];
player02.GetComponent<AnimationManager> ().turnLeft.speedAnimation = 1.25f;
player02.GetComponent<AnimationManager> ().turnRight.animation = (AnimationClip)objs[312];
player02.GetComponent<AnimationManager> ().turnRight.speedAnimation = 1.25f;
player02.GetComponent<AnimationManager> ().jumpUp.animation = (AnimationClip)objs[308];
player02.GetComponent<AnimationManager> ().jumpUp.speedAnimation = 1.0f;
player02.GetComponent<AnimationManager> ().jumpLoop.animation = (AnimationClip)objs[307];
player02.GetComponent<AnimationManager> ().jumpLoop.speedAnimation = 1.0f;
player02.GetComponent<AnimationManager> ().jumpDown.animation = (AnimationClip)objs[306];
player02.GetComponent<AnimationManager> ().jumpDown.speedAnimation = 1.0f;
player02.GetComponent<AnimationManager> ().roll.animation = (AnimationClip)objs[309];
player02.GetComponent<AnimationManager> ().roll.speedAnimation = 1.0f;
player02.GetComponent<AnimationManager> ().dead.animation = (AnimationClip)objs[132];
player02.GetComponent<AnimationManager> ().dead.speedAnimation = 1.0f;
player02.AddComponent<Controller>();
GameObject get_Item_For_Delete02 = player02.transform.Find ("Get_Item_For_Delete").gameObject;
GameObject magnetCollision02 = player02.transform.Find ("MagnetCollision").gameObject;
DestroyImmediate(magnetCollision02.GetComponent<Magnet>(),true);
magnetCollision02.AddComponent<Magnet>();
DestroyImmediate(get_Item_For_Delete02.GetComponent<CoinRotation>(),true);
get_Item_For_Delete02.AddComponent<CoinRotation>();
player02.GetComponent<Controller>().coinRotate = get_Item_For_Delete02.GetComponent<CoinRotation>();
player02.GetComponent<Controller> ().magnet = magnetCollision02;
player02.GetComponent<Controller> ().speedMove = 5;
player02.GetComponent<Controller> ().gravity = 20;
player02.GetComponent<Controller> ().jumpValue = 7;
player02.GetComponent<Controller> ().keyInput = true;
player02.GetComponent<Controller> ().touchInput = true;
////////////////////////////////////////////////////////////////////////////////////////////////////////////
DestroyImmediate (GameObject.Find ("Building01").GetComponent<MeshFilter> (), true);
GameObject.Find ("Building01").AddComponent<MeshFilter> ().mesh = (Mesh)objs[152];
DestroyImmediate (GameObject.Find("Building01").GetComponent<MeshRenderer>(),true);
GameObject.Find ("Building01").AddComponent<MeshRenderer> ();
GameObject.Find ("Building01").GetComponent<MeshRenderer> ().materials [0].CopyPropertiesFromMaterial(material11);
GameObject.Find ("Building01").GetComponent<MeshRenderer> ().materials [0].shader=
(Shader)Resources.LoadAssetAtPath("Assets/Endless Run/Shader/Curved.shader",typeof(Shader));
GameObject.Find ("Building01").GetComponent<MeshRenderer> ().materials [0].name =material11.name;
GameObject.Find ("Building01").GetComponent<MeshRenderer> ().castShadows = true;
GameObject.Find ("Building01").GetComponent<MeshRenderer> ().receiveShadows = true;
DestroyImmediate (GameObject.Find ("Building02").GetComponent<MeshFilter> (), true);
GameObject.Find ("Building02").AddComponent<MeshFilter> ().mesh = (Mesh)objs[152];
DestroyImmediate (GameObject.Find("Building02").GetComponent<MeshRenderer>(),true);
GameObject.Find ("Building02").AddComponent<MeshRenderer> ();
GameObject.Find ("Building02").GetComponent<MeshRenderer> ().materials [0].CopyPropertiesFromMaterial(material11);
GameObject.Find ("Building02").GetComponent<MeshRenderer> ().materials [0].shader=
(Shader)Resources.LoadAssetAtPath("Assets/Endless Run/Shader/Curved.shader",typeof(Shader));
GameObject.Find ("Building02").GetComponent<MeshRenderer> ().materials [0].name =material11.name;
GameObject.Find ("Building02").GetComponent<MeshRenderer> ().castShadows = true;
GameObject.Find ("Building02").GetComponent<MeshRenderer> ().receiveShadows = true;
DestroyImmediate (GameObject.Find ("Building03").GetComponent<MeshFilter> (), true);
GameObject.Find ("Building03").AddComponent<MeshFilter> ().mesh = (Mesh)objs[152];
DestroyImmediate (GameObject.Find("Building03").GetComponent<MeshRenderer>(),true);
GameObject.Find ("Building03").AddComponent<MeshRenderer> ();
GameObject.Find ("Building03").GetComponent<MeshRenderer> ().materials [0].CopyPropertiesFromMaterial(material12);
GameObject.Find ("Building03").GetComponent<MeshRenderer> ().materials [0].shader=
(Shader)Resources.LoadAssetAtPath("Assets/Endless Run/Shader/Curved.shader",typeof(Shader));
GameObject.Find ("Building03").GetComponent<MeshRenderer> ().materials [0].name =material12.name;
GameObject.Find ("Building03").GetComponent<MeshRenderer> ().castShadows = true;
GameObject.Find ("Building03").GetComponent<MeshRenderer> ().receiveShadows = true;
DestroyImmediate (GameObject.Find ("Building04").GetComponent<MeshFilter> (), true);
GameObject.Find ("Building04").AddComponent<MeshFilter> ().mesh = (Mesh)objs[152];
DestroyImmediate (GameObject.Find("Building04").GetComponent<MeshRenderer>(),true);
GameObject.Find ("Building04").AddComponent<MeshRenderer> ();
GameObject.Find ("Building04").GetComponent<MeshRenderer> ().materials [0].CopyPropertiesFromMaterial(material13);
GameObject.Find ("Building04").GetComponent<MeshRenderer> ().materials [0].shader=
(Shader)Resources.LoadAssetAtPath("Assets/Endless Run/Shader/Curved.shader",typeof(Shader));
GameObject.Find ("Building04").GetComponent<MeshRenderer> ().materials [0].name =material13.name;
GameObject.Find ("Building04").GetComponent<MeshRenderer> ().castShadows = true;
GameObject.Find ("Building04").GetComponent<MeshRenderer> ().receiveShadows = true;
DestroyImmediate (GameObject.Find ("Building05").GetComponent<MeshFilter> (), true);
GameObject.Find ("Building05").AddComponent<MeshFilter> ().mesh = (Mesh)objs[152];
DestroyImmediate (GameObject.Find("Building05").GetComponent<MeshRenderer>(),true);
GameObject.Find ("Building05").AddComponent<MeshRenderer> ();
GameObject.Find ("Building05").GetComponent<MeshRenderer> ().materials [0].CopyPropertiesFromMaterial(material14);
GameObject.Find ("Building05").GetComponent<MeshRenderer> ().materials [0].shader=
(Shader)Resources.LoadAssetAtPath("Assets/Endless Run/Shader/Curved.shader",typeof(Shader));
GameObject.Find ("Building05").GetComponent<MeshRenderer> ().materials [0].name =material14.name;
GameObject.Find ("Building05").GetComponent<MeshRenderer> ().castShadows = true;
GameObject.Find ("Building05").GetComponent<MeshRenderer> ().receiveShadows = true;
DestroyImmediate (GameObject.Find ("Building06").GetComponent<MeshFilter> (), true);
GameObject.Find ("Building06").AddComponent<MeshFilter> ().mesh = (Mesh)objs[152];
DestroyImmediate (GameObject.Find("Building06").GetComponent<MeshRenderer>(),true);
GameObject.Find ("Building06").AddComponent<MeshRenderer> ();
GameObject.Find ("Building06").GetComponent<MeshRenderer> ().materials [0].CopyPropertiesFromMaterial(material15);
GameObject.Find ("Building06").GetComponent<MeshRenderer> ().materials [0].shader=
(Shader)Resources.LoadAssetAtPath("Assets/Endless Run/Shader/Curved.shader",typeof(Shader));
GameObject.Find ("Building06").GetComponent<MeshRenderer> ().materials [0].name =material15.name;
GameObject.Find ("Building06").GetComponent<MeshRenderer> ().castShadows = true;
GameObject.Find ("Building06").GetComponent<MeshRenderer> ().receiveShadows = true;
DestroyImmediate (GameObject.Find ("Building07").GetComponent<MeshFilter> (), true);
GameObject.Find ("Building07").AddComponent<MeshFilter> ().mesh = (Mesh)objs[155];
DestroyImmediate (GameObject.Find("Building07").GetComponent<MeshRenderer>(),true);
GameObject.Find ("Building07").AddComponent<MeshRenderer> ();
GameObject.Find ("Building07").GetComponent<MeshRenderer> ().materials [0].CopyPropertiesFromMaterial(material10);
GameObject.Find ("Building07").GetComponent<MeshRenderer> ().materials [0].shader=
(Shader)Resources.LoadAssetAtPath("Assets/Endless Run/Shader/Curved.shader",typeof(Shader));
GameObject.Find ("Building07").GetComponent<MeshRenderer> ().materials [0].name =material10.name;
GameObject.Find ("Building07").GetComponent<MeshRenderer> ().castShadows = true;
GameObject.Find ("Building07").GetComponent<MeshRenderer> ().receiveShadows = true;
DestroyImmediate (GameObject.Find ("Building08").GetComponent<MeshFilter> (), true);
GameObject.Find ("Building08").AddComponent<MeshFilter> ().mesh = (Mesh)objs[155];
DestroyImmediate (GameObject.Find("Building08").GetComponent<MeshRenderer>(),true);
GameObject.Find ("Building08").AddComponent<MeshRenderer> ();
GameObject.Find ("Building08").GetComponent<MeshRenderer> ().materials [0].CopyPropertiesFromMaterial(material10);
GameObject.Find ("Building08").GetComponent<MeshRenderer> ().materials [0].shader=
(Shader)Resources.LoadAssetAtPath("Assets/Endless Run/Shader/Curved.shader",typeof(Shader));
GameObject.Find ("Building08").GetComponent<MeshRenderer> ().materials [0].name =material10.name;
GameObject.Find ("Building08").GetComponent<MeshRenderer> ().castShadows = true;
GameObject.Find ("Building08").GetComponent<MeshRenderer> ().receiveShadows = true;
DestroyImmediate (GameObject.Find ("Building09").GetComponent<MeshFilter> (), true);
GameObject.Find ("Building09").AddComponent<MeshFilter> ().mesh = (Mesh)objs[155];
DestroyImmediate (GameObject.Find("Building09").GetComponent<MeshRenderer>(),true);
GameObject.Find ("Building09").AddComponent<MeshRenderer> ();
GameObject.Find ("Building09").GetComponent<MeshRenderer> ().materials [0].CopyPropertiesFromMaterial(material10);
GameObject.Find ("Building09").GetComponent<MeshRenderer> ().materials [0].shader=
(Shader)Resources.LoadAssetAtPath("Assets/Endless Run/Shader/Curved.shader",typeof(Shader));
GameObject.Find ("Building09").GetComponent<MeshRenderer> ().materials [0].name =material10.name;
GameObject.Find ("Building09").GetComponent<MeshRenderer> ().castShadows = true;
GameObject.Find ("Building09").GetComponent<MeshRenderer> ().receiveShadows = true;
DestroyImmediate (GameObject.Find ("Building10").GetComponent<MeshFilter> (), true);
GameObject.Find ("Building10").AddComponent<MeshFilter> ().mesh = (Mesh)objs[155];
DestroyImmediate (GameObject.Find("Building10").GetComponent<MeshRenderer>(),true);
GameObject.Find ("Building10").AddComponent<MeshRenderer> ();
GameObject.Find ("Building10").GetComponent<MeshRenderer> ().materials [0].CopyPropertiesFromMaterial(material11);
GameObject.Find ("Building10").GetComponent<MeshRenderer> ().materials [0].shader=
(Shader)Resources.LoadAssetAtPath("Assets/Endless Run/Shader/Curved.shader",typeof(Shader));
GameObject.Find ("Building10").GetComponent<MeshRenderer> ().materials [0].name =material11.name;
GameObject.Find ("Building10").GetComponent<MeshRenderer> ().castShadows = true;
GameObject.Find ("Building10").GetComponent<MeshRenderer> ().receiveShadows = true;
DestroyImmediate (GameObject.Find ("Building11").GetComponent<MeshFilter> (), true);
GameObject.Find ("Building11").AddComponent<MeshFilter> ().mesh = (Mesh)objs[155];
DestroyImmediate (GameObject.Find("Building11").GetComponent<MeshRenderer>(),true);
GameObject.Find ("Building11").AddComponent<MeshRenderer> ();
GameObject.Find ("Building11").GetComponent<MeshRenderer> ().materials [0].CopyPropertiesFromMaterial(material12);
GameObject.Find ("Building11").GetComponent<MeshRenderer> ().materials [0].shader=
(Shader)Resources.LoadAssetAtPath("Assets/Endless Run/Shader/Curved.shader",typeof(Shader));
GameObject.Find ("Building11").GetComponent<MeshRenderer> ().materials [0].name =material12.name;
GameObject.Find ("Building11").GetComponent<MeshRenderer> ().castShadows = true;
GameObject.Find ("Building11").GetComponent<MeshRenderer> ().receiveShadows = true;
DestroyImmediate (GameObject.Find ("Building12").GetComponent<MeshFilter> (), true);
GameObject.Find ("Building12").AddComponent<MeshFilter> ().mesh = (Mesh)objs[155];
DestroyImmediate (GameObject.Find("Building12").GetComponent<MeshRenderer>(),true);
GameObject.Find ("Building12").AddComponent<MeshRenderer> ();
GameObject.Find ("Building12").GetComponent<MeshRenderer> ().materials [0].CopyPropertiesFromMaterial(material13);
GameObject.Find ("Building12").GetComponent<MeshRenderer> ().materials [0].shader=
(Shader)Resources.LoadAssetAtPath("Assets/Endless Run/Shader/Curved.shader",typeof(Shader));
GameObject.Find ("Building12").GetComponent<MeshRenderer> ().materials [0].name =material13.name;
GameObject.Find ("Building12").GetComponent<MeshRenderer> ().castShadows = true;
GameObject.Find ("Building12").GetComponent<MeshRenderer> ().receiveShadows = true;
DestroyImmediate (GameObject.Find ("Building13").GetComponent<MeshFilter> (), true);
GameObject.Find ("Building13").AddComponent<MeshFilter> ().mesh = (Mesh)objs[155];
DestroyImmediate (GameObject.Find("Building13").GetComponent<MeshRenderer>(),true);
GameObject.Find ("Building13").AddComponent<MeshRenderer> ();
GameObject.Find ("Building13").GetComponent<MeshRenderer> ().materials [0].CopyPropertiesFromMaterial(material14);
GameObject.Find ("Building13").GetComponent<MeshRenderer> ().materials [0].shader=
(Shader)Resources.LoadAssetAtPath("Assets/Endless Run/Shader/Curved.shader",typeof(Shader));
GameObject.Find ("Building13").GetComponent<MeshRenderer> ().materials [0].name =material14.name;
GameObject.Find ("Building13").GetComponent<MeshRenderer> ().castShadows = true;
GameObject.Find ("Building13").GetComponent<MeshRenderer> ().receiveShadows = true;
DestroyImmediate (GameObject.Find ("Building14").GetComponent<MeshFilter> (), true);
GameObject.Find ("Building14").AddComponent<MeshFilter> ().mesh = (Mesh)objs[155];
DestroyImmediate (GameObject.Find("Building14").GetComponent<MeshRenderer>(),true);
GameObject.Find ("Building14").AddComponent<MeshRenderer> ();
GameObject.Find ("Building14").GetComponent<MeshRenderer> ().materials [0].CopyPropertiesFromMaterial(material15);
GameObject.Find ("Building14").GetComponent<MeshRenderer> ().materials [0].shader=
(Shader)Resources.LoadAssetAtPath("Assets/Endless Run/Shader/Curved.shader",typeof(Shader));
GameObject.Find ("Building14").GetComponent<MeshRenderer> ().materials [0].name =material15.name;
GameObject.Find ("Building14").GetComponent<MeshRenderer> ().castShadows = true;
GameObject.Find ("Building14").GetComponent<MeshRenderer> ().receiveShadows = true;
DestroyImmediate (GameObject.Find ("Building15").GetComponent<MeshFilter> (), true);
GameObject.Find ("Building15").AddComponent<MeshFilter> ().mesh = (Mesh)objs[155];
DestroyImmediate (GameObject.Find("Building15").GetComponent<MeshRenderer>(),true);
GameObject.Find ("Building15").AddComponent<MeshRenderer> ();
GameObject.Find ("Building15").GetComponent<MeshRenderer> ().materials [0].CopyPropertiesFromMaterial(material15);
GameObject.Find ("Building15").GetComponent<MeshRenderer> ().materials [0].shader=
(Shader)Resources.LoadAssetAtPath("Assets/Endless Run/Shader/Curved.shader",typeof(Shader));
GameObject.Find ("Building15").GetComponent<MeshRenderer> ().materials [0].name =material15.name;
GameObject.Find ("Building15").GetComponent<MeshRenderer> ().castShadows = true;
GameObject.Find ("Building15").GetComponent<MeshRenderer> ().receiveShadows = true;
DestroyImmediate (GameObject.Find ("Building16").GetComponent<MeshFilter> (), true);
GameObject.Find ("Building16").AddComponent<MeshFilter> ().mesh = (Mesh)objs[155];
DestroyImmediate (GameObject.Find("Building16").GetComponent<MeshRenderer>(),true);
GameObject.Find ("Building16").AddComponent<MeshRenderer> ();
GameObject.Find ("Building16").GetComponent<MeshRenderer> ().materials [0].CopyPropertiesFromMaterial(material15);
GameObject.Find ("Building16").GetComponent<MeshRenderer> ().materials [0].shader=
(Shader)Resources.LoadAssetAtPath("Assets/Endless Run/Shader/Curved.shader",typeof(Shader));
GameObject.Find ("Building16").GetComponent<MeshRenderer> ().materials [0].name =material15.name;
GameObject.Find ("Building16").GetComponent<MeshRenderer> ().castShadows = true;
GameObject.Find ("Building16").GetComponent<MeshRenderer> ().receiveShadows = true;
DestroyImmediate (GameObject.Find("modelRoad01").GetComponent<MeshFilter>(),true);
GameObject.Find("modelRoad01").AddComponent<MeshFilter>().mesh=(Mesh)objs[176];
DestroyImmediate (GameObject.Find("modelRoad01").GetComponent<MeshRenderer>(),true);
GameObject.Find("modelRoad01").AddComponent<MeshRenderer>();
GameObject.Find ("modelRoad01").GetComponent<MeshRenderer> ().materials [0].CopyPropertiesFromMaterial(material4);
GameObject.Find("modelRoad01").GetComponent<MeshRenderer>().materials[0].shader=
(Shader)Resources.LoadAssetAtPath("Assets/Endless Run/Shader/Curved.shader",typeof(Shader));
GameObject.Find ("modelRoad01").GetComponent<MeshRenderer> ().materials [0].name =material4.name;
GameObject.Find ("modelRoad01").GetComponent<MeshRenderer> ().castShadows = true;
GameObject.Find ("modelRoad01").GetComponent<MeshRenderer> ().receiveShadows = true;
DestroyImmediate (GameObject.Find ("modelRoad01").GetComponent<MeshCollider> (), true);
GameObject.Find("modelRoad01").AddComponent<MeshCollider>();
GameObject.Find ("modelRoad01").GetComponent<MeshCollider> ().sharedMesh = (Mesh)objs [176];
DestroyImmediate (GameObject.Find("modelRoad02").GetComponent<MeshFilter>(),true);
GameObject.Find("modelRoad02").AddComponent<MeshFilter>().mesh=(Mesh)objs[176];
DestroyImmediate (GameObject.Find("modelRoad02").GetComponent<MeshRenderer>(),true);
GameObject.Find("modelRoad02").AddComponent<MeshRenderer>();
GameObject.Find ("modelRoad02").GetComponent<MeshRenderer> ().materials [0].CopyPropertiesFromMaterial(material4);
GameObject.Find("modelRoad02").GetComponent<MeshRenderer>().materials[0].shader=
(Shader)Resources.LoadAssetAtPath("Assets/Endless Run/Shader/Curved.shader",typeof(Shader));
GameObject.Find ("modelRoad02").GetComponent<MeshRenderer> ().materials [0].name =material4.name;
GameObject.Find ("modelRoad02").GetComponent<MeshRenderer> ().castShadows = true;
GameObject.Find ("modelRoad02").GetComponent<MeshRenderer> ().receiveShadows = true;
DestroyImmediate (GameObject.Find ("modelRoad02").GetComponent<MeshCollider> (), true);
GameObject.Find("modelRoad02").AddComponent<MeshCollider>();
GameObject.Find ("modelRoad02").GetComponent<MeshCollider> ().sharedMesh = (Mesh)objs [176];
DestroyImmediate (GameObject.Find("modelRoad03").GetComponent<MeshFilter>(),true);
GameObject.Find("modelRoad03").AddComponent<MeshFilter>().mesh=(Mesh)objs[176];
DestroyImmediate (GameObject.Find("modelRoad03").GetComponent<MeshRenderer>(),true);
GameObject.Find("modelRoad03").AddComponent<MeshRenderer>();
GameObject.Find ("modelRoad03").GetComponent<MeshRenderer> ().materials [0].CopyPropertiesFromMaterial(material4);
GameObject.Find("modelRoad03").GetComponent<MeshRenderer>().materials[0].shader=
(Shader)Resources.LoadAssetAtPath("Assets/Endless Run/Shader/Curved.shader",typeof(Shader));
GameObject.Find ("modelRoad03").GetComponent<MeshRenderer> ().materials [0].name =material4.name;
GameObject.Find ("modelRoad03").GetComponent<MeshRenderer> ().castShadows = true;
GameObject.Find ("modelRoad03").GetComponent<MeshRenderer> ().receiveShadows = true;
DestroyImmediate (GameObject.Find ("modelRoad03").GetComponent<MeshCollider> (), true);
GameObject.Find("modelRoad03").AddComponent<MeshCollider>();
GameObject.Find ("modelRoad03").GetComponent<MeshCollider> ().sharedMesh = (Mesh)objs [176];
DestroyImmediate (GameObject.Find("modelRoad04").GetComponent<MeshFilter>(),true);
GameObject.Find("modelRoad04").AddComponent<MeshFilter>().mesh=(Mesh)objs[176];
DestroyImmediate (GameObject.Find("modelRoad04").GetComponent<MeshRenderer>(),true);
GameObject.Find("modelRoad04").AddComponent<MeshRenderer>();
GameObject.Find ("modelRoad04").GetComponent<MeshRenderer> ().materials [0].CopyPropertiesFromMaterial(material4);
GameObject.Find("modelRoad04").GetComponent<MeshRenderer>().materials[0].shader=
(Shader)Resources.LoadAssetAtPath("Assets/Endless Run/Shader/Curved.shader",typeof(Shader));
GameObject.Find ("modelRoad04").GetComponent<MeshRenderer> ().materials [0].name =material4.name;
GameObject.Find ("modelRoad04").GetComponent<MeshRenderer> ().castShadows = true;
GameObject.Find ("modelRoad04").GetComponent<MeshRenderer> ().receiveShadows = true;
DestroyImmediate (GameObject.Find ("modelRoad04").GetComponent<MeshCollider> (), true);
GameObject.Find("modelRoad04").AddComponent<MeshCollider>();
GameObject.Find ("modelRoad04").GetComponent<MeshCollider> ().sharedMesh = (Mesh)objs [176];
////////////////////////////////////////////////////////////////////////////////////////////////////////////
GameObject.Find ("SoundManager").GetComponent<SoundManager> ().sound_List [0].audioClip = (AudioClip)objs [82];
GameObject.Find ("SoundManager").GetComponent<SoundManager> ().sound_List [1].audioClip = (AudioClip)objs [218];
GameObject.Find ("SoundManager").GetComponent<SoundManager> ().sound_List [2].audioClip = (AudioClip)objs [112];
GameObject.Find ("SoundManager").GetComponent<SoundManager> ().sound_List [3].audioClip = (AudioClip)objs [106];
GameObject.Find ("SoundManager").GetComponent<SoundManager> ().sound_List [4].audioClip = (AudioClip)objs [218];
GameObject.Find ("SoundManager").GetComponent<SoundManager> ().sound_List [5].audioClip = (AudioClip)objs [218];
GameObject.Find ("SoundManager").GetComponent<AudioSource> ().clip = (AudioClip)objs [28];
bundle.Unload(false);
yield return www;
}
}
几条主要代码分析:
Material material0 = bundle.Load("Board" ,typeof (Material)) as Material;
在.unity3d的包中寻找名字为Board的第一个资源,注意:是第一个,同名的第二个、三个。。。。。。这样找不到。
解决办法有两种:
第一种是在资源包命名时改掉同名的资源包
第二种是:
WWW www = WWW.LoadFromCacheOrDownload (url, 4);
//加载失败
if(www.error != null)
{
Debug.Log("Load Bundle Faile " + url + " Error Is " + www.error);
yield break;
}
AssetBundle bundle = www.assetBundle;
Object[] objs = bundle.LoadAll();
for(int i =0;i< objs.Length;i++){
if(objs[i].name.Equals("Board")){
Debug.Log("bgm - Bounce_It的index="+i);
}
}
通过objs[ index ]得到同名的资源对象。
GameObject itemPref4 = bundle.Load("Item_Jump" ,typeof (GameObject)) as GameObject;
GameObject.Find("PatternSystemManager").GetComponent<PatternSystem>().item_Pref[4]=itemPref4;
DestroyImmediate(itemPref4.GetComponent<Item>(),true);
因为之前的Item组件里面的内容都missing了,但如果直接加进去会加不进去参数值,所以要先删除组件。
itemPref4.AddComponent<Item>();
删除完组件再加入Item组件,再重新加参数可以加进来。
itemPref4.GetComponent<Item> ().scoreAdd = 2;
itemPref2.GetComponent<Item> ().decreaseLife = 1;
itemPref2.GetComponent<Item> ().speedMove = 0;
itemPref2.GetComponent<Item> ().duration = 15;
itemPref2.GetComponent<Item> ().itemEffectValue = 0;
GameObject itemPref2 = bundle.Load("Coin02" ,typeof (GameObject)) as GameObject;
GameObject Cylinder = itemPref2.transform.Find ("Cylinder").gameObject;
有的资源利用名字和objs[ index ]都查找不到,如Cylinder,因为它是资源Coin02的子对象。找到Coin02对象后,利用itemPref2.transform.Find ("Cylinder").gameObject;找到子对象Cylinder。
然后将c#文件myassets拖进Main Camera
⑤运行遇到错误。
需要更改一下。
⑥运行又遇到错误。
错误在下面:
把代码改为一下这样: