Search Unity

  1. If you have experience with import & exporting custom (.unitypackage) packages, please help complete a survey (open until May 15, 2024).
    Dismiss Notice
  2. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice

How to link a text to an entity

Discussion in 'Entity Component System' started by Celes_Eternal, Sep 26, 2018.

  1. Celes_Eternal

    Celes_Eternal

    Joined:
    May 18, 2018
    Posts:
    18
    Hello guys, it may be a noob question but I can't find a proper way to link a text (I want to writte position on an hexagonal map at the moment), with a entity (which are the hex cells). Because in some examples I found, it need a transform, I mean a object of type transform, not a float4x4.

    Thanks
    Have a nice day
     
  2. Spy-Shifty

    Spy-Shifty

    Joined:
    May 5, 2011
    Posts:
    546
  3. Celes_Eternal

    Celes_Eternal

    Joined:
    May 18, 2018
    Posts:
    18
    A sprite to write some numbers? I mean is there a way to create some custom texture with the code to generate the text I want to?
    But yeah the tutorial I was looking into use UnityEngine.UI.Text to simply display numbers on the cells. But to link it it use a transform. So maybe a system to translate my entities float4x4? Kinda sad though
     
  4. Celes_Eternal

    Celes_Eternal

    Joined:
    May 18, 2018
    Posts:
    18
    The only solution I see right now is create a component "LinkedText" and a system who update the poition of the text whitout using the transform of a game object.
    Nobody have already tried to put some text on mesh used by entities?
     
  5. Spy-Shifty

    Spy-Shifty

    Joined:
    May 5, 2011
    Posts:
    546
    Well I think ecs don't support RectTransform yet. So you have to write your own.

    But you can take a look into the CopyTransfromToGameObjectSystem
    You'll find it under:
    Packages/com.unity.entities/Unity.Transforms.Hybrid/
     
  6. Celes_Eternal

    Celes_Eternal

    Joined:
    May 18, 2018
    Posts:
    18
    Thanks I'll stay on doing a custom one who change text position on movement.
    But I was to curious to check what you said, but I can't find where is Packages/com.unity.entities/Unity.Transforms.Hybrid/
    Yeah I'm a newbie ^^
     
  7. Spy-Shifty

    Spy-Shifty

    Joined:
    May 5, 2011
    Posts:
    546
    upload_2018-9-28_15-19-3.png

    You can also right click this folder and click on "Show in Explorer".

    You should also have a look at the Test folders there for some usecases or implementation needs!
     
    Celes_Eternal likes this.