Search Unity

Exposing IComponentData to the inspector

Discussion in 'Entity Component System' started by Celes_Eternal, Jun 2, 2018.

  1. Celes_Eternal

    Celes_Eternal

    Joined:
    May 18, 2018
    Posts:
    18
    Hi guys,

    I saw some samples about exposing IComponentData to the inspector. And it should be really easy.
    But I can't make it work...

    Code (CSharp):
    1. using Unity.Entities;
    2. using Unity.Transforms;
    3.  
    4. namespace components
    5. {
    6.     [System.Serializable]
    7.     public struct SpawnPoint : IComponentData
    8.     {
    9.         public TransformMatrix  m_transform;
    10.     }
    11.  
    12.     public class SpawnPointComponent : ComponentDataWrapper<SpawnPoint> { }
    13. }
    I even tried with a simple float instead of the transform. But I can't find SpawnPointComponent anywhere, when I'm trying to add a component. Even after added the GameObjectEntity component, though it shouldn't be needed.

    Can someone show me a simple sample of how to do so?
    Thanks
     
  2. recursive

    recursive

    Joined:
    Jul 12, 2012
    Posts:
    669
    Is the file called SpawnPointComponent.cs?
    ComponentDataWrapper<T>
    is derived from MonoBehaviour, and in order to get it to show up in the editor, it must be in a file that shares the name of the concrete derived class (in this case, SpawnPointComponent).

    Otherwise it's still useable from code only.
     
    vanxining and Celes_Eternal like this.
  3. Celes_Eternal

    Celes_Eternal

    Joined:
    May 18, 2018
    Posts:
    18
    I could have searched for a long time... I guess I should learn a bit about the old system ^^"
    Thanks a lot!

    PS : Seems like the inspector support only the first transform matrix thought.
     
    recursive likes this.