Browse Source

Added Transition GameAction with fade-in and fade-out

James Peret 2 years ago
parent
commit
77acb13efe

+ 4 - 1
Readme.md

@@ -1,4 +1,4 @@
-# 📦 KairoEngine.UI.v0.2.4
+# 📦 KairoEngine.UI.v0.2.5
 
 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.5
+- Added Transition GameAction with fade-in and fade-out
+
 #### v0.2.4
 - Added Rolling Credits restart event
 

+ 82 - 0
Runtime/GameActions/TransitionGameAction.cs

@@ -0,0 +1,82 @@
+using System.Collections;
+using System.Linq;
+using System.Collections.Generic;
+using UnityEngine;
+using Sirenix.OdinInspector;
+using KairoEngine.Core;
+using KairoEngine.Core.GameActions;
+
+namespace KairoEngine.UI.GameActions
+{
+    [System.Serializable, HideReferenceObjectPicker]
+    public class TransitionGameAction : GameActionBase
+    {
+
+        public enum ActionType
+        {
+            FadeIn,
+            FadeOut
+        }
+        public override string name 
+        { 
+            get
+            {
+                if(actionType == ActionType.FadeIn) return "Fade In";
+                else if(actionType == ActionType.FadeOut) return "Fade Out";
+                else return "Transition";
+            }
+        }
+
+        public override GameActionsController controller { 
+            get => _controller; 
+            set 
+            {
+                _controller = value;
+                typeName = "TransitionGameAction";
+                className =  this.GetType().AssemblyQualifiedName;
+            }
+        }
+        public override string GetTypeName() => "TransitionGameAction";
+        public override string GetActionName() => "UI/Transition";
+
+        [FoldoutGroup("@name")] public ActionType actionType = ActionType.FadeIn;
+        [FoldoutGroup("@name")] public float fadeTime = 0.7f;
+
+        public TransitionGameAction(GameActionsController controller) : base(controller)
+        {
+            this.controller = controller;
+            className =  this.GetType().AssemblyQualifiedName;
+        }
+
+        public override void Start()
+        {
+            if (actionType == ActionType.FadeIn) TransitionController.FadeIn(fadeTime);
+            else if (actionType == ActionType.FadeOut) TransitionController.FadeOut(fadeTime);
+            _done = true;
+            _started = true;
+        }
+
+        public override void Update() { }
+
+        public override void Restart()
+        {
+            _done = false;
+            _started = false;
+        }
+
+        public static TransitionGameAction JSONToTransitionGameAction(string data)
+        {
+            return JsonUtility.FromJson<TransitionGameAction>(data);
+        }
+
+        private TransitionGameAction Duplicate(GameActionsController controller = null)
+        {
+            TransitionGameAction action = new TransitionGameAction(controller == null ? this.controller : controller);
+            action.controller = controller;
+            action.actionType = actionType;
+            return action;
+        }
+
+    }
+}
+

+ 11 - 0
Runtime/GameActions/TransitionGameAction.cs.meta

@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: d705dc4cc284a094fa9be28ec8cfd724
+MonoImporter:
+  externalObjects: {}
+  serializedVersion: 2
+  defaultReferences: []
+  executionOrder: 0
+  icon: {instanceID: 0}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 1 - 1
package.json

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