Tanoda
LoadModelFromFileSample.cs
Go to the documentation of this file.
1#pragma warning disable 649
2using UnityEngine;
3#if UNITY_EDITOR
4using UnityEditor;
5
6#endif
7namespace TriLibCore.Samples
8{
12 public class LoadModelFromFileSample : MonoBehaviour
13 {
14#if UNITY_EDITOR
18 [SerializeField] private Object ModelAsset;
19#endif
20
24 private string ModelPath
25 {
26 get
27 {
28#if UNITY_EDITOR
29 return AssetDatabase.GetAssetPath(ModelAsset);
30#else
31 return "Models/TriLibSampleModel.obj";
32#endif
33 }
34 }
35
43 private void Start()
44 {
45 var assetLoaderOptions = AssetLoader.CreateDefaultLoaderOptions();
46 AssetLoader.LoadModelFromFile(ModelPath, OnLoad, OnMaterialsLoad, OnProgress, OnError, null,
47 assetLoaderOptions);
48 }
49
57 private void OnError(IContextualizedError obj)
58 {
59 Debug.LogError($"An error ocurred while loading your Model: {obj.GetInnerException()}");
60 }
61
67 private void OnProgress(AssetLoaderContext assetLoaderContext, float progress)
68 {
69 Debug.Log($"Loading Model. Progress: {progress:P}");
70 }
71
77 private void OnMaterialsLoad(AssetLoaderContext assetLoaderContext)
78 {
79 Debug.Log("Materials loaded. Model fully loaded.");
80 }
81
87 private void OnLoad(AssetLoaderContext assetLoaderContext)
88 {
89 Debug.Log("Model loaded. Loading materials.");
90 }
91 }
92}
UnityEngine.Debug Debug
Definition: TanodaServer.cs:19
Represents a sample that loads the "TriLibSample.obj" Model from the "Models" folder.
UnityEngine.Object Object