Author Topic: GetProperty fails on string properties ("get")  (Read 1407 times)


  • Playmaker Newbie
  • *
  • Posts: 1
    • View Profile
GetProperty fails on string properties ("get")
« on: May 26, 2016, 07:11:50 AM »
1) What happened

When attempting to use the Get Property action to read a string property from an object, if the the property is actually a property and not a field (so has a "get") then Get Property is unable to actually get the text value, only the string length.

2) How can we reproduce it
Create a behaviour which has a string property:
public string _str;
public string MyString {get
_str; }

Then attempt to get the text value of MyString through GetProperty.  It will see the MyString property, but be unable to get the actual text (just the length, for some reason).

I submitted a bug report via the internal reporting function, but was hoping a workaround might exist.


  • Administrator
  • Hero Member
  • *****
  • Posts: 2488
  • Yup.
    • View Profile
    • Cleverous
Re: GetProperty fails on string properties ("get")
« Reply #1 on: May 26, 2016, 07:54:23 AM »
Properties can definitely be grabbed by GetProperty. You have an issue with your code which shouldn't even compile. Try this example.

Code: [Select]
using UnityEngine;

public class test : MonoBehaviour
    private string _internal = "Blueberry Pancakes";
    public string TargetString
        get { return _internal; }
        set { _internal = value; }

C# Properties have custom get and set methods. As long as they have a get{} method you can grab them.