-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathSpiderDeterrent.cs
50 lines (43 loc) · 1.26 KB
/
SpiderDeterrent.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace NoSpidersMod
{
public class SpiderDeterrent : MonoBehaviour
{
private List<GameObject> _deactivatedObjects = new List<GameObject>();
private void Awake()
{
StartCoroutine(CheckScene());
}
private IEnumerator CheckScene()
{
var fgSpiders = GameObject.Find("fg_spiders");
if (fgSpiders != null)
{
fgSpiders.SetActive(false);
_deactivatedObjects.Add(fgSpiders);
}
foreach (var childActivator in FindObjectsOfType<ActivateChildrenOnContact>())
{
if (!childActivator.name.ToLower().Contains("spider"))
{
continue;
}
childActivator.gameObject.SetActive(false);
_deactivatedObjects.Add(childActivator.gameObject);
}
yield break;
}
private void OnDisable()
{
foreach (var obj in _deactivatedObjects)
{
if (obj != null)
{
obj.SetActive(true);
}
}
}
}
}