Skip to content

Instantly share code, notes, and snippets.

@glitchersgames
Created July 14, 2017 12:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save glitchersgames/3b75559055ac007406d66ff0c1207ece to your computer and use it in GitHub Desktop.
Save glitchersgames/3b75559055ac007406d66ff0c1207ece to your computer and use it in GitHub Desktop.
using UnityEngine;
using UnityEditor;
using System.Collections;
using System.Collections.Generic;
public static class AssetBundleUtil
{
public static void FindAllAssetsInBundle( string assetBundleName )
{
List<Object> assets = new List<Object>();
foreach( var assetPathAndName in AssetDatabase.GetAssetPathsFromAssetBundle(assetBundleName) )
{
string nameWithoutPath = assetPathAndName.Substring( assetPathAndName.LastIndexOf( "/" ) + 1 );
string name = nameWithoutPath.Substring( 0, nameWithoutPath.LastIndexOf( "." ) );
Debug.LogFormat( "{0}:{1} @ {2}", assetBundleName, name, assetPathAndName);
assets.Add( AssetDatabase.LoadAssetAtPath( assetPathAndName, typeof(Object) ) );
}
Selection.objects = assets.ToArray();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment