playMaker

Author Topic: Unity canvas image to screen position  (Read 2909 times)

IIKII

  • Full Member
  • ***
  • Posts: 137
  • Lonely developer
    • Patreon
Unity canvas image to screen position
« on: October 31, 2016, 09:50:33 AM »
Hi, I am trying to make a UI image to stay directly on a gameobject in the scene. For example the enemy health bar image above the enemy object.

I can successfully do it using GUI texture but not with Canvas > image. The World to Screen doesn't work. I also tried using Rect transform world to screen but failed too.

Anyone has clear steps to making it work?

Thanks
Support me on Patreon for free adventure games and development insights - https://www.patreon.com/koexstudio

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Unity canvas image to screen position
« Reply #1 on: November 01, 2016, 02:48:06 AM »
Hi,

 There is a sample showing how to do this on the Ecosystem:



Bye,

 Jean

IIKII

  • Full Member
  • ***
  • Posts: 137
  • Lonely developer
    • Patreon
Re: Unity canvas image to screen position
« Reply #2 on: November 03, 2016, 11:21:23 PM »
Hi thank you that's explains.

But i realized that there's a weird problem of the ugui text appearing in the opposite spot of the gameobject when i turn the camera around. This problem is also with using the normal gui.

Any solution to this?
Support me on Patreon for free adventure games and development insights - https://www.patreon.com/koexstudio

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Unity canvas image to screen position
« Reply #3 on: November 04, 2016, 04:37:55 AM »
Hi,

 yes. I know about this issue. check using GameObjectIsVisible or IsVisibleInCameraFrustrum ( from the Ecosystem).

 Be careful, the sceneView in editor counts as a camera so is Visible will be true even if not in the game View but in the SceneView.

Bye,

 Jean