Hey guys,
I’m currently trying to read out all assetbundles (before actually loading them) and when that’s done it should create a button for every assetbundle it finds, and when the button is clicked it should instantiate all the assets in the assetbundle.
What i have right now: I can read out the assetbundle names, and create a button for every assetbundle.
What i need: I’m guessing (correct me if wrong) i need the asset names as well right now. So i can actually load the assets when the button is clicked. As of now, i have the assetbundle name, but the buttons have no idea which assetbundle belongs to them.
Code:
public GameObject TestFurniture;
int AmountOfBundles = 0;
public List<string> BundleList;
public string assetName;
void Start()
{
var names = AssetDatabase.GetAllAssetBundleNames();
foreach (string name in names)
{
AmountOfBundles++;
BundleList.Add(name);
print(name);
}
}
void OnGUI() {
for (int i = 0; i < AmountOfBundles; i++) {
//GUILayout.Button("I'm the first button");
if (GUI.Button(new Rect(20, 5 + i * 35, 80, 20), "Button")) {
Instantiate(TestFurniture, new Vector3(i * 0.2f, 0, 0), Quaternion.Euler(-50, -50, 0));
}
}
}
General idea of this project: I have furniture build to assetbundles, on start, the application needs to read out all assetbundles & assets inside those bundles. When done, it creates a button for every Assetbundle & when i click the button it spawns the furniture piece thats linked to that button.