Browse Source

Added Rolling Credits restart event

James Peret 2 years ago
parent
commit
efaafc3eba
3 changed files with 15 additions and 3 deletions
  1. 4 1
      Readme.md
  2. 10 1
      Runtime/CreditsController.cs
  3. 1 1
      package.json

+ 4 - 1
Readme.md

@@ -1,4 +1,4 @@
-# 📦 KairoEngine.UI.v0.2.3
+# 📦 KairoEngine.UI.v0.2.4
 
 The **UI** package contains the ``UiSystem`` component and the ``UiSystemModule``. The module loads the Ui System in place which manages canvases with UI data. The system now which canvases are enabled and has a global toggle for all the game UI.
 
@@ -76,6 +76,9 @@ The UI package adds new functionality for designing game user interfaces and too
 
 ### Changelog
 
+#### v0.2.4
+- Added Rolling Credits restart event
+
 #### v0.2.3
 - Added Rolling Credits Controller
 

+ 10 - 1
Runtime/CreditsController.cs

@@ -12,6 +12,9 @@ namespace KairoEngine.UI
     public class CreditsController : MonoBehaviour
     {
         public RectTransform textTransform;
+        public bool rollCreditsOnStart = true;
+        public bool listenForRestartEvent = true;
+        public string restartEventName = "RestartRollingCredits";
         [BoxGroup("Rolling Credits")] public KeyCode cancelInput = KeyCode.Escape;
         [BoxGroup("Rolling Credits")] public KeyCode fastForwardInput = KeyCode.DownArrow;
         [BoxGroup("Rolling Credits")] public KeyCode revereInput = KeyCode.UpArrow;
@@ -39,10 +42,16 @@ namespace KairoEngine.UI
             Timer.ExecuteRealTime(100, () => {
                 size = textTransform.sizeDelta;
                 desiredHeigth = (size.y * 2) + 100 + (Screen.currentResolution.height * 2);
-                StartRollingCredits();
+                if(listenForRestartEvent) GenericEvents.StartListening(restartEventName, StartRollingCredits);
+                if(rollCreditsOnStart) StartRollingCredits();
             } ); 
         }
 
+        private void OnDisable()
+        {
+            if(listenForRestartEvent) GenericEvents.StopListening(restartEventName, StartRollingCredits);
+        }
+
         
         private void Update()
         {

+ 1 - 1
package.json

@@ -1,7 +1,7 @@
 {
     "name": "at.kairoscope.kairoengine.ui",
     "displayName" : "KairoEngine UI",
-    "version": "0.2.3",
+    "version": "0.2.4",
     "unity": "2020.3",
     "description": "User Interface library for kairoEngine",
     "repository": {