summaryrefslogtreecommitdiff
path: root/ch.sycoforge.Decal.Demo/BasicBulletHoles.cs
diff options
context:
space:
mode:
authorchai <215380520@qq.com>2024-03-13 11:00:58 +0800
committerchai <215380520@qq.com>2024-03-13 11:00:58 +0800
commit6ce8b9e22fc13be34b442c7b6af48b42cd44275a (patch)
treeb38119d2acf0a982cb67e381f146924b9bfc3b3f /ch.sycoforge.Decal.Demo/BasicBulletHoles.cs
+init
Diffstat (limited to 'ch.sycoforge.Decal.Demo/BasicBulletHoles.cs')
-rw-r--r--ch.sycoforge.Decal.Demo/BasicBulletHoles.cs37
1 files changed, 37 insertions, 0 deletions
diff --git a/ch.sycoforge.Decal.Demo/BasicBulletHoles.cs b/ch.sycoforge.Decal.Demo/BasicBulletHoles.cs
new file mode 100644
index 0000000..0d6eef1
--- /dev/null
+++ b/ch.sycoforge.Decal.Demo/BasicBulletHoles.cs
@@ -0,0 +1,37 @@
+using UnityEngine;
+
+namespace ch.sycoforge.Decal.Demo;
+
+public class BasicBulletHoles : MonoBehaviour
+{
+ public EasyDecal DecalPrefab;
+
+ private bool t;
+
+ public void Start()
+ {
+ if (DecalPrefab == null)
+ {
+ Debug.LogError("The DynamicDemo script has no decal prefab attached.");
+ }
+ }
+
+ public void Update()
+ {
+ if (!Input.GetMouseButtonUp(0))
+ {
+ return;
+ }
+ Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
+ if (Physics.Raycast(ray, out var hitInfo, 200f))
+ {
+ Debug.DrawLine(ray.origin, hitInfo.point, Color.red);
+ EasyDecal easyDecal = EasyDecal.ProjectAt(DecalPrefab.gameObject, hitInfo.collider.gameObject, hitInfo.point, hitInfo.normal);
+ t = !t;
+ if (t)
+ {
+ easyDecal.CancelFade();
+ }
+ }
+ }
+}