Files
XCEngine/managed/GameScripts/RenderPipelineApiProbe.cs

82 lines
2.6 KiB
C#

using XCEngine;
namespace Gameplay
{
public sealed class LegacyRenderPipelineApiProbeAsset : RenderPipelineAsset
{
}
public sealed class RenderPipelineApiProbeAsset : ScriptableRenderPipelineAsset
{
}
public sealed class ManagedRenderPipelineProbeAsset : ScriptableRenderPipelineAsset
{
public static int CreatePipelineCallCount;
protected override ScriptableRenderPipeline CreatePipeline()
{
CreatePipelineCallCount++;
return new ManagedRenderPipelineProbe();
}
}
public sealed class ManagedRenderPipelineProbe : ScriptableRenderPipeline
{
public static int SupportsStageCallCount;
public static int RecordStageCallCount;
protected override bool SupportsStageRenderGraph(
CameraFrameStage stage)
{
SupportsStageCallCount++;
return stage == CameraFrameStage.MainScene;
}
protected override bool RecordStageRenderGraph(
ScriptableRenderContext context)
{
RecordStageCallCount++;
return context != null &&
context.stage == CameraFrameStage.MainScene &&
context.RenderBuiltinForwardMainScene();
}
}
public sealed class RenderPipelineApiProbe : MonoBehaviour
{
public bool InitialTypeWasNull;
public bool InvalidSelectionRejected;
public bool InvalidSelectionMentionsScriptableBase;
public bool SelectionRoundTripSucceeded;
public string SelectedPipelineTypeName = string.Empty;
public void Start()
{
InitialTypeWasNull = GraphicsSettings.renderPipelineAssetType == null;
try
{
GraphicsSettings.renderPipelineAssetType =
typeof(LegacyRenderPipelineApiProbeAsset);
InvalidSelectionRejected = false;
}
catch (System.ArgumentException ex)
{
InvalidSelectionRejected = true;
InvalidSelectionMentionsScriptableBase =
ex.Message.Contains("ScriptableRenderPipelineAsset");
}
GraphicsSettings.renderPipelineAssetType =
typeof(RenderPipelineApiProbeAsset);
System.Type selectedType = GraphicsSettings.renderPipelineAssetType;
SelectionRoundTripSucceeded =
selectedType == typeof(RenderPipelineApiProbeAsset);
SelectedPipelineTypeName = selectedType != null
? selectedType.FullName ?? string.Empty
: string.Empty;
}
}
}