Search Unity

ECS 0.4 Questions and General Best practices

Discussion in 'Entity Component System' started by Opeth001, Jan 13, 2020.

  1. Opeth001

    Opeth001

    Joined:
    Jan 28, 2017
    Posts:
    1,117
    Hello Everyone,

    i have few Questions about the new ECS Version and general Best practices.

    Questions Related to ECS 0.4 API:

    1) what's the new way of passing copies of values as readonly to Entities.ForEach job ?
    as you can see HERE in Unity's new Tutorial they are disabling Burst just cause it's using a non ReadOnly static Variable.

    2) is there any benefits of Using the new [AlwaysSynchronizeSystem] instead of the JobHandle.Complete() passed in the Update ?

    3) is there any way to use a Managed object inside a Job even in an unsafe way ?

    4) is it possible to make a system run only when 2 different queries are valid, and run a job with both queries data ?
    eg: camera follow system which require a camera to control and a focused player to follow.

    Questions Related to ECS General Best practices:

    5) im using ScriptableObjects to store WeaponsData at start by loading them from Addressables then storing them in a NativeArray as persistent, then i pass this array as ReadOnly to any job requiring this data and weapons entities are just storing their Data index in that array + Instance related data like Current Ammo count...
    the Struct that i store inside the WeaponsData NativeArray is containing only blittable data in order to be used inside Jobs, but how can i store some sized data inside the WeaponData Struct ?
    //Note: this struct is not intended to be added to any entity just to be passed to jobs
    eg:
    Code (CSharp):
    1. struct WeaponData {
    2. Public int ID;
    3. public int DefaultAmmo;
    4. public quaternion[] ProjectilesDirections; // Sized quaternion array to store directions from starting from original point.
    5. ...
    6. }
    6) is there a way to know what are systems that are not running in parallel for CD Read/Write Restrictions? and how can i tell to two systems writing to the same CD but using different archetypes to run in parallel when im 100% there is no race conditions ?

    Thank you!
     
    Last edited: Jan 13, 2020
    PereKastor likes this.