// TODO: Implement this protected override void OnUpdate() { var parents = GetComponentDataFromEntity <Parent>(true); Entities.ForEach((Entity entity, ref FillAmount c0, in MaterialPropertyIndex c1, in SpriteData c2) => { var current = c0.Amount; current = ((float)math.cos(Time.ElapsedTime) + 1) / 2; c0.Amount = current; var canvasRoot = HierarchyUtils.GetRoot(entity, parents); var properties = EntityManager.GetComponentData <MaterialPropertyBatch>(canvasRoot); var associatedProp = properties.Value[c1.Value]; associatedProp.SetInt(ShaderIDConstants.FillType, c0.FillTypeAsInt()); associatedProp.SetFloat(ShaderIDConstants.Fill, current); }).WithoutBurst().Run();
public void Execute(Entity msgEntity, DynamicBuffer <CloseTarget> b0) { var buffer = b0.AsNativeArray(); for (int i = 0; i < buffer.Length; i++) { var targetEntity = buffer[i].Value; // Check the metadata of the entity and update its state var root = HierarchyUtils.GetRoot(targetEntity, Parents); var activeStates = Metadata[root]; if (activeStates.Value.TryGetValue(targetEntity, out bool isActive)) { isActive = !isActive; activeStates.Value[targetEntity] = isActive; } if (isActive && Disabled.HasComponent(targetEntity) && (ShowButtons.HasComponent(msgEntity) || ToggleButtons.HasComponent(msgEntity))) { CmdBuffer.RemoveComponent <Disabled>(targetEntity); CmdBuffer.AddComponent <EnableRenderingTag>(targetEntity); if (LocalVertices.HasComponent(targetEntity)) { CmdBuffer.AddComponent <UpdateVertexColorTag>(targetEntity); } RecurseChildrenAndEnable(targetEntity, ref activeStates.Value); } if (!isActive && (CloseButtons.HasComponent(msgEntity) || ToggleButtons.HasComponent(msgEntity))) { CmdBuffer.AddComponent <Disabled>(targetEntity); if (LocalVertices.HasComponent(targetEntity)) { CmdBuffer.AddComponent <UpdateVertexColorTag>(targetEntity); } RecurseChildrenAndDisabled(targetEntity); } } }
protected override void OnUpdate() { var ltws = GetComponentDataFromEntity <LocalToWorld>(true); var parents = GetComponentDataFromEntity <Parent>(true); Entities.ForEach((Entity e, ref PingPongPositions c0, ref Translation c2, ref LocalToParent c3, in MaterialPropertyIndex c1) => { var x = c2.Value.x; if (math.distance(x, c0.Target) <= 0.2f) { c0.Target = c0.AdjustedWidth; } if (math.distance(x, c0.Target) <= 0.2f) { c0.Target = -c0.AdjustedWidth; } x = math.lerp(x, c0.Target, Time.DeltaTime); var matrix = float4x4.TRS(new float3(x, 0, 0), quaternion.identity, new float3(1)); var localSpace = new LocalToParent { Value = matrix }; var root = HierarchyUtils.GetRoot(e, parents); var batch = EntityManager.GetComponentData <MaterialPropertyBatch>(root); var property = batch.Value[c1.Value]; property.SetVector(ShaderIDConstants.Translation, new float4(localSpace.Position, 0)); c3 = localSpace; c2 = new Translation { Value = localSpace.Position }; }).WithoutBurst().Run(); }
public void Execute(ArchetypeChunk chunk, int chunkIndex, int firstEntityIndex) { var colors = chunk.GetNativeArray(AppliedColorType); var vertexBuffers = chunk.GetBufferAccessor(LocalVertexType); var entities = chunk.GetNativeArray(EntityType); var isDisabled = chunk.Has(DisabledType); var isNewlyEnabled = chunk.Has(EnableRenderingType); // If newly disabled if (isDisabled && !isNewlyEnabled) { for (int i = 0; i < chunk.Count; i++) { var entity = entities[i]; var vertices = vertexBuffers[i].AsNativeArray(); var color = colors[i].Value.ToNormalizedFloat4(); for (int m = 0; m < vertices.Length; m++) { var cpy = vertices[m]; cpy.Color = default; cpy.Position += Offset; vertices[m] = cpy; } var root = HierarchyUtils.GetRoot(entity, Parents); CmdBuffer.AddComponent <DisableRenderingTag>(chunkIndex, root); } } // If this has been rendered to begin with if (!isDisabled && !isNewlyEnabled) { for (int i = 0; i < chunk.Count; i++) { var entity = entities[i]; var vertices = vertexBuffers[i].AsNativeArray(); var color = colors[i].Value.ToNormalizedFloat4(); for (int m = 0; m < vertices.Length; m++) { var cpy = vertices[m]; cpy.Color = color; vertices[m] = cpy; } var root = HierarchyUtils.GetRoot(entity, Parents); CmdBuffer.AddComponent <UpdateVertexColorTag>(chunkIndex, root); } } // If the chunk is newly renabled if (!isDisabled && isNewlyEnabled) { for (int i = 0; i < chunk.Count; i++) { var entity = entities[i]; var vertices = vertexBuffers[i].AsNativeArray(); var color = colors[i].Value.ToNormalizedFloat4(); for (int m = 0; m < vertices.Length; m++) { var cpy = vertices[m]; cpy.Color = color; cpy.Position -= Offset; vertices[m] = cpy; } var root = HierarchyUtils.GetRoot(entity, Parents); CmdBuffer.AddComponent <UpdateVertexColorTag>(chunkIndex, root); } } }