/EntitasBlueprint

Blueprint parser for entitas

Primary LanguageC#

EntitasBlueprint

Blueprint parser for entitas. It uses Litjson as the default json parser.

Dependencies

Installation

Usage

Please see Example for component definitions.

The json format

{

  "Entity1": {
    "Movable": {},
    "Position": {
      "value": {
        "x": 1.0,
        "y": 2.0
      }
    },
    "Speed": {
      "value": 1.0
    },
    "Asset": {
      "value": "Player"
    }
  },
  "Entity2": {
    "Asset": {
      "value": "Player"
    }
  }
}

Unity code

using Entitas.Serialization;
using Entitas.Serialization.Json;

public class Test : MonoBehavior
{
    void Awake()
    {
        IBlueprints jsonBlueprints = new JsonBlueprints();
        var text = Resources.Load<TextAsset>("blueprints");
        var blueprints = jsonBlueprints.ToBlueprints(text.bytes);

        var entity = Contexts.sharedInstance.game.CreateEntity();
        blueprints["Entity1"].Apply(entity);
    }
}

TODO

  • Array data member in component support
  • Entity serialization
  • Integration with Unity editor
  • Protobuffer format support