1
This commit is contained in:
44
unity/Assets/Script/GameObject/Other/Destructeable.cs
Normal file
44
unity/Assets/Script/GameObject/Other/Destructeable.cs
Normal file
@@ -0,0 +1,44 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class Destructeable : MonoBehaviour
|
||||
{
|
||||
public GameObject destoryVFX;
|
||||
public GameObject big;
|
||||
public GameObject small;
|
||||
|
||||
private bool isDestory=false;
|
||||
public float reTiem = 5;
|
||||
|
||||
public void OnDestoryObject()
|
||||
{
|
||||
if (isDestory)
|
||||
return;
|
||||
if (destoryVFX != null)
|
||||
{
|
||||
Instantiate(destoryVFX,transform.position,transform.rotation);
|
||||
}
|
||||
|
||||
big.SetActive(false);
|
||||
SmallActive(true);
|
||||
isDestory = true;
|
||||
StartCoroutine(nameof(DestoryTime));
|
||||
}
|
||||
|
||||
IEnumerator DestoryTime()
|
||||
{
|
||||
yield return new WaitForSeconds(reTiem);
|
||||
big.SetActive(true);
|
||||
SmallActive(false);
|
||||
}
|
||||
|
||||
private void SmallActive(bool active)
|
||||
{
|
||||
if (small != null)
|
||||
{
|
||||
small.SetActive(active);
|
||||
isDestory = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user