diff --git a/Assets/Plugins/StatefulUI/Runtime/Core/StatefulComponent.cs b/Assets/Plugins/StatefulUI/Runtime/Core/StatefulComponent.cs index db24b4e..f51c38f 100644 --- a/Assets/Plugins/StatefulUI/Runtime/Core/StatefulComponent.cs +++ b/Assets/Plugins/StatefulUI/Runtime/Core/StatefulComponent.cs @@ -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) { @@ -445,7 +462,7 @@ public T GetItem(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;