Skip to content
This repository has been archived by the owner on Aug 11, 2024. It is now read-only.

Commit

Permalink
Implement utility to check for used render pipeline (#766)
Browse files Browse the repository at this point in the history
* Implement utility to check for used render pipeline

* Fix docs
  • Loading branch information
FejZa authored Jan 23, 2021
1 parent 1f980e6 commit 18c6dd7
Show file tree
Hide file tree
Showing 4 changed files with 89 additions and 0 deletions.
29 changes: 29 additions & 0 deletions Runtime/Definitions/Utilities/RenderPipeline.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// Copyright (c) XRTK. All rights reserved.
// Licensed under the MIT License. See LICENSE in the project root for license information.

namespace XRTK.Definitions.Utilities
{
/// <summary>
/// Available render pipelines for use in Unity applications.
/// </summary>
public enum RenderPipeline
{
/// <summary>
/// The legacy "built-in" render pipeline of Unity that was deprecated
/// when scriptable render pipelines were introduced.
/// </summary>
Legacy = 0,
/// <summary>
/// The universal render pipeline, formerly also known as lightweight render pipeline.
/// </summary>
UniversalRenderPipeline,
/// <summary>
/// The high definition pipeline.
/// </summary>
HighDefinitionRenderPipeline,
/// <summary>
/// A customized scriptable render pipeline.
/// </summary>
Custom
}
}
11 changes: 11 additions & 0 deletions Runtime/Definitions/Utilities/RenderPipeline.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

38 changes: 38 additions & 0 deletions Runtime/Utilities/RenderPipelineUtilities.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// Copyright (c) XRTK. All rights reserved.
// Licensed under the MIT License. See LICENSE in the project root for license information.

using UnityEngine.Rendering;
using XRTK.Extensions;
using RenderPipeline = XRTK.Definitions.Utilities.RenderPipeline;

namespace XRTK.Utilities
{
public static class RenderPipelineUtilities
{
private const string urpAssetTypeName = "UniversalRenderPipelineAsset";
private const string hdrpAssetTypeName = "HDRenderPipelineAsset";

/// <summary>
/// Gets the <see cref="RenderPipeline"/> used by the project.
/// </summary>
/// <returns>The <see cref="RenderPipeline"/> used by the project.</returns>
public static RenderPipeline GetActiveRenderingPipeline()
{
var renderPipelineAsset = GraphicsSettings.renderPipelineAsset;
if (renderPipelineAsset.IsNull())
{
return RenderPipeline.Legacy;
}

switch (renderPipelineAsset.GetType().Name)
{
case urpAssetTypeName:
return RenderPipeline.UniversalRenderPipeline;
case hdrpAssetTypeName:
return RenderPipeline.HighDefinitionRenderPipeline;
}

return RenderPipeline.Custom;
}
}
}
11 changes: 11 additions & 0 deletions Runtime/Utilities/RenderPipelineUtilities.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 18c6dd7

Please sign in to comment.