From 7f493f682503f5186308de7b8f74b5b49233cfe4 Mon Sep 17 00:00:00 2001 From: chai <215380520@qq.com> Date: Thu, 2 Nov 2023 11:51:31 +0800 Subject: +init --- GameCode/DestroyOrDisableOnEnable.cs | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 GameCode/DestroyOrDisableOnEnable.cs (limited to 'GameCode/DestroyOrDisableOnEnable.cs') diff --git a/GameCode/DestroyOrDisableOnEnable.cs b/GameCode/DestroyOrDisableOnEnable.cs new file mode 100644 index 0000000..5879f90 --- /dev/null +++ b/GameCode/DestroyOrDisableOnEnable.cs @@ -0,0 +1,27 @@ +using UnityEngine; + +public class DestroyOrDisableOnEnable : MonoBehaviour +{ + [SerializeField] + private Hp[] destroy; + + [SerializeField] + private GameObject[] disable; + + private void OnEnable() + { + Hp[] array = destroy; + foreach (Hp hp in array) + { + if (hp.gameObject.activeInHierarchy) + { + hp.TakeDamage(1E+09f); + } + } + GameObject[] array2 = disable; + for (int i = 0; i < array2.Length; i++) + { + array2[i].SetActive(value: false); + } + } +} -- cgit v1.1-26-g67d0