当前位置: 首页>>代码示例>>C#>>正文


C# AssetBundle.LoadAsset方法代码示例

本文整理汇总了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;
        }
开发者ID:ParkitectNexus,项目名称:CustomScenery,代码行数:15,代码来源:FenceDecorator.cs

示例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
 }
开发者ID:farreltr,项目名称:OneLastSunset,代码行数:8,代码来源:AssetBundleManager.cs

示例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;
        }
开发者ID:ParkitectNexus,项目名称:Billboards,代码行数:15,代码来源:TypeDecorator.cs

示例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();    //资源初始化完成,回调游戏管理器,执行后续操作 
        }
开发者ID:xq48799220,项目名称:SimpleFramework_NGUI,代码行数:19,代码来源:ResourceManager.cs

示例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();    //资源初始化完成,回调游戏管理器,执行后续操作 
        }
开发者ID:guyun008,项目名称:LuaFramework_ngui_mod,代码行数:21,代码来源:ResourceManager.cs

示例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;
        }
开发者ID:RandomGuy0099,项目名称:tropicalBuildingsMod,代码行数:22,代码来源:TypeDecorator.cs

示例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);
 }
开发者ID:yinlei,项目名称:Fishing,代码行数:54,代码来源:UIPackage.cs

示例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);
 }
开发者ID:hxyxj,项目名称:FairyGUI-unity,代码行数:11,代码来源:UIPackage.cs

示例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;
		}
开发者ID:pollend,项目名称:Parkitect_CustomShops_Template-depreciated-,代码行数:8,代码来源:ProductDecorator.cs


注:本文中的UnityEngine.AssetBundle.LoadAsset方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。