Search Unity

[Solved]Invisible data components

Discussion in 'Data Oriented Technology Stack' started by madks13, Aug 9, 2018.

  1. madks13

    madks13

    Joined:
    May 8, 2016
    Posts:
    161
    Hello,

    i wrote this piece of code :

    Code (CSharp):
    1.  
    2.     public struct CameraData : IComponentData
    3.     {
    4.         public float2 MovementSpeed;
    5.     }
    6.  
    7.  
    8.     public class CameraDataComponent : ComponentDataWrapper<CameraData>
    9.     {
    10.         public CameraDataComponent() { }
    11.     }
    The float2 is for the follow speed of the camera, and the DataComponent is based on MeshInstanceRendererComponent class.

    I can't find the component in the component list to add it to the camera, or to any other scene object. It's the same for all the other data structs that have been componentified
     
  2. eizenhorn

    eizenhorn

    Joined:
    Oct 17, 2016
    Posts:
    1,432
    Your .cs file named CameraDataComponent? And why you use empty constructor, is not needed in wrapper.
     
  3. madks13

    madks13

    Joined:
    May 8, 2016
    Posts:
    161
    As i said, i used MeshInstanceRendererComponent as exemple. And since it's in the same file as CameraData, the file is not named as such. For having the component in the same file as the data implementation, i remember seeing this inside another sample project, which is why i did that. I will move it to its own file. Thanks.
     
  4. tertle

    tertle

    Joined:
    Jan 25, 2011
    Posts:
    1,667
    They can be in the same file, just the file needs to be named after the monobehaviour.
     
  5. madks13

    madks13

    Joined:
    May 8, 2016
    Posts:
    161
    @tertle I see, well, i only tried the two in one approach because of the sample. I usally write one class per file, so this solution is better for me.