Hello Guest

Author Topic: Make UI work with Physics2d  (Read 3371 times)

cesarpo

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 8
    • View Profile
Make UI work with Physics2d
« on: February 24, 2014, 05:40:36 am »
I just realized that the UI system does not work with the new BoxCollider2D, which means that the classic BoxCollider has to be used,  which also means that unity has to include the Physix engine along with Box2D.

Mixing the 2 types of colliders will make unity run both engines at the same time if I'm not mistaken.

I'm worried about performance and file size, should I? HOw much difficult would be to update the tk2dUiManager to use the 2D engine?

update:

I added this to the tk2dUiManager, instead of the 3d code, seems to be working:

Code: [Select]

var hit = Physics2D.Raycast(ray.origin, ray.direction, 10f);

if(hit.collider != null)
{
return hit.collider.GetComponent<tk2dUIItem>();
}

Will this break some functionality somewhere?

« Last Edit: February 24, 2014, 05:59:39 am by cesarpo »

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Make UI work with Physics2d
« Reply #1 on: February 24, 2014, 12:08:29 pm »
No,
One of the reasons we didn't make it work with 2d physics is all the built in prefabs use 3d colliders. Changing that isn't practical as it would affect all existing users.

Yeah thats pretty much all that is required though. Go for it, no harm as long as you realise you need to change the prefabs before using them.