Skip to content

Commit

Permalink
Merge pull request #17 from turanheydarli/main
Browse files Browse the repository at this point in the history
Get Slider return value bug fixed
  • Loading branch information
dmitry-ivashenko authored Jul 30, 2024
2 parents 652d6ab + 48ad010 commit 6a5e303
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 16 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@
# Visual Studio cache directory
.vs/

# Rider perferences directory
.idea/

# Gradle cache directory
.gradle/

Expand Down
33 changes: 19 additions & 14 deletions Assets/Plugins/StatefulUI/Runtime/Core/ContainerView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<GameObject> Instances { get; } = new List<GameObject>();

public event Action OnAddTestItem = delegate { };
public event Action OnClearTestItems = delegate { };
public event Action OnAddTestItem = delegate { };
public event Action OnClearTestItems = delegate { };

public void AddTestItem()
{
Expand All @@ -31,6 +29,7 @@ public void AddTestItem()
{
Instances.Add(Instantiate(Prefab, Root));
}

OnAddTestItem?.Invoke();
}

Expand All @@ -45,7 +44,8 @@ public void ClearTransform()
OnClearTestItems?.Invoke();
}

public void FillWithItems<TL>(IEnumerable<TL> items, Action<StatefulComponent, TL> action, bool keepItems = false)
public void FillWithItems<TL>(IEnumerable<TL> items, Action<StatefulComponent, TL> action,
bool keepItems = false)
{
if (!keepItems)
{
Expand All @@ -56,16 +56,21 @@ public void FillWithItems<TL>(IEnumerable<TL> items, Action<StatefulComponent, T
{
var view = AddInstance().GetComponentAlways<StatefulComponent>();
view.Localize();

foreach (var InnerComponent in view.InnerComponents)
{
InnerComponent.InnerComponent.Localize();
}

action(view, item);
}
}

public void FillWithItems<TL>(Action<StatefulComponent, TL> action, bool keepItems = false, params TL[] items)
{
FillWithItems(items, action, keepItems);
}

public GameObject AddInstance()
{
var instance = Instances.Find(go => !go.activeSelf);
Expand All @@ -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);
Expand All @@ -92,12 +97,12 @@ public StatefulComponent AddStatefulComponent()
{
var view = AddInstance().GetComponent<StatefulComponent>();
view.Localize();

foreach (var InnerComponent in view.InnerComponents)
{
InnerComponent.InnerComponent.Localize();
}

return view;
}

Expand Down
4 changes: 2 additions & 2 deletions Assets/Plugins/StatefulUI/Runtime/Core/StatefulComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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];
}
}

Expand Down

0 comments on commit 6a5e303

Please sign in to comment.