Sfoglia il codice sorgente

Added Open URL GameAction

James Peret 2 anni fa
parent
commit
30e888af2d

+ 86 - 0
Runtime/GameActions/Actions/OpenUrlGameAction.cs

@@ -0,0 +1,86 @@
+using System.Collections;
+using System.Linq;
+using System.Collections.Generic;
+using UnityEngine;
+using Sirenix.OdinInspector;
+using KairoEngine.Core;
+
+namespace KairoEngine.Core.GameActions
+{
+
+    [System.Serializable, HideReferenceObjectPicker]
+    public class OpenUrlGameAction : GameActionBase
+    {
+        #region DefaultVariables
+        public override string name { get => $"Open URL ({url}) "; }
+
+        public override GameActionsController controller { 
+            get => _controller; 
+            set 
+            {
+                _controller = value;
+                typeName = "OpenUrlGameAction";
+            }
+        }
+        public override string GetTypeName() => "OpenUrlGameAction";
+        public override string GetActionName() => "Core/Open URL";
+
+        #endregion
+
+        #region ActionVariables
+        [FoldoutGroup("@name")]  public string url = "https://www.example.com";
+
+        #endregion
+
+        public OpenUrlGameAction(GameActionsController controller) : base(controller)
+        {
+            this.controller = controller;
+            className =  this.GetType().AssemblyQualifiedName;
+        }
+
+        #region Flow
+
+        public override void Start()
+        {
+            Application.OpenURL(url);
+            _done = true;
+            _started = true;
+        }
+
+        public override void Update() 
+        { 
+
+        }
+
+        public override void Restart()
+        {
+            _done = false;
+            _started = false;
+        }
+
+        #endregion
+
+        #region Utilities
+
+        private OpenUrlGameAction Duplicate(GameActionsController controller = null)
+        {
+            OpenUrlGameAction action = new OpenUrlGameAction(controller == null ? this.controller : controller);
+            action.controller = controller;
+            action.url = url;
+            return action;
+        }
+
+        #endregion
+
+        #region Serialization
+
+        public static OpenUrlGameAction JSONToOpenUrlGameAction(string data)
+        {
+            return JsonUtility.FromJson<OpenUrlGameAction>(data);
+        }
+
+        #endregion
+
+    }
+}
+

+ 11 - 0
Runtime/GameActions/Actions/OpenUrlGameAction.cs.meta

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

+ 1 - 1
Runtime/Utilities.cs

@@ -69,7 +69,7 @@ namespace KairoEngine.Core
 
         public static string FindFileByName(string fileName)
         {
-            string[] res = System.IO.Directory.GetFiles(Application.dataPath, fileName, System.IO.SearchOption.AllDirectories);
+            string[] res = System.IO.Directory.GetFiles(Application.dataPath + "/../", fileName, System.IO.SearchOption.AllDirectories);
             if (res.Length == 0)
             {
                 Debug.LogError("error message ....");