本文整理汇总了C#中UnityEngine.AssetBundle.LoadAsset方法的典型用法代码示例。如果您正苦于以下问题:C# AssetBundle.LoadAsset方法的具体用法?C# AssetBundle.LoadAsset怎么用?C# AssetBundle.LoadAsset使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UnityEngine.AssetBundle
的用法示例。
在下文中一共展示了AssetBundle.LoadAsset方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Decorate
public void Decorate(GameObject go, Dictionary<string, object> options, AssetBundle assetBundle)
{
go.AddComponent<Fence>();
Dictionary<string, object> fenceOptions = options["fence_options"] as Dictionary<string, object>;
GameObject flat = Object.Instantiate(assetBundle.LoadAsset((string)fenceOptions["flat"])) as GameObject;
flat.transform.rotation = Quaternion.identity;
GameObject post = Object.Instantiate(assetBundle.LoadAsset((string)fenceOptions["post"])) as GameObject;
post.transform.rotation = Quaternion.identity;
go.GetComponent<Fence>().flatGO = flat;
go.GetComponent<Fence>().postGO = post;
go.GetComponent<Fence>().hasMidPosts = false;
}
示例2: LoadFromBundle
private UnityEngine.Object LoadFromBundle(AssetBundle bundle, string name)
{
#if UNITY_4_3 || UNITY_4_5 || UNITY_4_6
return bundle.Load(name);
#else
return bundle.LoadAsset(name);
#endif
}
示例3: Decorate
public GameObject Decorate(Dictionary<string, object> options, AssetBundle bundle)
{
GameObject asset = null;
switch (_type)
{
case "billboard":
asset = Object.Instantiate(bundle.LoadAsset((string) options["model"])) as GameObject;
break;
}
Decorate(asset, options, bundle);
return asset;
}
示例4: initialize
/// <summary>
/// 初始化
/// </summary>
public void initialize(Action func) {
byte[] stream;
string uri = string.Empty;
//------------------------------------Shared--------------------------------------
uri = Util.DataPath + "shared.assetbundle";
Debug.LogWarning("LoadFile::>> " + uri);
stream = File.ReadAllBytes(uri);
shared = AssetBundle.CreateFromMemoryImmediate(stream);
#if UNITY_5
shared.LoadAsset("Dialog", typeof(GameObject));
#else
shared.Load("Dialog", typeof(GameObject));
#endif
if (func != null) func(); //资源初始化完成,回调游戏管理器,执行后续操作
}
示例5: initialize
/// <summary>
/// 初始化
/// </summary>
public void initialize(Action func) {
if (AppConst.ExampleMode) {
byte[] stream;
string uri = string.Empty;
//------------------------------------Shared--------------------------------------
uri = Util.DataPath + "shared" + AppConst.ExtName;
Debug.LogWarning("LoadFile::>> " + uri);
stream = File.ReadAllBytes(uri);
shared = AssetBundle.LoadFromMemory(stream);
#if UNITY_5
shared.LoadAsset("Dialog", typeof(GameObject));
#else
shared.Load("Dialog", typeof(GameObject));
#endif
}
if (func != null) func(); //资源初始化完成,回调游戏管理器,执行后续操作
}
示例6: Decorate
public GameObject Decorate(Dictionary<string, object> options, AssetBundle bundle)
{
GameObject asset = null;
switch (_type)
{
case "deco":
case "trashbin":
case "seating":
case "seatingAuto":
case "lamp":
asset = Object.Instantiate(bundle.LoadAsset((string) options["model"])) as GameObject;
break;
case "fence":
asset = new GameObject();
break;
}
Decorate(asset, options, bundle);
return asset;
}
示例7: AddPackage
/// <summary>
/// Add a UI package from two assetbundles with a optional main asset name.
/// </summary>
/// <param name="desc">A assetbunble contains description file.</param>
/// <param name="res">A assetbundle contains resources.</param>
/// <param name="mainAssetName">Main asset name.</param>
/// <returns>UIPackage</returns>
public static UIPackage AddPackage(AssetBundle desc, AssetBundle res, string mainAssetName)
{
string source = null;
#if UNITY_5
if (mainAssetName != null)
{
TextAsset ta = desc.LoadAsset<TextAsset>(mainAssetName);
if (ta != null)
source = ta.text;
}
else
{
string[] names = desc.GetAllAssetNames();
foreach (string n in names)
{
if (n.IndexOf("@") == -1)
{
TextAsset ta = desc.LoadAsset<TextAsset>(n);
if (ta != null)
{
source = ta.text;
if (mainAssetName == null)
mainAssetName = Path.GetFileNameWithoutExtension(n);
break;
}
}
}
}
#else
if (mainAssetName != null)
{
TextAsset ta = (TextAsset)desc.Load(mainAssetName, typeof(TextAsset));
if (ta != null)
source = ta.text;
}
else
{
source = ((TextAsset)desc.mainAsset).text;
mainAssetName = desc.mainAsset.name;
}
#endif
if (source == null)
throw new Exception("FairyGUI: invalid package.");
if (desc != res)
desc.Unload(true);
return AddPackage(source, res, mainAssetName);
}
示例8: Decorate
//.........这里部分代码省略.........
case "generic":
consumable.consumeAnimation = ConsumableProduct.ConsumeAnimation.GENERIC;
break;
case "drink_straw":
consumable.consumeAnimation = ConsumableProduct.ConsumeAnimation.DRINK_STRAW;
break;
case "lick":
consumable.consumeAnimation = ConsumableProduct.ConsumeAnimation.LICK;
break;
case "with_hands":
consumable.consumeAnimation = ConsumableProduct.ConsumeAnimation.WITH_HANDS;
break;
}
} else {
consumable.consumeAnimation = ConsumableProduct.ConsumeAnimation.GENERIC;
}
if (options.ContainsKey ("temperature")) {
switch ((string)options ["temperature"]) {
case "none":
consumable.temperaturePreference = ConsumableProduct.TemperaturePreference.NONE;
break;
case "cold":
consumable.temperaturePreference = ConsumableProduct.TemperaturePreference.COLD;
break;
case "hot":
consumable.temperaturePreference = ConsumableProduct.TemperaturePreference.HOT;
break;
}
} else {
consumable.temperaturePreference = ConsumableProduct.TemperaturePreference.NONE;
}
consumable.portions = (int)(Int64)options ["portions"];
if (options.ContainsKey ("trash")) {
Dictionary<string,object> trashItem = options ["trash"] as Dictionary<string,object>;
switch ((string)trashItem["model"]) {
case "PopCanTrash":
consumable.trash = AssetManager.Instance.getPrefab (Prefabs.PopCanTrash).gameObject;
break;
case "TeaTrash":
consumable.trash = AssetManager.Instance.getPrefab (Prefabs.TeaTrash).gameObject;
break;
case "CandyTrash":
consumable.trash = AssetManager.Instance.getPrefab (Prefabs.CandyTrash).gameObject;
break;
case "SoftDrinkTrash":
consumable.trash = AssetManager.Instance.getPrefab (Prefabs.SoftDrinkTrash).gameObject;
break;
case "SnowconeTrash":
consumable.trash = AssetManager.Instance.getPrefab (Prefabs.SnowconeTrash).gameObject;
break;
case "BubbleTeaTrash":
consumable.trash = AssetManager.Instance.getPrefab (Prefabs.BubbleTeaTrash).gameObject;
break;
case "ChipBagTrash":
consumable.trash = AssetManager.Instance.getPrefab (Prefabs.ChipBagTrash).gameObject;
break;
case "MiniDonutsTrash":
consumable.trash = AssetManager.Instance.getPrefab (Prefabs.MiniDonutsTrash).gameObject;
break;
case "ChineseFoodTrash":
consumable.trash = AssetManager.Instance.getPrefab (Prefabs.ChineseFoodTrash).gameObject;
break;
case "PopcornTrash":
consumable.trash = AssetManager.Instance.getPrefab (Prefabs.PopcornTrash).gameObject;
break;
case "FriesTrash":
consumable.trash = AssetManager.Instance.getPrefab (Prefabs.FriesTrash).gameObject;
break;
case "HotDrinkTrash":
consumable.trash = AssetManager.Instance.getPrefab (Prefabs.HotDrinkTrash).gameObject;
break;
default:
var asset = UnityEngine.Object.Instantiate (assetBundle.LoadAsset ((string)trashItem ["model"])) as GameObject;
UnityEngine.Debug.Log (asset);
asset.gameObject.SetActive (false);
Trash trash = asset.AddComponent<TrashInstance> ();
trash.setId (consumable.name + "_trash");
if (trashItem.ContainsKey("disgustfactor")) {
trash.disgustFactor = (float)(double)trashItem ["disgustfactor"];
}
if (trashItem.ContainsKey("canwiggle")) {
trash.canWiggle = (bool)trashItem ["canwiggle"];
}
if (trashItem.ContainsKey("volume")) {
trash.volume = (float)(double)trashItem ["volume"];
}
AssetManager.Instance.registerObject (asset);
consumable.trash = asset;
break;
}
}
}
开发者ID:pollend,项目名称:Parkitect_CustomShops_Template-depreciated-,代码行数:101,代码来源:ConsumableProductDecorator.cs
示例9: AddPackage
public static UIPackage AddPackage(AssetBundle desc, AssetBundle res, string resourceNamePrefix)
{
#if UNITY_5
byte[] bytes = desc.LoadAsset<TextAsset>(desc.GetAllAssetNames()[0]).bytes;
#else
byte[] bytes = ((TextAsset)desc.mainAsset).bytes;
#endif
if (desc != res)
desc.Unload(true);
return AddPackage(bytes, res, resourceNamePrefix);
}
示例10: Decorate
public GameObject Decorate(Dictionary<string, object> options, AssetBundle assetBundle)
{
var asset = UnityEngine.Object.Instantiate(assetBundle.LoadAsset((string)options["model"])) as GameObject;
asset.gameObject.SetActive (false);
this.Decorate (asset,options, assetBundle);
AssetManager.Instance.registerObject (asset.gameObject.GetComponent<Product> ());
return asset;
}