24-05-2019, 03:03 PM
(24-05-2019, 02:27 PM)josemendez Wrote: Implementing a marquee selection tool has very little to do with Obi. It mainly involves Unity GUI/events, so it's unfortunately out of the scope of Obi support.
Once you have a screen-space marquee rectangle working (all the clicking/dragging logic in place, as well as UI drawing) you can simply iterate trough all particles getting their world space position and projecting it to screen space to see it they're within the marquee.
Code:for (int i = 0; i < actor.particleIndices.Length; ++i){
Vector3 wsPos = actor.GetParticlePosition(i);
//TODO: convert wsPos to screen space, and check if the coordinates are within the marquee.
}
I'd suggest taking a look at some Unity GUI tutorials, or browse the Unity forums for ready-made stuff:
https://forum.unity.com/threads/rts-styl...ox.265739/
https://www.habrador.com/tutorials/selec...rectangle/
Can I implement such marquee tool without combining with Edit Particle of Obi cloth or Obi tearable cloth? If I should, how can I connect marquee tool made by myself to obi cloth editor?