forked from Unity-Technologies/EntityComponentSystemSamples
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSetPlayerToDebugColorSystem.cs
More file actions
26 lines (26 loc) · 905 Bytes
/
Copy pathSetPlayerToDebugColorSystem.cs
File metadata and controls
26 lines (26 loc) · 905 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
using System;
using Unity.Collections;
using Unity.Entities;
using Unity.NetCode;
using Unity.Rendering;
using UnityEngine;
namespace Unity.NetCode.Samples.Common
{
/// <summary>
/// Every NetworkId has its own unique Debug color. This system sets it.
/// </summary>
[AlwaysSynchronizeSystem]
[RequireMatchingQueriesForUpdate]
[WorldSystemFilter(WorldSystemFilterFlags.Presentation)]
public partial class SetPlayerToDebugColorSystem : SystemBase
{
protected override void OnUpdate()
{
foreach (var (color, ghostOwner) in SystemAPI.Query<RefRW<URPMaterialPropertyBaseColor>, RefRO<GhostOwner>>()
.WithAll<SetPlayerToDebugColor>().WithChangeFilter<MaterialMeshInfo, GhostOwner>())
{
color.ValueRW.Value = NetworkIdDebugColorUtility.Get(ghostOwner.ValueRO.NetworkId);
}
}
}
}