Last active
October 9, 2020 11:14
-
-
Save AnsisMalins/51a210eda92f4c38ca70f2e4af4d3883 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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