playMaker

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

Zenneth

  • Playmaker Newbie
  • *
  • Posts: 6
    • View Profile
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: 13622
  • Official Playmaker Support
    • View Profile
Re: Need to get a variable attached to a GameObject's C# Script
« Reply #1 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

Zenneth

  • Playmaker Newbie
  • *
  • Posts: 6
    • View Profile
Re: Need to get a variable attached to a GameObject's C# Script
« Reply #2 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,

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 13622
  • Official Playmaker Support
    • View Profile
Re: Need to get a variable attached to a GameObject's C# Script
« Reply #3 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

Zenneth

  • Playmaker Newbie
  • *
  • Posts: 6
    • View Profile
Re: Need to get a variable attached to a GameObject's C# Script
« Reply #4 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.

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 13622
  • Official Playmaker Support
    • View Profile
Re: Need to get a variable attached to a GameObject's C# Script
« Reply #5 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

Bye,

 Jean