Playmaker Forum

PlayMaker Help & Tips => PlayMaker Help => Topic started by: stitchlips on May 29, 2016, 12:08:16 AM

Title: Get public static int from script
Post by: stitchlips on May 29, 2016, 12:08:16 AM
I have a score script that of all things keeps track of score ::). Here is the code.

Code: [Select]
using UnityEngine;
using UnityEngine.UI;
using System.Collections;

public class Point_giver : MonoBehaviour
{
public static int score;        // The player's score.


TextMesh text;                      // Reference to the Text component.


void Awake ()
{
// Set up the reference.
text = GetComponent <TextMesh> ();

// Reset the score.
score = 0;
}


void Update ()
{
// Set the displayed text to be the word "Score" followed by the score value.
text.text = "Score: " + score;
}
}

How do I access the text.text portion in Playmaker? I have tried get property but it only returns the words text and length.
Title: Re: Get public static int from script
Post by: ergin on May 29, 2016, 05:10:13 AM
Did you try sendmessage? Although it is named send, it has access to many get methods.
Title: Re: Get public static int from script
Post by: PlaymakerNOOB on May 29, 2016, 08:19:58 AM
this way should do it 
Title: Re: Get public static int from script
Post by: Lane on May 29, 2016, 09:25:52 AM
Get property doesn't work on static variables. Create a public property in your script and in the get/set methods return the static variable.

Similar to here http://hutonggames.com/playmakerforum/index.php?topic=12868.msg60054#msg60054
Title: Re: Get public static int from script
Post by: stitchlips on May 29, 2016, 10:42:32 AM
Thanks Lane, I will try the thread you linked to and see what I can get. I'm not too sure how to make the public variable in my score script.