From 61c6e6b6434627864a2767b5f14b5a8ae1f00861 Mon Sep 17 00:00:00 2001 From: Batuhan Dursun <60223533+frutbn@users.noreply.github.com> Date: Fri, 17 May 2024 15:40:43 +0300 Subject: [PATCH 1/7] Add package.json --- Assets/Plugins/StatefulUI/package.json | 12 ++++++++++++ Assets/Plugins/StatefulUI/package.json.meta | 7 +++++++ README.md | 14 ++++++++++++++ 3 files changed, 33 insertions(+) create mode 100644 Assets/Plugins/StatefulUI/package.json create mode 100644 Assets/Plugins/StatefulUI/package.json.meta diff --git a/Assets/Plugins/StatefulUI/package.json b/Assets/Plugins/StatefulUI/package.json new file mode 100644 index 0000000..27c4b38 --- /dev/null +++ b/Assets/Plugins/StatefulUI/package.json @@ -0,0 +1,12 @@ +{ + "name": "dmitry-ivashenko.statefului", + "displayName": "StatefulUI", + "version": "1.0.3", + "unity": "2021.3", + "description": "Stateful UI - A library for structured state-based UI development in Unity", + "keywords": ["UI"], + "license": "MIT", + "documentationUrl": "https://github.com/dmitry-ivashenko/StatefulUI/blob/main/README.md", + "changelogUrl": "https://github.com/dmitry-ivashenko/StatefulUI/releases", + "licensesUrl": "https://github.com/dmitry-ivashenko/StatefulUI/blob/main/LICENSE" + } \ No newline at end of file diff --git a/Assets/Plugins/StatefulUI/package.json.meta b/Assets/Plugins/StatefulUI/package.json.meta new file mode 100644 index 0000000..3893699 --- /dev/null +++ b/Assets/Plugins/StatefulUI/package.json.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 2e050fe0781741dc844552dce4f3438f +PackageManifestImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: \ No newline at end of file diff --git a/README.md b/README.md index 5c008c9..4dfec18 100644 --- a/README.md +++ b/README.md @@ -106,6 +106,20 @@ public void ShowResults(IEnumerable rewards) } ``` +## Installation + +### Install via UPM (using Git URL) + +1. Open UPM from Window -> Package Manager. +2. Click "+" then click "Add package from git URL" +3. Enter the URL "https://github.com/dmitry-ivashenko/StatefulUI.git?path=Assets/Plugins/StatefulUI" and click add. +3. UPM should now install the package. + +### Install manually (using .unitypackage) + +1. Download the .unitypackage from [releases](https://github.com/dmitry-ivashenko/StatefulUI/releases) page. +2. Open .unitypackage file. + ## Roadmap - Enhancing State capabilities, including new UI changes such as animations and sound effects. From cfca3fa03d33abdcd234d5f5e53f4400f6fef84d Mon Sep 17 00:00:00 2001 From: Batuhan Dursun <60223533+frutbn@users.noreply.github.com> Date: Fri, 17 May 2024 15:58:36 +0300 Subject: [PATCH 2/7] Fix missing reference --- Assets/Plugins/StatefulUI/Editor/Core/TypeGenerator.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Assets/Plugins/StatefulUI/Editor/Core/TypeGenerator.cs b/Assets/Plugins/StatefulUI/Editor/Core/TypeGenerator.cs index 969c244..19346a5 100644 --- a/Assets/Plugins/StatefulUI/Editor/Core/TypeGenerator.cs +++ b/Assets/Plugins/StatefulUI/Editor/Core/TypeGenerator.cs @@ -84,7 +84,7 @@ private void AddEndBracket() _result.AppendLine("}"); } - public override String ToString() + public override string ToString() { return _result.ToString(); } From 2c12706e55e26be7f2279636b4250762f4870281 Mon Sep 17 00:00:00 2001 From: Dmitrii Ivashchenko Date: Wed, 26 Jun 2024 12:32:44 +0800 Subject: [PATCH 3/7] add editor animation update loop --- .../Editor/Core/EditCommentWindow.cs | 2 +- .../Editor/Selector/ItemsSelector.cs | 15 ++++++- .../Runtime/Core/StatefulUiUtils.cs | 41 +++++++++++++++++-- .../StatefulUI/Runtime/States/NodeData.cs | 16 +------- .../Runtime/States/StateProcessor.cs | 3 +- 5 files changed, 55 insertions(+), 22 deletions(-) diff --git a/Assets/Plugins/StatefulUI/Editor/Core/EditCommentWindow.cs b/Assets/Plugins/StatefulUI/Editor/Core/EditCommentWindow.cs index b87044e..b18008f 100644 --- a/Assets/Plugins/StatefulUI/Editor/Core/EditCommentWindow.cs +++ b/Assets/Plugins/StatefulUI/Editor/Core/EditCommentWindow.cs @@ -39,7 +39,7 @@ public static void Button(SerializedObject serializedObject, SerializedProperty } } - public void Init(Vector2 mousePos, SerializedProperty property, SerializedObject serializedObject, string name) + private void Init(Vector2 mousePos, SerializedProperty property, SerializedObject serializedObject, string name) { _name = name; _serializedObject = serializedObject; diff --git a/Assets/Plugins/StatefulUI/Editor/Selector/ItemsSelector.cs b/Assets/Plugins/StatefulUI/Editor/Selector/ItemsSelector.cs index d7028ee..e52fd0c 100644 --- a/Assets/Plugins/StatefulUI/Editor/Selector/ItemsSelector.cs +++ b/Assets/Plugins/StatefulUI/Editor/Selector/ItemsSelector.cs @@ -112,9 +112,20 @@ private void OnGUI() { GUILayout.Space(10); GUI.SetNextControlName("NameFilter"); - _filter = GUILayout.TextField(_filter ?? "", GUI.skin.FindStyle("ToolbarSearchTextField")); + var style = GUI.skin.FindStyle("ToolbarSearchTextField"); + if (style == null) + { + style = new GUIStyle(GUI.skin.FindStyle("SearchTextField")); + } + _filter = GUILayout.TextField(_filter ?? "", style); + + var cancelStyle = GUI.skin.FindStyle("ToolbarSearchCancelButton"); + if (cancelStyle == null) + { + cancelStyle = new GUIStyle(GUI.skin.FindStyle("SearchCancelButton")); + } - if (GUILayout.Button("", GUI.skin.FindStyle("ToolbarSearchCancelButton"))) + if (GUILayout.Button("", cancelStyle)) { // Remove focus if cleared _filter = ""; diff --git a/Assets/Plugins/StatefulUI/Runtime/Core/StatefulUiUtils.cs b/Assets/Plugins/StatefulUI/Runtime/Core/StatefulUiUtils.cs index 1bc1903..2acaac1 100644 --- a/Assets/Plugins/StatefulUI/Runtime/Core/StatefulUiUtils.cs +++ b/Assets/Plugins/StatefulUI/Runtime/Core/StatefulUiUtils.cs @@ -3,7 +3,6 @@ using System.Globalization; using System.Linq; using System.Text; -using StatefulUI.Runtime.Localization; using UnityEngine; using UnityEngine.UI; @@ -311,7 +310,7 @@ public static string CamelCase(this string format) return result; } - + public static T GetComponentAlways(this GameObject gameObject) where T : Component { return gameObject.TryGetComponent(out var component) ? component : gameObject.AddComponent(); @@ -350,7 +349,7 @@ public static T FindImplementation(params Type[] excludes) return default; } - + public static bool IsImplementationExists(params Type[] excludes) { var baseType = typeof(T); @@ -369,5 +368,41 @@ public static bool IsImplementationExists(params Type[] excludes) return false; } + + private static float _updateFinishTime; + + public static void StartEditorUpdateLoop(float duration) + { +#if UNITY_EDITOR + if (Application.isPlaying || duration <= 0f) return; + + if (_updateFinishTime > Time.realtimeSinceStartup) + { + _updateFinishTime = Mathf.Max(_updateFinishTime, Time.realtimeSinceStartup + duration); + return; + } + + _updateFinishTime = Time.realtimeSinceStartup + duration; + + UnityEditor.EditorApplication.CallbackFunction callback = null; + callback = () => + { + if (Time.realtimeSinceStartup > _updateFinishTime) + { + UnityEditor.EditorApplication.update -= callback; + Debug.Log("Editor update loop finished"); + return; + } + + UnityEditor.EditorApplication.QueuePlayerLoopUpdate(); + UnityEditor.SceneView.RepaintAll(); + }; + + UnityEditor.EditorApplication.update += callback; + + UnityEditor.EditorApplication.QueuePlayerLoopUpdate(); + UnityEditor.SceneView.RepaintAll(); +#endif + } } } diff --git a/Assets/Plugins/StatefulUI/Runtime/States/NodeData.cs b/Assets/Plugins/StatefulUI/Runtime/States/NodeData.cs index 3d151f3..51753fd 100644 --- a/Assets/Plugins/StatefulUI/Runtime/States/NodeData.cs +++ b/Assets/Plugins/StatefulUI/Runtime/States/NodeData.cs @@ -5,23 +5,9 @@ namespace StatefulUI.Runtime.States { [Serializable] - public class NodeData : ISerializationCallbackReceiver + public class NodeData { public Vector2 Position; - public int ParentRole; - public bool HasParent; public List ParentRoles = new List(); - - public void OnBeforeSerialize() - { - } - - public void OnAfterDeserialize() - { - if (HasParent && !ParentRoles.Contains(ParentRole)) - { - ParentRoles.Add(ParentRole); - } - } } } \ No newline at end of file diff --git a/Assets/Plugins/StatefulUI/Runtime/States/StateProcessor.cs b/Assets/Plugins/StatefulUI/Runtime/States/StateProcessor.cs index ccaddfb..3f2d179 100644 --- a/Assets/Plugins/StatefulUI/Runtime/States/StateProcessor.cs +++ b/Assets/Plugins/StatefulUI/Runtime/States/StateProcessor.cs @@ -154,6 +154,8 @@ private float ApplyAnimation(StateReference state, StateDescription desc) duration = clip.length; } + StatefulUiUtils.StartEditorUpdateLoop(clip.isLooping ? 100 * clip.length : clip.length); + stateAnimationInfo.OnUpdate(); break; } @@ -165,7 +167,6 @@ private float ApplyAnimation(StateReference state, StateDescription desc) } return duration; - } private static void ApplyButton(StateDescription desc) From c7043d3405f72049598b87f384ac513e1b334c7c Mon Sep 17 00:00:00 2001 From: Dmitrii Ivashchenko Date: Thu, 27 Jun 2024 10:26:25 +0800 Subject: [PATCH 4/7] update player version --- Assets/Plugins/StatefulUI/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Assets/Plugins/StatefulUI/package.json b/Assets/Plugins/StatefulUI/package.json index 27c4b38..cafe426 100644 --- a/Assets/Plugins/StatefulUI/package.json +++ b/Assets/Plugins/StatefulUI/package.json @@ -1,7 +1,7 @@ { "name": "dmitry-ivashenko.statefului", "displayName": "StatefulUI", - "version": "1.0.3", + "version": "1.0.4", "unity": "2021.3", "description": "Stateful UI - A library for structured state-based UI development in Unity", "keywords": ["UI"], From 8d665b428d2fca23c985ad5bf3cf735b39798891 Mon Sep 17 00:00:00 2001 From: Dmitrii Ivashchenko Date: Thu, 27 Jun 2024 11:00:16 +0800 Subject: [PATCH 5/7] fix inner component getter --- Assets/Plugins/StatefulUI/Runtime/Core/StatefulComponent.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Assets/Plugins/StatefulUI/Runtime/Core/StatefulComponent.cs b/Assets/Plugins/StatefulUI/Runtime/Core/StatefulComponent.cs index f51c38f..b56657c 100644 --- a/Assets/Plugins/StatefulUI/Runtime/Core/StatefulComponent.cs +++ b/Assets/Plugins/StatefulUI/Runtime/Core/StatefulComponent.cs @@ -352,13 +352,13 @@ private Toggle GetToggle(int role) return null; } - private StatefulComponent GetInnerComponent(int role) + private InnerComponentReference GetInnerComponent(int role) { for (var i = 0; i < InnerComponents.Count; i++) { if (InnerComponents[i].Role == role) { - return InnerComponents[i].InnerComponent; + return InnerComponents[i]; } } From b1e226fdad7c65d7cc40ed34ce5e66f84a8e8189 Mon Sep 17 00:00:00 2001 From: Dmitrii Ivashchenko Date: Tue, 16 Jul 2024 07:37:30 +0800 Subject: [PATCH 6/7] fix view.GetContainer() returns null #16 --- Assets/Plugins/StatefulUI/Runtime/Core/StatefulComponent.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Assets/Plugins/StatefulUI/Runtime/Core/StatefulComponent.cs b/Assets/Plugins/StatefulUI/Runtime/Core/StatefulComponent.cs index b56657c..26ed175 100644 --- a/Assets/Plugins/StatefulUI/Runtime/Core/StatefulComponent.cs +++ b/Assets/Plugins/StatefulUI/Runtime/Core/StatefulComponent.cs @@ -290,7 +290,7 @@ private AnimatorReference GetAnimator(int role) return null; } - public bool TryGetContainer(int role, out ContainerView view) + public bool TryGetContainer(int role, out ContainerReference view) { view = null; @@ -298,7 +298,7 @@ public bool TryGetContainer(int role, out ContainerView view) { if (Containers[i].Role == role) { - view = Containers[i].Container; + view = Containers[i]; return true; } } @@ -306,7 +306,7 @@ public bool TryGetContainer(int role, out ContainerView view) return false; } - private ContainerView GetContainer(int role) + private ContainerReference GetContainer(int role) { if (!TryGetContainer(role, out var view)) { From 34c376aa9e9f28797857aa35c292da656cfa27ea Mon Sep 17 00:00:00 2001 From: Dmitrii Ivashchenko Date: Tue, 16 Jul 2024 07:38:40 +0800 Subject: [PATCH 7/7] update plugin version --- Assets/Plugins/StatefulUI/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Assets/Plugins/StatefulUI/package.json b/Assets/Plugins/StatefulUI/package.json index cafe426..7603938 100644 --- a/Assets/Plugins/StatefulUI/package.json +++ b/Assets/Plugins/StatefulUI/package.json @@ -1,7 +1,7 @@ { "name": "dmitry-ivashenko.statefului", "displayName": "StatefulUI", - "version": "1.0.4", + "version": "1.0.5", "unity": "2021.3", "description": "Stateful UI - A library for structured state-based UI development in Unity", "keywords": ["UI"],