playMaker

Author Topic: Get public static int from script  (Read 561 times)

stitchlips

  • Playmaker Newbie
  • *
  • Posts: 18
    • View Profile
Get public static int from script
« on: May 28, 2016, 09:08:16 PM »
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.

ergin

  • Junior Playmaker
  • **
  • Posts: 86
    • View Profile
Re: Get public static int from script
« Reply #1 on: May 29, 2016, 02:10:13 AM »
Did you try sendmessage? Although it is named send, it has access to many get methods.

PlaymakerNOOB

  • Full Member
  • ***
  • Posts: 117
    • View Profile
Re: Get public static int from script
« Reply #2 on: May 29, 2016, 05:19:58 AM »

Lane

  • Administrator
  • Hero Member
  • *****
  • Posts: 2484
  • Yup.
    • View Profile
    • Cleverous
Re: Get public static int from script
« Reply #3 on: May 29, 2016, 06: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

stitchlips

  • Playmaker Newbie
  • *
  • Posts: 18
    • View Profile
Re: Get public static int from script
« Reply #4 on: May 29, 2016, 07: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.