GameObjectSerialization.txt 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. TODO
  2. - Ability to break external references as a pre-processing step
  3. - I need to properly unload all assemblies (and possibly shutdown mono runtime?) before I shut down various modules used in ScriptBansheeEngine.
  4. ---------------------------------------
  5. IMMEDIATE:
  6. Create a wrapper around MonoArray to make it easier to use?
  7. - With support for multirank
  8. Create a similar wrapper for ICollection
  9. - Expose mono_class_bind_generic_parameters
  10. - Expose mono_reflection_bind_generic_method_parameters
  11. - MonoReflectionMethod->method to get MonoMethod
  12. setValue in ScriptSerializableObject & ScriptSerializableArray should check if value is null and if the field type isn't a value type (can't be null)
  13. LOW PRIORITY
  14. - Add Multi-dimensional arrays / Lists / Dictionaries
  15. - (To get array lengths per rank I probably need to cast to System.Array and then call GetLength)
  16. - For List/Dictionary I will probably want to do it though ICollection interface
  17. - Use mono_object_get_virtual_method() to get virtual method
  18. - Getting a generic type: Try mono_reflection_type_from_name
  19. - Ensure that unknown components retain their field data so when they are no longer unknown their data may be restored
  20. - Get rid of ScriptObject::createInstance and replace it with parameter in constructor
  21. - A way to serialize any object into a Resource (and deserialize it from Resource)
  22. ----------------------------------------
  23. I attempt to resolve SceneObject handle during deserialization, while it should only be done after deserialization is done
  24. - Issue happens in ScriptSerializableFieldDataGameObjectRef::getValue
  25. HACKY WAY: <- THE RIGHT WAY
  26. - I can add a callback to GameObject that gets triggered when deserialization for a GameObject is fully done
  27. - Then I perform ManagedComponent deserilization there
  28. - SerializableSceneObject & SerializableSceneArray would have to be modified so that they don't resolve fields on deserialization
  29. In ScriptSerializableObject & ScriptSerializableArray add:
  30. serializeManagedInstance <- Called when serialization starts and recursively
  31. deserializeManagedInstance <- Called by the deserialization callback in ManagedComponent and recursively
  32. ---------------------------------------
  33. Testing:
  34. Test arrays
  35. Test arrays of arrays
  36. Test how structs work
  37. Test how things work when class gets removed
  38. Test and implement multi-rank arrays
  39. ------------------------------------------------------
  40. General C# component management
  41. Native components like Camera
  42. - ScriptCamera derives from Camera
  43. - Then whenever I check for managed Components I need to check if object type of ScriptComponent or
  44. any of the built-in types.
  45. - Checking each type might be a bit slow, but normally we will be looking for an exact type
  46. so hopefully this will only matter when enumerating all components which shouldn't be during performance
  47. critical moments.
  48. TODO - When reloading scripts how to handle restoring references?
  49. TODO - When I destroy a Component, how will I refresh the inspector to let it know that something has changed
  50. - Can happen from C# and C++
  51. -------------------------------------------------------
  52. Other:
  53. Instantiating mono generic classes: http://stackoverflow.com/questions/17628411/get-generic-type-using-mono-embedded
  54. * /*MonoClass* kvpClass = mscorlib->getClass("System.Collections.Generic", "KeyValuePair`2");
  55. *
  56. * MonoType* kvpTypes[2];
  57. * kvpTypes[0] = mono_class_get_type(mono_get_string_class());
  58. * kvpTypes[1] = mono_class_get_type(mono_get_int32_class());
  59. * ::MonoClass* kvpStrIntClass = mono_class_bind_generic_parameters(kvpClass->_getInternalClass(), 2, kvpTypes, false);
  60. *
  61. * MonoObject* kvpStrIntInstance = mono_object_new(MonoManager::instance().getDomain(), kvpStrIntClass);
  62. * ::MonoProperty* prop = mono_class_get_property_from_name(kvpStrIntClass, "Key");
  63. *
  64. * int propDummy = 7;
  65. * void* propParams[1] = { &propDummy };
  66. * mono_property_set_value(prop, kvpStrIntInstance, propParams, nullptr);
  67. *
  68. * int propVal = *(int*)mono_property_get_value(prop, kvpStrIntInstance, nullptr, nullptr);*/