A 2d-array of TableMatrix is initialized after starting play mode.
I have a problem that a 2d-array of TableMatrix is initialized after starting play mode.
I use a code almost same as example on manual page. It works well if TableMatrix is a member of the class which is inherited from MonoBehavior. However, if TableMatrix is a member of the class which is not inherited from MonoBehavior, the issue is happened.
My code is below that
And, in inspector, Table is shown as well.
But after starting play mode, Table is initialized.
Could you please help me what is the root cause of this problem and how to solve it?
Comments (3)
-
-
reporter OK, I found out that 2d-array is not serialized by Unity System. So I use [OdinSerialize] instead of [SerializedField] for mGrid (2d-array in AttackRange class). Also I changed the class which contains AttackRange to be inherited from SerializedMonoBehaviour instead of MonoBehaviour and use [OdinSerialize] too. This seems to solve the my problem.
-
- changed status to resolved
Glad to hear the issue was resolved, then :)
- Log in to comment
An issue was introduced in 2.0.10 where members would be shown even despite not being serialized - this was fixed in 2.0.11. Can you install Odin 2.0.11, open the serialization debugger, and verify that your array is serialized by Odin? You may also find this FAQ answer helpful.