|
@@ -20,7 +20,7 @@ namespace KairoEngine.StorySystem
|
|
|
public class StoryObject : System.Object
|
|
|
{
|
|
|
[HorizontalGroup("line", 0.3f), HideLabel] public string name;
|
|
|
- [HorizontalGroup("line", 0.7f), HideLabel] public GameObject prefab;
|
|
|
+ [HorizontalGroup("line", 0.7f), HideLabel, NonSerialized, ShowInInspector] public GameObject prefab;
|
|
|
[HideInInspector, NonSerialized] public GameObject instance;
|
|
|
}
|
|
|
|
|
@@ -29,19 +29,18 @@ namespace KairoEngine.StorySystem
|
|
|
{
|
|
|
public override string name => "Story Module";
|
|
|
|
|
|
- [FoldoutGroup("@name"), ShowInInspector, NonSerialized] public TextAsset inkJSONAsset = null;
|
|
|
- [FoldoutGroup("@name")] public string storyName = "Storyline";
|
|
|
+ [ShowInInspector, NonSerialized] public TextAsset inkJSONAsset = null;
|
|
|
+ public string storyName = "Storyline";
|
|
|
|
|
|
- [FoldoutGroup("@name")] public bool showStoryLog = false;
|
|
|
+ public bool showStoryLog = false;
|
|
|
|
|
|
- [FoldoutGroup("@name")] public int lineInverval = 250;
|
|
|
+ public int lineInverval = 250;
|
|
|
|
|
|
- [FoldoutGroup("@name"), LabelText("Start")] public StoryInitType startType;
|
|
|
+ [LabelText("Start")] public StoryInitType startType;
|
|
|
|
|
|
- [FoldoutGroup("@name"), ShowIf("@startType == StoryInitType.OnEvent")] public string eventStartName = "StartStory";
|
|
|
+ [ShowIf("@startType == StoryInitType.OnEvent")] public string eventStartName = "StartStory";
|
|
|
|
|
|
- [FoldoutGroup("@name"), Space] public List<StoryObject> storyObjects = new List<StoryObject>();
|
|
|
- [SerializeField, HideInInspector] private int storyObjectsCount = 0;
|
|
|
+ [Space] public List<StoryObject> storyObjects = new List<StoryObject>();
|
|
|
|
|
|
private StoryController storyController;
|
|
|
private Transform storyObjectsContainer = null;
|
|
@@ -103,15 +102,16 @@ namespace KairoEngine.StorySystem
|
|
|
if(inkJSONAsset != null) serializer.AddUnityObject("inkJSONAsset", inkJSONAsset);
|
|
|
if(storyObjectsContainer != null) serializer.AddGameObject("storyObjectsContainer", storyObjectsContainer.gameObject);
|
|
|
if(storyController != null) serializer.AddObject("storyController", storyController);
|
|
|
- storyObjectsCount = storyObjects.Count;
|
|
|
for (int i = 0; i < storyObjects.Count; i++)
|
|
|
{
|
|
|
- serializer.AddObject($"storyObjects_{i}", storyObjects[i]);
|
|
|
+ serializer.AddGameObject($"storyObjects_{i}_gameObject", storyObjects[i].prefab);
|
|
|
}
|
|
|
+
|
|
|
}
|
|
|
|
|
|
public override void OnBeforeDeserialize(ObjectSerializer serializer)
|
|
|
{
|
|
|
+
|
|
|
// inkJSONAsset
|
|
|
inkJSONAsset = (TextAsset)serializer.GetUnityObject("inkJSONAsset");
|
|
|
// storyObjectsContainer
|
|
@@ -120,10 +120,12 @@ namespace KairoEngine.StorySystem
|
|
|
// storyController
|
|
|
storyController = (StoryController)serializer.GetObject("storyController");
|
|
|
// storyObjects
|
|
|
- for (int i = 0; i < storyObjectsCount; i++)
|
|
|
+ if(storyObjects == null) storyObjects = new List<StoryObject>();
|
|
|
+ for (int i = 0; i < storyObjects.Count; i++)
|
|
|
{
|
|
|
- var obj = serializer.GetObject($"storyObjects_{i}");
|
|
|
- if(obj != null) storyObjects.Add((StoryObject)obj);
|
|
|
+ var obj = storyObjects[i];
|
|
|
+ if(obj == null) return;
|
|
|
+ obj.prefab = serializer.GetGameObject($"storyObjects_{i}_gameObject");
|
|
|
}
|
|
|
}
|
|
|
}
|