Search Unity

Copy Transform From Gameobject Proxy performance sucks.

Discussion in 'Entity Component System' started by CWatsonT2, Feb 21, 2020.

  1. CWatsonT2

    CWatsonT2

    Joined:
    Jan 9, 2019
    Posts:
    114
    I'm trying to use the hybrid renderer to increase the rendering performance for the thousands of gameobjects I have. CopyTransformFromGameobjectProxy is exactly what I need as far as functionality. I want the created entities to stay in the position of the gameobject they were created from. The performance of this is terrible however. It looks like the entity's renderer is only active when the gameobject mesh renderer is also active so it's rendering everything twice. Am I going about this wrong? If I use ConvertToEntity performance is excellent but the entities don't move with my gameobjects.
     
  2. thelebaron

    thelebaron

    Joined:
    Jun 2, 2013
    Posts:
    857
    add a script that adds the actual IComponentData into your conversion, ie something like(my own variation)

    Code (CSharp):
    1.    
    2. public class CopyTransformToGameObjectAuthoring : MonoBehaviour, IConvertGameObjectToEntity
    3.     {
    4.         [SerializeField] private bool Reverse;
    5.         [SerializeField] private bool DontAdd;
    6.      
    7.         public void Convert(Entity entity, EntityManager dstManager, GameObjectConversionSystem conversionSystem)
    8.         {
    9.             if (DontAdd)
    10.                 return;
    11.          
    12.             if(!Reverse)
    13.                 dstManager.AddComponentData(entity, new CopyTransformToGameObject());
    14.             else
    15.             {
    16.                 dstManager.AddComponentData(entity, new CopyTransformFromGameObject());
    17.             }          
    18.         }
    19.     }