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

Fix wrong return type of GetImage #3

Merged
merged 2 commits into from
Oct 16, 2023
Merged
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
19 changes: 18 additions & 1 deletion Assets/Plugins/StatefulUI/Runtime/Core/StatefulComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,23 @@ private Image GetImage(int role)

return null;
}

private ImageReference GetImageReference(int role)
{
for (var i = 0; i < Images.Count; i++)
{
if (Images[i].Role == role)
{
return Images[i];
}
}

var go = gameObject;
var roleName = RoleUtils.GetName(RoleUtils.ImageRoleType, role);
Debug.LogError($"View {name} does not contain image with role {roleName}, scene path: {go.GetScenePath()}", go);

return null;
}

public void SetImageByRawRole(int role, Sprite sprite)
{
Expand Down Expand Up @@ -445,7 +462,7 @@ public T GetItem<T>(int roleValue) where T : class
if (type == manager.ButtonReferenceType) return GetButton(roleValue) as T;
if (type == manager.ContainerReferenceType) return GetContainer(roleValue) as T;
if (type == manager.DropdownReferenceType) return GetDropdown(roleValue) as T;
if (type == manager.ImageReferenceType) return GetImage(roleValue) as T;
if (type == manager.ImageReferenceType) return GetImageReference(roleValue) as T;
if (type == manager.InnerComponentReferenceType) return GetInnerComponent(roleValue) as T;
if (type == manager.ObjectReferenceType) return GetObject(roleValue) as T;
if (type == manager.SliderReferenceType) return GetSlider(roleValue) as T;
Expand Down