init
This commit is contained in:
commit
bd5b1556ff
269 changed files with 6249829 additions and 0 deletions
37
Assets/Scripts/TriggerEnableAndDisable.cs
Normal file
37
Assets/Scripts/TriggerEnableAndDisable.cs
Normal file
|
@ -0,0 +1,37 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class TriggerEnableAndDisable : MonoBehaviour{
|
||||
|
||||
public GameObject enable;
|
||||
public GameObject disable;
|
||||
public float delay;
|
||||
|
||||
void OnTriggerEnter2D(Collider2D col){
|
||||
if(col.gameObject.tag == "Player"){
|
||||
if(delay == 0){
|
||||
if (enable != null){
|
||||
enable.SetActive(true);
|
||||
}
|
||||
if (disable != null){
|
||||
disable.SetActive(false);
|
||||
}
|
||||
gameObject.SetActive(false);
|
||||
}else{
|
||||
StartCoroutine(Delay());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
IEnumerator Delay(){
|
||||
yield return new WaitForSeconds(delay);
|
||||
if (enable != null){
|
||||
enable.SetActive(true);
|
||||
}
|
||||
if (disable != null){
|
||||
disable.SetActive(false);
|
||||
}
|
||||
gameObject.SetActive(false);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue