vexe / VFW

MIT License
491 stars 67 forks source link

public readonly fields & [Show] properties are reset when you hit play #83

Closed Deepscorn closed 8 years ago

Deepscorn commented 8 years ago

Code:

public readonly float JumpHeight = 10;

[Show]
public float Speed { get; set; }

Reproduce:

  1. Find corresponding attributes in Editor
  2. Set some values
  3. Hit play and you'll get: JumpHeight = 10; Speed = 0;

Environment: Unity 5.3.2f1 Personal VFW 5207d69499f9548693c22ec176468ad66a2541c4

vexe commented 8 years ago

Did you read my latest post in VFW thread? Support for custom serialization has been deprecated. Although the code for BetterBehaviour is still there. You're probably inheriting BaseBehaviour which doesn't have custom serialization, in previous versions you could get this to work with the deprecated-now BetterBehaviour.

Just use a public field instead and save your self a lot of headaches.

Deepscorn commented 8 years ago

"Did you read my latest post in VFW thread? Support for custom serialization has been deprecated. Although the code for BetterBehaviour is still there." Can you, please, provide a link? I don't understand what are you talking about.

1) I just started to use VFW because I thought it would give possibility to use getter/setter even for fields shown in Unity Editor. Which syntax I must use to do that? I used:

[Show]
public float Speed { get; set; }

2) And about

public readonly float JumpHeight = 10;

I thought it will create readonly field which: a. Can be set in Editor b. Can't be assigned in code

I need (2) to get rid of searching through project to understand if public field is set somewhere in it. It's readonly, so it can be 10 or set in the editor and nowhere else. And I need (1) to be able to put debug break point to position when the field is set