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

How to Copy Transform to Game Object with newer version of ECS?

Discussion in 'Entity Component System' started by xVergilx, Jul 18, 2019.

  1. xVergilx

    xVergilx

    Joined:
    Dec 22, 2014
    Posts:
    3,292
    I think previously LocalToWorld component / proxy was used, how do I copy translation from the entity to the gameobject now?

    LocalToWorldProxy is marked as deprecated.
     
  2. tertle

    tertle

    Joined:
    Jan 25, 2011
    Posts:
    3,626
    You can still just add the CopyTransformToGameObject component to your entity.
     
  3. xVergilx

    xVergilx

    Joined:
    Dec 22, 2014
    Posts:
    3,292
    But it doesn't work for me with Translation component attached (translation proxy is modified, but transform is not).
    Or I'm doing something wrong.
     
  4. xVergilx

    xVergilx

    Joined:
    Dec 22, 2014
    Posts:
    3,292
    Yep, it still uses LocalToWorld =|
     
  5. tertle

    tertle

    Joined:
    Jan 25, 2011
    Posts:
    3,626
    LocalToWorld is a standard component of the TransformSystem, what's wrong with using that? All entities that have a transform have a LocalToWorld component.
     
  6. eizenhorn

    eizenhorn

    Joined:
    Oct 17, 2016
    Posts:
    2,653
    And it will. Translation itself it's just convenient way of modifying LTW, without LTW is nothing. Anyway if you don't want LTW just write your own CopyTo system with your own entity query.
     
    SenseEater likes this.
  7. xVergilx

    xVergilx

    Joined:
    Dec 22, 2014
    Posts:
    3,292
    No idea
    upload_2019-7-18_12-18-27.png

    Translation is marked as deprecated as well:
    upload_2019-7-18_12-19-6.png
     
  8. eizenhorn

    eizenhorn

    Joined:
    Oct 17, 2016
    Posts:
    2,653
    It's proxy marked as deprecated, and not Translation and LTW itself, cause proxy should be replaced to new Conversion workflow.
     
    xVergilx likes this.
  9. xVergilx

    xVergilx

    Joined:
    Dec 22, 2014
    Posts:
    3,292
    I'm fine, as long as its not going to be dumped away at some version.

    There should be a replacement for anything if its marked as deprecated, right?
     
  10. tertle

    tertle

    Joined:
    Jan 25, 2011
    Posts:
    3,626
    Yes, GameObjectEntity and Proxy components are depreciated.

    That's not the same as depreciating the actual LocalToWorld component.
    Don't use LocalToWorldProxy.

    The replacement is the conversion system.
     
    xVergilx likes this.
  11. xVergilx

    xVergilx

    Joined:
    Dec 22, 2014
    Posts:
    3,292
    Ok, got it. Thanks :)
     
  12. Mesayah

    Mesayah

    Joined:
    Jul 26, 2015
    Posts:
    3
    Sorry for digging it out after a year, but it's the most returned topic on Google searches when it comes to copying Translation to GameObject. Currently, we get messages encouraging usage of the new conversion workflow, but I don't know how it should look in implementation. How can I add CopyTransformToGameObject component? There is no script like that on its own in the Entities package (although it is mentioned in my version of the package in the Scripting API documentation), the only scripts available for attaching to GO are the deprecated proxies. How it is done to implement this reflection of Entity Translation on GO's Transform in the "new conversion workflow"?
     
  13. TheSmokingGnu

    TheSmokingGnu

    Joined:
    May 1, 2017
    Posts:
    22
    @Mesayah, new conversion system is basically using ConvertToEntity scripts to initiate the convertion for a gameobject, and defining the components of the resulting entity via the Authoring scipts in the editor, or by custom Monobehaviors that implement IConvertGameObjectToEntity interface, and add the component manually in the Convert method.

    Since we don't have the CopyTransformToGameObjectAuthoring script provided (which I think should be handled in the future - all it takes is to add [GenerateAuthoring] attribute, if I can guess), we can't use the neat Authoring from editor trick. So, you need to create your own monobehavor and add the CopyTransformToGameObject in the Convert method like this:


    Code (CSharp):
    1.     public void Convert(Entity entity, EntityManager dstManager, GameObjectConversionSystem conversionSystem)
    2.     {
    3.             dstManager.AddComponentData(entity, new CopyTransformToGameObject());
    4.         }
     
    bb8_1, hugokostic and jashan like this.