[Netcode 0.5] Making CodeGenTypes public

Hey there! I have a small feature request.
I can see that you made a possibility of creating a custom assembly for custom NetCode generator templates.
I was able to add my own CodeGen templates for classes in my project, however I had to modify the visibility of the CodeGenTypes class to be able to access the Registry and add the template description.

This is the code example:

public static class CustomCodeGenTypeRegister
    {
        public const string TEMPLATE_PATH = "Assets/Scripts/Editor/NetCode/Generator/Templates/";

        [InitializeOnLoadMethod]
        public static void Initialize()
        {
            var typeRegistry = CodeGenTypes.Registry;
            typeRegistry.RegisterType(typeof(InventoryDTO), TypeAttribute.Empty(), new TypeTemplate
            {
                TemplatePath = TEMPLATE_PATH + "InventoryDTOSerializer.cs"
            });
           
            typeRegistry.RegisterType(typeof(NavAgentPathDTO), TypeAttribute.Empty(), new TypeTemplate
            {
                TemplatePath = TEMPLATE_PATH + "NavAgentPathSerializer.cs"
            });
           
            typeRegistry.RegisterType(typeof(ulong), TypeAttribute.Empty(), new TypeTemplate
            {
                TemplatePath = TEMPLATE_PATH + "ULongSerializer.cs"
            });
        }
    }

I’d say it makes sense to make it public so that people can add their own templates.
Thanks!

3 Likes

It does! Much cleaner. I just made custom RPC (de)serializers because I was too lazy to integrate a ulong like you did.

Also ulong should be added as default type. SteamId, anyone?

2 Likes