This repository has been archived by the owner on Jun 26, 2021. It is now read-only.
forked from MicroGSD/RoadArchitect
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathGSDRoadSystem.cs
129 lines (105 loc) · 3.52 KB
/
GSDRoadSystem.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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
#region "Imports"
using UnityEngine;
//#if UNITY_EDITOR
//using System.Collections; // Unused
//#endif
#endregion
public class GSDRoadSystem : MonoBehaviour
{
public static string AssetBasePath = GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "";
#if UNITY_EDITOR
public bool opt_bMultithreading = true;
public bool opt_bSaveMeshes = false;
public bool opt_bAllowRoadUpdates = true;
public GameObject AddRoad(bool bForceSelect = false)
{
GSDRoad[] tObj = GetComponentsInChildren<GSDRoad>();
int NewRoadNumber = (tObj.Length + 1);
//Road:
GameObject tRoadObj = new GameObject("Road" + NewRoadNumber.ToString());
UnityEditor.Undo.RegisterCreatedObjectUndo(tRoadObj, "Created road");
tRoadObj.transform.parent = transform;
GSDRoad tRoad = tRoadObj.AddComponent<GSDRoad>();
//Spline:
GameObject tSplineObj = new GameObject("Spline");
tSplineObj.transform.parent = tRoad.transform;
tRoad.GSDSpline = tSplineObj.AddComponent<GSDSplineC>();
tRoad.GSDSpline.mSplineRoot = tSplineObj;
tRoad.GSDSpline.tRoad = tRoad;
tRoad.GSDSplineObj = tSplineObj;
tRoad.GSDRS = this;
tRoad.SetupUniqueIdentifier();
tRoad.ConstructRoad_ResetTerrainHistory();
if (bForceSelect)
{
UnityEditor.Selection.activeGameObject = tRoadObj;
}
return tRoadObj;
}
public Camera EditorPlayCamera = null;
public void EditorCameraSetSingle()
{
if (EditorPlayCamera == null)
{
Camera[] EditorCams = (Camera[]) GameObject.FindObjectsOfType(typeof(Camera));
if (EditorCams != null && EditorCams.Length == 1)
{
EditorPlayCamera = EditorCams[0];
}
}
}
public void UpdateAllRoads()
{
GSDRoad[] tRoadObjs = GetComponentsInChildren<GSDRoad>();
// int i=0;
int RoadCount = tRoadObjs.Length;
GSDRoad tRoad = null;
GSDSplineC[] tPiggys = null;
if (RoadCount > 1)
{
tPiggys = new GSDSplineC[RoadCount];
for (int h = 0; h < RoadCount; h++)
{
tRoad = tRoadObjs[h];
tPiggys[h] = tRoad.GSDSpline;
}
}
tRoad = tRoadObjs[0];
if (tPiggys != null && tPiggys.Length > 0)
{
tRoad.PiggyBacks = tPiggys;
}
tRoad.UpdateRoad();
}
//Workaround for submission rules:
public void UpdateAllRoads_MultiThreadOptions()
{
GSDRoad[] tRoadObjs = (GSDRoad[]) GetComponentsInChildren<GSDRoad>();
int RoadCount = tRoadObjs.Length;
GSDRoad tRoad = null;
for (int h = 0; h < RoadCount; h++)
{
tRoad = tRoadObjs[h];
if (tRoad != null)
{
tRoad.opt_bMultithreading = opt_bMultithreading;
}
}
}
//Workaround for submission rules:
public void UpdateAllRoads_SaveMeshesAsAssetsOptions()
{
GSDRoad[] tRoadObjs = (GSDRoad[]) GetComponentsInChildren<GSDRoad>();
int RoadCount = tRoadObjs.Length;
GSDRoad tRoad = null;
for (int h = 0; h < RoadCount; h++)
{
tRoad = tRoadObjs[h];
if (tRoad != null)
{
tRoad.opt_bSaveMeshes = opt_bSaveMeshes;
}
}
}
#endif
}