UnityEvent.Invoke() causing ArgumentOutOfRangeException
Hello, I'm trying to use UnityEvents and I saw that for some reason this error when I try to invoke an UnityEvent:
ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index
The code I has nothing that seeming has anything to do with indexes, and everything in the editor appears fine (the event would normally be valid otherwise). Here's my code:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Events;
public class MouseInteractionScript : MonoBehaviour
{
public UnityEvent EYE_Event;
// Start is called before the first frame update
void Start()
{
}
void Awake()
{
Collider2D col2D = gameObject.AddComponent<BoxCollider2D>() as BoxCollider2D;
}
// Update is called once per frame
void Update()
{
}
void OnMouseDown()
{
EYE_Event.Invoke();
}
}
EYE_Event is set in the editor
Please, provide the stack trace and the actual script throwing the error.
Your answer
Follow this Question
Related Questions
UI Text is not being rebuilt/updated in edit mode, when changing text from OnInspectorGUI 1 Answer
How to create an event trigger script for intercepted events 0 Answers
PrefabUtility.CreatePrefab() results in "not a valid asset file name" error? 2 Answers
How can i rotate all the child objects together at the same time ? 1 Answer
Player Can't Interact With UI 3 Answers