Playmaker Forum

Playmaker Help & Tips => Playmaker Help => Topic started by: Zenneth on June 04, 2012, 11:35:46 AM

Title: Need to get a variable attached to a GameObject's C# Script
Post by: Zenneth on June 04, 2012, 11:35:46 AM
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, 12: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, 08: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, 12: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, 10:47:21 AM
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 19, 2012, 10:34:12 PM
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