- Home /
Render non-UI object next to a UI element on Screen Space - Overlay
I have an object utilizing SpriteRenderers for a visual effect when the player takes damage. The object was purchased from the Asset Store and has a texture that acts as a spritesheet which is applied to the material at a rate defined by a script. This works fine in the game (which is 3D).
However, now I have a Screen Space - Overlay Canvas which needs to stay an Overlay, and I want to also display this effect near a UI element that shows up when the player gets hurt. I have tried many things including RectTransformUtility.WorldToScreenPoint() with a null camera, converting from screen to world coordinates, and parenting the object to the UI element, but the issue is the object is never in the camera's field of view and is thus not getting rendered.
I performed a workaround on one of our applications by manually positioning the effect where the UI element is on the screen and then parenting it to the camera. This application has a fixed resolution so this will work. However, another application can have different resolutions and it's possible to dynamically resize the window, so this is where I'm stumped.
For reference I'm on Unity 5.6.1p3.
Any advice is greatly appreciated!