12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788 |
- #pragma warning disable 649
- using TriLibCore.General;
- using UnityEngine;
- #if UNITY_EDITOR
- using UnityEditor;
- #endif
- namespace TriLibCore.Samples
- {
-
-
-
- public class LoadModelFromFileSample : MonoBehaviour
- {
-
-
-
- private string ModelPath
- {
- get
- {
- #if UNITY_EDITOR
- return $"{Application.dataPath}/TriLib/TriLibSamples/LoadModelFromFile/Models/TriLibSampleModel.obj";
- #else
- return "Models/TriLibSampleModel.obj";
- #endif
- }
- }
-
-
-
- private AssetLoaderOptions _assetLoaderOptions;
-
-
-
-
-
-
- private void Start()
- {
- if (_assetLoaderOptions == null)
- {
- _assetLoaderOptions = AssetLoader.CreateDefaultLoaderOptions(false, true);
- }
- AssetLoader.LoadModelFromFile(ModelPath, OnLoad, OnMaterialsLoad, OnProgress, OnError, null, _assetLoaderOptions);
- }
-
-
-
-
- private void OnError(IContextualizedError obj)
- {
- Debug.LogError($"An error occurred 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.");
- }
- }
- }
|