Search Unity

Unable to modify NonUniformScale or Scale of entity at runtime?

Discussion in 'Entity Component System' started by abhi3188, Feb 8, 2020.

  1. abhi3188

    abhi3188

    Joined:
    Dec 13, 2015
    Posts:
    31
    Hi,

    I tried modifying the scale of my entity which is created at runtime using a gameobject prefab but I am unable to do so. The prefab is a simple cube with a meshrenderer and a collider.

    Here is my system. The entity doesn't respond to this.

    Code (CSharp):
    1. public class ResizeSystem : JobComponentSystem
    2. {
    3.     protected override JobHandle OnUpdate(JobHandle inputDeps)
    4.     {
    5.         float dt = Time.DeltaTime;
    6.  
    7.         // resizing, scaling does not seem to work
    8.  
    9.         Entities
    10.             .WithAll<ResizeTag>()
    11.             .ForEach((ref Scale scale) =>
    12.         {
    13.             scale.Value += 0.1f * dt;
    14.         }).Run();
    15.  
    16.         return default;
    17.     }
    18. }
    Even when I inspect the entity after clicking on it in the Entity Debugger, it doesn't seem to show a scale or NonUniformScale component.

    I even tried explicitly adding NonUniformScale to the entity when it is instantiated but it made no difference.

    If I try to write a system that modifies the rotation or translation component instead, it works without issues.