-
Notifications
You must be signed in to change notification settings - Fork 58
/
Copy pathObjectSpawnerCommands.cs
75 lines (68 loc) · 1.72 KB
/
ObjectSpawnerCommands.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
// --------------------------------------------------------------------------------------------------------------------
// <copyright file="ObjectSpawner.cs">
// Copyright (c) 2020 Johannes Deml. All rights reserved.
// </copyright>
// <author>
// Johannes Deml
// public@deml.io
// </author>
// --------------------------------------------------------------------------------------------------------------------
using Supyrb.Attributes;
using UnityEngine;
namespace Supyrb
{
/// <summary>
/// Browser commands for spawning cubes
/// </summary>
public class ObjectSpawnerCommands : WebCommands
{
private ObjectSpawnController _objectSpawnController;
private ObjectSpawnController ObjectSpawnController
{
get
{
if (_objectSpawnController == null)
{
#if UNITY_2023_2_OR_NEWER
_objectSpawnController = Object.FindFirstObjectByType<ObjectSpawnController>();
#else
_objectSpawnController = Object.FindObjectOfType<ObjectSpawnController>();
#endif
}
return _objectSpawnController;
}
}
[WebCommand(Description = "Pause spawning of cubes")]
public void PauseSpawning()
{
if (ObjectSpawnController != null)
{
ObjectSpawnController.PauseSpawning();
}
}
[WebCommand(Description = "Resume spawning of cubes")]
public void ResumeSpawning()
{
if (ObjectSpawnController != null)
{
ObjectSpawnController.ResumeSpawning();
}
}
[WebCommand(Description = "Add a spawner")]
public void AddSpawner()
{
if (ObjectSpawnController != null)
{
ObjectSpawnController.AddSpawner();
}
}
[WebCommand(Description = "Remove a spawner")]
public void RemoveSpawner()
{
if (ObjectSpawnController != null)
{
ObjectSpawnController.RemoveSpawner();
}
}
}
}