2D Toolkit Forum
2D Toolkit => Support => Topic started by: griden on February 06, 2014, 11:24:43 am
-
So I have a regular button (from the demo prefab) and attached the following custom script to it:
private tk2dUIItem uiItem;
void Start () {
uiItem = GetComponent<tk2dUIItem>();
}
void OnEnable()
{
uiItem.OnDown += ButtonDown;
}
void ButtonDown()
{
Debug.Log("Button Down!");
}
... And clicking it doesn't do anything. The collider is ok, and the tk2dCamera has a tk2dUICamera component attached. What am I missing is the question? :) Thanks.
-
Does the button actually press if you click on it? Is it too close to the camera that it is clipping with the near clip plane? Do you have a negative near clip plane (there was a bug which will be fixed in tk2d 2.4, for now you should just move your camera back and use a positive near clip plane if this is the case).
-
Oh yes, the button does the scale down animation and the clicking sound. And the near clipping plane is positive 0.3, far is 25 (took the values from the tutorial). The button itself is at Z: -2, and the camera - at Z: -10. And they all look pretty far from each other in 3D view.
UPDATE: it works now. I just dragged the same object to the Target field (under 'Send Message' in the inspector) and simply picked the method from the list. Object sending message to itself. Still wondering why the code approach didn't work, but everything is fine now.
Thanks again!
-
Hi,
Just got into the same problem. so i post the solution if it gonna help someone in the future...
use:
void Awake()
instead of:
void Start()