Skip to content

Commit 401eae3

Browse files
Refactor shader assignment for GunPointer and GunLine
Ensure the shader is set to 'GUI/Text Shader' only if it's not already set, for both GunPointer and GunLine.
1 parent d34082c commit 401eae3

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

Menu/Main.cs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4355,7 +4355,10 @@ public static (RaycastHit Ray, GameObject NewPointer) RenderGun(int? overrideLay
43554355
GunPointer.transform.position = EndPosition;
43564356

43574357
Renderer PointerRenderer = GunPointer.GetComponent<Renderer>();
4358-
PointerRenderer.material.shader = Shader.Find("GUI/Text Shader");
4358+
4359+
if (PointerRenderer.material.shader.name != "GUI/Text Shader")
4360+
PointerRenderer.material.shader = Shader.Find("GUI/Text Shader");
4361+
43594362
PointerRenderer.material.color = gunLocked || GetGunInput(true) ? buttonColors[1].GetCurrentColor() : buttonColors[0].GetCurrentColor();
43604363

43614364
if (disableGunPointer)
@@ -4371,7 +4374,9 @@ public static (RaycastHit Ray, GameObject NewPointer) RenderGun(int? overrideLay
43714374
Destroy(Particle.GetComponent<Collider>());
43724375
}
43734376

4374-
Destroy(GunPointer.GetComponent<Collider>());
4377+
Collider gunPointerCollider = GunPointer.GetComponent<Collider>();
4378+
if (gunPointerCollider != null)
4379+
Destroy(gunPointerCollider);
43754380

43764381
if (disableGunLine) return (Ray, GunPointer);
43774382
if (GunLine == null)
@@ -4381,7 +4386,8 @@ public static (RaycastHit Ray, GameObject NewPointer) RenderGun(int? overrideLay
43814386
}
43824387

43834388
GunLine.gameObject.SetActive(true);
4384-
GunLine.material.shader = Shader.Find("GUI/Text Shader");
4389+
if (GunLine.material.shader.name != "GUI/Text Shader")
4390+
GunLine.material.shader = Shader.Find("GUI/Text Shader");
43854391
GunLine.startColor = backgroundColor.GetCurrentColor();
43864392
GunLine.endColor = backgroundColor.GetCurrentColor(0.5f);
43874393
GunLine.startWidth = 0.025f * (scaleWithPlayer ? GTPlayer.Instance.scale : 1f);
@@ -7051,4 +7057,4 @@ public static string currentCategoryName
70517057
"multifactor was also here - kingofnetflix"
70527058
};
70537059
}
7054-
}
7060+
}

0 commit comments

Comments
 (0)