- Home /
Detect Collision between two Guitextures or Guitexts etc.
I need to detect the Collision between two GuiTextures, but I heard it's impossible with collider. Is there any other way?
Answer by robertbu · Aug 14, 2014 at 08:33 AM
I can think of two approaches, both of which are ugly. First, you can have game objects with colliders and rigidbodies sized to the GUITextures and GUITexts and have those game objects track the position of the GUITextures and GUITexts. These colliders would report triggers or collisions. The second way is to use rectangles. You would generate and track the GUITextures/Texts mathematically and see if the rectangles overlap. If you use the Rect class, you can use Rect.Overlaps().
If these objects remain fixed size, it is easier since you can just size colliders or rectangles (with a bit of work) to the GUITexture/GUIText in the Editor. But if these objects change size, it is some work to dynamically generate size for them....especially GUIText, and even more if it is multi-line text.
Your answer
Follow this Question
Related Questions
Distribute terrain in zones 3 Answers
Multiple Cars not working 1 Answer
2D Checkpoint Collide not block 1 Answer
Collision detection from specific directions using rigid body character? 0 Answers