Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Question Argument Out Of Range

Discussion in 'C# Job System' started by AhmedSafaKoral, Apr 19, 2023.

  1. AhmedSafaKoral

    AhmedSafaKoral

    Joined:
    Apr 19, 2023
    Posts:
    2
    Code (CSharp):
    1.     public void PickPuzzle()
    2.     {
    3.         //string name = UnityEngine.EventSystems.EventSystem.current.currentSelectedGameObject.name;
    4.  
    5.         if (!firstGuess)
    6.         {
    7.             firstGuess = true;
    8.             firstGuessIndex = int.Parse(UnityEngine.EventSystems.EventSystem.current.currentSelectedGameObject.name);
    9.             firstGuessPuzzle = gamePuzzles[firstGuessIndex].name;
    10.             btns[firstGuessIndex].image.sprite = gamePuzzles[firstGuessIndex];
    11.             btns[firstGuessIndex].interactable = false;
    12.         }
    13.         else if (!secondGuess)
    14.         {
    15.             secondGuess = true;
    16.             secondGuessIndex = int.Parse(UnityEngine.EventSystems.EventSystem.current.currentSelectedGameObject.name);
    17.             secondGuessPuzzle = gamePuzzles[secondGuessIndex].name;
    18.             btns[secondGuessIndex].image.sprite = gamePuzzles[secondGuessIndex];
    19.             btns[firstGuessIndex].interactable = true;
    20.  
    21.             if (firstGuessPuzzle == secondGuessPuzzle)
    22.             {
    23.                 print("Puzzle match");
    24.             }
    25.             else
    26.             {
    27.                 print("Puzzle don't match");
    28.             }
    29.             StartCoroutine(checkThePuzzleMatch());
    30.         }
    giving me errors on
    Code (CSharp):
    1. secondGuessPuzzle = gamePuzzles[secondGuessIndex].name;
    tried to solve it couldn't do anything
     
  2. AhmedSafaKoral

    AhmedSafaKoral

    Joined:
    Apr 19, 2023
    Posts:
    2