From a04ebec7f09ce36914c54afb9737f36a1015c763 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B3=AF=E5=B2=B8=E3=80=80=E4=BA=AE?= <1920071390@campus.ouj.ac.jp> Date: Fri, 5 Apr 2024 10:57:45 +0900 Subject: [PATCH] =?UTF-8?q?booth=E5=85=AC=E9=96=8B=E6=AD=A3=E5=BC=8F?= =?UTF-8?q?=E7=89=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit (2024-04-05)0057(GMT) Signed-off-by: 峯岸 亮 <1920071390@campus.ouj.ac.jp> --- VRCTrailFXFree.prefab.unitypackage | 157 +++++++++++++++++++++++++++++ 1 file changed, 157 insertions(+) create mode 100644 VRCTrailFXFree.prefab.unitypackage diff --git a/VRCTrailFXFree.prefab.unitypackage b/VRCTrailFXFree.prefab.unitypackage new file mode 100644 index 0000000..04323e8 --- /dev/null +++ b/VRCTrailFXFree.prefab.unitypackage @@ -0,0 +1,157 @@ +using UnityEngine; +using System; + +public class VRCTrailFXFree : MonoBehaviour +{ + public bool isTrailEnabled = true; + public Color[] predefinedColors = new Color[5]; + public float[] trailLengths = new float[3]; + public float[] trailWidths = new float[3]; + public Texture[] trailTextures = new Texture[3]; + + private TrailRenderer trailRenderer; + + private void Awake() + { + try + { + trailRenderer = GetComponent(); + if (trailRenderer == null) + { + throw new InvalidOperationException("TrailRenderer component not found!"); + } + } + catch (Exception ex) + { + Debug.LogError($"Error in VRCTrailFXFree Awake: {ex.Message}"); + enabled = false; + } + } + + private void OnEnable() + { + try + { + ApplyTrailSettings(); + } + catch (Exception ex) + { + Debug.LogError($"Error enabling VRCTrailFXFree: {ex.Message}"); + enabled = false; + } + } + + private void OnDisable() + { + try + { + trailRenderer.enabled = false; + } + catch (Exception ex) + { + Debug.LogError($"Error disabling VRCTrailFXFree: {ex.Message}"); + } + } + + public void SetTrailEnabled(bool enabled) + { + try + { + isTrailEnabled = enabled; + ApplyTrailSettings(); + } + catch (Exception ex) + { + Debug.LogError($"Error setting trail enabled: {ex.Message}"); + } + } + + public void SetTrailColor(int colorIndex) + { + try + { + if (colorIndex >= 0 && colorIndex < predefinedColors.Length) + { + trailRenderer.material.color = predefinedColors[colorIndex]; + } + else + { + throw new ArgumentOutOfRangeException(nameof(colorIndex), "Invalid color index!"); + } + } + catch (Exception ex) + { + Debug.LogError($"Error setting trail color: {ex.Message}"); + } + } + + public void SetTrailLength(int lengthIndex) + { + try + { + if (lengthIndex >= 0 && lengthIndex < trailLengths.Length) + { + trailRenderer.time = trailLengths[lengthIndex]; + } + else + { + throw new ArgumentOutOfRangeException(nameof(lengthIndex), "Invalid length index!"); + } + } + catch (Exception ex) + { + Debug.LogError($"Error setting trail length: {ex.Message}"); + } + } + + public void SetTrailWidth(int widthIndex) + { + try + { + if (widthIndex >= 0 && widthIndex < trailWidths.Length) + { + trailRenderer.startWidth = trailWidths[widthIndex]; + trailRenderer.endWidth = trailWidths[widthIndex]; + } + else + { + throw new ArgumentOutOfRangeException(nameof(widthIndex), "Invalid width index!"); + } + } + catch (Exception ex) + { + Debug.LogError($"Error setting trail width: {ex.Message}"); + } + } + + public void SetTrailTexture(int textureIndex) + { + try + { + if (textureIndex >= 0 && textureIndex < trailTextures.Length) + { + trailRenderer.material.mainTexture = trailTextures[textureIndex]; + } + else + { + throw new ArgumentOutOfRangeException(nameof(textureIndex), "Invalid texture index!"); + } + } + catch (Exception ex) + { + Debug.LogError($"Error setting trail texture: {ex.Message}"); + } + } + + private void ApplyTrailSettings() + { + try + { + trailRenderer.enabled = isTrailEnabled; + } + catch (Exception ex) + { + Debug.LogError($"Error applying trail settings: {ex.Message}"); + } + } +} \ No newline at end of file