diff --git a/.gitignore b/.gitignore index cad145c..313a461 100644 --- a/.gitignore +++ b/.gitignore @@ -22,6 +22,9 @@ # Visual Studio cache directory .vs/ +# Rider perferences directory +.idea/ + # Gradle cache directory .gradle/ diff --git a/Assets/Plugins/StatefulUI/Runtime/Core/ContainerView.cs b/Assets/Plugins/StatefulUI/Runtime/Core/ContainerView.cs index d302e9a..ed76f60 100644 --- a/Assets/Plugins/StatefulUI/Runtime/Core/ContainerView.cs +++ b/Assets/Plugins/StatefulUI/Runtime/Core/ContainerView.cs @@ -8,18 +8,16 @@ public class ContainerView : MonoBehaviour { public RectTransform RectTransform => transform as RectTransform; - [ProjectAssetOnly] - public GameObject Prefab; - - [SerializeField] - private Transform _root; + [ProjectAssetOnly] public GameObject Prefab; + + [SerializeField] private Transform _root; public Transform Root => _root ? _root : transform; - + public List Instances { get; } = new List(); - public event Action OnAddTestItem = delegate { }; - public event Action OnClearTestItems = delegate { }; + public event Action OnAddTestItem = delegate { }; + public event Action OnClearTestItems = delegate { }; public void AddTestItem() { @@ -31,6 +29,7 @@ public void AddTestItem() { Instances.Add(Instantiate(Prefab, Root)); } + OnAddTestItem?.Invoke(); } @@ -45,7 +44,8 @@ public void ClearTransform() OnClearTestItems?.Invoke(); } - public void FillWithItems(IEnumerable items, Action action, bool keepItems = false) + public void FillWithItems(IEnumerable items, Action action, + bool keepItems = false) { if (!keepItems) { @@ -56,16 +56,21 @@ public void FillWithItems(IEnumerable items, Action(); view.Localize(); - + foreach (var InnerComponent in view.InnerComponents) { InnerComponent.InnerComponent.Localize(); } - + action(view, item); } } + public void FillWithItems(Action action, bool keepItems = false, params TL[] items) + { + FillWithItems(items, action, keepItems); + } + public GameObject AddInstance() { var instance = Instances.Find(go => !go.activeSelf); @@ -74,7 +79,7 @@ public GameObject AddInstance() instance = StatefulUiManager.Instance.InstantiatePrefab(Prefab); Instances.Add(instance); } - + instance.SetActive(true); var instanceTransform = instance.transform; instanceTransform.SetParent(Root); @@ -92,12 +97,12 @@ public StatefulComponent AddStatefulComponent() { var view = AddInstance().GetComponent(); view.Localize(); - + foreach (var InnerComponent in view.InnerComponents) { InnerComponent.InnerComponent.Localize(); } - + return view; } diff --git a/Assets/Plugins/StatefulUI/Runtime/Core/StatefulComponent.cs b/Assets/Plugins/StatefulUI/Runtime/Core/StatefulComponent.cs index 26ed175..d8c75da 100644 --- a/Assets/Plugins/StatefulUI/Runtime/Core/StatefulComponent.cs +++ b/Assets/Plugins/StatefulUI/Runtime/Core/StatefulComponent.cs @@ -318,13 +318,13 @@ private ContainerReference GetContainer(int role) return view; } - private Slider GetSlider(int role) + private SliderReference GetSlider(int role) { for (var i = 0; i < Sliders.Count; i++) { if (Sliders[i].Role == role) { - return Sliders[i].Slider; + return Sliders[i]; } }