Hello Guest

Author Topic: Getting mouse click for specific TK2DSprite  (Read 4709 times)

mochatony

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 14
    • View Profile
Getting mouse click for specific TK2DSprite
« 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");
   }   
}

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Getting mouse click for specific TK2DSprite
« Reply #1 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.

mochatony

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 14
    • View Profile
Re: Getting mouse click for specific TK2DSprite
« Reply #2 on: March 11, 2013, 12:27:18 pm »
Thanks. Solved the problem.