Esempio n. 1
0
        public ProtobufSerializer2()
        {
            model = new TypeModelCreator().Create();
            model.DynamicTypeFormatting += (sender, args) =>
            {
                if (args.FormattedName == null)
                {
                    return;
                }
                string typename = args.FormattedName;
                typename = Regex.Replace(typename, @", Version=\d+.\d+.\d+.\d+", string.Empty);
                typename = Regex.Replace(typename, @", Culture=\w+", string.Empty);
                typename = Regex.Replace(typename, @", PublicKeyToken=\w+", string.Empty);
                typename = typename.Replace(", Battlehub.VoxelCombat.Server", string.Empty);
                typename = typename.TrimEnd(' ');
                typename = typename.TrimEnd(',');
                Type type = Type.GetType(typename);
                if (type == null)
                {
                    args.Type = typeof(NilContainer2);
                }
                else
                {
                    args.Type = type;
                }
            };

#if UNITY_EDITOR || UNITY_WSA || SERVER
            model.MetadataTimeoutMilliseconds *= 1000;
            model.CompileInPlace();
#endif
        }