Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get Slider return value bug fixed #17

Merged
merged 9 commits into from
Jul 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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