playMaker

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

xcompwiz

  • Playmaker Newbie
  • *
  • Posts: 1
GetProperty fails on string properties ("get")
« on: May 26, 2016, 10: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.
Cheers!

Lane

  • Administrator
  • Hero Member
  • *****
  • Posts: 2511
  • Mender of the past
    • Cleverous
Re: GetProperty fails on string properties ("get")
« Reply #1 on: May 26, 2016, 10: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.
Products by Cleverous
|| Vault Core : Database
|| Vault Inventory : Multiplayer Inventory
|| Vault Attributes : Character Stats
|| That Hurt! : Dmg Floaties
|| Quinn : 3D