playMaker

Author Topic: Need to get a variable attached to a GameObject's C# Script  (Read 6338 times)

Zenneth

  • Playmaker Newbie
  • *
  • Posts: 6
Let say that I have a C# script with the following variable within a class

float m_Height;

Assumed that the variable was properly declared, have proper value, and attached to a GameObject,
How do I reference that variable, so that I can use it in Playmaker?

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Need to get a variable attached to a GameObject's C# Script
« Reply #1 on: June 05, 2012, 03:33:08 AM »
Hi,

1: your class will have to be a monobehavior,
2: you'll need to make that variable public, and then you can use the "get Property" to get it from that script and store it in a Fsm variable,
3:You can create an "object" variable, select its type to be of your script class, and drag and drop that component onto this variable, and in the "get property" action, you reference that "object" variable, and your variable will be listed

If that's not clear, I'll make a working example.

Bye,

 Jean

Zenneth

  • Playmaker Newbie
  • *
  • Posts: 6
Re: Need to get a variable attached to a GameObject's C# Script
« Reply #2 on: June 05, 2012, 11:25:50 AM »
Hi Jean,

I tried to do it but couldn't get it to work.
It would be great help if you can provide me with a sample project.

Thank you,

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Need to get a variable attached to a GameObject's C# Script
« Reply #3 on: June 06, 2012, 03:30:25 AM »
Hi,

 ok, please find a working example, modifying the camera FOV using the Fsm Object and set property technic.

NOTE:  an action is available to so this ( set camera FOV) this is just to illustrate usage with a very simple example.

If you have more questions, do not hesitate.

 Bye,

 Jean

Zenneth

  • Playmaker Newbie
  • *
  • Posts: 6
Re: Need to get a variable attached to a GameObject's C# Script
« Reply #4 on: June 19, 2012, 01:47:21 PM »
ok, please find a working example,

The reason I asked in this thread, is because I cannot find a working sample.

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Need to get a variable attached to a GameObject's C# Script
« Reply #5 on: June 20, 2012, 01:34:12 AM »
Hi,

 I have attached a working example to that post, you need to download it and then you'll have your working example.

Here's the link in case you don't see it:
http://hutonggames.com/playmakerforum/index.php?action=dlattach;topic=1701.0;attach=986

Bye,

 Jean