I've been given an error that does not specificy why exactly I'm getting one.

There is an error I get with the line

It has been attached.
Here is a snip of the code:

GameObject cardHolder;
    GameObject cardScrollPanel;
    Transform CardScrollPanel;

    public GameObject GameBehavior;
    public GameObject CardSpawner;

void Start()
    {
        CardSpawner = GameObject.Find("CardSpawner");
        isJudgeSet = false;
        GameBehavior = GameObject.Find("GameBehaviorManager");
        cardHolder = GameObject.Find("CardHolder");
        cardScrollPanel = GameObject.Find("JudgeCardSlots");
        cardScrollPanel = GameBehavior.GetComponent<GameBehavior>().judgeCardScrollPanel;
        CardHolder = cardHolder.transform;
        CardScrollPanel = cardScrollPanel.transform;
        str = CardSpawner.GetComponent<CardSpawner>().tempJudgeableCardName[0];
        CardSpawner.GetComponent<CardSpawner>().tempJudgeableCardName.Remove(str);
        SetCard(str);
        gameObject.transform.SetParent(CardScrollPanel);
    }

Line 53 is actually line 23 since this is just a part of the code.

Here are some notes on IndexOutOfRangeException and ArgumentOutOfRangeException:

http://plbm.com/?p=236

Steps to success:

  • find which collection it is (critical first step!)
  • find out why it has fewer items than you expect
  • fix whatever logic is making the indexing value exceed the collection
  • remember you might have more than one instance of this script in your scene/prefab
2 Likes

Is that your whole code, I assume it’s not, but what I would do is I’d just debug the whole code, explore is. Look where your accessing the index and see if it is null or doesn’t exist or something like that. It might be a bit hard to find where it is but you’ll get there, posting your whole would be a good choice as well

EDIT: Damn dekker beat me here :frowning:

Ok I just looked at when you said [quote=“Kurt-Dekker, post:2, topic: 858620, username:Kurt-Dekker”]

  • remember you might have more than one instance of this script in your scene/prefab
    [/quote]
    and saw that it was instantiating two of the same prefabs that had the script instead of one which would cause the script to be run more than once. Thanks, sorry for posting such a small mild inconvenience.
1 Like