AfterInitialize调整
This commit is contained in:
@@ -118,7 +118,7 @@ namespace MhRender.RendererFeatures
|
||||
// Shader shader = Shader.Find("XuanXuan/Postprocess/NBPostProcessUber");
|
||||
NBPostProcessMaterial = CoreUtils.CreateEngineMaterial(Shader.Find("XuanXuan/Postprocess/NBPostProcessUber"));
|
||||
|
||||
PostProcessingManager.InitMat();
|
||||
NBPostProcessingManager.InitMat();
|
||||
|
||||
// if (Application.isPlaying)
|
||||
// {
|
||||
@@ -439,7 +439,7 @@ namespace MhRender.RendererFeatures
|
||||
public static Material _material;
|
||||
public Mesh _fullScreenMesh;
|
||||
|
||||
public NBPostProcessFlags _shaderFlag => PostProcessingManager.flags;
|
||||
public NBPostProcessFlags _shaderFlag => NBPostProcessingManager.flags;
|
||||
|
||||
private Vector4 _lastOutlineProps;
|
||||
public Vector4 outLinePorps = Vector4.one;
|
||||
|
||||
@@ -13,14 +13,14 @@ using UnityEditor;
|
||||
|
||||
|
||||
[ExecuteInEditMode]
|
||||
public class PostProcessingController : MonoBehaviour
|
||||
public class NBPostProcessingController : MonoBehaviour
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
public AnimBool[] AnimBools = new AnimBool[10];
|
||||
#endif
|
||||
// [ShowInInspector][ReadOnly]
|
||||
[SerializeField]
|
||||
private PostProcessingManager _manager;
|
||||
//[SerializeField]
|
||||
public NBPostProcessingManager _manager;
|
||||
|
||||
public int index
|
||||
{
|
||||
@@ -225,7 +225,7 @@ public class PostProcessingController : MonoBehaviour
|
||||
return;
|
||||
}
|
||||
|
||||
_manager = PostProcessingManager.Instance;
|
||||
_manager = NBPostProcessingManager.Instance;
|
||||
|
||||
_manager.InitController(this);
|
||||
InitAllSettings();
|
||||
@@ -245,30 +245,30 @@ public class PostProcessingController : MonoBehaviour
|
||||
|
||||
void SetScreenCenterPos()
|
||||
{
|
||||
PostProcessingManager.customScreenCenterPos = customScreenCenterPos;
|
||||
NBPostProcessingManager.customScreenCenterPos = customScreenCenterPos;
|
||||
_lastCustomScreenCenterPos = customScreenCenterPos;
|
||||
}
|
||||
|
||||
void SetUVFromDistort()
|
||||
{
|
||||
PostProcessingManager.isDistortScreenUVMode = distortScreenUVMode;
|
||||
PostProcessingManager.isCaByDistort = caFromDistort;
|
||||
PostProcessingManager.isRadialBlurByDistort = radialBlurFromDistort;
|
||||
NBPostProcessingManager.isDistortScreenUVMode = distortScreenUVMode;
|
||||
NBPostProcessingManager.isCaByDistort = caFromDistort;
|
||||
NBPostProcessingManager.isRadialBlurByDistort = radialBlurFromDistort;
|
||||
}
|
||||
|
||||
private void SetTexture()
|
||||
{
|
||||
if(PostProcessingManager.material == null) return;
|
||||
if(NBPostProcessingManager.material == null) return;
|
||||
if (distortSpeedToggle)
|
||||
{
|
||||
if (distortSpeedTexture != null)
|
||||
{
|
||||
PostProcessingManager.material.SetTexture(_distortSpeedTextureID, distortSpeedTexture);
|
||||
PostProcessingManager.distortTextureMidValue = distortTextureMidValue;
|
||||
NBPostProcessingManager.material.SetTexture(_distortSpeedTextureID, distortSpeedTexture);
|
||||
NBPostProcessingManager.distortTextureMidValue = distortTextureMidValue;
|
||||
}
|
||||
else
|
||||
{
|
||||
PostProcessingManager.material.SetTexture(_distortSpeedTextureID, null);
|
||||
NBPostProcessingManager.material.SetTexture(_distortSpeedTextureID, null);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -276,34 +276,34 @@ public class PostProcessingController : MonoBehaviour
|
||||
{
|
||||
if (overlayTexturePolarCoordMode)
|
||||
{
|
||||
PostProcessingManager.flags.SetFlagBits(NBPostProcessFlags.FLAG_BIT_OVERLAYTEXTURE_POLLARCOORD);
|
||||
NBPostProcessingManager.flags.SetFlagBits(NBPostProcessFlags.FLAG_BIT_OVERLAYTEXTURE_POLLARCOORD);
|
||||
}
|
||||
else
|
||||
{
|
||||
PostProcessingManager.flags.ClearFlagBits(NBPostProcessFlags.FLAG_BIT_OVERLAYTEXTURE_POLLARCOORD);
|
||||
NBPostProcessingManager.flags.ClearFlagBits(NBPostProcessFlags.FLAG_BIT_OVERLAYTEXTURE_POLLARCOORD);
|
||||
}
|
||||
|
||||
if (overlayTexture)
|
||||
{
|
||||
Debug.Log("SetOverlayTexture");
|
||||
PostProcessingManager.material.SetTexture(_overlayTextureID,overlayTexture);
|
||||
NBPostProcessingManager.material.SetTexture(_overlayTextureID,overlayTexture);
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.Log("ClearOverlayTexture");
|
||||
PostProcessingManager.material.SetTexture(_overlayTextureID,null);
|
||||
NBPostProcessingManager.material.SetTexture(_overlayTextureID,null);
|
||||
}
|
||||
|
||||
if (overlayMaskTexture)
|
||||
{
|
||||
Debug.Log("SetOverlayMaskTexture");
|
||||
PostProcessingManager.material.SetTexture(_textureOverlayMaskProperty,overlayMaskTexture);
|
||||
PostProcessingManager.flags.SetFlagBits(NBPostProcessFlags.FLAG_BIT_OVERLAYTEXTURE_MASKMAP);
|
||||
NBPostProcessingManager.material.SetTexture(_textureOverlayMaskProperty,overlayMaskTexture);
|
||||
NBPostProcessingManager.flags.SetFlagBits(NBPostProcessFlags.FLAG_BIT_OVERLAYTEXTURE_MASKMAP);
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.Log("ClearOverlayMaskTexture");
|
||||
PostProcessingManager.flags.ClearFlagBits(NBPostProcessFlags.FLAG_BIT_OVERLAYTEXTURE_MASKMAP);
|
||||
NBPostProcessingManager.flags.ClearFlagBits(NBPostProcessFlags.FLAG_BIT_OVERLAYTEXTURE_MASKMAP);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -311,15 +311,15 @@ public class PostProcessingController : MonoBehaviour
|
||||
|
||||
private void SetToggles()
|
||||
{
|
||||
SetBit(ref PostProcessingManager.chromaticAberrationToggles,index,chromaticAberrationToggle);
|
||||
SetBit(ref PostProcessingManager.distortSpeedToggles,index,distortSpeedToggle);
|
||||
SetBit(ref NBPostProcessingManager.chromaticAberrationToggles,index,chromaticAberrationToggle);
|
||||
SetBit(ref NBPostProcessingManager.distortSpeedToggles,index,distortSpeedToggle);
|
||||
#if CINIMACHINE_3_0
|
||||
SetBit(ref PostProcessingManager.cameraShakeToggles,index,cameraShakeToggle);
|
||||
#endif
|
||||
SetBit(ref PostProcessingManager.overlayTextureToggles,index,overlayTextureToggle);
|
||||
SetBit(ref PostProcessingManager.flashToggles,index,flashToggle);
|
||||
SetBit(ref PostProcessingManager.radialBlurToggles,index,radialBlurToggle);
|
||||
SetBit(ref PostProcessingManager.vignetteToggles,index,vignetteToggle);
|
||||
SetBit(ref NBPostProcessingManager.overlayTextureToggles,index,overlayTextureToggle);
|
||||
SetBit(ref NBPostProcessingManager.flashToggles,index,flashToggle);
|
||||
SetBit(ref NBPostProcessingManager.radialBlurToggles,index,radialBlurToggle);
|
||||
SetBit(ref NBPostProcessingManager.vignetteToggles,index,vignetteToggle);
|
||||
|
||||
#if UNITY_EDITOR
|
||||
SetTexture();
|
||||
@@ -329,15 +329,15 @@ public class PostProcessingController : MonoBehaviour
|
||||
|
||||
private void ClearToggles()
|
||||
{
|
||||
SetBit(ref PostProcessingManager.chromaticAberrationToggles,index,false);
|
||||
SetBit(ref PostProcessingManager.distortSpeedToggles,index,false);
|
||||
SetBit(ref NBPostProcessingManager.chromaticAberrationToggles,index,false);
|
||||
SetBit(ref NBPostProcessingManager.distortSpeedToggles,index,false);
|
||||
#if CINIMACHINE_3_0
|
||||
SetBit(ref PostProcessingManager.cameraShakeToggles,index,false);
|
||||
#endif
|
||||
SetBit(ref PostProcessingManager.overlayTextureToggles,index,false);
|
||||
SetBit(ref PostProcessingManager.flashToggles,index,false);
|
||||
SetBit(ref PostProcessingManager.radialBlurToggles,index,false);
|
||||
SetBit(ref PostProcessingManager.vignetteToggles,index,false);
|
||||
SetBit(ref NBPostProcessingManager.overlayTextureToggles,index,false);
|
||||
SetBit(ref NBPostProcessingManager.flashToggles,index,false);
|
||||
SetBit(ref NBPostProcessingManager.radialBlurToggles,index,false);
|
||||
SetBit(ref NBPostProcessingManager.vignetteToggles,index,false);
|
||||
}
|
||||
|
||||
private bool _lastChormaticAberrationToggle = false;
|
||||
@@ -455,7 +455,7 @@ public class PostProcessingController : MonoBehaviour
|
||||
isFirstUpdate = false;
|
||||
return;
|
||||
}
|
||||
if(!PostProcessingManager.material) return;
|
||||
if(!NBPostProcessingManager.material) return;
|
||||
//#if UNITY_EDITOR
|
||||
//Odin的ToggleGroup和OnValueChange功能冲突,导致不一定生效。不好调试。所以用手动的方式更新。
|
||||
bool isToggleChanged = false;
|
||||
@@ -482,35 +482,35 @@ public class PostProcessingController : MonoBehaviour
|
||||
|
||||
if (chromaticAberrationToggle)
|
||||
{
|
||||
PostProcessingManager.chromaticAberrationIntensity =
|
||||
Mathf.Max(PostProcessingManager.chromaticAberrationIntensity, chromaticAberrationIntensity);
|
||||
PostProcessingManager.chromaticAberrationPos =
|
||||
Mathf.Max(PostProcessingManager.chromaticAberrationPos, chromaticAberrationPos);
|
||||
PostProcessingManager.chromaticAberrationRange =
|
||||
Mathf.Max(PostProcessingManager.chromaticAberrationRange, chromaticAberrationRange);
|
||||
NBPostProcessingManager.chromaticAberrationIntensity =
|
||||
Mathf.Max(NBPostProcessingManager.chromaticAberrationIntensity, chromaticAberrationIntensity);
|
||||
NBPostProcessingManager.chromaticAberrationPos =
|
||||
Mathf.Max(NBPostProcessingManager.chromaticAberrationPos, chromaticAberrationPos);
|
||||
NBPostProcessingManager.chromaticAberrationRange =
|
||||
Mathf.Max(NBPostProcessingManager.chromaticAberrationRange, chromaticAberrationRange);
|
||||
}
|
||||
|
||||
if (distortSpeedToggle)
|
||||
{
|
||||
if (index == PostProcessingManager.laseUpdateControllerIndex)
|
||||
if (index == NBPostProcessingManager.laseUpdateControllerIndex)
|
||||
{
|
||||
//只有这里才会更新Scale
|
||||
PostProcessingManager.material.SetVector(_distortSpeedTextureStID, distortSpeedTexSt);
|
||||
NBPostProcessingManager.material.SetVector(_distortSpeedTextureStID, distortSpeedTexSt);
|
||||
}
|
||||
|
||||
PostProcessingManager.distortSpeedIntensity =
|
||||
Mathf.Max(PostProcessingManager.distortSpeedIntensity, distortSpeedIntensity);
|
||||
PostProcessingManager.distortSpeedPosition =
|
||||
Mathf.Max(PostProcessingManager.distortSpeedPosition, distortSpeedPosition);
|
||||
PostProcessingManager.distortSpeedRange =
|
||||
Mathf.Max(PostProcessingManager.distortSpeedRange, distortSpeedRange);
|
||||
PostProcessingManager.distortSpeedMoveSpeedX =
|
||||
Mathf.Abs(PostProcessingManager.distortSpeedMoveSpeedX) > Mathf.Abs(distortSpeedMoveSpeedX)
|
||||
? PostProcessingManager.distortSpeedMoveSpeedX
|
||||
NBPostProcessingManager.distortSpeedIntensity =
|
||||
Mathf.Max(NBPostProcessingManager.distortSpeedIntensity, distortSpeedIntensity);
|
||||
NBPostProcessingManager.distortSpeedPosition =
|
||||
Mathf.Max(NBPostProcessingManager.distortSpeedPosition, distortSpeedPosition);
|
||||
NBPostProcessingManager.distortSpeedRange =
|
||||
Mathf.Max(NBPostProcessingManager.distortSpeedRange, distortSpeedRange);
|
||||
NBPostProcessingManager.distortSpeedMoveSpeedX =
|
||||
Mathf.Abs(NBPostProcessingManager.distortSpeedMoveSpeedX) > Mathf.Abs(distortSpeedMoveSpeedX)
|
||||
? NBPostProcessingManager.distortSpeedMoveSpeedX
|
||||
: distortSpeedMoveSpeedX;
|
||||
PostProcessingManager.distortSpeedMoveSpeedY =
|
||||
Mathf.Abs(PostProcessingManager.distortSpeedMoveSpeedY) > Mathf.Abs(distortSpeedMoveSpeed)
|
||||
? PostProcessingManager.distortSpeedMoveSpeedY
|
||||
NBPostProcessingManager.distortSpeedMoveSpeedY =
|
||||
Mathf.Abs(NBPostProcessingManager.distortSpeedMoveSpeedY) > Mathf.Abs(distortSpeedMoveSpeed)
|
||||
? NBPostProcessingManager.distortSpeedMoveSpeedY
|
||||
: distortSpeedMoveSpeed;
|
||||
}
|
||||
|
||||
@@ -525,47 +525,47 @@ public class PostProcessingController : MonoBehaviour
|
||||
|
||||
if (overlayTextureToggle)
|
||||
{
|
||||
if (index == PostProcessingManager.laseUpdateControllerIndex)
|
||||
if (index == NBPostProcessingManager.laseUpdateControllerIndex)
|
||||
{
|
||||
PostProcessingManager.material.SetVector(_overlayTextureStID, overlayTextureSt);
|
||||
PostProcessingManager.material.SetVector(_textureOverlayMaskStProperty, overlayMaskTextureSt);
|
||||
PostProcessingManager.material.SetVector(_textureOverlayAnimProperty,overlayTextureAnim);
|
||||
NBPostProcessingManager.material.SetVector(_overlayTextureStID, overlayTextureSt);
|
||||
NBPostProcessingManager.material.SetVector(_textureOverlayMaskStProperty, overlayMaskTextureSt);
|
||||
NBPostProcessingManager.material.SetVector(_textureOverlayAnimProperty,overlayTextureAnim);
|
||||
}
|
||||
|
||||
PostProcessingManager.overlayTextureIntensity = Mathf.Max(PostProcessingManager.overlayTextureIntensity,
|
||||
NBPostProcessingManager.overlayTextureIntensity = Mathf.Max(NBPostProcessingManager.overlayTextureIntensity,
|
||||
overlayTextureIntensity);
|
||||
}
|
||||
|
||||
if (flashToggle)
|
||||
{
|
||||
PostProcessingManager.flashDesaturateIntensity =
|
||||
Mathf.Max(PostProcessingManager.flashDesaturateIntensity, flashDeSaturateIntensity);
|
||||
PostProcessingManager.flashInvertIntensity =
|
||||
Mathf.Max(PostProcessingManager.flashInvertIntensity, flashInvertIntensity);
|
||||
PostProcessingManager.flashContrast =
|
||||
Mathf.Max(PostProcessingManager.flashContrast, flashContrast);
|
||||
PostProcessingManager.flashColor = flashColor;
|
||||
NBPostProcessingManager.flashDesaturateIntensity =
|
||||
Mathf.Max(NBPostProcessingManager.flashDesaturateIntensity, flashDeSaturateIntensity);
|
||||
NBPostProcessingManager.flashInvertIntensity =
|
||||
Mathf.Max(NBPostProcessingManager.flashInvertIntensity, flashInvertIntensity);
|
||||
NBPostProcessingManager.flashContrast =
|
||||
Mathf.Max(NBPostProcessingManager.flashContrast, flashContrast);
|
||||
NBPostProcessingManager.flashColor = flashColor;
|
||||
}
|
||||
|
||||
if (radialBlurToggle)
|
||||
{
|
||||
PostProcessingManager.radialBlurIntensity =
|
||||
Mathf.Max(PostProcessingManager.radialBlurIntensity, radialBlurIntensity);
|
||||
PostProcessingManager.radialBlurSampleCount = Mathf.Max(PostProcessingManager.radialBlurSampleCount,
|
||||
NBPostProcessingManager.radialBlurIntensity =
|
||||
Mathf.Max(NBPostProcessingManager.radialBlurIntensity, radialBlurIntensity);
|
||||
NBPostProcessingManager.radialBlurSampleCount = Mathf.Max(NBPostProcessingManager.radialBlurSampleCount,
|
||||
radialBlurSampleCount);
|
||||
PostProcessingManager.radialBlurPos = Mathf.Max(PostProcessingManager.radialBlurPos, radialBlurPos);
|
||||
PostProcessingManager.radialBlurRange = Mathf.Max(PostProcessingManager.radialBlurRange, radialBlurRange);
|
||||
NBPostProcessingManager.radialBlurPos = Mathf.Max(NBPostProcessingManager.radialBlurPos, radialBlurPos);
|
||||
NBPostProcessingManager.radialBlurRange = Mathf.Max(NBPostProcessingManager.radialBlurRange, radialBlurRange);
|
||||
}
|
||||
|
||||
if (vignetteToggle)
|
||||
{
|
||||
PostProcessingManager.vignetteIntensity =
|
||||
Mathf.Max(PostProcessingManager.vignetteIntensity, vignetteIntensity);
|
||||
PostProcessingManager.vignetteRoundness = Mathf.Max(PostProcessingManager.vignetteRoundness, vignetteRoundness);
|
||||
PostProcessingManager.vignetteSmothness = Mathf.Max(PostProcessingManager.vignetteSmothness, vignetteSmothness);
|
||||
if (index == PostProcessingManager.laseUpdateControllerIndex)
|
||||
NBPostProcessingManager.vignetteIntensity =
|
||||
Mathf.Max(NBPostProcessingManager.vignetteIntensity, vignetteIntensity);
|
||||
NBPostProcessingManager.vignetteRoundness = Mathf.Max(NBPostProcessingManager.vignetteRoundness, vignetteRoundness);
|
||||
NBPostProcessingManager.vignetteSmothness = Mathf.Max(NBPostProcessingManager.vignetteSmothness, vignetteSmothness);
|
||||
if (index == NBPostProcessingManager.laseUpdateControllerIndex)
|
||||
{
|
||||
PostProcessingManager.material.SetColor(_vignetteColorID,vignetteColor);
|
||||
NBPostProcessingManager.material.SetColor(_vignetteColorID,vignetteColor);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -586,7 +586,7 @@ public class PostProcessingController : MonoBehaviour
|
||||
{
|
||||
GameObject Effect = new GameObject();
|
||||
Effect.name = "NBPostprocessController";
|
||||
PostProcessingController controller = Effect.AddComponent<PostProcessingController>();
|
||||
NBPostProcessingController controller = Effect.AddComponent<NBPostProcessingController>();
|
||||
|
||||
UnityEditor.Selection.activeObject = Effect;
|
||||
}
|
||||
@@ -17,26 +17,26 @@ using MhRender.RendererFeatures;
|
||||
|
||||
|
||||
[ExecuteAlways]
|
||||
public class PostProcessingManager : MonoBehaviour
|
||||
public class NBPostProcessingManager : MonoBehaviour
|
||||
{
|
||||
//单例实现
|
||||
private static PostProcessingManager _instance = null;
|
||||
private static NBPostProcessingManager _instance = null;
|
||||
|
||||
public static PostProcessingManager Instance
|
||||
public static NBPostProcessingManager Instance
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_instance == null)
|
||||
{
|
||||
#if UNITY_2022_1_OR_NEWER
|
||||
_instance = FindFirstObjectByType<PostProcessingManager>();
|
||||
_instance = FindFirstObjectByType<NBPostProcessingManager>();
|
||||
#else
|
||||
_instance = FindObjectOfType<PostProcessingManager>();
|
||||
#endif
|
||||
if (_instance == null)
|
||||
{
|
||||
GameObject singletonObj = new GameObject();
|
||||
_instance = singletonObj.AddComponent<PostProcessingManager>();
|
||||
_instance = singletonObj.AddComponent<NBPostProcessingManager>();
|
||||
if (Application.isPlaying)
|
||||
{
|
||||
singletonObj.name = "NBPostProcessManager";
|
||||
@@ -62,7 +62,7 @@ public class PostProcessingManager : MonoBehaviour
|
||||
}
|
||||
else
|
||||
{
|
||||
DestroyImmediate(this);
|
||||
//DestroyImmediate(this);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -88,7 +88,7 @@ public class PostProcessingManager : MonoBehaviour
|
||||
|
||||
public static void InitMat()
|
||||
{
|
||||
flags.SetMaterial(PostProcessingManager.material);
|
||||
flags.SetMaterial(NBPostProcessingManager.material);
|
||||
if (_instance)
|
||||
{
|
||||
_instance.ResetEffect();
|
||||
@@ -197,7 +197,7 @@ public class PostProcessingManager : MonoBehaviour
|
||||
return count;
|
||||
}
|
||||
//每次Controller触发Play都会触发Init
|
||||
public void InitController(PostProcessingController controller)
|
||||
public void InitController(NBPostProcessingController controller)
|
||||
{
|
||||
#if CINIMACHINE_3_0
|
||||
if (controller.cinemachineCamera != null)
|
||||
@@ -210,7 +210,7 @@ public class PostProcessingManager : MonoBehaviour
|
||||
controller.SetIndex(GetControllerIndex());
|
||||
}
|
||||
|
||||
public void EndController(PostProcessingController controller)
|
||||
public void EndController(NBPostProcessingController controller)
|
||||
{
|
||||
#if CINIMACHINE_3_0
|
||||
if (currentVirtualCamera == controller.cinemachineCamera)
|
||||
Reference in New Issue
Block a user