浏览代码

Fixed some secondary bugs related to buttons spawning

jamesperet 2 年之前
父节点
当前提交
6f3c2f5abe
共有 3 个文件被更改,包括 13 次插入3 次删除
  1. 1 1
      Readme.md
  2. 11 1
      Runtime/UI/StoryViewUI.cs
  3. 1 1
      package.json

+ 1 - 1
Readme.md

@@ -1,4 +1,4 @@
-# 📦 KairoEngine.StorySystem v0.1.4
+# 📦 KairoEngine.StorySystem v0.1.5
 
 The Story System uses the Ink Language and runtime to navigate through a story written in a plain text file. This package contains the Story Module that receives an ink story and runs it. The story can show lines and branches, execute functions in unity and wait for events. Unity also has an API for navigating, getting and setting variables in the story.
 

+ 11 - 1
Runtime/UI/StoryViewUI.cs

@@ -56,6 +56,16 @@ namespace KairoEngine.StorySystem.UI
 
         void Start()
         {
+            if(buttons != null)
+            {
+                for (int i = 0; i < buttons.Count; i++) Destroy(buttons[i]);
+            }
+            buttons.Clear();
+            GameObject[] oldButtons = branchContainer.GetComponentsInChildren<GameObject>();
+            if(oldButtons != null)
+            {
+                for (int i = 0; i < oldButtons.Length; i++) Destroy(oldButtons[i]);
+            }
             for (int i = 0; i < prePopulateButtons; i++)
             {
                 GameObject obj = Instantiate(storyBranchPrefab, branchContainer);
@@ -115,7 +125,7 @@ namespace KairoEngine.StorySystem.UI
         {
             if(buttons != null)
             {
-                for (int i = storyStep.branches.Count; i < buttons.Count; i++) 
+                for (int i = 0; i < buttons.Count; i++) 
                 {
                     //Destroy(buttons[i]);
                     buttons[i].SetActive(false);

+ 1 - 1
package.json

@@ -1,7 +1,7 @@
 {
     "name": "at.kairoscope.kairoengine.story-system",
     "displayName": "KairoEngine Story System",
-    "version": "0.1.4",
+    "version": "0.1.5",
     "unity": "2020.3",
     "description": "Kairoengine story system based on the Ink language.",
     "dependencies": {