Entitas.Unity.Serialization.Blueprints.BinaryBlueprint.Serialize C# (CSharp) Method

Serialize() public method

public Serialize ( Blueprint blueprint ) : void
blueprint Entitas.Serialization.Blueprints.Blueprint
return void
        public void Serialize(Blueprint blueprint)
        {
            using (var stream = new MemoryStream()) {
                _serializer.Serialize(stream, blueprint);
                blueprintData = stream.ToArray();
            }
        }

Same methods

BinaryBlueprint::Serialize ( Entity entity ) : void

Usage Example

        public static bool UpdateBinaryBlueprint(BinaryBlueprint binaryBlueprint, string[] allPoolNames)
        {
            var allPools = findAllPools();

            if (allPools == null)
            {
                return(false);
            }

            var blueprint   = binaryBlueprint.Deserialize();
            var needsUpdate = false;

            var poolIndex = Array.IndexOf(allPoolNames, blueprint.poolIdentifier);

            if (poolIndex < 0)
            {
                poolIndex   = 0;
                needsUpdate = true;
            }

            var pool = allPools[poolIndex];

            blueprint.poolIdentifier = pool.metaData.poolName;

            foreach (var component in blueprint.components)
            {
                var type  = component.fullTypeName.ToType();
                var index = Array.IndexOf(pool.metaData.componentTypes, type);

                if (index != component.index)
                {
                    Debug.Log(string.Format(
                                  "Blueprint '{0}' has invalid or outdated component index for '{1}'. Index was {2} but should be {3}. This will be fixed now!",
                                  blueprint.name, component.fullTypeName, component.index, index));

                    component.index = index;
                    needsUpdate     = true;
                }
            }

            if (needsUpdate)
            {
                Debug.Log("Updating Blueprint '" + blueprint.name + "'");
                binaryBlueprint.Serialize(blueprint);
            }

            return(needsUpdate);
        }
All Usage Examples Of Entitas.Unity.Serialization.Blueprints.BinaryBlueprint::Serialize