playMaker

Author Topic: Set Game Object as Viewport label...  (Read 6571 times)

holyfingers

  • Playmaker Newbie
  • *
  • Posts: 34
  • 3D-artist and fledgling Unity Dev.
    • holyfingers.co.uk
Set Game Object as Viewport label...
« on: October 13, 2015, 10:06:41 AM »
Hi there,

I've been re-visiting some of my UI elements this week and thought I'd share my Game Object Label action. It works in a similar fashion to a GUI Label only it uses Game Objects, handy if you're making 3d interface elements, in-scene UI etc.



It takes the world-space position of a target-object and gets the viewport position, then positions a label object at that point at the corresponding world-space including optional offsets.

I've also including some limited functionality from http://wiki.unity3d.com/index.php?title=CameraFacingBillboard#Alternative_Mod so you can have the label align itself with your chosen camera.

Apologies if this already exists somewhere, I'd previously been using 4 or 5 separate actions and a script to achieve the same result and thought this was a bit tidier!

Let me know if you have any problems or spot any mistakes!

Cheers,

Nick 
« Last Edit: October 13, 2015, 02:20:01 PM by holyfingers »
Twitter: @holyfingers

dblincoeii

  • Playmaker Newbie
  • *
  • Posts: 14
Re: Set Game Object as Viewport label...
« Reply #1 on: January 05, 2018, 08:35:18 PM »
Hi Holyfingers.  I just found this playmaker action.  Looks like what I am needing but I cant seem to get it to do what I need it to.  I have a camera with a canvas and I want text on the canvas to follow the 3d objects screen pos.  Is that what this does?  How should I arrange the objects in my hierachy.  I'm assuming I use ui text.

Any help would be appreciated.  Thanks.

holyfingers

  • Playmaker Newbie
  • *
  • Posts: 34
  • 3D-artist and fledgling Unity Dev.
    • holyfingers.co.uk
Re: Set Game Object as Viewport label...
« Reply #2 on: January 06, 2018, 08:53:29 AM »
Hey there,

It's been a long time since I looked at this action but it was more for using 3d objects as a sort of pseudo-GUI, so not not really what you're after I don't think?

I had a quick check in Unity though and Playmaker has actions for converting back and forth between screen and world space, and has actions for Rect transforms...



Scene here has a canvas set to Screen Space - Camera, a sphere and a UI text component, when I move the sphere about the text follows. There are loads of Rect Transform actions for setting offsets on the pivot etc as well...

Hope that helps!

Cheers,

Nick
« Last Edit: January 06, 2018, 08:55:18 AM by holyfingers »
Twitter: @holyfingers

ivabibliocad

  • Playmaker Newbie
  • *
  • Posts: 3
Re: Set Game Object as Viewport label...
« Reply #3 on: September 16, 2018, 02:10:08 AM »
Followed your template with no succees. Where did you get "sphere world pos" is that a variable? I created one and didn't work....
Where did you get the "rect transform to local" action?

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7615
    • jinxtergames
Re: Set Game Object as Viewport label...
« Reply #4 on: September 16, 2018, 02:29:00 AM »
Hi.
Many Custom actions can be found on the Ecosystem.

holyfingers

  • Playmaker Newbie
  • *
  • Posts: 34
  • 3D-artist and fledgling Unity Dev.
    • holyfingers.co.uk
Re: Set Game Object as Viewport label...
« Reply #5 on: September 16, 2018, 06:02:58 AM »
Followed your template with no succees. Where did you get "sphere world pos" is that a variable? I created one and didn't work....
Where did you get the "rect transform to local" action?

Hey, yes Sphere World Pos is a Vector3 variable, it's being set by the Get Position action there at the top.

As Djaydino says above, you can grab custom actions on the Ecosystem or they're on Github here: https://github.com/jeanfabre/PlayMaker--Unity--UI/tree/master/Assets/PlayMaker%20Custom%20Actions/RectTransform

Cheers,

Nick
Twitter: @holyfingers

ivabibliocad

  • Playmaker Newbie
  • *
  • Posts: 3
Re: Set Game Object as Viewport label...
« Reply #6 on: September 17, 2018, 12:07:03 PM »
Thanks man! I tested it with a vector 3  variable and works great!!!

craigz

  • Beta Group
  • Full Member
  • *
  • Posts: 234
    • Haven Made
Re: Set Game Object as Viewport label...
« Reply #7 on: March 26, 2020, 03:01:25 AM »
Just wanted to hop in here real quick and mention this action isn't popping up on the latest version of Ecosystem 🤷‍♂️