ProwlEngine / Prowl

An Open Source C# 3D Game Engine under MIT license, inspired by Unity and featuring a complete editor and built on Silk.NET
MIT License
328 stars 27 forks source link

[Inspector] Need to rewrite how Component Drawing works #102

Closed michaelsakharov closed 5 months ago

michaelsakharov commented 5 months ago

In Unity, the inspector uses a SerializedObject version of the object it's inspecting Changes are then saved back into the object

Our serializer, the TagSerializer outputs a tag that isn't entirely far off from what the SerializeObject and Properties are in unity and could be reused for a similar purpose.

Let's try and recreate the Unity PropertyDrawer API and custom editor API, we won't be able to get the EditorGUI class to be 1:1 due to ImGUI, but we could at least try and get a simple Unity Editor code to be able to run in prowl.

Ideally, Tags stay simple as they are for Serializing everything not just editor stuff so some hurdles I can think of:

  1. Detecting a change in Tags for Undo/Redo
  2. Field Attributes need to be stored somewhere, ideally not inside the tags
michaelsakharov commented 5 months ago

Im gonna postpone this one for the foreseeable future. I was working on this for a little while and while it does have some pros, I'm not sure the pro's are worth the effort, at least not now.

The Serializer needs a way to Populate existing objects with a serializedProperty, at first I thought Serialized.DeserializeInto() would do the job, but after actually doing it I quickly realized DeserializeInto is only half of the deserialization process, and lacks some needed features, which to implement would require re-writing deserialization.

So for the time being at least, I'm gonna close this, What we have now works just as well, its just not 1:1 with how unity does it.