2024-04-21 22:38:26 +08:00
|
|
|
using System;
|
|
|
|
using System.Collections;
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
public class ModelBuilder : MonoBehaviour
|
|
|
|
{
|
|
|
|
public static ModelBuilder _mainInstance;
|
|
|
|
|
|
|
|
public static ModelBuilder GetInstance()
|
|
|
|
{
|
|
|
|
return _mainInstance;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static T GetInstance<T>() where T : ModelBuilder
|
|
|
|
{
|
|
|
|
return _mainInstance as T;
|
|
|
|
}
|
|
|
|
|
2024-04-23 18:25:12 +08:00
|
|
|
protected virtual void Awake()
|
|
|
|
{
|
|
|
|
_mainInstance = this;
|
|
|
|
}
|
|
|
|
|
2024-05-10 15:56:39 +08:00
|
|
|
public ObjectContainer SpawnAsset(string assetPath)
|
2024-04-21 22:38:26 +08:00
|
|
|
{
|
2024-05-10 15:56:39 +08:00
|
|
|
return SpawnAsset(AssetTypes.Unknown, assetPath);
|
2024-04-21 22:38:26 +08:00
|
|
|
}
|
|
|
|
|
2024-05-10 15:56:39 +08:00
|
|
|
public virtual ObjectContainer SpawnAsset(Enum assetType, string assetPath)
|
2024-04-21 22:38:26 +08:00
|
|
|
{
|
2024-05-10 15:56:39 +08:00
|
|
|
if (this.GetType() == typeof(ModelBuilder)) throw new NotImplementedException();
|
|
|
|
|
|
|
|
ModelViewerMain.GetInstance().PrepareForLoad();
|
|
|
|
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
public IEnumerator SpawnAssetCoroutine(string assetPath, Action<ObjectContainer> callback = null)
|
|
|
|
{
|
|
|
|
yield return SpawnAssetCoroutine(AssetTypes.Unknown, assetPath, callback);
|
|
|
|
}
|
|
|
|
|
|
|
|
public virtual IEnumerator SpawnAssetCoroutine(Enum assetType, string assetPath, Action<ObjectContainer> callback = null)
|
|
|
|
{
|
|
|
|
if(this.GetType() == typeof(ModelBuilder)) throw new NotImplementedException();
|
|
|
|
|
|
|
|
ModelViewerMain.GetInstance().PrepareForLoad();
|
|
|
|
|
|
|
|
yield break;
|
2024-04-21 22:38:26 +08:00
|
|
|
}
|
|
|
|
|
2024-05-10 15:56:39 +08:00
|
|
|
public virtual ObjectContainer SpawnSerialized(ObjectContainerSerializable oc)
|
2024-04-21 22:38:26 +08:00
|
|
|
{
|
2024-05-10 15:56:39 +08:00
|
|
|
if (this.GetType() == typeof(ModelBuilder)) throw new NotImplementedException();
|
|
|
|
|
|
|
|
ModelViewerMain.GetInstance().PrepareForLoad();
|
|
|
|
|
|
|
|
return null;
|
2024-04-21 22:38:26 +08:00
|
|
|
}
|
|
|
|
|
2024-05-10 15:56:39 +08:00
|
|
|
public virtual IEnumerator SpawnSerializedCoroutine(ObjectContainerSerializable oc, Action<ObjectContainer> callback = null)
|
2024-04-21 22:38:26 +08:00
|
|
|
{
|
2024-05-10 15:56:39 +08:00
|
|
|
if (this.GetType() == typeof(ModelBuilder)) throw new NotImplementedException();
|
|
|
|
|
|
|
|
ModelViewerMain.GetInstance().PrepareForLoad();
|
|
|
|
|
|
|
|
yield break;
|
2024-04-21 22:38:26 +08:00
|
|
|
}
|
|
|
|
}
|