Playmaker Forum

PlayMaker Help & Tips => PlayMaker Help => Topic started by: Zenneth on June 04, 2012, 02:35:46 PM

Title: Need to get a variable attached to a GameObject's C# Script
Post by: Zenneth on June 04, 2012, 02:35:46 PM
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?
Title: Re: Need to get a variable attached to a GameObject's C# Script
Post by: jeanfabre 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
Title: Re: Need to get a variable attached to a GameObject's C# Script
Post by: Zenneth 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,
Title: Re: Need to get a variable attached to a GameObject's C# Script
Post by: jeanfabre 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
Title: Re: Need to get a variable attached to a GameObject's C# Script
Post by: Zenneth 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.
Title: Re: Need to get a variable attached to a GameObject's C# Script
Post by: jeanfabre 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 (http://hutonggames.com/playmakerforum/index.php?action=dlattach;topic=1701.0;attach=986)

Bye,

 Jean