vexe / VFW

MIT License
492 stars 67 forks source link

Unable to create new instance of custom type in Dictionary #70

Open wizcas opened 8 years ago

wizcas commented 8 years ago

I'm trying to use a dictionary with my own defined type (say, Dictionary<string, SceneInfo>), but it seems impossible to properly create a new instance of SceneInfo and serialize it with Vexe editor. #The value member keeps null, no matter how many items I click the type name in SelectionWindow.#

I debugged the code and found that the new instance of SceneInfo was correctly created and set to the underlying EditorMember within TryCreateInstance. The problem seems to be that it failed to write back to the dictionary.

I was totally confused by the mult-level nested EditorMember things, and now hopeless to get it done. I believe it's a bug. Could you take a look and make it right? Thanks.

wizcas commented 8 years ago

And by the way, the SceneInfo in the example is not a MonoBehaviour/BetterBehaviour

vexe commented 8 years ago

Is it a struct or class? Have you tried 'right clicking' on the object selection circle?

vexe commented 8 years ago

Did that solve your problem @wizcas?

bastrakov-sergei commented 8 years ago

Hello, I have same problem with Dictionary. (Dictionary<string, CustomType>) If CustomType is not abstract, 'right click' is working. But selection type in SelectionWindow does not result. If CustomType is abstract, 'right click' does not work, as expected. In SelectionWindow I see all CustomType's child, but selection does not work.

vexe commented 8 years ago

Right clicking doesn't work on an abstract class because, well it's abstract, you can't instantiate an instance of it. I'll add testing the selection to my notes.

bastrakov-sergei commented 8 years ago

Yes, I know why abstract class can not be instatntiate, but it seems I don't know English =) Now I use List, and "Key" from dictionary moved in CustomType as property. It not exactly as originally planned, but it solves my problem. If I find anything else, I'll tell you.