This repository has been archived by the owner on Aug 11, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement utility to check for used render pipeline (#766)
* Implement utility to check for used render pipeline * Fix docs
- Loading branch information
Showing
4 changed files
with
89 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.