Skip to content

Instantly share code, notes, and snippets.

@AnsisMalins
Last active October 9, 2020 11:14
Show Gist options
  • Save AnsisMalins/51a210eda92f4c38ca70f2e4af4d3883 to your computer and use it in GitHub Desktop.
Save AnsisMalins/51a210eda92f4c38ca70f2e4af4d3883 to your computer and use it in GitHub Desktop.
using UnityEditor;
using UnityEngine;
public sealed class AssetBundleLoader : ScriptableWizard
{
public string sourcePath;
[MenuItem("Wizard/Load Asset Bundle")]
private static void CreateWizard()
{
DisplayWizard<AssetBundleLoader>("Load Asset Bundle", "Load");
}
protected override bool DrawWizardGUI()
{
bool modified = base.DrawWizardGUI();
if (GUILayout.Button("Browse..."))
{
string value = EditorUtility.OpenFilePanel("Load asset bundle", "", "*");
if (sourcePath != value)
{
sourcePath = value;
modified = true;
}
}
return modified;
}
private void OnWizardCreate()
{
var assetBundle = AssetBundle.LoadFromFile(sourcePath);
foreach (GameObject gameObject in assetBundle.LoadAllAssets())
Instantiate(gameObject);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment