12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788 |
- using TriLibCore.General;
- using UnityEngine;
- #if UNITY_EDITOR
- using UnityEditor;
- #endif
- namespace TriLibCore.Samples
- {
-
-
-
- public class LoadModelFromFileSample : MonoBehaviour
- {
- #if UNITY_EDITOR
-
-
-
- [SerializeField]
- private Object ModelAsset;
- #endif
-
-
-
- private string ModelPath
- {
- get
- {
- #if UNITY_EDITOR
- return AssetDatabase.GetAssetPath(ModelAsset);
- #else
- return "Models/TriLibSampleModel.obj";
- #endif
- }
- }
-
-
-
-
-
-
- private void Start()
- {
- var assetLoaderOptions = AssetLoader.CreateDefaultLoaderOptions();
- AssetLoader.LoadModelFromFile(ModelPath, OnLoad, OnMaterialsLoad, OnProgress, OnError, null, assetLoaderOptions);
- }
-
-
-
-
- private void OnError(IContextualizedError obj)
- {
- Debug.LogError($"An error ocurred while loading your Model: {obj.GetInnerException()}");
- }
-
-
-
-
-
- private void OnProgress(AssetLoaderContext assetLoaderContext, float progress)
- {
- Debug.Log($"Loading Model. Progress: {progress:P}");
- }
-
-
-
-
-
- private void OnMaterialsLoad(AssetLoaderContext assetLoaderContext)
- {
- Debug.Log("Materials loaded. Model fully loaded.");
- }
-
-
-
-
-
- private void OnLoad(AssetLoaderContext assetLoaderContext)
- {
- Debug.Log("Model loaded. Loading materials.");
- }
- }
- }
|