-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUnityGameObject.cs
More file actions
59 lines (50 loc) · 1.69 KB
/
Copy pathUnityGameObject.cs
File metadata and controls
59 lines (50 loc) · 1.69 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
52
53
54
55
56
57
58
59
namespace UnityIceFebruary
{
using IceFebruary;
using IceFebruary.Proxy;
using GameObject = UnityEngine.GameObject;
/// <summary>
/// Bridge component for controlling the Unity gameobject.
/// </summary>
public sealed class UnityGameObject : UnityBaseEntity<GameObject>, IGameObject
{
/// <summary>
/// Сomponent that stores the position, rotation, and scale of an object.
/// </summary>
public ITransform Transform { get; private init; }
/// <summary>
/// Physical layer on which the object resides.
/// </summary>
public int Layer
{
get => Original.layer;
set => Original.layer = value;
}
/// <summary>
/// Main component that implements the object.
/// </summary>
public IBaseEntity MainComponent { get; set; }
/// <summary>
/// Creates a new component for controlling the Unity gameobject.
/// </summary>
[FieldProxy(typeof(IGameObject))]
public UnityGameObject(GameObject gameObject) : base(gameObject)
{
Transform = UnityMethods.Upsert<UnityEngine.Transform, ITransform>(gameObject.transform);
}
/// <summary>
/// Attempting to get the root config from an object.
/// </summary>
public bool TryGetRootConfig<T>(out T rootConfig) where T : class
{
if (!Original.TryGetComponent(out UnityInfo info))
{
rootConfig = null;
return false;
}
rootConfig = info.ToPoco() as T;
UnityEngine.Object.Destroy(info);
return true;
}
}
}