非public变量需要加[SerializeField]才能序列化

例如:

MonoBehaviour中:

[SerializeField]

private float m_xxx;

在相应的CustomEditor脚本中:

SerializedProperty m_xxx= serializedObject.FindProperty ("m_xxx");

m_xxx.floatValue=1.0f;//***

否则的话***句会报空引用错误。

 

相关文章:

  • 2021-06-27
  • 2021-12-30
  • 2022-12-23
  • 2021-10-09
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-07-12
  • 2021-11-10
  • 2022-12-23
  • 2022-12-23
  • 2022-01-02
  • 2021-10-11
相关资源
相似解决方案