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


C# AssetBundle.LoadAllAssets方法代码示例

本文整理汇总了C#中AssetBundle.LoadAllAssets方法的典型用法代码示例。如果您正苦于以下问题:C# AssetBundle.LoadAllAssets方法的具体用法?C# AssetBundle.LoadAllAssets怎么用?C# AssetBundle.LoadAllAssets使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在AssetBundle的用法示例。


在下文中一共展示了AssetBundle.LoadAllAssets方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: RefreshShader

 /// <summary>
 /// 刷新shader
 /// </summary>
 /// <param name="assetBundle"></param>
 public static void RefreshShader(AssetBundle assetBundle)
 {
     #if UNITY_5
     UnityEngine.Material[] materials = assetBundle.LoadAllAssets<Material>();
     #else
     UnityEngine.Object[] materials = assetBundle.LoadAll(typeof(Material));  //LoadAll<Material>();
     #endif
     foreach (UnityEngine.Object m in materials)
     {
         Material mat = m as Material;
         string shaderName = mat.shader.name;
         Shader newShader = Shader.Find(shaderName);
         if (newShader != null)
         {
             mat.shader = newShader;
         }
         else
         {
             Debug.LogWarning("unable to refresh shader: " + shaderName + " in material " + m.name);
         }
     }
 }
开发者ID:coder-han,项目名称:hugula,代码行数:26,代码来源:LuaHelper.cs

示例2: Download

    private IEnumerator Download(string url)
    {
        // Start a download of the given URL
        //Random argument added to the back of the URL to prevent caching
        string randomValue = "?t=" + Random.value;
        url += randomValue;
        www = new WWW(url);
        isDownloading = true;
        downloadStatus.color = Color.black;
        
        // Wait for download to complete
        yield return www;
        isDownloading = false;
        if (www.error != null)
        {
            Debug.Log(www.error);
            downloadStatus.text = www.error;
        }

        // Load and retrieve the AssetBundle
        bundle = www.assetBundle;
        if (bundle == null)
        {
            downloadStatus.color = Color.red;
            downloadStatus.text = DOWNLOAD_FAIL_MESSAGE;
        }
        // Load all the objects
        Object[] assetbundlesObject = bundle.LoadAllAssets();

        foreach (Object o in assetbundlesObject)
        {
            objectCollection.AddGameObjects((GameObject)o);
        }

        objectCollection.PrepareUserObjects();

        // Unload the AssetBundles compressed contents to conserve memory
        bundle.Unload(false);

        // Frees the memory from the web stream
        www.Dispose();
        downloadStatus.color = Color.blue;
        downloadStatus.text = DOWNLOAD_PASS_MESSAGE;


    }
开发者ID:nus-mtp,项目名称:ar-design-tool,代码行数:46,代码来源:LoadAssetBundle.cs

示例3: ApplyLoadedVegetationBundle

	private void ApplyLoadedVegetationBundle( AssetBundle bundle, string bundleName ){
		Object[] objects = bundle.LoadAllAssets (typeof(Texture2D));
		for ( int i = 0; i < objects.Length; i++ ){
			Texture2D tex = (Texture2D)objects[i];	
			GameObject.Find ("AGF_TerrainManager").GetComponent<AGF_TerrainManager>().AddVegetationTextureToList( tex, bundleName );
		}
	}	
开发者ID:Waltari10,项目名称:LifeRitual,代码行数:7,代码来源:AGF_LevelLoader.cs

示例4: ApplyLoadedWarehouseBundle

	private void ApplyLoadedWarehouseBundle( AssetBundle bundle, string bundleName ){
		// grab every element of the bundle, and add it to the tileList.
		AGF_TileListManager tileListManager = GameObject.Find ("AGF_TileListManager").GetComponent<AGF_TileListManager>();
		AGF_GibManager gibManager = GameObject.Find ("AGF_GibManager").GetComponent<AGF_GibManager>();
		Object[] objects = bundle.LoadAllAssets(typeof(GameObject));
		for ( int i = 0; i < objects.Length; i++ ){ 
			GameObject obj = (GameObject)objects[i];

			if ( obj.GetComponent<GibProperties>() != null ){
				gibManager.AddGibTolist( obj.GetComponent<GibProperties>().category, obj.GetComponent<GibProperties>().bundle, obj.transform );
				
			} else if ( obj.GetComponent<GibSettings>() != null ){
				gibManager.AddGibSettingsToList( obj.GetComponent<GibSettings>().category, obj.GetComponent<GibSettings>().bundle, obj.transform );
				
			} else if ( obj.GetComponent<TileProperties>() != null ){
				obj.GetComponent<TileProperties>().tileID += "/" + bundleName;

				tileListManager.AddToList( obj.GetComponent<TileProperties>().tileID, obj.transform );
			}
		}
	}
开发者ID:Waltari10,项目名称:LifeRitual,代码行数:21,代码来源:AGF_LevelLoader.cs

示例5: LoadExtraInstruments

	public void LoadExtraInstruments(AssetBundle bundle)
	{
		AudioClip[] extraInstrumentsClips = bundle.LoadAllAssets<AudioClip>();
		LoadExtraInstruments(extraInstrumentsClips);
	}
开发者ID:jquentin,项目名称:tap-the-lights,代码行数:5,代码来源:PadController.cs

示例6: UnpackConfigAssetBundleFn

    /// <summary>
    /// 
    /// </summary>
    /// <param name="ab"></param>
    /// <param name="luaFn"></param>
    public static void UnpackConfigAssetBundleFn(AssetBundle ab, LuaFunction luaFn)
    {
        callBackFn = luaFn;
#if UNITY_5
        UnityEngine.Object[] all = ab.LoadAllAssets();
#else
        UnityEngine.Object[] all = ab.LoadAll();
#endif
        foreach (UnityEngine.Object i in all)
        {
            if (i is TextAsset)
            {
                TextAsset a = (TextAsset)i;
                if (callBackFn != null)
                    callBackFn.call(a.name, a.text);
            }
        }
    }     
开发者ID:QinFangbi,项目名称:hugula,代码行数:23,代码来源:FileHelper.cs

示例7: OnXGUI

    public override void OnXGUI()
    {
        //TODO List
        if(Selection.objects != null && Selection.objects.Length > 0){
            selectedObject = Selection.objects[0];
        }

        if(CreateSpaceButton("Packing Selected Objects")){
            Object[] objects = Selection.objects;

            string path = EditorUtility.SaveFilePanel("Create A Bundle", AssetDatabase.GetAssetPath(objects[0]), "newbundle.assetbundle", "assetbundle");
            if (path == "")
                return;

            CreateXMLWithDependencies(objects, path);

            BuildPipeline.BuildAssetBundle(
                null, objects,
                path ,
                BuildAssetBundleOptions.CollectDependencies | BuildAssetBundleOptions.UncompressedAssetBundle
                | BuildAssetBundleOptions.DeterministicAssetBundle, BuildTarget.Android);
        }

        if(CreateSpaceButton("GetObject")){
            string path = EditorUtility.OpenFilePanel("Open A Bundle", Application.streamingAssetsPath, "" );
            if (path == "")
                return;
            _bundlepath = "file://" + path;
            LoadingConfig = true;
            asset = null;
        //			AssetDatabase.Refresh();
            if(currBundle != null){
                currBundle.Unload(true);
            }
        }

        if(CreateSpaceButton("Clean Cache")){
            currentBundleObjects = null;
            Caching.CleanCache();
        }

        if( LoadingConfig ){
            XLogger.Log("start loading");
            if( null == asset )
                asset = new WWW(_bundlepath);
            LoadingConfig = false;
        }
        //		Logger.Log(string.Format("asset == null is {0}" , asset == null));
        if(asset != null ){
        //			Logger.Log("asset.isDone is " + asset.isDone);
        //			if(asset.isDone){

            XLogger.Log("end loading");
            currBundle = asset.assetBundle;
            if(currBundle == null){
                CreateNotification("Selected the asset bundle 's format is error.");
                LoadingConfig = false;
                asset = null;
                return;
            }
            #if UNITY_5_0
            currentBundleObjects = currBundle.LoadAllAssets();
            #endif
            #if UNITY_4_6
            currentBundleObjects = currBundle.LoadAll();
            #endif
            LoadingConfig = false;
            asset = null;
        //			}
        }

        if( null != currentBundleObjects ){
            for (int pos = 0; pos < currentBundleObjects.Length; pos++) {
                CreateObjectField(currentBundleObjects[pos].GetType().ToString(),currentBundleObjects[pos]);
            }
        }

        if(CreateSpaceButton("Add A AssetBundle")){
            allAssets.Add(new AssetBundleModel());
        }
        if(CreateSpaceButton("Clean All AssetBundle")){
            allAssets.Clear();
        }
        if(CreateSpaceButton("Collect") && allAssets.Count > 0){
            List<AssetBundleModel> AllChilds = new List<AssetBundleModel>();
            sortAssets.Clear();

            BundlePath = EditorUtility.SaveFolderPanel("Save Bundles", Application.streamingAssetsPath, "" );
            if(BundlePath == null){
                return;
            }
            BundlePath += "/";
            XmlDocument xmlDoc = new XmlDocument();
            XmlElement root = xmlDoc.CreateElement("root");
            for(int pos = 0; pos < allAssets.Count; pos++){
                if(allAssets[pos].ParentName.Equals("")){
                    sortAssets.Add(allAssets[pos].ModelName, allAssets[pos]);
                    XmlElement child = xmlDoc.CreateElement(allAssets[pos].ModelName);
                    root.AppendChild(child);
                }else{
//.........这里部分代码省略.........
开发者ID:wuxingogo,项目名称:WuxingogoExtension,代码行数:101,代码来源:XCreateAssetBundle.cs

示例8: HandleAssetBundle

    private void HandleAssetBundle(RPCSerializer rpcData)
    {
        int index = (int) rpcData.args[0];
        if (index == -1) {
            sceneBundle = AssetBundle.LoadFromMemory (data);
            sceneBundle.LoadAllAssets ();

            string[] scenes = sceneBundle.GetAllScenePaths ();
            string mySceneName = scenes[0];
            mySceneName = mySceneName.Substring(0, mySceneName.Length - 6); //remove .unity
            mySceneName = mySceneName.Substring(mySceneName.LastIndexOf("/") + 1); //remove path

            SceneManager.LoadScene (mySceneName);
        } else if (index == 0) {
            data = new byte[ (int) rpcData.args[1] ] ;
            if (sceneBundle != null) {
                SceneManager.LoadScene (1);
                sceneBundle.Unload (true);
            }
        } else {
            int start = (int)rpcData.args [1];
            byte[] bData = (byte[] )rpcData.args [2];
            for (int i = 0; i < bData.Length; i++) {
                data [i + start] = bData [i];
            }
        }
    }
开发者ID:vmohan7,项目名称:Navi,代码行数:27,代码来源:NaviMobileManager.cs


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