Skip to content

Commit d46d757

Browse files
authored
Merge pull request #5 from SAM-tak/fix/avoid-fail-to-initialize
Fix/avoid fail to initialize
2 parents f25638a + 59515eb commit d46d757

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

CP_SSSSS_Main.cs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,15 +67,15 @@ void OnEnable()
6767
return;
6868
}
6969

70+
CleanupBuffer();
71+
7072
// Disable the image effect if the shader can't
7173
// run on the users graphics card
72-
if (!shader || !shader.isSupported)
74+
if(shader && !shader.isSupported)
7375
{
7476
enabled = false;
7577
return;
7678
}
77-
78-
CleanupBuffer();
7979
if(buffer == null) ApplyBuffer();
8080
}
8181

@@ -88,7 +88,6 @@ private void OnPreRender()
8888
void OnPostRender()
8989
{
9090
TargetMeshes.Clear();
91-
Shader.SetGlobalTexture("SSSMaskTexture", null);
9291
}
9392

9493
public struct SSSParameter
@@ -246,7 +245,7 @@ void CleanupBuffer()
246245

247246
public void AddMakeSSSMaskCommands(CommandBuffer buffer)
248247
{
249-
if(!Camera.current || TargetMeshes.Count == 0) return;
248+
if(TargetMeshes.Count == 0) return;
250249

251250
for(int i = m_MaskMaterials.Count; i < TargetMeshes.Count; i++) {
252251
if(maskShader != null) {

CP_SSSSS_Object.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ void OnWillRenderObject()
3737
{
3838
if(r) {
3939
var camera = Camera.current;
40-
var sssssMain = camera.gameObject.GetComponent<CP_SSSSS_Main>();
40+
var sssssMain = camera.GetComponent<CP_SSSSS_Main>();
4141
if(sssssMain && sssssMain.isActiveAndEnabled) {
4242
if(Application.isPlaying) {
4343
for(int i = 0; i < subMeshIndicies.Count; ++i) {

0 commit comments

Comments
 (0)