Serialize managed SRP asset graphs
This commit is contained in:
@@ -3314,6 +3314,135 @@ namespace Gameplay
|
||||
}
|
||||
}
|
||||
|
||||
public sealed class SerializedUniversalRenderPipelineAssetGraphProbe
|
||||
: MonoBehaviour
|
||||
{
|
||||
public int UpdateCount;
|
||||
public bool ObservedAssetWasNull = true;
|
||||
public int ObservedDefaultRendererIndex = -1;
|
||||
public int ObservedRendererDataCount;
|
||||
public int ObservedRendererFeatureCount;
|
||||
public bool ObservedFeatureActive = true;
|
||||
public string ObservedFeatureTypeName = string.Empty;
|
||||
public Vector4 ObservedColorScale;
|
||||
public bool ObservedShadowsSupportMainLight = true;
|
||||
public Vector4 ObservedFinalColorScale;
|
||||
|
||||
public void Start()
|
||||
{
|
||||
UniversalRenderPipelineAsset asset =
|
||||
ScriptableObject
|
||||
.CreateInstance<UniversalRenderPipelineAsset>();
|
||||
UniversalRendererData rendererData =
|
||||
ScriptableObject
|
||||
.CreateInstance<UniversalRendererData>();
|
||||
ColorScalePostProcessRendererFeature colorScaleFeature =
|
||||
ScriptableObject
|
||||
.CreateInstance<ColorScalePostProcessRendererFeature>();
|
||||
if (asset == null ||
|
||||
rendererData == null ||
|
||||
colorScaleFeature == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
colorScaleFeature.colorScale = new Vector4(
|
||||
0.42f,
|
||||
0.51f,
|
||||
0.63f,
|
||||
1.0f);
|
||||
colorScaleFeature.SetActive(false);
|
||||
rendererData.rendererFeatures =
|
||||
new ScriptableRendererFeature[]
|
||||
{
|
||||
colorScaleFeature
|
||||
};
|
||||
asset.rendererDataList =
|
||||
new ScriptableRendererData[]
|
||||
{
|
||||
rendererData
|
||||
};
|
||||
asset.defaultRendererIndex = 0;
|
||||
asset.shadows =
|
||||
UniversalShadowSettings.CreateDefault();
|
||||
asset.shadows.supportsMainLightShadows = false;
|
||||
asset.finalColor =
|
||||
UniversalFinalColorSettings.CreateDefault();
|
||||
asset.finalColor.settings.finalColorScale =
|
||||
new Vector4(
|
||||
0.90f,
|
||||
1.10f,
|
||||
1.20f,
|
||||
1.0f);
|
||||
|
||||
GraphicsSettings.renderPipelineAsset = asset;
|
||||
}
|
||||
|
||||
public void Update()
|
||||
{
|
||||
++UpdateCount;
|
||||
if (UpdateCount < 2)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
UniversalRenderPipelineAsset asset =
|
||||
GraphicsSettings.renderPipelineAsset as
|
||||
UniversalRenderPipelineAsset;
|
||||
ObservedAssetWasNull = asset == null;
|
||||
if (asset == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
ObservedDefaultRendererIndex =
|
||||
asset.defaultRendererIndex;
|
||||
ObservedRendererDataCount =
|
||||
asset.rendererDataList != null
|
||||
? asset.rendererDataList.Length
|
||||
: 0;
|
||||
ObservedShadowsSupportMainLight =
|
||||
asset.shadows != null &&
|
||||
asset.shadows.supportsMainLightShadows;
|
||||
ObservedFinalColorScale =
|
||||
asset.finalColor != null
|
||||
? asset.finalColor.settings.finalColorScale
|
||||
: new Vector4();
|
||||
|
||||
ScriptableRendererData rendererData =
|
||||
asset.rendererDataList != null &&
|
||||
asset.rendererDataList.Length > 0
|
||||
? asset.rendererDataList[0]
|
||||
: null;
|
||||
ObservedRendererFeatureCount =
|
||||
rendererData != null &&
|
||||
rendererData.rendererFeatures != null
|
||||
? rendererData.rendererFeatures.Length
|
||||
: 0;
|
||||
|
||||
ScriptableRendererFeature feature =
|
||||
rendererData != null &&
|
||||
rendererData.rendererFeatures != null &&
|
||||
rendererData.rendererFeatures.Length > 0
|
||||
? rendererData.rendererFeatures[0]
|
||||
: null;
|
||||
ObservedFeatureTypeName =
|
||||
feature != null
|
||||
? feature.GetType().FullName ?? string.Empty
|
||||
: string.Empty;
|
||||
ObservedFeatureActive =
|
||||
feature != null &&
|
||||
feature.isActive;
|
||||
|
||||
ColorScalePostProcessRendererFeature colorScaleFeature =
|
||||
feature as ColorScalePostProcessRendererFeature;
|
||||
ObservedColorScale =
|
||||
colorScaleFeature != null
|
||||
? colorScaleFeature.colorScale
|
||||
: new Vector4();
|
||||
}
|
||||
}
|
||||
|
||||
public sealed class ScriptCoreUniversalShadowlessRendererFeatureRuntimeSelectionProbe
|
||||
: MonoBehaviour
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user