1using MPewsey.Common.Serialization;
5using UnityEngine.AddressableAssets;
19 public bool EditId {
get => _editId;
set => _editId = value; }
26 public int Id {
get => _id;
set => _id = value; }
29 private string _name =
"<None>";
33 public string Name {
get => _name;
set => _name = value; }
36 private string _prefabGuid;
40 public string PrefabGuid {
get => _prefabGuid;
private set => _prefabGuid = value; }
43 private string _prefabPath;
47 public string PrefabPath {
get => _prefabPath;
private set => _prefabPath = value; }
50 [TextArea(3,
int.MaxValue)]
51 private string _serializedText;
55 public string SerializedText {
get => _serializedText;
private set => _serializedText = value; }
57 private void OnValidate()
68 public void Initialize(RoomTemplate
template,
string prefabGuid,
string prefabPath)
70 SerializedText = JsonSerialization.GetJsonString(
template,
new JsonWriterSettings());
84 return JsonSerialization.LoadJsonString<RoomTemplate>(
SerializedText);
92 return new AssetReferenceGameObject(
PrefabGuid);
Raised when a room template has not been initialized.
Contains methods for creating random ID's.
static int AutoAssignId(int id)
If the specified ID is greater than zero, returns the ID. Otherwise, returns a random positive intege...
A container for storing a serialized room template.
string PrefabGuid
The prefab GUID.
string SerializedText
The serialized text for the template.
string Name
The template name.
AssetReferenceGameObject GetAssetReference()
Returns the asset reference based on the assigned prefab GUID.
RoomTemplate GetMMRoomTemplate()
Creates a new Mania Map room template from the serialized text and returns it.
void Initialize(RoomTemplate template, string prefabGuid, string prefabPath)
Sets the properties for the room template.
bool EditId
If true, the ID can be edited in the inspector.
int Id
The template unique ID.
string PrefabPath
The path of the prefab from the project root when the template was last updated.