Entitas-csharp: Blueprints Phase II

Created on 15 Apr 2016  路  12Comments  路  Source: sschmid/Entitas-CSharp

Phase I laid the groundwork for creating, saving, loading and modifying blueprints (introduced in 0.30.2).

Phase II focuses on updating and repairing blueprints, e.g when a component got renamed or fields got renamed or removed.

Blueprints are considered as external configuration and they eventually have to be migrated every time you change your code.

enhancement

Most helpful comment

  1. When creating new blueprint and typing it's name right away, after "Enter" name becomes "New Blueprint" again.
  2. When renaming blueprint in it's field - it looks like it saves assets after each letter typed - IMO better to save it manually with "cmd + s".
  3. Sometimes (I have not figured out when exactly) VisualDebugger Pools appears in Edit Mode.

It's all bugs I found at the moment.

Blueprints are very cool :)

All 12 comments

If you already tested Blueprints Beta you can drop your feedback here. Does it work? Any pain points? Bugs?

It would be nice to have event firing when Blueprint inspector is updated in playmode, that would give a possibility to test blueprints live.

@grygus on my list now :) thanks

  1. When creating new blueprint and typing it's name right away, after "Enter" name becomes "New Blueprint" again.
  2. When renaming blueprint in it's field - it looks like it saves assets after each letter typed - IMO better to save it manually with "cmd + s".
  3. Sometimes (I have not figured out when exactly) VisualDebugger Pools appears in Edit Mode.

It's all bugs I found at the moment.

Blueprints are very cool :)

Found another little bug.

When BinaryBlueprint selected in Project tab, right after compilation:

NullReferenceException: Object reference not set to an instance of an object
Entitas.Unity.VisualDebugging.EntityDrawer.DrawComponents (Entitas.Pool pool, Entitas.Entity entity) (at Assets/Libraries/Entitas/Unity/VisualDebugging/Entity/Editor/EntityDrawer.cs:91)
Entitas.Unity.Serialization.Blueprints.BinaryBlueprintInspector.OnInspectorGUI () (at Assets/Libraries/Entitas/Unity/Serialization/Blueprints/Editor/BinaryBlueprintInspector.cs:145)

And from my previous post - bug 3 was my bug. Looks like you fixed it in 30.2, and I did not get fix because I create pools manually, without generator.

It seems that it only generates one blueprints class. I was hoping it would generate one blueprints class for each blueprints.asset file.

So I tried something like that in a component for blueprints.

using Entitas;
using System;

[Meta]
public class CharactersComponent : IComponent
{
    public Character[] chars;
}

[Serializable]
public class Phrases
{
    public string greetings;
    public string grief;
    public string happy;
}

[Serializable]
public class Character
{
    public string name;
    public int age;
    public Phrases phrases;
}

And thought of using it as a some kind of scriptableObject alternative, but I guess this functionality is not there yet. :)
http://goo.gl/QKLZGl
And after Add element. BOOM!
http://goo.gl/Jkk4X9

Overall Blueprints are great! It's a very nice idea and it fits very well into Entitas.
However here are some features that would make them even better.

  • In Unity you can work with prefabs same as with instances: you can access any values from them. I'd like Blueprints to have the same interface as Entities.

Here's a bit of my code with blueprints at the moment:

var tubeSegmentBlueprints = _pools.pool.blueprints.instance.blueprints
    .Select(b => b.Deserialize())
    .Where(b => b.components.Any(c => c.index == ComponentIds.TubeSegment))
    .ToArray();

var currentEnvironmentTubeSegmentBlueprints = tubeSegmentBlueprints
    .Where(b => (EnvironmentType)b.components.First(c => c.index == ComponentIds.StartEnvironment).members.First().value == startEnvironment 
    && (EnvironmentType)b.components.First(c => c.index == ComponentIds.EndEnvironment).members.First().value == endEnvironment)
    .ToArray();

var tubeSegmentBlueprint = currentEnvironmentTubeSegmentBlueprints[Random.Range(0, currentEnvironmentTubeSegmentBlueprints.Length)];

_pools.pool.CreateEntity()
    .ApplyBlueprint(tubeSegmentBlueprint)
    .AddId(newTubeSegmentId)
    .AddPosition(position)
    .AddRotation(rotation);

This code filters the blueprints that match criteria, then selects a random blueprint from selected ones and creates an entity from that blueprint.
This code could be much more simple and neat if I could access blueprint components and their values same as entity components: blueprint.startEnvironment.type, and check if blueprint has a component like this: blueprint.hasTubeSegment.

  • When I create new blueprint it's created in the root folder, not in the folder where I create it. And the name I give to it when creating is not saved. I need to rename it then.
  • When I save Unity scene by pressing Ctrl + S blueprints are saved as well. Then when I commit code to git it commits all blueprints since they've changed.

related #267 JSON Blueprints

Update:
I will drop support for BinaryBlueprints in favour of a text-based format. Blueprints might turn out to be Unity only, so we can use Unity's serialization mechanisms (e.g. ScriptableObject). This should improve the current issues with binary blueprints and the problems when migrating to newer versions.

Will these changes make it possible to have Blueprint component fields save references to UnityEngine.Object types such as assets and ScriptableObjects? That'd be a big win!

No further development on Blueprints for now, see #390 Blueprint sources will stay in the repo so they can be extended.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

FiveP picture FiveP  路  3Comments

CCludts picture CCludts  路  3Comments

FNGgames picture FNGgames  路  5Comments

jakovd picture jakovd  路  3Comments

xkyii picture xkyii  路  3Comments