From 6e81a37211a8a67f217014ede189d8424baa91e9 Mon Sep 17 00:00:00 2001 From: ural89 Date: Mon, 28 Jul 2025 17:11:56 +0300 Subject: [PATCH] option to change fracture layers to main object layer --- Runtime/Scripts/Fracture.cs | 4 ++++ Runtime/Scripts/Options/FractureOptions.cs | 5 ++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/Runtime/Scripts/Fracture.cs b/Runtime/Scripts/Fracture.cs index 8190676..1fe5248 100644 --- a/Runtime/Scripts/Fracture.cs +++ b/Runtime/Scripts/Fracture.cs @@ -207,6 +207,10 @@ private GameObject CreateFragmentTemplate() obj.name = "Fragment"; obj.tag = this.tag; + if (fractureOptions.shouldInheritLayer) + { + obj.layer = gameObject.layer; + } // Update mesh to the new sliced mesh obj.AddComponent(); diff --git a/Runtime/Scripts/Options/FractureOptions.cs b/Runtime/Scripts/Options/FractureOptions.cs index fec7b7d..5236695 100644 --- a/Runtime/Scripts/Options/FractureOptions.cs +++ b/Runtime/Scripts/Options/FractureOptions.cs @@ -28,13 +28,15 @@ public class FractureOptions [Tooltip("The material to use for the inside faces")] public Material insideMaterial; - + [Tooltip("Scale factor to apply to texture coordinates")] public Vector2 textureScale; [Tooltip("Offset to apply to texture coordinates")] public Vector2 textureOffset; + [Tooltip("Inherits the layer of the original gameobject")] + public bool shouldInheritLayer; public FractureOptions() { this.fragmentCount = 10; @@ -46,5 +48,6 @@ public FractureOptions() this.insideMaterial = null; this.textureScale = Vector2.one; this.textureOffset = Vector2.zero; + this.shouldInheritLayer = true; } } \ No newline at end of file