A common problem in Unity - my OnMouseUpAsButton() is not being called, and I do not understand why. I have attached box collider 2d (though its size is set up during runtime, but by the time I click on it it has proper size and covers the whole button). My object is an UI element, created from prefab during runtime. Here you can see its inspector info:
Code:
using UnityEngine;
using System.Collections;
public class button_controller : MonoBehaviour {
void OnMouseUpAsButton()
{
Debug.Log("Clicked event button");
switch(click_action){
case action.NONE:
action_none();
break;
}
}
I tried going through other threads where people had similar problems but nothing seems to work. Any ideas what might be happening?
EDIT: I found out that if I add a new button , directly from the inspector to the canvas, whose collider is within the canvas all other buttons start working. Interestingly I cannot put this new button anywhere, it has to be at least a bit within the canvas
