修改框架
This commit is contained in:
@@ -1,27 +0,0 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace MuHua {
|
||||
/// <summary>
|
||||
/// 数据可视化
|
||||
/// </summary>
|
||||
public class ModuleVisual {
|
||||
/// <summary> 创建可视化内容 </summary>
|
||||
public static void Create<Type>(ref Type value, Transform original, Transform parent) {
|
||||
if (value != null) { return; }
|
||||
Transform temp = CreateTransform(original, parent);
|
||||
value = temp.GetComponent<Type>();
|
||||
}
|
||||
/// <summary> 创建Transform </summary>
|
||||
public static Transform CreateTransform(Transform original, Transform parent) {
|
||||
Transform temp = Transform.Instantiate(original, parent);
|
||||
temp.gameObject.SetActive(true);
|
||||
return temp;
|
||||
}
|
||||
/// <summary> 删除可视化内容 </summary>
|
||||
public static void Remove<Type>(Type visual) where Type : Component {
|
||||
if (visual != null) { GameObject.Destroy(visual.gameObject); }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: aff4fda1c9fd8164384489f6750e34f4
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -4,13 +4,11 @@ using UnityEngine;
|
||||
using UnityEngine.Rendering;
|
||||
using UnityEngine.Rendering.Universal;
|
||||
|
||||
namespace MuHua
|
||||
{
|
||||
namespace MuHua {
|
||||
/// <summary>
|
||||
/// 轮廓渲染设置
|
||||
/// </summary>
|
||||
public class SRFOutlineSettings
|
||||
{
|
||||
public class SRFOutlineSettings {
|
||||
/// <summary> 辅助材质 </summary>
|
||||
public Material unlit;
|
||||
/// <summary> 轮廓材质 </summary>
|
||||
@@ -25,8 +23,7 @@ namespace MuHua
|
||||
/// <summary>
|
||||
/// 轮廓渲染通道
|
||||
/// </summary>
|
||||
public class SRFOutlinePass : ScriptableRenderPass
|
||||
{
|
||||
public class SRFOutlinePass : ScriptableRenderPass {
|
||||
public const string ProfilerTag = "Outline";
|
||||
|
||||
/// <summary> 渲染设置 </summary>
|
||||
@@ -38,8 +35,7 @@ namespace MuHua
|
||||
public RTHandle outlineRTHandle;
|
||||
|
||||
/// <summary> 渲染前设置 </summary>
|
||||
public void Setup(SRFOutlineSettings settings, in RenderingData renderingData)
|
||||
{
|
||||
public void Setup(SRFOutlineSettings settings, in RenderingData renderingData) {
|
||||
this.settings = settings;
|
||||
renderPassEvent = settings.renderPassEvent;
|
||||
RenderTextureDescriptor descriptor = renderingData.cameraData.cameraTargetDescriptor;
|
||||
@@ -48,8 +44,7 @@ namespace MuHua
|
||||
RenderingUtils.ReAllocateIfNeeded(ref tempRTHandle, descriptor, name: "TempRT");
|
||||
}
|
||||
|
||||
public override void Execute(ScriptableRenderContext context, ref RenderingData renderingData)
|
||||
{
|
||||
public override void Execute(ScriptableRenderContext context, ref RenderingData renderingData) {
|
||||
if (renderingData.cameraData.cameraType == CameraType.SceneView || renderingData.cameraData.cameraType == CameraType.Preview) return;
|
||||
|
||||
CommandBuffer command = CommandBufferPool.Get(ProfilerTag);
|
||||
@@ -78,16 +73,13 @@ namespace MuHua
|
||||
outlineRTHandle?.Release();
|
||||
}
|
||||
|
||||
public void DrawRenderer(CommandBuffer command, Material material)
|
||||
{
|
||||
for (int i = 0; i < settings.renderObjs.Length; i++)
|
||||
{
|
||||
public void DrawRenderer(CommandBuffer command, Material material) {
|
||||
for (int i = 0; i < settings.renderObjs.Length; i++) {
|
||||
Renderer renderer = settings.renderObjs[i];
|
||||
if (renderer == null) { continue; }
|
||||
|
||||
// 遍历所有的子网格
|
||||
for (int subMeshIndex = 0; subMeshIndex < renderer.sharedMaterials.Length; subMeshIndex++)
|
||||
{
|
||||
for (int subMeshIndex = 0; subMeshIndex < renderer.sharedMaterials.Length; subMeshIndex++) {
|
||||
command.DrawRenderer(renderer, material, subMeshIndex, 0);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user