Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Get entity variables

Discussion in 'Entity Component System' started by Risine, Apr 26, 2022.

  1. Risine

    Risine

    Joined:
    Dec 10, 2009
    Posts:
    154
    Ok, I'm trying to understand ECS, by converting a classic GameObject with its monobehaviour components (MB_Test being one of them).
    I have successfully used ConvertGameObjectHierarchy and Instantiated the entity.
    Now I'm wondering how to access variables and functions from the Entity.
    Let's say I have a Monobehaviour :
    Code (CSharp):
    1. public class MB_Test {
    2. ...
    3. float m_timer = 0;
    4. public float GetTimer() {return m_timer;}
    5. public void SetTimer(float timer) {m_timer = timer;}
    6. ...
    7. }
    How do I access GetTimer and m_timer from entity?
     
    Last edited: Apr 26, 2022
  2. Risine

    Risine

    Joined:
    Dec 10, 2009
    Posts:
    154
    Thanks for your reply,
    I still have a long way to get the whole picture it seems.
    I think I get the "conversion" part, from Monobehaviour to Entity : you create a struct with mirror values.
    But how do you deal with your monobehaviour functions members? Do you transfer or copy them from your monobehaviour to your entity struct?