Explorar el Código

Added FindFileByName function to Utilities

James Peret hace 2 años
padre
commit
0949621078

+ 3 - 2
Editor/IconFoldoutGroupAttributeDrawer.cs

@@ -23,11 +23,12 @@ namespace KairoEngine.Core.Editor
             SirenixEditorGUI.BeginBox();
             SirenixEditorGUI.BeginBoxHeader();
             string text = ValueResolver.GetForString(this.Property, this.Attribute.text, null).GetValue();
-            Texture2D image = EditorGUIUtility.FindTexture(this.Attribute.iconPath);
+            string path = ValueResolver.GetForString(this.Property, this.Attribute.iconPath, null).GetValue();
+            Texture2D image = EditorGUIUtility.FindTexture(path);
             if(image == null)
             {
                 image = new Texture2D(1, 1);
-                var data = System.IO.File.ReadAllBytes(this.Attribute.iconPath);
+                var data = System.IO.File.ReadAllBytes(path);
                 if(data != null) image.LoadImage(data);
                 image.Apply();
             }

+ 5 - 0
Readme.md

@@ -25,6 +25,11 @@ This contains the base code that other packages will use. It includes code for t
 
 ### 📄Changelog
 
+##### v0.2.2
+- Fixed WaitGameAction icon path to find the file instead of using a fixed path
+- Added FindFileByName function to Utilities
+- Fixed bug in IconFoldoutGroupAttributeDrawer icon path
+
 ##### v0.2.1
 - Added TriggerGenericEvent GameAction
 

+ 11 - 2
Runtime/GameActions/Actions/WaitGameAction.cs

@@ -28,9 +28,18 @@ namespace KairoEngine.Core.GameActions
         #endregion
 
         #region ActionVariables
+        private string GetIconPath 
+        {
+            get 
+            {
+                if(_iconPath == "") _iconPath = Utilities.FindFileByName("WaitGameActionIcon.png");
+                return _iconPath;
+            }
+        }
+        [SerializeField, HideInInspector] private string _iconPath = "";
 
-        [IconFoldoutGroup("@name", "Assets/Plugins/KairoEngine/Core/Editor/Icons/WaitGameActionIcon.png")]  public float time = 1f;
-        [IconFoldoutGroup("@name", "Assets/Plugins/KairoEngine/Core/Editor/Icons/WaitGameActionIcon.png")]  public bool realtime = true;
+        [IconFoldoutGroup("@name", "@GetIconPath")]  public float time = 1f;
+        [IconFoldoutGroup("@name", "@GetIconPath")]  public bool realtime = true;
         private float elapsedTime = 0f;
 
         #endregion

+ 12 - 0
Runtime/Utilities.cs

@@ -66,5 +66,17 @@ namespace KairoEngine.Core
         {
             return Deserialze<T>(Serialize(source));
         }
+
+        public static string FindFileByName(string fileName)
+        {
+            string[] res = System.IO.Directory.GetFiles(Application.dataPath, fileName, System.IO.SearchOption.AllDirectories);
+            if (res.Length == 0)
+            {
+                Debug.LogError("error message ....");
+                return fileName;
+            }
+            string path = res[0].Replace("\\", "/");
+            return path;
+        }
     }
 }

+ 1 - 1
package.json

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