keijiro/MidiAnimationTrack

Properties doesn't appear in Control Element

fredazarty opened this issue · 4 comments

Hi Keijiro,

First, thank you for this package! It's really helpful!

I have some issues to define a property in a MonoBehaviour.

The documentation mention :

Please note that it requires a public property to be animated; Just providing a public variable is not enough.

So I followed the "Creating Properties" tutorial of unity to create something like :

public class TestProp : MonoBehaviour
{
    private float experience;

    //Experience is a basic property
    public float Experience
    {
        get
        {
            //Some other code
            return experience;
        }
        set
        {
            //Some other code
            experience = value;
        }
    }   
}

But the property doesn't appear in the Control Element

Screenshot 2020-10-02 at 22 31 35

What did I miss ?

Could you try renaming as follows?

private float m_experience;

//Experience is a basic property
public float experience

Thank you for your fast answer!

I have the same result with your modification :

public class TestProp : MonoBehaviour
{
    private float m_experience;

    public float experience
    {
        get
        {
            return m_experience;
        }
        set
        {
            m_experience = value;
        }
    }    
}

Try adding the SerializeField attribute to m_experience.

[SerializeField] private float m_experience;

It's work! Thank you 👍 !
I put the final code for others who will have the need :)

public class TestProp : MonoBehaviour
{

    [SerializeField] 
    private float m_experience;

    public float experience
    {
        get
        {
            //Some other code
            return m_experience;
        }
        set
        {
            //Some other code
            m_experience = value;
        }
    }
    
}