-
Notifications
You must be signed in to change notification settings - Fork 869
Expand file tree
/
Copy pathRenderGraphEditorRemoteDebugSession.cs
More file actions
69 lines (61 loc) · 2.92 KB
/
RenderGraphEditorRemoteDebugSession.cs
File metadata and controls
69 lines (61 loc) · 2.92 KB
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
using UnityEditor.Rendering.Analytics;
using static UnityEngine.Rendering.RenderGraphModule.RenderGraph;
namespace UnityEngine.Rendering.RenderGraphModule
{
internal sealed class RenderGraphEditorRemoteDebugSession : RenderGraphDebugSession
{
public override bool isActive => false;
DebugMessageHandler m_DebugMessageHandler = ScriptableObject.CreateInstance<DebugMessageHandler>();
public RenderGraphEditorRemoteDebugSession() : base()
{
m_DebugMessageHandler.Register(OnMessageFromPlayer);
// In the case of auto-connect profiler option, the player doesn't receive the OnEditorConnected callback.
// Therefore send an explicit activation message to ensure the player becomes aware of the editor.
m_DebugMessageHandler.Send(DebugMessageHandler.MessageType.Activate);
}
public override void Dispose()
{
base.Dispose();
m_DebugMessageHandler.UnregisterAll();
CoreUtils.Destroy(m_DebugMessageHandler);
}
void OnMessageFromPlayer(DebugMessageHandler.MessageType messageType, DebugMessageHandler.IPayload payload)
{
if (messageType == DebugMessageHandler.MessageType.Activate)
{
// In the event that the player starts after the editor, it will request activation from the editor.
m_DebugMessageHandler.Send(DebugMessageHandler.MessageType.Activate);
}
else if (messageType == DebugMessageHandler.MessageType.DebugData)
{
var debugDataPayload = payload as DebugMessageHandler.DebugDataPayload;
if (!debugDataPayload.isCompatible)
{
string errorStr = "<Incompatible version>";
RegisterAndUpdateDebugData(errorStr, EntityId.None, errorStr, null);
}
else
{
RegisterAndUpdateDebugData(
debugDataPayload.graphName,
debugDataPayload.executionId,
debugDataPayload.debugData.executionName,
debugDataPayload.debugData);
}
}
else if (messageType == DebugMessageHandler.MessageType.AnalyticsData)
{
if (payload is DebugMessageHandler.AnalyticsPayload { isCompatible: true } analyticsPayload)
{
RenderGraphViewerSessionCreatedAnalytic.Send(RenderGraphViewerSessionCreatedAnalytic.SessionType.Remote, analyticsPayload);
}
}
}
void RegisterAndUpdateDebugData(string graphName, EntityId executionId, string executionName, DebugData debugData)
{
RegisterGraph(graphName);
RegisterExecution(graphName, executionId, executionName);
SetDebugData(graphName, executionId, debugData);
}
}
}