-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGameObject.cs
More file actions
41 lines (38 loc) · 1.32 KB
/
GameObject.cs
File metadata and controls
41 lines (38 loc) · 1.32 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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;
namespace ObjectPoolExample
{
internal class GameObject
{
public string name = "";
public Vector3 position = Vector3.Zero;
public GameObject parent { get; private set; } = null;
public bool activeSelf { get; private set; } = false;
public GameObject(string _name, Vector3 _position, GameObject _parent = null, bool _activeSelf = false)
{
name = _name;
position = _position;
parent = _parent;
activeSelf = _activeSelf;
}
public GameObject(GameObject _gameObject)
{
name = _gameObject.name;
position = _gameObject.position;
parent = _gameObject.parent;
activeSelf = _gameObject.activeSelf;
}
public void SetActive(bool state) => activeSelf = state;
public void SetParent(GameObject newParent) => parent = newParent;
public void SetPosition(Vector3 newPos) => position = newPos;
public override string ToString()
{
string parentName = parent != null ? parent.name : "none";
return $"GameObject {name} in pos {position}, child of {parentName}";
}
}
}