Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

GetRayIntersectionAll result is not sorted?

Discussion in 'Editor & General Support' started by valyard, Nov 25, 2013.

  1. valyard

    valyard

    Unity Technologies

    Joined:
    Jun 4, 2010
    Posts:
    291
    Hi.

    Is the array GetRayIntersectionAll returns not sorted?
    I'm getting to this conclusion after several tests with 2d layers and orderings.
    My tests show that visual order doesn't always reflect the order GetRayIntersectionAll returns.
    So, the question is, I should expect the returning array not to be sorted, right?
     
  2. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    Right. Unless specified otherwise, the array order is undefined.

    --Eric
     
  3. valyard

    valyard

    Unity Technologies

    Joined:
    Jun 4, 2010
    Posts:
    291
    Unless specified where? In the docs?
     
  4. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    Yes.

    --Eric
     
  5. valyard

    valyard

    Unity Technologies

    Joined:
    Jun 4, 2010
    Posts:
    291
    Just to resolve this.
    GetRayIntersectionAll sorts hits by Z but it doesn't respect other render order parameters nor it knows about them.
    If you need to, you should sort return values as you like.