-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUnityBaseEntity.cs
More file actions
51 lines (44 loc) · 1.25 KB
/
Copy pathUnityBaseEntity.cs
File metadata and controls
51 lines (44 loc) · 1.25 KB
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
namespace UnityIceFebruary
{
using IceFebruary;
/// <summary>
/// Abstract class for bridge components.
/// </summary>
public abstract class UnityBaseEntity<T> : BaseEntity where T : UnityEngine.Object
{
/// <summary>
/// Reference to the original Unity object that this bridge component wraps.
/// </summary>
public T Original { get; private init; }
/// <summary>
/// True, if the Unity object is enabled.
/// </summary>
public override bool Enabled
{
get => _enabled;
set
{
_enabled = value;
UnityToggler.Set(Original, _enabled);
}
}
/// <summary>
/// Destroying an Unity object.
/// Don't use destroyed entities.
/// </summary>
public override void Destroy()
{
base.Destroy();
UnityMethods.Remove(this);
UnityEngine.Object.Destroy(Original);
}
/// <summary>
/// Creates a new bridge component.
/// </summary>
protected UnityBaseEntity(T original)
{
Original = original;
_enabled = UnityToggler.Get(Original);
}
}
}