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


C# AssetBundle.LoadAll方法代码示例

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


在下文中一共展示了AssetBundle.LoadAll方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: Start

	// Use this for initialization
	void Start () 
	{
		if( true == m_LoadFromLocal )
		{
			m_Unity3DURL = m_LocalURLTag + m_LocalDirectory + m_LocalAssetBundleName ;
		}
		else
		{
			// use m_Unity3DURL as parameter
		}
		Debug.Log( m_Unity3DURL ) ;
	
		if( 0 == m_Unity3DURL.Length )
			return ;

		
		WWW download = WWW.LoadFromCacheOrDownload( m_Unity3DURL , 0 ) ;
		if( null == download )
		{
			Debug.LogError( "null == download" ) ;
		}
		else
		{
			
			// Try mark this line
			m_AssetBundle = download.assetBundle;
			
			if( null == m_AssetBundle )
			{
				Debug.Log( "null == assetBundle" ) ;
			}
			else
			{
				Debug.Log( "null != assetBundle" ) ;
				Object[] objs = m_AssetBundle.LoadAll() ;
				Debug.Log( "objNumbers" + objs.Length ) ;
				foreach( Object obj in objs )
				{
					Debug.Log( obj.name ) ;
				}
			}
		}
	}
开发者ID:NDark,项目名称:Ntust2013Unity_GitHub,代码行数:44,代码来源:LoadAssetBundle01.cs

示例3: 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

示例4: 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

示例5: DefaultDownloadedCB

 public static void DefaultDownloadedCB(string name, AssetBundle bundle, Object obj, System.Object userData)
 {
     if (bundle != null)
         bundle.LoadAll();
 }
开发者ID:GHunique,项目名称:MyU3dFrame,代码行数:5,代码来源:AssetManager.cs

示例6: Update

    void Update()
    {
        if (null != m_www &&
            m_www.isDone)
        {
            if (null == m_www.assetBundle)
            {
                Debug.LogError("!!Asset bundle was not found");
                m_www = null;
                return;
            }

            m_assetBundle =
                m_www.assetBundle;

            m_www = null;

            Debug.Log("**Loading asset bundle assets");

            m_assetBundleObjects =
                m_assetBundle.LoadAll();

            m_assetBundleLoaded = true;
        }

        if (null != m_assetBundleObjects)
        {
            if ((m_objectIndex + 1) < m_assetBundleObjects.Length)
            {
                ++m_objectIndex;

                Object obj =
                    m_assetBundleObjects[m_objectIndex];

                InspectAndSaveObject(obj);
            }

            else if ((m_objectIndexPass2 + 1) < m_copiedGameObjects.Keys.Count)
            {
                int index = -1;
                foreach (string key in m_copiedGameObjects.Keys)
                {
                    ++index;

                    if (index < (m_objectIndexPass2+1))
                    {
                        continue;
                    }

                    ++m_objectIndexPass2;

                    if (string.IsNullOrEmpty(key))
                    {
                        Debug.LogError("**!!Empty object name skipping...");
                        continue;
                    }

                    Object obj =
                        (Object)m_copiedGameObjects[key];

                    if (null == obj)
                    {
                        Debug.LogError("**!!Null object skipping...");
                        continue;
                    }

                    if (obj.GetType() == typeof(Material))
                    {
                        Debug.Log("**Detected Material...");
                        Material material = obj as Material;

                        if (null == material)
                        {
                            Debug.Log("**Material reference is null");
                            continue;
                        }

                        if (null == material.shader)
                        {
                            Debug.Log("**Material shader reference is null");
                            continue;
                        }

                        Debug.Log(string.Format("**Need to fix shader reference to: {0}...", material.shader.name));
                        string findObject =
                            string.Format("{0}_{1}", GetShortType(material.shader), material.shader.name);
                        if (!m_copiedGameObjects.ContainsKey(findObject))
                        {
                            Debug.LogError(string.Format("!!Could not find referenced shader: {0}...", findObject));
                            continue;
                        }

                        Shader shader = m_copiedGameObjects[findObject] as Shader;

                        if (null == shader)
                        {
                            Debug.Log("**Shader is blank");
                            continue;
                        }

//.........这里部分代码省略.........
开发者ID:merveilles,项目名称:OZML,代码行数:101,代码来源:SaveAssetBundleAsAssets.cs


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