2D Toolkit Forum

2D Toolkit => Support => Topic started by: mochatony on March 11, 2013, 05:29:13 am

Title: Getting mouse click for specific TK2DSprite
Post by: mochatony on March 11, 2013, 05:29:13 am
Hi,

I am having problem with getting OnMouseDown and OnMouseEvent for TK2DSprite that have mesh collider. But, it works fine for TK2DSprite with box collider implemented.

My question is how do I get OnMouseDown event to works for sprite that implement mesh collider. Thank you

Some of my codes below:

using UnityEngine;
using System.Collections;

public class Crate : MonoBehaviour {

   void OnMouseDown() {
      Debug.Log("MouseDown");
   }

   void OnMouseUp() {
      Debug.Log("MouseUp");
   }   
}
Title: Re: Getting mouse click for specific TK2DSprite
Post by: unikronsoftware on March 11, 2013, 09:31:44 am
You will need to enable Collider Caps (front / back / both) so there is something for the ray to hit. By default, the mesh collider created in tk2d doesn't have any caps at all to reduce polygon count.
Title: Re: Getting mouse click for specific TK2DSprite
Post by: mochatony on March 11, 2013, 12:27:18 pm
Thanks. Solved the problem.