2024-04-21 22:38:26 +08:00
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.Linq;
|
|
|
|
using UnityEngine;
|
|
|
|
|
2024-05-10 15:56:39 +08:00
|
|
|
[System.Serializable]
|
|
|
|
public class SceneContainer
|
2024-04-21 22:38:26 +08:00
|
|
|
{
|
2024-05-10 15:56:39 +08:00
|
|
|
public string GUID;
|
2024-04-21 22:38:26 +08:00
|
|
|
public List<ObjectContainer> AllObjects = new List<ObjectContainer>();
|
|
|
|
|
|
|
|
public List<T> Objects<T>() where T : ObjectContainer
|
|
|
|
{
|
|
|
|
return AllObjects.Cast<T>().ToList();
|
|
|
|
}
|
|
|
|
|
2024-05-10 15:56:39 +08:00
|
|
|
public SceneContainer() { }
|
|
|
|
|
|
|
|
public static SceneContainer Create<T>(ModelViewerMain main) where T : SceneContainer, new()
|
2024-04-21 22:38:26 +08:00
|
|
|
{
|
2024-05-10 15:56:39 +08:00
|
|
|
var container = new T();
|
2024-04-21 22:38:26 +08:00
|
|
|
container.Init(main);
|
|
|
|
return container;
|
|
|
|
}
|
|
|
|
|
|
|
|
public virtual void Init(ModelViewerMain main)
|
|
|
|
{
|
|
|
|
GUID = "scene";
|
2024-05-10 15:56:39 +08:00
|
|
|
if (!AllObjects.Contains(main.MainCameraOrbit)) { AllObjects.Add(main.MainCameraOrbit); }
|
2024-04-21 22:38:26 +08:00
|
|
|
}
|
|
|
|
|
2024-05-10 15:56:39 +08:00
|
|
|
public virtual SceneSerializable Serialize()
|
2024-04-21 22:38:26 +08:00
|
|
|
{
|
|
|
|
return new SceneSerializable(this);
|
|
|
|
}
|
2024-04-23 18:25:12 +08:00
|
|
|
|
2024-05-10 15:56:39 +08:00
|
|
|
public virtual void Destroy()
|
2024-04-23 18:25:12 +08:00
|
|
|
{
|
|
|
|
for (int i = AllObjects.Count - 1; i >= 0; i--)
|
|
|
|
{
|
|
|
|
var obj = AllObjects[i];
|
|
|
|
obj.Destroy();
|
|
|
|
}
|
2024-05-10 15:56:39 +08:00
|
|
|
|
|
|
|
AllObjects.Clear();
|
2024-04-23 18:25:12 +08:00
|
|
|
}
|
2024-04-21 22:38:26 +08:00
|
|
|
}
|