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
25 lines (25 loc) · 856 Bytes
/
Copy pathSetPlayerToDebugColorSystem.cs
File metadata and controls
25 lines (25 loc) · 856 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
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()
{
Entities.WithAll<SetPlayerToDebugColor>().WithChangeFilter<MaterialMeshInfo, GhostOwner>().ForEach((ref URPMaterialPropertyBaseColor color, in GhostOwner ghostOwner) =>
{
color.Value = NetworkIdDebugColorUtility.Get(ghostOwner.NetworkId);
}).Run();
}
}
}