This commit is contained in:
shenjianxing 2025-04-02 14:37:35 +08:00
parent d1776762c7
commit 40de877779
23 changed files with 746 additions and 546 deletions

View File

@ -114,7 +114,7 @@ Material:
- _ZWrite: 1
m_Colors:
- _BaseColor: {r: 0.8, g: 0.46728, b: 0, a: 0.6786941}
- _Color: {r: 0.8, g: 0.4672799, b: 0, a: 0.6786941}
- _Color: {r: 0.8, g: 0.46728, b: 0, a: 0.6786941}
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
- _SpecColor: {r: 0.19999996, g: 0.19999996, b: 0.19999996, a: 1}
m_BuildTextureStacks: []

View File

@ -117,7 +117,7 @@ Material:
- _ZWrite: 0
m_Colors:
- _BaseColor: {r: 0.4, g: 0.4, b: 0.4, a: 0.41339868}
- _Color: {r: 0.39999998, g: 0.39999998, b: 0.39999998, a: 0.41339868}
- _Color: {r: 0.4, g: 0.4, b: 0.4, a: 0.41339868}
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
- _SpecColor: {r: 0.19999996, g: 0.19999996, b: 0.19999996, a: 1}
m_BuildTextureStacks: []

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 1eefb47a51c39494ebdb4e38d10950bc
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,25 @@
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class OutLineDraw : MonoBehaviour
{
public Color color=Color.green;
private OutLineDrawPam _outLineDrawPam;
private void OnEnable()
{
_outLineDrawPam=OutLineSingle.Instance().GetOutLineDrawPam(GetComponentsInChildren<Renderer>(),this);
OutLineSingle.Instance().AddOutLineRender(_outLineDrawPam);
}
private void OnDisable()
{
OutLineSingle.Instance().RemoveOutLineRender(_outLineDrawPam);
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 959ea4c0f60027140bb39b690d81b157
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,48 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1 &2322806451925117664
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 3681589371309184014}
- component: {fileID: 4603763608405150698}
m_Layer: 0
m_Name: OutLineManager
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &3681589371309184014
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2322806451925117664}
serializedVersion: 2
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: -0.50488526, y: 0.5785435, z: 6.718124}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &4603763608405150698
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2322806451925117664}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 0d01c7122a2dac645826961452d1c2a0, type: 3}
m_Name:
m_EditorClassIdentifier:
OutLineScale: 2
OutLineStrength: 1

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 5344d294e9c8ea149ab4e028ea523af3
PrefabImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 502c2ca33cfec104e844eda8b287f717
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,207 @@
using CG.Framework;
using System;
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;
using UnityEngine.Rendering;
using UnityEngine.Rendering.Universal;
using Object = UnityEngine.Object;
//[ExecuteAlways]
public class OutLineCameraRender : MonoSingleton<OutLineCameraRender>
{
[Range(1.5f, 5.0f)] public float OutLineScale = 2;
[Range(0, 3.0f)] public float OutLineStrength = 1;
// Camera cam ;
// Start is called before the first frame update
private OutLineRenderPass outLineRenderPass;
void Start()
{
outLineRenderPass = new OutLineRenderPass();
RenderPipelineManager.beginCameraRendering += BeginCameraRendering;
}
private void BeginCameraRendering(ScriptableRenderContext arg1, Camera arg2)
{
if (arg2.cameraType == CameraType.SceneView || arg2.transform.CompareTag("MainCamera"))
{
outLineRenderPass.renderPassEvent = RenderPassEvent.BeforeRenderingPostProcessing;
outLineRenderPass.outLinePam = OutLineSingle.Instance().GetOutLineRenders();
outLineRenderPass.OutLineScale = OutLineScale;
outLineRenderPass.OutLineStrength = OutLineStrength;
arg2.GetUniversalAdditionalCameraData().scriptableRenderer.EnqueuePass(outLineRenderPass);
}
}
protected override void OnDestroy()
{
RenderPipelineManager.endCameraRendering -= BeginCameraRendering;
if (outLineRenderPass != null)
outLineRenderPass.Distory();
base.OnDestroy();
}
//private void OnDestroy()
//{
// RenderPipelineManager.endCameraRendering -= BeginCameraRendering;
// if(outLineRenderPass != null)
// outLineRenderPass.Distory();
//}
class OutLineRenderPass : ScriptableRenderPass
{
private RTHandle OutLineTemp;
private RTHandle OutLineTemp1;
private RTHandle OutLineTemp11;
private RTHandle OutLineTemp2;
private RTHandle OutLineTemp3;
private RTHandle OutLineTemp4;
private RTHandle OutLineTemp9;
private RTHandle OutLineTemp10;
private RTHandle depth;
private Material OutMat;
private Material OutMatAll;
public float OutLineScale;
public float OutLineStrength;
public List<OutLineDrawPam> outLinePam = new List<OutLineDrawPam>();
public override void OnCameraSetup(CommandBuffer cmd, ref RenderingData renderingData)
{
if (OutMat == null)
{
OutMat = CoreUtils.CreateEngineMaterial("Unlit URP Shader/OutLine");
OutMatAll = CoreUtils.CreateEngineMaterial("Unlit URP Shader/OutLine2");
}
RenderTextureDescriptor rtd = renderingData.cameraData.cameraTargetDescriptor;
rtd.msaaSamples = 1;
rtd.colorFormat = RenderTextureFormat.DefaultHDR;
rtd.depthBufferBits = 0;
RenderingUtils.ReAllocateIfNeeded(ref OutLineTemp1, rtd, name: "OutLineTemp1");
RenderingUtils.ReAllocateIfNeeded(ref OutLineTemp11, rtd, name: "OutLineTemp11");
RenderingUtils.ReAllocateIfNeeded(ref OutLineTemp, rtd, name: "OutLineTemp");
rtd.depthBufferBits = 32;
rtd.colorFormat = RenderTextureFormat.Depth;
RenderingUtils.ReAllocateIfNeeded(ref depth, rtd, name: "depth");
rtd.colorFormat = RenderTextureFormat.DefaultHDR;
rtd.depthBufferBits = 0;
rtd.width /= 2;
rtd.height /= 2;
RenderingUtils.ReAllocateIfNeeded(ref OutLineTemp2, rtd, name: "OutLineTemp2");
RenderingUtils.ReAllocateIfNeeded(ref OutLineTemp10, rtd, name: "OutLineTemp10");
rtd.width /= 2;
rtd.height /= 2;
RenderingUtils.ReAllocateIfNeeded(ref OutLineTemp3, rtd, name: "OutLineTemp3");
RenderingUtils.ReAllocateIfNeeded(ref OutLineTemp9, rtd, name: "OutLineTemp9");
rtd.width /= 2;
rtd.height /= 2;
RenderingUtils.ReAllocateIfNeeded(ref OutLineTemp4, rtd, name: "OutLineTemp4");
ConfigureTarget(OutLineTemp, depth);
ConfigureClear(ClearFlag.All, Vector4.zero);
}
public override void Execute(ScriptableRenderContext context, ref RenderingData renderingData)
{
CommandBuffer cmd = CommandBufferPool.Get("OutLine");
cmd.SetGlobalVector("_HeightLightColor", Vector4.one);
if (outLinePam.Count == 0) return;
for (int i = 0; i < outLinePam.Count; i++)
{
if (outLinePam[i].renders == null || outLinePam[i].renders.Length == 0 || outLinePam[i].draw.color == Color.black) continue;
cmd.SetGlobalColor("_OutLineColor", outLinePam[i].draw.color);
for (int j = 0; j < outLinePam[i].renders.Length; j++)
{
if (outLinePam[i].renders[j] == null) continue;
cmd.DrawRenderer(outLinePam[i].renders[j], OutMat, 0);
}
}
//高亮范围
cmd.SetGlobalFloat("Scale", OutLineScale);
cmd.SetGlobalFloat("Strength", OutLineStrength);
//降采样
Blitter.BlitCameraTexture(cmd, OutLineTemp, OutLineTemp2, OutMatAll, 1);
Blitter.BlitCameraTexture(cmd, OutLineTemp2, OutLineTemp3, OutMatAll, 1);
Blitter.BlitCameraTexture(cmd, OutLineTemp3, OutLineTemp4, OutMatAll, 1);
//升采样
cmd.SetGlobalTexture("_Temp", OutLineTemp3);
Blitter.BlitCameraTexture(cmd, OutLineTemp4, OutLineTemp9, OutMatAll, 2);
cmd.SetGlobalTexture("_Temp", OutLineTemp2);
Blitter.BlitCameraTexture(cmd, OutLineTemp9, OutLineTemp10, OutMatAll, 2);
cmd.SetGlobalTexture("_Temp", OutLineTemp);
Blitter.BlitCameraTexture(cmd, OutLineTemp10, OutLineTemp1, OutMatAll, 2);
//全采样进行一次模糊
cmd.SetGlobalFloat("Scale", 3);
Blitter.BlitCameraTexture(cmd, OutLineTemp1, OutLineTemp11, OutMatAll, 1);
Blitter.BlitCameraTexture(cmd, OutLineTemp11, OutLineTemp, OutMatAll, 1);
//3、通过模板测试裁剪描边内部像素
cmd.SetRenderTarget(OutLineTemp, depth);
Blitter.BlitTexture(cmd, OutLineTemp1, new Vector4(1, 1, 0, 0), OutMatAll, 3);
//4、混合颜色顺便再模糊一次
Blitter.BlitCameraTexture(cmd, OutLineTemp, renderingData.cameraData.renderer.cameraColorTargetHandle, OutMatAll, 4);
context.ExecuteCommandBuffer(cmd);
cmd.Release();
}
public void Distory()
{
#if UNITY_EDITOR
if (EditorApplication.isPlaying)
{
Object.Destroy(OutMat);
Object.Destroy(OutMatAll);
}
else
{
Object.DestroyImmediate(OutMat);
Object.DestroyImmediate(OutMatAll);
}
#else
Object.Destroy(OutMat);
Object.Destroy(OutMatAll);
#endif
if (OutLineTemp != null) OutLineTemp.Release();
if (OutLineTemp11 != null) OutLineTemp11.Release();
if (OutLineTemp1 != null) OutLineTemp1.Release();
if (OutLineTemp2 != null) OutLineTemp2.Release();
if (OutLineTemp3 != null) OutLineTemp3.Release();
if (OutLineTemp4 != null) OutLineTemp4.Release();
if (OutLineTemp9 != null) OutLineTemp9.Release();
if (OutLineTemp10 != null) OutLineTemp10.Release();
if (depth != null) depth.Release();
}
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 0d01c7122a2dac645826961452d1c2a0
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,57 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class OutLineSingle
{
private static OutLineSingle _instance;
private List<OutLineDrawPam> _outLineDrawPams = new List<OutLineDrawPam>();
private OutLineSingle(){}
public static OutLineSingle Instance()
{
if(_instance==null)
{
_instance = new OutLineSingle();
}
return _instance;
}
public OutLineDrawPam GetOutLineDrawPam(Renderer[] renders,OutLineDraw draw)
{
OutLineDrawPam pam = new OutLineDrawPam();
pam.renders = renders;
pam.draw = draw;
return pam;
}
public void AddOutLineRender(OutLineDrawPam outLineDrawPam)
{
_outLineDrawPams.Add(outLineDrawPam);
}
public void RemoveOutLineRender(OutLineDrawPam outLineDrawPam)
{
if (_outLineDrawPams.Contains(outLineDrawPam))
{
_outLineDrawPams.Remove(outLineDrawPam);
}
}
public void RemoveAllOutLineRenders()
{
_outLineDrawPams.Clear();
}
public List<OutLineDrawPam> GetOutLineRenders()
{
return _outLineDrawPams;
}
}
public struct OutLineDrawPam
{
public Renderer[] renders;
public OutLineDraw draw;
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 3cb95d243e2fe4f4691e0aee2ddeee19
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -17,7 +17,7 @@ MonoBehaviour:
m_RendererType: 1
m_RendererData: {fileID: 0}
m_RendererDataList:
- {fileID: 11400000, guid: 90582f0335a69ac40ae2119aa82820d4, type: 2}
- {fileID: 11400000, guid: c40be3174f62c4acf8c1216858c64956, type: 2}
m_DefaultRendererIndex: 0
m_RequireDepthTexture: 0
m_RequireOpaqueTexture: 1

View File

@ -18,7 +18,7 @@ Shader "Unlit URP Shader/OutLine"
Pass
{
Name "0_Fill"
ZWrite Off
ZWrite On
ZTest LEqual
Cull Off
Stencil
@ -26,7 +26,7 @@ Shader "Unlit URP Shader/OutLine"
Ref 2
Comp Always
Pass Replace
ZFail Replace
Fail Keep
}
HLSLPROGRAM
// Required to compile gles 2.0 with standard srp library

View File

@ -2,148 +2,219 @@ Shader "Unlit URP Shader/OutLine2"
{
Properties
{
_MainTex("MainTex",2d)="white"{}
//_MainTex("MainTex",2d)="white"{}
//_OutLineColor("OutLineColor",color)=(1,1,1,1)
//_OutLineWide("OutLineWide",float)=1
}
HLSLINCLUDE
SubShader
{
Tags { "Queue"="Transparent" "RenderPipeline" = "UniversalPipeline" }
LOD 100
Pass
{
Name "0_Fill"
ZWrite Off
ZTest Always
Cull Off
Stencil
{
Ref 2
Comp Always
Pass Replace
ZFail Replace
}
HLSLPROGRAM
// Required to compile gles 2.0 with standard srp library
#pragma vertex vert
#pragma fragment frag
#pragma multi_compile_fog
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Color.hlsl"
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Lighting.hlsl"
struct Attributes
{
float4 vertex : POSITION;
float3 normal : NORMAL;
float3 smoothNormal : TEXCOORD3;
};
struct Varyings
{
float4 position : SV_POSITION;
float4 color : COLOR;
};
#include "Packages/com.unity.render-pipelines.core/Runtime/Utilities/Blit.hlsl"
CBUFFER_START(UnityPerMaterial)
half4 _OutLineColor;
half _OutLineWide;
CBUFFER_END
Varyings vert(Attributes v)
{
Varyings o = (Varyings)0;
o.position = TransformObjectToHClip(v.vertex);
o.color = _OutLineColor;
//o.color.a=saturate(o.color.a*0.5+_OutLineWide*0.25);
return o;
}
half4 frag(Varyings i) : SV_Target
{
return i.color;
}
ENDHLSL
}
Pass
{
Name "1_Bur"
ZWrite Off
ZTest Always
Cull Off
Lighting Off
HLSLPROGRAM
// Required to compile gles 2.0 with standard srp library
#pragma vertex vert
#pragma fragment frag
#pragma multi_compile_fog
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Color.hlsl"
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Lighting.hlsl"
struct Attributes
float Scale;
TEXTURE2D(_Temp);//SAMPLER(sampler_Temp);
TEXTURE2D(_Cut);SAMPLER(sampler_Cut);
//TEXTURE2D(_MainTex);SAMPLER(sampler_MainTex);
//SAMPLER(sampler_BlitTexture);
float4 _BlitTexture_TexelSize;
TEXTURE2D(_OutLineTex);SAMPLER(sampler_OutLineTex);
float Strength;
float2 HoV;
struct Attributes2
{
float4 vertex : POSITION;
float3 normal : NORMAL;
//float3 smoothNormal : TEXCOORD3;
float2 uv : TEXCOORD0;
};
struct Varyings
struct Varyings2
{
float4 position : SV_POSITION;
float4 color : COLOR;
float2 uv : TEXCOORD0;
};
CBUFFER_START(UnityPerMaterial)
half4 _OutLineColor;
half _OutLineWide;
CBUFFER_END
float _BurStength;
TEXTURE2D(_MainTex);SAMPLER(sampler_MainTex);
float4 _MainTex_TexelSize;
//圆形模糊
float4 Bur(float2 uv)
{
float d=_MainTex_TexelSize.xy*_BurStength;
half4 col=SAMPLE_TEXTURE2D(_MainTex,sampler_MainTex,uv+float2(1,0)*d);
float2 d=_BlitTexture_TexelSize.xy*Scale;
half4 col=SAMPLE_TEXTURE2D(_BlitTexture,sampler_LinearClamp,uv+float2(0,1)*d);
col+=SAMPLE_TEXTURE2D(_BlitTexture,sampler_LinearClamp,uv+float2(-1,0)*d);
col+=SAMPLE_TEXTURE2D(_BlitTexture,sampler_LinearClamp,uv+float2(0,-1)*d);
col+=SAMPLE_TEXTURE2D(_BlitTexture,sampler_LinearClamp,uv+float2(1,0)*d);
col+=SAMPLE_TEXTURE2D(_MainTex,sampler_MainTex,uv+float2(0,1)*d);
col+=SAMPLE_TEXTURE2D(_MainTex,sampler_MainTex,uv+float2(-1,0)*d);
col+=SAMPLE_TEXTURE2D(_MainTex,sampler_MainTex,uv+float2(0,-1)*d);
return col*0.25;
col+=SAMPLE_TEXTURE2D(_BlitTexture,sampler_LinearClamp,uv+float2(-1,1)*d)*0.5;
col+=SAMPLE_TEXTURE2D(_BlitTexture,sampler_LinearClamp,uv+float2(1,-1)*d)*0.5;
col+=SAMPLE_TEXTURE2D(_BlitTexture,sampler_LinearClamp,uv+float2(-1,-1)*d)*0.5;
col+=SAMPLE_TEXTURE2D(_BlitTexture,sampler_LinearClamp,uv+float2(1,1)*d)*0.5;
return col*0.1666;
}
Varyings vert(Attributes v)
float4 BurHoV(float2 uv)
{
Varyings o = (Varyings)0;
float2 d=_BlitTexture_TexelSize.xy*Scale*HoV;
half4 col=SAMPLE_TEXTURE2D(_BlitTexture,sampler_LinearClamp,uv)*0.4;
col+=SAMPLE_TEXTURE2D(_BlitTexture,sampler_LinearClamp,uv+1*d)*0.15;
col+=SAMPLE_TEXTURE2D(_BlitTexture,sampler_LinearClamp,uv+-1*d)*0.15;
col+=SAMPLE_TEXTURE2D(_BlitTexture,sampler_LinearClamp,uv+2*d)*0.10;
col+=SAMPLE_TEXTURE2D(_BlitTexture,sampler_LinearClamp,uv+-2*d)*0.10;
col+=SAMPLE_TEXTURE2D(_BlitTexture,sampler_LinearClamp,uv+3*d)*0.05;
col+=SAMPLE_TEXTURE2D(_BlitTexture,sampler_LinearClamp,uv+-3*d)*0.05;
return col;
}
float Remap(float x, float t1, float t2, float s1, float s2)
{
return (s2 - s1) / (t2 - t1) * (x - t1) + s1;
}
float3 ACESToneMapping(float3 color, float adapted_lum)
{
const float A = 2.51f;
const float B = 0.03f;
const float C = 2.43f;
const float D = 0.59f;
const float E = 0.14f;
color *= adapted_lum;
return (color * (A * color + B)) / (color * (C * color + D) + E);
}
Varyings2 vert(Attributes2 v)
{
Varyings2 o = (Varyings2)0;
o.position = TransformObjectToHClip(v.vertex);
o.uv=v.uv;
o.color = _OutLineColor;
return o;
}
half4 frag(Varyings i) : SV_Target
float4 _HeightLightColor;
//填充颜色
float4 fragFill(Varyings2 i) : SV_Target
{
float4 col=Bur(i.uv);
return _OutLineColor;
}
//降采样模糊
float4 fragDownBlur(Varyings i) : SV_Target
{
float4 col=Bur(i.texcoord);
return col;
}
ENDHLSL
}
Pass
//升采样模糊
half4 fragUpBlur(Varyings i) : SV_Target
{
Name "2_Cut"
float4 col=Bur(i.texcoord);
float4 tempColor=SAMPLE_TEXTURE2D(_Temp,sampler_LinearClamp,i.texcoord);
col.rgb=col.rgb+tempColor.rgb;
return col;
}
//高斯模糊
float4 fragHoV(Varyings i) : SV_Target
{
float4 col=BurHoV(i.texcoord);
return col;
}
//模板剔除
float4 fragCull(Varyings2 i) : SV_Target
{
//float4 mainColor=SAMPLE_TEXTURE2D(_MainTex,sampler_MainTex,i.texcoord);
//float4 mainColorC=SAMPLE_TEXTURE2D(_Cut,sampler_Cut,i.texcoord);
// mainColorC.rgb=ACESToneMapping(mainColorC.rgb,0.4);
return float4(0,0,0,0);
}
//模板剔除2
float4 fragCull2(Varyings i) : SV_Target
{
return float4(0,1,0,0);
}
//混合颜色
float4 fragBlend(Varyings i) : SV_Target
{
float4 mainColor=SAMPLE_TEXTURE2D(_BlitTexture,sampler_LinearClamp,i.texcoord);
mainColor.rgb*=Strength;
//mainColor.rgb=ACESToneMapping(mainColor.rgb,0.6);
return mainColor;
}
ENDHLSL
SubShader
{
Tags { "Queue"="Transparent" "RenderPipeline" = "UniversalPipeline" }
LOD 100
ZWrite Off
ZTest Always
Cull Off
Lighting Off
Pass
{
Name "0_Fill"
Stencil
{
Ref 3
Comp Always
Pass Replace
Fail Keep
}
//ZWrite On
HLSLPROGRAM
#pragma vertex vert
#pragma fragment fragFill
ENDHLSL
}
Pass
{
Name "1_DownBlur"
HLSLPROGRAM
#pragma vertex Vert
#pragma fragment fragDownBlur
ENDHLSL
}
Pass
{
Name "2_UpBlur"
HLSLPROGRAM
#pragma vertex Vert
#pragma fragment fragUpBlur
ENDHLSL
}
Pass
{
Name "3_Cut"
Stencil
{
Ref 2
Comp Equal
Pass Keep
Fail Keep
}
//ColorMask 0
//BlendOp RevSub
HLSLPROGRAM
#pragma vertex Vert
#pragma fragment fragCull
ENDHLSL
}
Pass
{
Name "4_Blend"
Blend One One
HLSLPROGRAM
#pragma vertex Vert
#pragma fragment fragBlend
ENDHLSL
}
Pass
{
Name "5_Cut"
Stencil
{
Ref 2
@ -151,380 +222,13 @@ Shader "Unlit URP Shader/OutLine2"
Pass Keep
ZFail Keep
}
//BlendOp RevSub
HLSLPROGRAM
// Required to compile gles 2.0 with standard srp library
#pragma vertex vert
#pragma fragment frag
#pragma multi_compile_fog
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Color.hlsl"
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Lighting.hlsl"
struct Attributes
{
float4 vertex : POSITION;
float3 normal : NORMAL;
float2 uv : TEXCOORD0;
};
struct Varyings
{
float4 position : SV_POSITION;
float2 uv:TEXCOORD0;
};
CBUFFER_START(UnityPerMaterial)
half4 _OutLineColor;
half _OutLineWide;
CBUFFER_END
TEXTURE2D(_MainTex);SAMPLER(sampler_MainTex);
Varyings vert(Attributes v)
{
Varyings o = (Varyings)0;
o.position = TransformObjectToHClip(v.vertex);
o.uv=v.uv;
return o;
}
half4 frag(Varyings i) : SV_Target
{
return float4(0,0,0,0);//SAMPLE_TEXTURE2D(_MainTex,sampler_MainTex,i.uv);
}
#pragma vertex Vert
#pragma fragment fragCull2
ENDHLSL
}
Pass
{
Name "3_Blend"
ZWrite Off
ZTest Always
Cull Off
Lighting Off
HLSLPROGRAM
// Required to compile gles 2.0 with standard srp library
#pragma vertex vert
#pragma fragment frag
#pragma multi_compile_fog
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Color.hlsl"
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Lighting.hlsl"
//#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/DeclareDepthTexture.hlsl"
struct Attributes
{
float4 vertex : POSITION;
float3 normal : NORMAL;
float2 uv : TEXCOORD0;
};
struct Varyings
{
float4 position : SV_POSITION;
float4 color : COLOR;
float2 uv:TEXCOORD0;
};
CBUFFER_START(UnityPerMaterial)
half4 _OutLineColor;
half _OutLineWide;
CBUFFER_END
float Remap(float x, float t1, float t2, float s1, float s2)
{
return (s2 - s1) / (t2 - t1) * (x - t1) + s1;
}
TEXTURE2D(_MainTex);SAMPLER(sampler_MainTex);
TEXTURE2D(_OutLineTex);SAMPLER(sampler_OutLineTex);
TEXTURE2D_X_FLOAT(_CameraDepthTexture);
SAMPLER(sampler_CameraDepthTexture);
Varyings vert(Attributes v)
{
Varyings o = (Varyings)0;
o.position = TransformObjectToHClip(v.vertex);
o.uv=v.uv;
return o;
}
half4 frag(Varyings i) : SV_Target
{
half4 mainColor=SAMPLE_TEXTURE2D(_MainTex,sampler_MainTex,i.uv);
half4 OutColor=SAMPLE_TEXTURE2D(_OutLineTex,sampler_OutLineTex,i.uv);
float a=pow(OutColor.a,0.5);
mainColor.rgb=(saturate((OutColor.rgb)*a*3+mainColor.rgb*pow((1-OutColor.a),3)));
return mainColor;
}
ENDHLSL
}
Pass
{
Name "4_Cut"
ZWrite Off
ZTest Always
Cull Off
Lighting Off
Stencil
{
Ref 2
Comp NotEqual
Pass Keep
ZFail Keep
}
HLSLPROGRAM
// Required to compile gles 2.0 with standard srp library
#pragma vertex vert
#pragma fragment frag
#pragma multi_compile_fog
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Color.hlsl"
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Lighting.hlsl"
struct Attributes
{
float4 vertex : POSITION;
float3 normal : NORMAL;
float2 uv : TEXCOORD0;
};
struct Varyings
{
float4 position : SV_POSITION;
float2 uv:TEXCOORD0;
};
CBUFFER_START(UnityPerMaterial)
half4 _OutLineColor;
half _OutLineWide;
CBUFFER_END
TEXTURE2D(_MainTex);SAMPLER(sampler_MainTex);
Varyings vert(Attributes v)
{
Varyings o = (Varyings)0;
o.position = TransformObjectToHClip(v.vertex);
o.uv=v.uv;
return o;
}
half4 frag(Varyings i) : SV_Target
{
return SAMPLE_TEXTURE2D(_MainTex,sampler_MainTex,i.uv);
}
ENDHLSL
}
Pass
{
Name "5_BurH"
ZWrite Off
ZTest Always
Cull Off
Lighting Off
HLSLPROGRAM
// Required to compile gles 2.0 with standard srp library
#pragma vertex vert
#pragma fragment frag
#pragma multi_compile_fog
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Color.hlsl"
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Lighting.hlsl"
struct Attributes
{
float4 vertex : POSITION;
float3 normal : NORMAL;
float2 uv : TEXCOORD0;
};
struct Varyings
{
float4 position : SV_POSITION;
float4 color : COLOR;
float2 uv:TEXCOORD0;
};
CBUFFER_START(UnityPerMaterial)
half4 _OutLineColor;
half _OutLineWide;
CBUFFER_END
TEXTURE2D(_MainTex);SAMPLER(sampler_MainTex);
float4 _MainTex_TexelSize;
float4 Bur(float2 uv)
{
float d=_MainTex_TexelSize.xy*1;
half4 col=SAMPLE_TEXTURE2D(_MainTex,sampler_MainTex,uv)*0.4;
//if(col.a<0.001) return float4(0,0,0,0);
col+=SAMPLE_TEXTURE2D(_MainTex,sampler_MainTex,uv+float2(1,0)*d)*0.25;
col+=SAMPLE_TEXTURE2D(_MainTex,sampler_MainTex,uv+float2(2,0)*d)*0.05;
col+=SAMPLE_TEXTURE2D(_MainTex,sampler_MainTex,uv+float2(-1,0)*d)*0.25;
col+=SAMPLE_TEXTURE2D(_MainTex,sampler_MainTex,uv+float2(-2,0)*d)*0.05;
return col;
}
Varyings vert(Attributes v)
{
Varyings o = (Varyings)0;
o.position = TransformObjectToHClip(v.vertex);
o.uv=v.uv;
o.color = _OutLineColor;
return o;
}
half4 frag(Varyings i) : SV_Target
{
return Bur(i.uv);
}
ENDHLSL
}
Pass
{
Name "6_BurV"
ZWrite Off
ZTest Always
Cull Off
Lighting Off
HLSLPROGRAM
// Required to compile gles 2.0 with standard srp library
#pragma vertex vert
#pragma fragment frag
#pragma multi_compile_fog
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Color.hlsl"
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Lighting.hlsl"
struct Attributes
{
float4 vertex : POSITION;
float3 normal : NORMAL;
float2 uv : TEXCOORD0;
};
struct Varyings
{
float4 position : SV_POSITION;
float4 color : COLOR;
float2 uv:TEXCOORD0;
};
CBUFFER_START(UnityPerMaterial)
half4 _OutLineColor;
half _OutLineWide;
CBUFFER_END
TEXTURE2D(_MainTex);SAMPLER(sampler_MainTex);
float4 _MainTex_TexelSize;
float4 Bur(float2 uv)
{
float d=_MainTex_TexelSize.xy*1;
half4 col=SAMPLE_TEXTURE2D(_MainTex,sampler_MainTex,uv)*0.4;
//if(col.a<0.001) return float4(0,0,0,0);
col+=SAMPLE_TEXTURE2D(_MainTex,sampler_MainTex,uv+float2(0,1)*d)*0.25;
col+=SAMPLE_TEXTURE2D(_MainTex,sampler_MainTex,uv+float2(0,2)*d)*0.05;
col+=SAMPLE_TEXTURE2D(_MainTex,sampler_MainTex,uv+float2(0,-1)*d)*0.25;
col+=SAMPLE_TEXTURE2D(_MainTex,sampler_MainTex,uv+float2(0,-2)*d)*0.05;
return col;
}
Varyings vert(Attributes v)
{
Varyings o = (Varyings)0;
o.position = TransformObjectToHClip(v.vertex);
o.uv=v.uv;
o.color = _OutLineColor;
return o;
}
half4 frag(Varyings i) : SV_Target
{
return Bur(i.uv);
}
ENDHLSL
}
Pass
{
Name "1_Bur"
ZWrite Off
ZTest Always
Cull Off
Lighting Off
HLSLPROGRAM
// Required to compile gles 2.0 with standard srp library
#pragma vertex vert
#pragma fragment frag
#pragma multi_compile_fog
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Color.hlsl"
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Lighting.hlsl"
struct Attributes
{
float4 vertex : POSITION;
float3 normal : NORMAL;
float2 uv : TEXCOORD0;
};
struct Varyings
{
float4 position : SV_POSITION;
float4 color : COLOR;
float2 uv:TEXCOORD0;
};
CBUFFER_START(UnityPerMaterial)
half4 _OutLineColor;
half _OutLineWide;
CBUFFER_END
float _BurStength;
TEXTURE2D(_Temp);SAMPLER(sampler_Temp);
TEXTURE2D(_MainTex);SAMPLER(sampler_MainTex);
float4 _MainTex_TexelSize;
float4 Bur(float2 uv)
{
float d=_MainTex_TexelSize.xy*_BurStength;
half4 col=SAMPLE_TEXTURE2D(_MainTex,sampler_MainTex,uv+float2(0,1)*d);
col+=SAMPLE_TEXTURE2D(_MainTex,sampler_MainTex,uv+float2(-1,0)*d);
col+=SAMPLE_TEXTURE2D(_MainTex,sampler_MainTex,uv+float2(0,-1)*d);
col+=SAMPLE_TEXTURE2D(_MainTex,sampler_MainTex,uv+float2(1,0)*d);
return col*0.25;
}
Varyings vert(Attributes v)
{
Varyings o = (Varyings)0;
o.position = TransformObjectToHClip(v.vertex);
o.uv=v.uv;
o.color = _OutLineColor;
return o;
}
half4 frag(Varyings i) : SV_Target
{
float4 col=Bur(i.uv);
float4 tempColor=SAMPLE_TEXTURE2D(_Temp,sampler_Temp,i.uv);
col.rgb=col.rgb+tempColor.rgb;
return col;
}
ENDHLSL
}
}
}

View File

@ -326,19 +326,7 @@ MonoBehaviour:
m_TargetGraphic: {fileID: 8147970708272896595}
m_OnClick:
m_PersistentCalls:
m_Calls:
- m_Target: {fileID: 6556020211398727058}
m_TargetAssemblyTypeName: UnityEngine.UI.Slider, UnityEngine.UI
m_MethodName: set_value
m_Mode: 4
m_Arguments:
m_ObjectArgument: {fileID: 0}
m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine
m_IntArgument: 0
m_FloatArgument: 0
m_StringArgument:
m_BoolArgument: 0
m_CallState: 2
m_Calls: []
--- !u!1 &5644128529509198926
GameObject:
m_ObjectHideFlags: 0
@ -1532,6 +1520,7 @@ MonoBehaviour:
_audioCtrlImgs:
- {fileID: 21300000, guid: 9134f4f00a1354a498f8ace7e6c2268d, type: 3}
- {fileID: 21300000, guid: 7c946027fb633c942b8d8c2f58391edb, type: 3}
audioBtn: {fileID: 6339696320142083510}
--- !u!222 &9015679679242121875
CanvasRenderer:
m_ObjectHideFlags: 0

View File

@ -8,6 +8,7 @@ using CG.UTility;
using UnityEngine.EventSystems;
using ZXK.LouDiXvMuNiu;
using System;
using GCSeries.Core.Input;
/*******************************************************************************
*Create By CG
*Function
@ -51,14 +52,19 @@ public class VCRCustom : MonoBehaviour
private float _curMouseTime = 0.0f;
private Vector2 _previousPos = Vector2.zero;
public Button audioBtn;
private Action _finishHandle;
//private string _videoPath = Application.streamingAssetsPath + @"/AVProVideoSamples/BigBuckBunny_720p30.mp4";
void Start()
private void Awake()
{
audioBtn.onClick.AddListener(() =>
{
_audioVolumeSlider.gameObject.SetActive(!_audioVolumeSlider.gameObject.activeSelf);
});
}
public void OnOpenVideoFile(string path)
{
_audioVolumeSlider.onValueChanged.RemoveAllListeners();
@ -79,8 +85,8 @@ public class VCRCustom : MonoBehaviour
}
});
_mRaycaster = GameObject.FindGameObjectWithTag("MainCanvas").GetComponent<GraphicRaycaster>();
_mEventSystem = GameManager.Instance.transform.GetChild(0).GetComponent<EventSystem>();
_mRaycaster = UIRoot.Instance.GetRaycaster();
_mEventSystem = UIRoot.Instance.GetEventSystem();
_playingPlayer.m_VideoPath = path;
if (string.IsNullOrEmpty(_playingPlayer.m_VideoPath))
@ -91,6 +97,9 @@ public class VCRCustom : MonoBehaviour
{
_playingPlayer.OpenVideoFromFile(MediaPlayer.FileLocation.AbsolutePathOrURL, _playingPlayer.m_VideoPath, true);
_playCtrlBtn.GetComponent<Image>().sprite = _playSmallCtrlImgs[0];
#if VR
_playBigCtrlBtn.gameObject.SetActive(false);
#endif
}
if (_playingPlayer)
{
@ -127,6 +136,8 @@ public class VCRCustom : MonoBehaviour
_videoSeekSlider.value = d;
}
#if !VR
Vector2 curPos = Input.mousePosition;
//监听鼠标是否正在调节声音
GraphicRaycaster(curPos);
@ -155,6 +166,7 @@ public class VCRCustom : MonoBehaviour
CtrlContainerDownUp(false);
}
_previousPos = curPos;
#endif
}
private void OnDestroy()
{
@ -178,7 +190,6 @@ public class VCRCustom : MonoBehaviour
_finishHandle?.Invoke();
break;
}
WDebug.Log("Event: " + et.ToString());
}
public void OnVideoSeekSlider()
@ -215,12 +226,18 @@ public class VCRCustom : MonoBehaviour
_playingPlayer.Control.Pause();
_playCtrlBtn.GetComponent<Image>().sprite = _playSmallCtrlImgs[1];
_playBigCtrlBtn.GetComponent<Image>().sprite = _playBigCtrlImgs[1];
#if VR
_playBigCtrlBtn.gameObject.SetActive(true);
#endif
}
else
{
_playingPlayer.Control.Play();
_playCtrlBtn.GetComponent<Image>().sprite = _playSmallCtrlImgs[0];
_playBigCtrlBtn.GetComponent<Image>().sprite = _playBigCtrlImgs[0];
#if VR
_playBigCtrlBtn.gameObject.SetActive(false);
#endif
}
}
private void CtrlContainerDownUp(bool isDown)

View File

@ -1006,6 +1006,7 @@ MonoBehaviour:
_audioCtrlImgs:
- {fileID: 21300000, guid: 9134f4f00a1354a498f8ace7e6c2268d, type: 3}
- {fileID: 21300000, guid: 7c946027fb633c942b8d8c2f58391edb, type: 3}
audioBtn: {fileID: 7090191865517402919}
--- !u!1 &8027070936257184517
GameObject:
m_ObjectHideFlags: 0
@ -2021,16 +2022,4 @@ MonoBehaviour:
m_TargetGraphic: {fileID: 4939643850441897154}
m_OnClick:
m_PersistentCalls:
m_Calls:
- m_Target: {fileID: 8027070936364563203}
m_TargetAssemblyTypeName: UnityEngine.UI.Slider, UnityEngine.UI
m_MethodName: set_value
m_Mode: 4
m_Arguments:
m_ObjectArgument: {fileID: 0}
m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine
m_IntArgument: 0
m_FloatArgument: 0
m_StringArgument:
m_BoolArgument: 0
m_CallState: 2
m_Calls: []

View File

@ -136,7 +136,7 @@ GameObject:
- component: {fileID: 193637491}
m_Layer: 0
m_Name: LeftCamera
m_TagString: Untagged
m_TagString: MainCamera
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
@ -317,7 +317,7 @@ MonoBehaviour:
m_EditorClassIdentifier:
EventCamera: {fileID: 467422561}
Visualization: {fileID: 1023887710}
MaxHitDistance: 2.5
MaxHitDistance: 5
MaxHitRadius: 0
IgnoreMask:
serializedVersion: 2
@ -375,7 +375,7 @@ GameObject:
- component: {fileID: 328527057}
m_Layer: 0
m_Name: RightCamera
m_TagString: Untagged
m_TagString: MainCamera
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
@ -1397,6 +1397,52 @@ MonoBehaviour:
MinAngle: 0
MaxAngle: 90
Pivot: 0
--- !u!1 &1116630617
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1116630619}
- component: {fileID: 1116630618}
m_Layer: 0
m_Name: OutLineManager
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!114 &1116630618
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1116630617}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 0d01c7122a2dac645826961452d1c2a0, type: 3}
m_Name:
m_EditorClassIdentifier:
OutLineScale: 2
OutLineStrength: 1
--- !u!4 &1116630619
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1116630617}
serializedVersion: 2
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &1222075433
GameObject:
m_ObjectHideFlags: 0
@ -2674,3 +2720,4 @@ SceneRoots:
- {fileID: 832575519}
- {fileID: 2223146455129701296}
- {fileID: 2058174970}
- {fileID: 1116630619}

View File

@ -1,3 +1,5 @@
using GCSeries.Core.Input;
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
@ -11,6 +13,60 @@ namespace ZXK.LouDiXvMuNiu
{
[SerializeField]
private float _rotSpeed = 180.0f;
#if VR
bool isEnter = false;
private void Awake()
{
var zStylus = UIRoot.Instance.vrRoot.transform.Find("ZStylus").GetComponent<ZStylus>();
zStylus.OnObjectEntered.AddListener(VROnEnter);
zStylus.OnObjectExited.AddListener(VROnExit);
zStylus.OnClick.AddListener(VROnClick);
var zMouse = UIRoot.Instance.vrRoot.transform.Find("ZMouse").GetComponent<ZMouse>();
zMouse.OnObjectEntered.AddListener(VROnEnter);
zMouse.OnObjectExited.AddListener(VROnExit);
zMouse.OnClick.AddListener(VROnClick);
}
private void Update()
{
if (isEnter)
{
transform.Rotate(Vector3.forward * Time.deltaTime * _rotSpeed);
}
}
private void VROnClick(ZPointer arg0, int arg1, GameObject arg2)
{
}
private void VROnExit(ZPointer arg0, GameObject arg1)
{
if (arg1==gameObject)
{
isEnter = false;
}
}
private void VROnEnter(ZPointer arg0, GameObject arg1)
{
if (arg1 == gameObject)
{
isEnter = true;
}
}
private void OnDestroy()
{
var zStylus = UIRoot.Instance.vrRoot.transform.Find("ZStylus").GetComponent<ZStylus>();
zStylus.OnObjectEntered.RemoveListener(VROnEnter);
zStylus.OnObjectExited.RemoveListener(VROnExit);
zStylus.OnClick.RemoveListener(VROnClick);
var zMouse = UIRoot.Instance.vrRoot.transform.Find("ZMouse").GetComponent<ZMouse>();
zMouse.OnObjectEntered.RemoveListener(VROnEnter);
zMouse.OnObjectExited.RemoveListener(VROnExit);
zMouse.OnClick.RemoveListener(VROnClick);
}
#endif
private void OnMouseOver()
{
transform.Rotate(Vector3.forward * Time.deltaTime * _rotSpeed);

View File

@ -36,7 +36,7 @@ namespace ZXK.LouDiXvMuNiu
private Dictionary<bool, List<GameObject>> _curStepUseBTDic;//当前步骤要点击的所有物体true表示两个物体都要点false表示点击其中一个即可
public Dictionary<bool, List<GameObject>> _CurStepUseBtDic { get => _curStepUseBTDic; }
private List<OutLineRender> _currentHighlights = new List<OutLineRender>();
private List<OutLineDraw> _currentHighlights = new List<OutLineDraw>();
private PlayableDirector _curTimeLine = null;
private TimelineDirectorCtrl _curTimeLineCtrl = null;
[SerializeField]
@ -764,14 +764,14 @@ namespace ZXK.LouDiXvMuNiu
string modelBTName = modelBTsName[i].name;
if (!modelBTName.Contains("_sign"))
{
OutLineRender outlineRender;
OutLineDraw outlineRender;
// 如果模型上没有泛光效果组件,则添加一个新的
if (!modelBTsName[i].TryGetComponent(out outlineRender))
{
outlineRender = modelBTsName[i].AddComponent<OutLineRender>();
outlineRender = modelBTsName[i].AddComponent<OutLineDraw>();
}
// 设置泛光强度和默认禁用泛光效果
outlineRender.OutLineStrength = 1;
//outlineRender.OutLineStrength = 1;
outlineRender.enabled = true;
// 将泛光效果组件添加到高亮列表中
_currentHighlights.Add(outlineRender);
@ -792,9 +792,9 @@ namespace ZXK.LouDiXvMuNiu
List<GameObject> useBts = _curStepUseBTDic[true];
if (useBts.Contains(triGeo))
{
if (triGeo.GetComponent<OutLineRender>())
if (triGeo.GetComponent<OutLineDraw>())
{
triGeo.GetComponent<OutLineRender>().enabled = false;
triGeo.GetComponent<OutLineDraw>().enabled = false;
}
if (triGeo.tag != ConstCtrl.SceneTool_Tag)
@ -846,9 +846,9 @@ namespace ZXK.LouDiXvMuNiu
useBts = _curStepUseBTDic[true];
if (useBts.Contains(triGeo))
{
if (triGeo.GetComponent<OutLineRender>())
if (triGeo.GetComponent<OutLineDraw>())
{
triGeo.GetComponent<OutLineRender>().enabled = false;
triGeo.GetComponent<OutLineDraw>().enabled = false;
}
if (triGeo.tag != ConstCtrl.SceneTool_Tag)
{

View File

@ -43,7 +43,7 @@ namespace CG.UTility
_loadedCall?.Invoke();
_isLoadScene = false;
StopCoroutine("LoadScene");
UIRoot.Instance.GetEventSystem().SetActive(true);
UIRoot.Instance.GetEventSystem().gameObject.SetActive(true);
Framework.UI_Manage.Instance.ClosePanel("LoadingSceenPanel");
}
_async.allowSceneActivation = true;
@ -62,7 +62,7 @@ namespace CG.UTility
_isLoadScene = true;
StartCoroutine("LoadScene", sceneName);
Framework.UI_Manage.Instance.ShowPanel("LoadingSceenPanel", System.Type.GetType("CG.Framework.LoadingSceenPanel"), Framework.UIGroup.Tip);
UIRoot.Instance.GetEventSystem().SetActive(false);
UIRoot.Instance.GetEventSystem().gameObject.SetActive(false);
}
private IEnumerator LoadScene(string sceneName)

View File

@ -2,6 +2,8 @@ using CG.Framework;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.UI;
using ZXK.LouDiXvMuNiu;
public class UIRoot : MonoSingleton<UIRoot>
@ -10,27 +12,30 @@ public class UIRoot : MonoSingleton<UIRoot>
public GameObject vrRoot;
Transform vrCamera;
EventSystem eventsytem;
protected override void AwakeSelf()
{
base.AwakeSelf();
#if VR
vrRoot.gameObject.SetActive(true);
vrCamera = vrRoot.transform.Find("ZFrame");
eventsytem = vrRoot.transform.Find("ZEventSystem").gameObject.GetComponent<EventSystem>();
#else
pcCanvas.gameObject.SetActive(true);
eventsytem = pcCanvas.transform.Find("EventSystem").GetComponent<EventSystem>();
#endif
}
public GameObject GetEventSystem()
public EventSystem GetEventSystem()
{
#if VR
return vrRoot.transform.Find("ZEventSystem").gameObject;
#else
return pcCanvas.transform.Find("EventSystem").gameObject;
#endif
return eventsytem;
}
public GraphicRaycaster GetRaycaster()
{
return UI_Manage.Instance.GetComponent<GraphicRaycaster>();
}
public void SetCamera(Vector3 pos, Vector3 rot)
{