1#pragma warning disable 649
16 private GameObject _loadedGameObject;
21 [SerializeField]
private Button _loadModelButton;
26 [SerializeField]
private Text _progressText;
37 var assetLoaderOptions = AssetLoader.CreateDefaultLoaderOptions();
40 OnProgress, OnBeginLoad, OnError,
null, assetLoaderOptions);
47 private void OnBeginLoad(
bool filesSelected)
49 _loadModelButton.interactable = !filesSelected;
50 _progressText.enabled = filesSelected;
60 private void OnError(IContextualizedError obj)
62 Debug.LogError($
"An error ocurred while loading your Model: {obj.GetInnerException()}");
70 private void OnProgress(AssetLoaderContext assetLoaderContext,
float progress)
72 _progressText.text = $
"Progress: {progress:P}";
80 private void OnMaterialsLoad(AssetLoaderContext assetLoaderContext)
82 if (assetLoaderContext.RootGameObject !=
null)
83 Debug.Log(
"Model fully loaded.");
85 Debug.Log(
"Model could not be loaded.");
86 _loadModelButton.interactable =
true;
87 _progressText.enabled =
false;
95 private void OnLoad(AssetLoaderContext assetLoaderContext)
97 if (_loadedGameObject !=
null) Destroy(_loadedGameObject);
98 _loadedGameObject = assetLoaderContext.RootGameObject;
99 if (_loadedGameObject !=
null) Camera.main.FitToBounds(assetLoaderContext.RootGameObject, 2f);
UnityEngine.UI.Button Button
Represents an Asset Loader which loads files using a platform-specific file picker.
static AssetLoaderFilePicker Create()
Creates the Asset Loader File Picker Singleton instance.
void LoadModelFromFilePickerAsync(string title, Action< AssetLoaderContext > onLoad, Action< AssetLoaderContext > onMaterialsLoad, Action< AssetLoaderContext, float > onProgress, Action< bool > onBeginLoad, Action< IContextualizedError > onError, GameObject wrapperGameObject, AssetLoaderOptions assetLoaderOptions)
Loads a Model from the OS file picker asynchronously, or synchronously when the OS doesn't support Th...
Represents a sample that loads a Model from a file-picker.
void LoadModel()
Creates the AssetLoaderOptions instance and displays the Model file-picker.