Properties doesn't appear in Control Element
fredazarty opened this issue · 4 comments
fredazarty commented
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
What did I miss ?
keijiro commented
Could you try renaming as follows?
private float m_experience;
//Experience is a basic property
public float experience
fredazarty commented
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;
}
}
}
keijiro commented
Try adding the SerializeField attribute to m_experience
.
[SerializeField] private float m_experience;
fredazarty commented
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;
}
}
}