ソースを参照

Updated Timer function

jamesperet 2 年 前
コミット
e09bf279bd
4 ファイル変更26 行追加3 行削除
  1. 1 1
      Readme.md
  2. 1 1
      Runtime/ConfigOptions/Templates/VolumeConfigOption.cs
  3. 23 0
      Runtime/Timer.cs
  4. 1 1
      package.json

+ 1 - 1
Readme.md

@@ -1,4 +1,4 @@
-# 📦 KairoEngine.Core v0.1.6
+# 📦 KairoEngine.Core v0.1.7
 
 This contains the base code that other packages will use. It includes code for the module system, event system and common interfaces.
 

+ 1 - 1
Runtime/ConfigOptions/Templates/VolumeConfigOption.cs

@@ -18,7 +18,7 @@ namespace KairoEngine.Core.ConfigOptions
 
         public override ConfigOptionUiData GetUiData()
         {
-            Debug.Log($"Current {title} is {currentVolume}");
+            //Debug.Log($"Current {title} is {currentVolume}");
             var sliderData = new ConfigOptionUiData.SliderData(0.0001f, 1f, currentVolume);
             return new ConfigOptionUiData(title, description, sliderData);
         }

+ 23 - 0
Runtime/Timer.cs

@@ -55,6 +55,12 @@ namespace KairoEngine.Core
                 callback();
         }
 
+        /// <summary>
+        /// Executes a function after a certain time has passed, based on Time.scale.
+        /// </summary>
+        /// <param name="time">In miliseconds</param>
+        /// <param name="action">A function to be executed</param>
+        /// <returns>A CompositeDisposable which can be used to cancel the timer</returns>
         public static CompositeDisposable Execute(float time, Action action)
         {
             var timer = Observable.Timer(TimeSpan.FromMilliseconds(time));
@@ -65,6 +71,23 @@ namespace KairoEngine.Core
             }).AddTo(cancel);
             return cancel;
         }
+
+        /// <summary>
+        /// Executes a function after a certain real time has passed.
+        /// </summary>
+        /// <param name="time">In miliseconds</param>
+        /// <param name="action">A function to be executed</param>
+        /// <returns>A CompositeDisposable which can be used to cancel the timer</returns>
+        public static CompositeDisposable ExecuteRealTime(float time, Action action)
+        {
+            var timer = Observable.Timer(TimeSpan.FromMilliseconds(time), Scheduler.MainThreadIgnoreTimeScale);
+            CompositeDisposable cancel = new CompositeDisposable();
+            timer.Subscribe(xs => {
+                action();
+                cancel.Dispose();
+            }).AddTo(cancel);
+            return cancel;
+        }
     }
 }
 

+ 1 - 1
package.json

@@ -1,7 +1,7 @@
 {
   "name": "at.kairoscope.kairoengine.core",
   "displayName" : "KairoEngine Core",
-  "version": "0.1.6",
+  "version": "0.1.7",
   "unity": "2020.3",
   "description": "Base package for the KairoEngine library by Kairoscope",
   "repository": {