Search Unity

"Rich Text" and "Raycast Target" - Possible Optimizations?

Discussion in 'UGUI & TextMesh Pro' started by kromenak, Mar 14, 2016.

  1. kromenak

    kromenak

    Joined:
    Feb 9, 2011
    Posts:
    270
    I've got some fairly complicated UI canvases in my game, and I've noticed that Image components have a "Raycast Target" boolean exposed, while Text components have both "Rich Text" and "Raycast Target" booleans exposed. They are both toggled "on" by default.

    While it's clear what these booleans do, I was wondering if there're any performance gains to be had by disabling either toggle. Probably like 95% of my Text components don't utilize rich text features, and a good chunk of my Image & Text components don't necessarily need to block raycasts.

    For example, if I disable "Rich Text" on a Text component, does that lead to reduced processing or more efficient rendering in any way? If I turn off "Raycast Target", does that reduce the number of items that need to be checked each frame for input?
     
  2. IzzySoft

    IzzySoft

    Joined:
    Feb 11, 2013
    Posts:
    376
    I can only guess and say that, like kissUI, which is still in development, the raycast hits a collider (Image/Text) and it checks to see if an Image/Text component is present. If the Image/Text option "Is Interactive" (raycast can hit it), then no further rays are cast.

    Ahhh, I've read a few ppl say that unityUI does RaycastAll each iteration, but im hoping its more like what kissUI does, one raycast, and checks if the hit Image is Interactive, and if its not, cast another ray. But I cant say for certain if unityUI also does raycast pass throughs, even if the Image Is Interactive, the way kissUI does ATM.

    I will say that 60 FPS might not be good enough for responsive looking mouse dragging of Images... should be at least 70+ FPS for the Desktops, at least thats what its like on my machine. No clue about Mobile. :[
    A simple example: http://kissui.izzysoft.com/Examples/DragDrop501.html
    You see that the FPS at the top left is close to or slightly below 80 FPS (firefox for me), and dragging stuff looks decent.