Skip to content

Commit 3709452

Browse files
committed
Pathholder names
- PathHolder objects now are set to the name of the path, rather than Path(Clone).
1 parent 6cda3d0 commit 3709452

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

Assets/MapEditor/Managers/PathManager.cs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55

66
public static class PathManager
77
{
8-
public static GameObject defaultPath { get; private set; }
9-
public static GameObject defaultNode { get; private set; }
10-
public static Transform pathParent { get; private set; }
8+
public static GameObject DefaultPath { get; private set; }
9+
public static GameObject DefaultNode { get; private set; }
10+
public static Transform PathParent { get; private set; }
1111

1212
public enum PathType
1313
{
@@ -24,27 +24,27 @@ public static void Init()
2424

2525
static void OnProjectLoad()
2626
{
27-
defaultPath = Resources.Load<GameObject>("Paths/Path");
28-
defaultNode = Resources.Load<GameObject>("Paths/PathNode");
29-
pathParent = GameObject.FindGameObjectWithTag("Paths").transform;
27+
DefaultPath = Resources.Load<GameObject>("Paths/Path");
28+
DefaultNode = Resources.Load<GameObject>("Paths/PathNode");
29+
PathParent = GameObject.FindGameObjectWithTag("Paths").transform;
3030
EditorApplication.update -= OnProjectLoad;
3131
}
3232

3333
public static void Spawn(PathData pathData)
3434
{
3535
Vector3 averageLocation = Vector3.zero;
3636
for (int j = 0; j < pathData.nodes.Length; j++)
37-
{
3837
averageLocation += pathData.nodes[j];
39-
}
38+
4039
averageLocation /= pathData.nodes.Length;
41-
GameObject newObject = GameObject.Instantiate(defaultPath, averageLocation + pathParent.position, Quaternion.identity, pathParent);
40+
GameObject newObject = GameObject.Instantiate(DefaultPath, averageLocation + PathParent.position, Quaternion.identity, PathParent);
41+
newObject.name = pathData.name;
4242

4343
List<GameObject> pathNodes = new List<GameObject>();
4444
for (int j = 0; j < pathData.nodes.Length; j++)
4545
{
46-
GameObject newNode = GameObject.Instantiate(defaultNode, newObject.transform);
47-
newNode.transform.position = pathData.nodes[j] + pathParent.position;
46+
GameObject newNode = GameObject.Instantiate(DefaultNode, newObject.transform);
47+
newNode.transform.position = pathData.nodes[j] + PathParent.position;
4848
pathNodes.Add(newNode);
4949
}
5050
newObject.GetComponent<PathDataHolder>().pathData = pathData;

0 commit comments

Comments
 (0)