Hello, I have a class called Building, this class contains several lists from another class called MeshesType, and both classes are children of a class called BaseMesh.
First of all, I put the BaseMesh class code here:
Also, the code of the MeshesType class is below:
And finally the Building class whose code is below.
Also, I have a simple scriptable object in which a list of the Building class is stored.
And using the codes below, I put a building object in this list.
public static void AddToBuildingsList(Building building)
{
if (!StaticResources.BuildingsList.Exists(t => t.Name.Equals(building.Name)))
{
StaticResources.BuildingsList.Add(building);
AssetDatabase.SaveAssets();
AssetDatabase.Refresh();
}
}
and BuildingList code is here:
public static List<Building> BuildingsList = BuildingsListFromScriptableObject();
private static List<Building> BuildingsListFromScriptableObject()
{
var buildingListScriptableObject =
AssetDatabase.LoadAssetAtPath<BuildingListScriptableObject>("Assets/AC Smart Building/Resource/Content/BuildingList.asset");
if (buildingListScriptableObject.BuildingsList == null)
{
Debug.LogError("Failed to load BuildingListScriptableObject.");
}
return buildingListScriptableObject.BuildingsList;
}
For this scriptable object, I also created a customized inspector to show the specifications.
custom inspector code
// the full inspector image:
Everything is great, but when I close Unity, nothing is included in this scriptable object, and the buildings must be calculated again to show the information in this list.
// the empty inspector image

