Browse Source

加两判断为空

Void_F 3 days ago
parent
commit
d46c2242a2
1 changed files with 3 additions and 3 deletions
  1. 3 3
      Assets/Scripts/UI/UIView/GCYW/TaskPhotoPanel.cs

+ 3 - 3
Assets/Scripts/UI/UIView/GCYW/TaskPhotoPanel.cs

@@ -40,7 +40,7 @@ public class TaskPhotoPanel : MonoBehaviour
 
     public void Next()
     {
-        if (currentIndex < task_item.files.Length - 1)
+        if (task_item is { files: not null } && currentIndex < task_item.files.Length - 1)
         {
             currentIndex++;
             ChangePage(currentIndex);
@@ -49,7 +49,7 @@ public class TaskPhotoPanel : MonoBehaviour
 
     public void Last()
     {
-        if (currentIndex > 0)
+        if (task_item is { files: not null } &&currentIndex > 0)
         {
             currentIndex--;
             ChangePage(currentIndex);
@@ -59,7 +59,7 @@ public class TaskPhotoPanel : MonoBehaviour
     public void ChangePage(int pageIndex)
     {
         img.texture = null;
-        if (task_item.files.Length < 1)
+        if (task_item?.files == null || task_item.files.Length < 1)
         {
             pageText.text = $"0/0";
             return;