diff --git a/CHANGELOG.md b/CHANGELOG.md
new file mode 100644
index 00000000..213b46df
--- /dev/null
+++ b/CHANGELOG.md
@@ -0,0 +1,37 @@
+# Changelog
+All notable changes to this RoadArchitect project will be documented in this file.
+
+The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
+and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
+
+
+## [Version: 1.8_FH] - 2019.02.10
+### Improvements
+- Added some FH_Tag Optimizable as comments, since there is a way to further optimize the Code tagged by this
+- Added a few Lines of comments to the code, to get a better idea of what the code does
+
+### Changed
+- Changed some Layouts of the Scripts
+- Changed some Vars in Scripts to better reflect their purpose
+
+### Added
+- Added a few Regions to some Scripts
+
+###Fixed
+- Fixed embeddedt/RoadArchitect/issues/4
+
+## [Version: 1.7.5a_FH] - 2019.01.31
+### Changed
+- Changed most Layouts of the Scripts
+- Changed some Vars in Scripts to better reflect their purpose
+
+## [Version 1.7] - 2018.07.16
+### Changed
+- Adds support for Unity 2018.x
+- Updates to unit tests
+- No further Informations given at this point
+
+## [Version 1.6] - 2017.02.28
+### Changed
+- Initial Release
+- No further Informations given at this point
\ No newline at end of file
diff --git a/CHANGELOG.md.meta b/CHANGELOG.md.meta
new file mode 100644
index 00000000..0c0897b8
--- /dev/null
+++ b/CHANGELOG.md.meta
@@ -0,0 +1,7 @@
+fileFormatVersion: 2
+guid: 82263ce59907a4c45acd2234af48e7e9
+TextScriptImporter:
+ externalObjects: {}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Editor/GSDEditorProgressWindow.cs b/Editor/GSDEditorProgressWindow.cs
index d9f2e99e..431b5507 100755
--- a/Editor/GSDEditorProgressWindow.cs
+++ b/Editor/GSDEditorProgressWindow.cs
@@ -1,54 +1,63 @@
-#if UNITY_EDITOR
-using UnityEditor;
-#endif
-using UnityEngine;
-
-///
-/// Used for progress information for other areas of RA.
-///
-public class GSDEditorProgressWindow : EditorWindow
-{
- float secs = 10.0f;
- float startVal = 0f;
- float progress = 0f;
-
-#if UNITY_EDITOR
- static void Init()
- {
- GSDEditorProgressWindow window = (GSDEditorProgressWindow)EditorWindow.GetWindow(typeof(GSDEditorProgressWindow));
- window.Show();
- }
-#endif
-
-#if UNITY_EDITOR
- void OnGUI()
- {
- secs = EditorGUILayout.FloatField("Time to wait:", secs);
- if (GUILayout.Button("Display bar"))
- {
- if (secs < 1)
- {
- Debug.LogError("Seconds should be bigger than 1");
- return;
- }
- startVal = (float)EditorApplication.timeSinceStartup;
- }
-
- if (progress < secs)
- EditorUtility.DisplayProgressBar(
- "Simple Progress Bar",
- "Shows a progress bar for the given seconds",
- progress / secs);
- else
- EditorUtility.ClearProgressBar();
-
- progress = (float)(EditorApplication.timeSinceStartup - startVal);
- }
-
-
- void OnInspectorUpdate()
- {
- Repaint();
- }
-#endif
+#region "Imports"
+#if UNITY_EDITOR
+using UnityEditor;
+#endif
+using UnityEngine;
+#endregion
+
+
+///
+/// Used for progress information for other areas of RA.
+///
+public class GSDEditorProgressWindow : EditorWindow
+{
+ float secs = 10.0f;
+ float startVal = 0f;
+ float progress = 0f;
+
+
+#if UNITY_EDITOR
+ static void Init()
+ {
+ GSDEditorProgressWindow window = (GSDEditorProgressWindow) EditorWindow.GetWindow(typeof(GSDEditorProgressWindow));
+ window.Show();
+ }
+#endif
+
+
+#if UNITY_EDITOR
+ void OnGUI()
+ {
+ secs = EditorGUILayout.FloatField("Time to wait:", secs);
+ if (GUILayout.Button("Display bar"))
+ {
+ if (secs < 1)
+ {
+ Debug.LogError("Seconds should be bigger than 1");
+ return;
+ }
+ startVal = (float) EditorApplication.timeSinceStartup;
+ }
+
+ if (progress < secs)
+ {
+ EditorUtility.DisplayProgressBar(
+ "Simple Progress Bar",
+ "Shows a progress bar for the given seconds",
+ progress / secs);
+ }
+ else
+ {
+ EditorUtility.ClearProgressBar();
+ }
+
+ progress = (float) (EditorApplication.timeSinceStartup - startVal);
+ }
+
+
+ void OnInspectorUpdate()
+ {
+ Repaint();
+ }
+#endif
}
\ No newline at end of file
diff --git a/Editor/GSDHelpWindow.cs b/Editor/GSDHelpWindow.cs
index 83c79070..87aa3014 100755
--- a/Editor/GSDHelpWindow.cs
+++ b/Editor/GSDHelpWindow.cs
@@ -1,37 +1,40 @@
-#region "Imports"
-using UnityEngine;
-using UnityEditor;
-#endregion
-public class GSDHelpWindow : EditorWindow
-{
- void OnGUI()
- {
- EditorStyles.label.wordWrap = true;
- EditorStyles.miniLabel.wordWrap = true;
-
- EditorGUILayout.LabelField("Road Architect Help", EditorStyles.boldLabel);
- EditorGUILayout.LabelField("Please visit the online manual for help.");
- GUILayout.Space(4f);
-
- if (GUILayout.Button("Click here to open online manual", EditorStyles.miniButton, GUILayout.Width(300f)))
- {
- Application.OpenURL("http://microgsd.com/Support.aspx");
- }
-
- EditorGUILayout.LabelField("http://microgsd.com/Support.aspx", EditorStyles.miniLabel);
- GUILayout.Space(4f);
- EditorGUILayout.LabelField("Please visit the online manual for help.", EditorStyles.miniLabel);
- GUILayout.Space(4f);
- EditorGUILayout.LabelField("Please visit our unity forum thread or contact support@microgsd.com with any questions or comments.", EditorStyles.miniLabel);
- }
-
- #region "Init"
- public void Initialize()
- {
- Rect fRect = new Rect(340, 170, 420, 180);
- position = fRect;
- Show();
- titleContent.text = "Help Info";
- }
- #endregion
+#region "Imports"
+using UnityEngine;
+using UnityEditor;
+#endregion
+
+
+public class GSDHelpWindow : EditorWindow
+{
+ void OnGUI()
+ {
+ EditorStyles.label.wordWrap = true;
+ EditorStyles.miniLabel.wordWrap = true;
+
+ EditorGUILayout.LabelField("Road Architect Help", EditorStyles.boldLabel);
+ EditorGUILayout.LabelField("Please visit the online manual for help.");
+ GUILayout.Space(4f);
+
+ if (GUILayout.Button("Click here to open online manual", EditorStyles.miniButton, GUILayout.Width(300f)))
+ {
+ Application.OpenURL("http://microgsd.com/Support.aspx");
+ }
+
+ EditorGUILayout.LabelField("http://microgsd.com/Support.aspx", EditorStyles.miniLabel);
+ GUILayout.Space(4f);
+ EditorGUILayout.LabelField("Please visit the online manual for help.", EditorStyles.miniLabel);
+ GUILayout.Space(4f);
+ EditorGUILayout.LabelField("Please visit our unity forum thread or contact support@microgsd.com with any questions or comments.", EditorStyles.miniLabel);
+ }
+
+
+ #region "Init"
+ public void Initialize()
+ {
+ Rect fRect = new Rect(340, 170, 420, 180);
+ position = fRect;
+ Show();
+ titleContent.text = "Help Info";
+ }
+ #endregion
}
\ No newline at end of file
diff --git a/Editor/GSDNotification.cs b/Editor/GSDNotification.cs
index 2a9b548a..5f7e3039 100755
--- a/Editor/GSDNotification.cs
+++ b/Editor/GSDNotification.cs
@@ -1,29 +1,35 @@
-using UnityEngine;
-using UnityEditor;
-using System.Collections;
-
-///
-/// Used for notifications in other areas of RA.
-///
-public class GSDNotification : EditorWindow
-{
- string notification = "This is a Notification";
- static void Initialize()
- {
- GSDNotification window = EditorWindow.GetWindow();
- window.Show();
- }
-
- void OnGUI()
- {
- notification = EditorGUILayout.TextField(notification);
- if (GUILayout.Button("Show Notification"))
- {
- this.ShowNotification(new GUIContent(notification));
- }
- if (GUILayout.Button("Remove Notification"))
- {
- this.RemoveNotification();
- }
- }
+#region Imports
+using UnityEngine;
+using UnityEditor;
+using System.Collections;
+#endregion
+
+
+///
+/// Used for notifications in other areas of RA.
+///
+public class GSDNotification : EditorWindow
+{
+ string notification = "This is a Notification";
+
+
+ static void Initialize()
+ {
+ GSDNotification window = EditorWindow.GetWindow();
+ window.Show();
+ }
+
+
+ void OnGUI()
+ {
+ notification = EditorGUILayout.TextField(notification);
+ if (GUILayout.Button("Show Notification"))
+ {
+ this.ShowNotification(new GUIContent(notification));
+ }
+ if (GUILayout.Button("Remove Notification"))
+ {
+ this.RemoveNotification();
+ }
+ }
}
\ No newline at end of file
diff --git a/Editor/GSDObjExporter.cs b/Editor/GSDObjExporter.cs
index 838cbb0c..2bef8ad1 100755
--- a/Editor/GSDObjExporter.cs
+++ b/Editor/GSDObjExporter.cs
@@ -1,364 +1,394 @@
-/*
-Based on ObjExporter.cs, this "wrapper" lets you export to .OBJ directly from the editor menu.
-
-This should be put in your "Editor"-folder. Use by selecting the objects you want to export, and select
-the appropriate menu item from "Custom->Export". Exported models are put in a folder called
-"ExportedObj" in the root of your Unity-project. Textures should also be copied and placed in the
-same folder.
-N.B. there may be a bug so if the custom option doesn't come up refer to this thread
-http://answers.unity3d.com/questions/317951/how-to-use-editorobjexporter-obj-saving-script-fro.html
-http://wiki.unity3d.com/index.php?title=ObjExporter
-http://wiki.unity3d.com/index.php/User:KeliHlodversson
-*/
-
-using UnityEngine;
-using UnityEditor;
-using System.Collections;
-using System.Collections.Generic;
-using System.IO;
-using System.Text;
-using System;
-
-struct ObjMaterial
-{
- public string name;
- public string textureName;
-}
-
-public class GSDObjExporter : ScriptableObject
-{
- private static int vertexOffset = 0;
- private static int normalOffset = 0;
- private static int uvOffset = 0;
-
-
- //User should probably be able to change this. It is currently left as an excercise for
- //the reader.
- private static string targetFolder = "ExportedObj";
-
- private static string MeshToString(MeshFilter mf, Dictionary materialList)
- {
- Mesh m = mf.sharedMesh;
- Renderer rend = mf.GetComponent();
- //Material[] mats = mf.renderer.sharedMaterials;
- Material[] mats = rend.sharedMaterials;
-
- StringBuilder sb = new StringBuilder();
-
- sb.Append("g ").Append(mf.name).Append("\n");
- foreach (Vector3 lv in m.vertices)
- {
- Vector3 wv = mf.transform.TransformPoint(lv);
-
- //This is sort of ugly - inverting x-component since we're in
- //a different coordinate system than "everyone" is "used to".
- sb.Append(string.Format("v {0} {1} {2}\n", -wv.x, wv.y, wv.z));
- }
- sb.Append("\n");
-
- foreach (Vector3 lv in m.normals)
- {
- Vector3 wv = mf.transform.TransformDirection(lv);
-
- sb.Append(string.Format("vn {0} {1} {2}\n", -wv.x, wv.y, wv.z));
- }
- sb.Append("\n");
-
- foreach (Vector3 v in m.uv)
- {
- sb.Append(string.Format("vt {0} {1}\n", v.x, v.y));
- }
-
- for (int material = 0; material < m.subMeshCount; material++)
- {
- sb.Append("\n");
- sb.Append("usemtl ").Append(mats[material].name).Append("\n");
- sb.Append("usemap ").Append(mats[material].name).Append("\n");
-
- //See if this material is already in the materiallist.
- try
- {
- ObjMaterial objMaterial = new ObjMaterial();
-
- objMaterial.name = mats[material].name;
-
- if (mats[material].mainTexture)
- objMaterial.textureName = AssetDatabase.GetAssetPath(mats[material].mainTexture);
- else
- objMaterial.textureName = null;
-
- materialList.Add(objMaterial.name, objMaterial);
- }
- catch (ArgumentException)
- {
- //Already in the dictionary
- }
-
-
- int[] triangles = m.GetTriangles(material);
- for (int i = 0; i < triangles.Length; i += 3)
- {
- //Because we inverted the x-component, we also needed to alter the triangle winding.
- sb.Append(string.Format("f {1}/{1}/{1} {0}/{0}/{0} {2}/{2}/{2}\n",
- triangles[i] + 1 + vertexOffset, triangles[i + 1] + 1 + normalOffset, triangles[i + 2] + 1 + uvOffset));
- }
- }
-
- vertexOffset += m.vertices.Length;
- normalOffset += m.normals.Length;
- uvOffset += m.uv.Length;
-
- return sb.ToString();
- }
-
- private static void Clear()
- {
- vertexOffset = 0;
- normalOffset = 0;
- uvOffset = 0;
- }
-
- private static Dictionary PrepareFileWrite()
- {
- Clear();
-
- return new Dictionary();
- }
-
- private static void MaterialsToFile(Dictionary materialList, string folder, string filename)
- {
- using (StreamWriter sw = new StreamWriter(folder + "/" + filename + ".mtl"))
- {
- foreach (KeyValuePair kvp in materialList)
- {
- sw.Write("\n");
- sw.Write("newmtl {0}\n", kvp.Key);
- sw.Write("Ka 0.6 0.6 0.6\n");
- sw.Write("Kd 0.6 0.6 0.6\n");
- sw.Write("Ks 0.9 0.9 0.9\n");
- sw.Write("d 1.0\n");
- sw.Write("Ns 0.0\n");
- sw.Write("illum 2\n");
-
- if (kvp.Value.textureName != null)
- {
- string destinationFile = kvp.Value.textureName;
-
-
- int stripIndex = destinationFile.LastIndexOf('/');//FIXME: Should be Path.PathSeparator;
-
- if (stripIndex >= 0)
- destinationFile = destinationFile.Substring(stripIndex + 1).Trim();
-
-
- string relativeFile = destinationFile;
-
- destinationFile = folder + "/" + destinationFile;
-
- // Debug.Log("Copying texture from " + kvp.Value.textureName + " to " + destinationFile);
-
- try
- {
- //Copy the source file
- File.Copy(kvp.Value.textureName, destinationFile);
- }
- catch
- {
-
- }
-
-
- sw.Write("map_Kd {0}", relativeFile);
- }
-
- sw.Write("\n\n\n");
- }
- }
- }
-
- private static void MeshToFile(MeshFilter mf, string folder, string filename)
- {
- Dictionary materialList = PrepareFileWrite();
-
- using (StreamWriter sw = new StreamWriter(folder + "/" + filename + ".obj"))
- {
- sw.Write("mtllib ./" + filename + ".mtl\n");
-
- sw.Write(MeshToString(mf, materialList));
- }
-
- MaterialsToFile(materialList, folder, filename);
- }
-
- private static void MeshesToFile(MeshFilter[] mf, string folder, string filename)
- {
- Dictionary materialList = PrepareFileWrite();
-
- using (StreamWriter sw = new StreamWriter(folder + "/" + filename + ".obj"))
- {
- sw.Write("mtllib ./" + filename + ".mtl\n");
-
- for (int i = 0; i < mf.Length; i++)
- {
- sw.Write(MeshToString(mf[i], materialList));
- }
- }
-
- MaterialsToFile(materialList, folder, filename);
- }
-
- private static bool CreateTargetFolder()
- {
- try
- {
- System.IO.Directory.CreateDirectory(targetFolder);
- }
- catch
- {
- EditorUtility.DisplayDialog("Error!", "Failed to create target folder!", "");
- return false;
- }
-
- return true;
- }
-
- [MenuItem("Window/Road Architect/Export/Export all MeshFilters in selection to separate OBJs")]
- static void ExportSelectionToSeparate()
- {
- if (!CreateTargetFolder())
- return;
-
- Transform[] selection = Selection.GetTransforms(SelectionMode.Editable | SelectionMode.ExcludePrefab);
-
- if (selection.Length == 0)
- {
- EditorUtility.DisplayDialog("No source object selected!", "Please select one or more target objects", "");
- return;
- }
-
- int exportedObjects = 0;
-
- for (int i = 0; i < selection.Length; i++)
- {
- Component[] meshfilter = selection[i].GetComponentsInChildren(typeof(MeshFilter));
-
- for (int m = 0; m < meshfilter.Length; m++)
- {
- exportedObjects++;
- MeshToFile((MeshFilter)meshfilter[m], targetFolder, selection[i].name + "_" + i + "_" + m);
- }
- }
-
- if (exportedObjects > 0)
- EditorUtility.DisplayDialog("Objects exported", "Exported " + exportedObjects + " objects", "");
- else
- EditorUtility.DisplayDialog("Objects not exported", "Make sure at least some of your selected objects have mesh filters!", "");
- }
-
- [MenuItem("Window/Road Architect/Export/Export whole selection to single OBJ")]
- static void ExportWholeSelectionToSingle()
- {
- if (!CreateTargetFolder())
- return;
-
-
- Transform[] selection = Selection.GetTransforms(SelectionMode.Editable | SelectionMode.ExcludePrefab);
-
- if (selection.Length == 0)
- {
- EditorUtility.DisplayDialog("No source object selected!", "Please select one or more target objects", "");
- return;
- }
-
- int exportedObjects = 0;
-
- ArrayList mfList = new ArrayList();
-
- for (int i = 0; i < selection.Length; i++)
- {
- Component[] meshfilter = selection[i].GetComponentsInChildren(typeof(MeshFilter));
-
- for (int m = 0; m < meshfilter.Length; m++)
- {
- exportedObjects++;
- mfList.Add(meshfilter[m]);
- }
- }
-
- if (exportedObjects > 0)
- {
- MeshFilter[] mf = new MeshFilter[mfList.Count];
-
- for (int i = 0; i < mfList.Count; i++)
- {
- mf[i] = (MeshFilter)mfList[i];
- }
-
-
- string tSceneName = UnityEditor.SceneManagement.EditorSceneManager.GetActiveScene().name;
- //string filename = EditorApplication.currentScene + "_" + exportedObjects;
- string filename = tSceneName + "_" + exportedObjects;
-
- int stripIndex = filename.LastIndexOf('/');//FIXME: Should be Path.PathSeparator
-
- if (stripIndex >= 0)
- filename = filename.Substring(stripIndex + 1).Trim();
-
- MeshesToFile(mf, targetFolder, filename);
-
-
- EditorUtility.DisplayDialog("Objects exported", "Exported " + exportedObjects + " objects to " + filename, "");
- }
- else
- EditorUtility.DisplayDialog("Objects not exported", "Make sure at least some of your selected objects have mesh filters!", "");
- }
-
-
-
- [MenuItem("Window/Road Architect/Export/Export each selected to single OBJ")]
- static void ExportEachSelectionToSingle()
- {
- if (!CreateTargetFolder())
- return;
-
- Transform[] selection = Selection.GetTransforms(SelectionMode.Editable | SelectionMode.ExcludePrefab);
-
- if (selection.Length == 0)
- {
- EditorUtility.DisplayDialog("No source object selected!", "Please select one or more target objects", "");
- return;
- }
-
- int exportedObjects = 0;
-
-
- for (int i = 0; i < selection.Length; i++)
- {
- Component[] meshfilter = selection[i].GetComponentsInChildren(typeof(MeshFilter));
-
- MeshFilter[] mf = new MeshFilter[meshfilter.Length];
-
- for (int m = 0; m < meshfilter.Length; m++)
- {
- exportedObjects++;
- mf[m] = (MeshFilter)meshfilter[m];
- }
-
- MeshesToFile(mf, targetFolder, selection[i].name + "_" + i);
- }
-
- if (exportedObjects > 0)
- {
- EditorUtility.DisplayDialog("Objects exported", "Exported " + exportedObjects + " objects", "");
- }
- else
- EditorUtility.DisplayDialog("Objects not exported", "Make sure at least some of your selected objects have mesh filters!", "");
- }
-
-
- [MenuItem("Window/Road Architect/Export/Exporters by Hrafnkell Freyr Hlooversson from Unity3D wiki")]
- static void DoNothing1()
- {
- Application.OpenURL("http://wiki.unity3d.com/index.php?title=ObjExporter");
- }
+/*
+Based on ObjExporter.cs, this "wrapper" lets you export to .OBJ directly from the editor menu.
+
+This should be put in your "Editor"-folder. Use by selecting the objects you want to export, and select
+the appropriate menu item from "Custom->Export". Exported models are put in a folder called
+"ExportedObj" in the root of your Unity-project. Textures should also be copied and placed in the
+same folder.
+N.B. there may be a bug so if the custom option doesn't come up refer to this thread
+http://answers.unity3d.com/questions/317951/how-to-use-editorobjexporter-obj-saving-script-fro.html
+http://wiki.unity3d.com/index.php?title=ObjExporter
+http://wiki.unity3d.com/index.php/User:KeliHlodversson
+*/
+
+
+#region "Imports"
+using UnityEngine;
+using UnityEditor;
+using System.Collections;
+using System.Collections.Generic;
+using System.IO;
+using System.Text;
+using System;
+#endregion
+
+
+struct ObjMaterial
+{
+ public string name;
+ public string textureName;
+}
+
+
+public class GSDObjExporter : ScriptableObject
+{
+ private static int vertexOffset = 0;
+ private static int normalOffset = 0;
+ private static int uvOffset = 0;
+
+
+ //User should probably be able to change this. It is currently left as an excercise for
+ //the reader.
+ private static string targetFolder = "ExportedObj";
+
+
+ private static string MeshToString(MeshFilter mf, Dictionary materialList)
+ {
+ Mesh m = mf.sharedMesh;
+ Renderer rend = mf.GetComponent();
+ //Material[] mats = mf.renderer.sharedMaterials;
+ Material[] mats = rend.sharedMaterials;
+
+ StringBuilder sb = new StringBuilder();
+
+ sb.Append("g ").Append(mf.name).Append("\n");
+ foreach (Vector3 lv in m.vertices)
+ {
+ Vector3 wv = mf.transform.TransformPoint(lv);
+
+ //This is sort of ugly - inverting x-component since we're in
+ //a different coordinate system than "everyone" is "used to".
+ sb.Append(string.Format("v {0} {1} {2}\n", -wv.x, wv.y, wv.z));
+ }
+ sb.Append("\n");
+
+ foreach (Vector3 lv in m.normals)
+ {
+ Vector3 wv = mf.transform.TransformDirection(lv);
+
+ sb.Append(string.Format("vn {0} {1} {2}\n", -wv.x, wv.y, wv.z));
+ }
+ sb.Append("\n");
+
+ foreach (Vector3 v in m.uv)
+ {
+ sb.Append(string.Format("vt {0} {1}\n", v.x, v.y));
+ }
+
+ for (int material = 0; material < m.subMeshCount; material++)
+ {
+ sb.Append("\n");
+ sb.Append("usemtl ").Append(mats[material].name).Append("\n");
+ sb.Append("usemap ").Append(mats[material].name).Append("\n");
+
+ //See if this material is already in the materiallist.
+ try
+ {
+ ObjMaterial objMaterial = new ObjMaterial();
+
+ objMaterial.name = mats[material].name;
+
+ if (mats[material].mainTexture)
+ objMaterial.textureName = AssetDatabase.GetAssetPath(mats[material].mainTexture);
+ else
+ objMaterial.textureName = null;
+
+ materialList.Add(objMaterial.name, objMaterial);
+ }
+ catch (ArgumentException)
+ {
+ //Already in the dictionary
+ }
+
+
+ int[] triangles = m.GetTriangles(material);
+ for (int index = 0; index < triangles.Length; index += 3)
+ {
+ //Because we inverted the x-component, we also needed to alter the triangle winding.
+ sb.Append(string.Format("f {1}/{1}/{1} {0}/{0}/{0} {2}/{2}/{2}\n",
+ triangles[index] + 1 + vertexOffset, triangles[index + 1] + 1 + normalOffset, triangles[index + 2] + 1 + uvOffset));
+ }
+ }
+
+ vertexOffset += m.vertices.Length;
+ normalOffset += m.normals.Length;
+ uvOffset += m.uv.Length;
+
+ return sb.ToString();
+ }
+
+
+ private static void Clear()
+ {
+ vertexOffset = 0;
+ normalOffset = 0;
+ uvOffset = 0;
+ }
+
+
+ private static Dictionary PrepareFileWrite()
+ {
+ Clear();
+
+ return new Dictionary();
+ }
+
+
+ private static void MaterialsToFile(Dictionary materialList, string folder, string filename)
+ {
+ using (StreamWriter sw = new StreamWriter(folder + "/" + filename + ".mtl"))
+ {
+ foreach (KeyValuePair kvp in materialList)
+ {
+ sw.Write("\n");
+ sw.Write("newmtl {0}\n", kvp.Key);
+ sw.Write("Ka 0.6 0.6 0.6\n");
+ sw.Write("Kd 0.6 0.6 0.6\n");
+ sw.Write("Ks 0.9 0.9 0.9\n");
+ sw.Write("d 1.0\n");
+ sw.Write("Ns 0.0\n");
+ sw.Write("illum 2\n");
+
+ if (kvp.Value.textureName != null)
+ {
+ string destinationFile = kvp.Value.textureName;
+
+
+ int stripIndex = destinationFile.LastIndexOf('/');//FIXME: Should be Path.PathSeparator;
+
+ if (stripIndex >= 0)
+ {
+ destinationFile = destinationFile.Substring(stripIndex + 1).Trim();
+ }
+
+
+ string relativeFile = destinationFile;
+
+ destinationFile = folder + "/" + destinationFile;
+
+ // Debug.Log("Copying texture from " + kvp.Value.textureName + " to " + destinationFile);
+
+ try
+ {
+ //Copy the source file
+ File.Copy(kvp.Value.textureName, destinationFile);
+ }
+ catch
+ {
+
+ }
+
+
+ sw.Write("map_Kd {0}", relativeFile);
+ }
+
+ sw.Write("\n\n\n");
+ }
+ }
+ }
+
+
+ private static void MeshToFile(MeshFilter mf, string folder, string filename)
+ {
+ Dictionary materialList = PrepareFileWrite();
+
+ using (StreamWriter sw = new StreamWriter(folder + "/" + filename + ".obj"))
+ {
+ sw.Write("mtllib ./" + filename + ".mtl\n");
+
+ sw.Write(MeshToString(mf, materialList));
+ }
+
+ MaterialsToFile(materialList, folder, filename);
+ }
+
+
+ private static void MeshesToFile(MeshFilter[] mf, string folder, string filename)
+ {
+ Dictionary materialList = PrepareFileWrite();
+
+ using (StreamWriter sw = new StreamWriter(folder + "/" + filename + ".obj"))
+ {
+ sw.Write("mtllib ./" + filename + ".mtl\n");
+
+ for (int index = 0; index < mf.Length; index++)
+ {
+ sw.Write(MeshToString(mf[index], materialList));
+ }
+ }
+
+ MaterialsToFile(materialList, folder, filename);
+ }
+
+
+ private static bool CreateTargetFolder()
+ {
+ try
+ {
+ System.IO.Directory.CreateDirectory(targetFolder);
+ }
+ catch
+ {
+ EditorUtility.DisplayDialog("Error!", "Failed to create target folder!", "");
+ return false;
+ }
+
+ return true;
+ }
+
+
+ [MenuItem("Window/Road Architect/Export/Export all MeshFilters in selection to separate OBJs")]
+ static void ExportSelectionToSeparate()
+ {
+ if (!CreateTargetFolder())
+ {
+ return;
+ }
+
+ Transform[] selection = Selection.GetTransforms(SelectionMode.Editable | SelectionMode.ExcludePrefab);
+
+ if (selection.Length == 0)
+ {
+ EditorUtility.DisplayDialog("No source object selected!", "Please select one or more target objects", "");
+ return;
+ }
+
+ int exportedObjects = 0;
+
+ for (int index = 0; index < selection.Length; index++)
+ {
+ Component[] meshfilter = selection[index].GetComponentsInChildren(typeof(MeshFilter));
+
+ for (int m = 0; m < meshfilter.Length; m++)
+ {
+ exportedObjects++;
+ MeshToFile((MeshFilter) meshfilter[m], targetFolder, selection[index].name + "_" + index + "_" + m);
+ }
+ }
+
+ if (exportedObjects > 0)
+ {
+ EditorUtility.DisplayDialog("Objects exported", "Exported " + exportedObjects + " objects", "");
+ }
+ else
+ {
+ EditorUtility.DisplayDialog("Objects not exported", "Make sure at least some of your selected objects have mesh filters!", "");
+ }
+ }
+
+
+ [MenuItem("Window/Road Architect/Export/Export whole selection to single OBJ")]
+ static void ExportWholeSelectionToSingle()
+ {
+ if (!CreateTargetFolder())
+ {
+ return;
+ }
+
+
+ Transform[] selection = Selection.GetTransforms(SelectionMode.Editable | SelectionMode.ExcludePrefab);
+
+ if (selection.Length == 0)
+ {
+ EditorUtility.DisplayDialog("No source object selected!", "Please select one or more target objects", "");
+ return;
+ }
+
+ int exportedObjects = 0;
+
+ ArrayList mfList = new ArrayList();
+
+ for (int index = 0; index < selection.Length; index++)
+ {
+ Component[] meshfilter = selection[index].GetComponentsInChildren(typeof(MeshFilter));
+
+ for (int m = 0; m < meshfilter.Length; m++)
+ {
+ exportedObjects++;
+ mfList.Add(meshfilter[m]);
+ }
+ }
+
+ if (exportedObjects > 0)
+ {
+ MeshFilter[] mf = new MeshFilter[mfList.Count];
+
+ for (int index = 0; index < mfList.Count; index++)
+ {
+ mf[index] = (MeshFilter) mfList[index];
+ }
+
+
+ string tSceneName = UnityEditor.SceneManagement.EditorSceneManager.GetActiveScene().name;
+ //string filename = EditorApplication.currentScene + "_" + exportedObjects;
+ string filename = tSceneName + "_" + exportedObjects;
+
+ int stripIndex = filename.LastIndexOf('/');//FIXME: Should be Path.PathSeparator
+
+ if (stripIndex >= 0)
+ {
+ filename = filename.Substring(stripIndex + 1).Trim();
+ }
+
+ MeshesToFile(mf, targetFolder, filename);
+
+
+ EditorUtility.DisplayDialog("Objects exported", "Exported " + exportedObjects + " objects to " + filename, "");
+ }
+ else
+ EditorUtility.DisplayDialog("Objects not exported", "Make sure at least some of your selected objects have mesh filters!", "");
+ }
+
+
+
+ [MenuItem("Window/Road Architect/Export/Export each selected to single OBJ")]
+ static void ExportEachSelectionToSingle()
+ {
+ if (!CreateTargetFolder())
+ {
+ return;
+ }
+
+ Transform[] selection = Selection.GetTransforms(SelectionMode.Editable | SelectionMode.ExcludePrefab);
+
+ if (selection.Length == 0)
+ {
+ EditorUtility.DisplayDialog("No source object selected!", "Please select one or more target objects", "");
+ return;
+ }
+
+ int exportedObjects = 0;
+
+
+ for (int index = 0; index < selection.Length; index++)
+ {
+ Component[] meshfilter = selection[index].GetComponentsInChildren(typeof(MeshFilter));
+
+ MeshFilter[] mf = new MeshFilter[meshfilter.Length];
+
+ for (int m = 0; m < meshfilter.Length; m++)
+ {
+ exportedObjects++;
+ mf[m] = (MeshFilter) meshfilter[m];
+ }
+
+ MeshesToFile(mf, targetFolder, selection[index].name + "_" + index);
+ }
+
+ if (exportedObjects > 0)
+ {
+ EditorUtility.DisplayDialog("Objects exported", "Exported " + exportedObjects + " objects", "");
+ }
+ else
+ {
+ EditorUtility.DisplayDialog("Objects not exported", "Make sure at least some of your selected objects have mesh filters!", "");
+ }
+ }
+
+
+ [MenuItem("Window/Road Architect/Export/Exporters by Hrafnkell Freyr Hlooversson from Unity3D wiki")]
+ static void DoNothing1()
+ {
+ Application.OpenURL("http://wiki.unity3d.com/index.php?title=ObjExporter");
+ }
}
\ No newline at end of file
diff --git a/Editor/GSDRoadEditor.cs b/Editor/GSDRoadEditor.cs
index ba148f69..4f85d8f8 100755
--- a/Editor/GSDRoadEditor.cs
+++ b/Editor/GSDRoadEditor.cs
@@ -1,1445 +1,1522 @@
-#region "Imports"
-using UnityEngine;
-using UnityEditor;
-using System.Collections;
-using GSD.Roads;
-using GSD;
-[CustomEditor(typeof(GSDRoad))]
-#endregion
-public class GSDRoadEditor : Editor
-{
-
- private static string[] RoadMaterialDropdownEnumDesc = new string[]{
- "Asphalt",
- "Dirt",
- "Brick",
- "Cobblestone"
- };
-
-
- protected GSDRoad RS { get { return (GSDRoad)target; } }
-
- //Serialized properties:
- SerializedProperty t_opt_GizmosEnabled;
- SerializedProperty t_opt_Lanes;
- SerializedProperty t_opt_LaneWidth;
- SerializedProperty t_opt_bShouldersEnabled;
- SerializedProperty t_opt_ShoulderWidth;
- SerializedProperty t_opt_RoadDefinition;
- SerializedProperty t_opt_UseDefaultMaterials;
- SerializedProperty t_opt_bMaxGradeEnabled;
- SerializedProperty t_opt_MaxGrade;
- SerializedProperty t_opt_bMultithreading;
- SerializedProperty t_opt_bSaveMeshes;
- SerializedProperty t_opt_TerrainSubtract_Match;
- SerializedProperty t_opt_MagnitudeThreshold;
- SerializedProperty t_opt_HeightModEnabled;
- SerializedProperty t_opt_DetailModEnabled;
- SerializedProperty t_opt_TreeModEnabled;
- SerializedProperty t_opt_MatchHeightsDistance;
- SerializedProperty t_opt_ClearDetailsDistance;
- SerializedProperty t_opt_ClearDetailsDistanceHeight;
- SerializedProperty t_opt_ClearTreesDistance;
- SerializedProperty t_opt_ClearTreesDistanceHeight;
- SerializedProperty t_opt_SaveTerrainHistoryOnDisk;
- SerializedProperty t_opt_bRoadCuts;
- SerializedProperty t_opt_bDynamicCuts;
- SerializedProperty t_opt_bShoulderCuts;
- SerializedProperty t_bEditorCameraRotate;
- SerializedProperty t_EditorCameraMetersPerSecond;
- SerializedProperty t_opt_bUseMeshColliders;
- SerializedProperty t_opt_tRoadMaterialDropdown;
- SerializedProperty t_opt_bIsStatic;
- SerializedProperty t_opt_bIsLightmapped;
-
- SerializedProperty t_RoadMaterial1;
- SerializedProperty t_RoadMaterial2;
- SerializedProperty t_RoadMaterial3;
- SerializedProperty t_RoadMaterial4;
- SerializedProperty t_RoadMaterialMarker1;
- SerializedProperty t_RoadMaterialMarker2;
- SerializedProperty t_RoadMaterialMarker3;
- SerializedProperty t_RoadMaterialMarker4;
- SerializedProperty t_ShoulderMaterial1;
- SerializedProperty t_ShoulderMaterial2;
- SerializedProperty t_ShoulderMaterial3;
- SerializedProperty t_ShoulderMaterial4;
- SerializedProperty t_ShoulderMaterialMarker1;
- SerializedProperty t_ShoulderMaterialMarker2;
- SerializedProperty t_ShoulderMaterialMarker3;
- SerializedProperty t_ShoulderMaterialMarker4;
- SerializedProperty t_RoadPhysicMaterial;
- SerializedProperty t_ShoulderPhysicMaterial;
-
- //Editor only variables:
- string status = "Show help";
- const string tOnlineHelpDesc = "Visit the online manual for the most effective help.";
- bool bShowCutsHelp = false;
- bool bShowMatsHelp = false;
- bool bShowHelpRoad = false;
- bool bShowHelpTerrain = false;
- bool bShowCameraHelp = false;
- GUIStyle GSDLoadButton = null;
- bool bResetTH = false;
- public enum tempEnum { Two, Four, Six };
- Texture btnRefreshText = null;
- Texture btnDeleteText = null;
- Texture btnRefreshTextReal = null;
- tempEnum LanesEnum = tempEnum.Two;
- tempEnum tLanesEnum = tempEnum.Two;
- private static string[] tempEnumDescriptions = new string[]{
- "Two",
- "Four",
- "Six"
- };
- GUIStyle WarningLabelStyle;
- Texture2D WarningLabelBG;
- GUIStyle GSDImageButton = null;
- GUIStyle GSDMaybeButton = null;
- bool bHasInit = false;
- Texture2D LoadBtnBG = null;
- Texture2D LoadBtnBGGlow = null;
-
- //Buffers:
- //float TempChangeChecker = 0f;
- //bool bMatChange = false;
- bool bNeedRoadUpdate = false;
- bool bSetDefaultMats = false;
- bool bApplyMatsCheck = false;
- bool t_bApplyMatsCheck = false;
-
- private void OnEnable()
- {
- t_opt_GizmosEnabled = serializedObject.FindProperty("opt_GizmosEnabled");
- t_opt_Lanes = serializedObject.FindProperty("opt_Lanes");
- t_opt_LaneWidth = serializedObject.FindProperty("opt_LaneWidth");
- t_opt_bShouldersEnabled = serializedObject.FindProperty("opt_bShouldersEnabled");
- t_opt_ShoulderWidth = serializedObject.FindProperty("opt_ShoulderWidth");
- t_opt_RoadDefinition = serializedObject.FindProperty("opt_RoadDefinition");
- t_opt_UseDefaultMaterials = serializedObject.FindProperty("opt_UseDefaultMaterials");
- t_opt_bMaxGradeEnabled = serializedObject.FindProperty("opt_bMaxGradeEnabled");
- t_opt_MaxGrade = serializedObject.FindProperty("opt_MaxGrade");
- t_opt_bMultithreading = serializedObject.FindProperty("opt_bMultithreading");
- t_opt_bSaveMeshes = serializedObject.FindProperty("opt_bSaveMeshes");
- t_opt_TerrainSubtract_Match = serializedObject.FindProperty("opt_TerrainSubtract_Match");
- t_opt_MagnitudeThreshold = serializedObject.FindProperty("opt_MagnitudeThreshold");
- t_opt_HeightModEnabled = serializedObject.FindProperty("opt_HeightModEnabled");
- t_opt_DetailModEnabled = serializedObject.FindProperty("opt_DetailModEnabled");
- t_opt_TreeModEnabled = serializedObject.FindProperty("opt_TreeModEnabled");
- t_opt_MatchHeightsDistance = serializedObject.FindProperty("opt_MatchHeightsDistance");
- t_opt_ClearDetailsDistance = serializedObject.FindProperty("opt_ClearDetailsDistance");
- t_opt_ClearDetailsDistanceHeight = serializedObject.FindProperty("opt_ClearDetailsDistanceHeight");
- t_opt_ClearTreesDistance = serializedObject.FindProperty("opt_ClearTreesDistance");
- t_opt_ClearTreesDistanceHeight = serializedObject.FindProperty("opt_ClearTreesDistanceHeight");
- t_opt_SaveTerrainHistoryOnDisk = serializedObject.FindProperty("opt_SaveTerrainHistoryOnDisk");
- t_opt_bRoadCuts = serializedObject.FindProperty("opt_bRoadCuts");
- t_opt_bDynamicCuts = serializedObject.FindProperty("opt_bDynamicCuts");
- t_opt_bShoulderCuts = serializedObject.FindProperty("opt_bShoulderCuts");
- t_bEditorCameraRotate = serializedObject.FindProperty("bEditorCameraRotate");
- t_EditorCameraMetersPerSecond = serializedObject.FindProperty("EditorCameraMetersPerSecond");
- t_opt_bUseMeshColliders = serializedObject.FindProperty("opt_bUseMeshColliders");
- t_opt_tRoadMaterialDropdown = serializedObject.FindProperty("opt_tRoadMaterialDropdown");
- t_opt_bIsStatic = serializedObject.FindProperty("opt_bIsStatic");
- t_opt_bIsLightmapped = serializedObject.FindProperty("opt_bIsLightmapped");
-
- t_RoadMaterial1 = serializedObject.FindProperty("RoadMaterial1");
- t_RoadMaterial2 = serializedObject.FindProperty("RoadMaterial2");
- t_RoadMaterial3 = serializedObject.FindProperty("RoadMaterial3");
- t_RoadMaterial4 = serializedObject.FindProperty("RoadMaterial4");
- t_RoadMaterialMarker1 = serializedObject.FindProperty("RoadMaterialMarker1");
- t_RoadMaterialMarker2 = serializedObject.FindProperty("RoadMaterialMarker2");
- t_RoadMaterialMarker3 = serializedObject.FindProperty("RoadMaterialMarker3");
- t_RoadMaterialMarker4 = serializedObject.FindProperty("RoadMaterialMarker4");
- t_ShoulderMaterial1 = serializedObject.FindProperty("ShoulderMaterial1");
- t_ShoulderMaterial2 = serializedObject.FindProperty("ShoulderMaterial2");
- t_ShoulderMaterial3 = serializedObject.FindProperty("ShoulderMaterial3");
- t_ShoulderMaterial4 = serializedObject.FindProperty("ShoulderMaterial4");
- t_ShoulderMaterialMarker1 = serializedObject.FindProperty("ShoulderMaterialMarker1");
- t_ShoulderMaterialMarker2 = serializedObject.FindProperty("ShoulderMaterialMarker2");
- t_ShoulderMaterialMarker3 = serializedObject.FindProperty("ShoulderMaterialMarker3");
- t_ShoulderMaterialMarker4 = serializedObject.FindProperty("ShoulderMaterialMarker4");
- t_RoadPhysicMaterial = serializedObject.FindProperty("RoadPhysicMaterial");
- t_ShoulderPhysicMaterial = serializedObject.FindProperty("ShoulderPhysicMaterial");
- }
-
- void Init()
- {
- bHasInit = true;
- EditorStyles.label.wordWrap = true;
-
- if (WarningLabelBG == null)
- {
- WarningLabelBG = (Texture2D)AssetDatabase.LoadAssetAtPath(GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Editor/Icons/WarningLabelBG.png", typeof(Texture2D)) as Texture2D;
- }
- if (btnRefreshText == null)
- {
- btnRefreshText = (Texture)AssetDatabase.LoadAssetAtPath(GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Editor/Icons/refresh2.png", typeof(Texture)) as Texture;
- }
- if (btnRefreshTextReal == null)
- {
- btnRefreshTextReal = (Texture)AssetDatabase.LoadAssetAtPath(GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Editor/Icons/refresh.png", typeof(Texture)) as Texture;
- }
- if (LoadBtnBG == null)
- {
- LoadBtnBG = (Texture2D)AssetDatabase.LoadAssetAtPath(GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Editor/Icons/otherbg.png", typeof(Texture2D)) as Texture2D;
- }
- if (LoadBtnBGGlow == null)
- {
- LoadBtnBGGlow = (Texture2D)AssetDatabase.LoadAssetAtPath(GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Editor/Icons/otherbg2.png", typeof(Texture2D)) as Texture2D;
- }
- if (btnDeleteText == null)
- {
- btnDeleteText = (Texture)AssetDatabase.LoadAssetAtPath(GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Editor/Icons/delete.png", typeof(Texture)) as Texture;
- }
-
- if (WarningLabelStyle == null)
- {
- WarningLabelStyle = new GUIStyle(GUI.skin.textArea);
- WarningLabelStyle.normal.textColor = Color.red;
- WarningLabelStyle.active.textColor = Color.red;
- WarningLabelStyle.hover.textColor = Color.red;
- WarningLabelStyle.normal.background = WarningLabelBG;
- WarningLabelStyle.active.background = WarningLabelBG;
- WarningLabelStyle.hover.background = WarningLabelBG;
- WarningLabelStyle.padding = new RectOffset(8, 8, 8, 8);
- }
-
- if (GSDImageButton == null)
- {
- GSDImageButton = new GUIStyle(GUI.skin.button);
- GSDImageButton.contentOffset = new Vector2(0f, 0f);
- GSDImageButton.border = new RectOffset(0, 0, 0, 0);
- GSDImageButton.fixedHeight = 16f;
- GSDImageButton.padding = new RectOffset(0, 0, 0, 0);
- GSDImageButton.normal.background = null;
- }
-
- if (GSDLoadButton == null)
- {
- GSDLoadButton = new GUIStyle(GUI.skin.button);
- GSDLoadButton.contentOffset = new Vector2(0f, 1f);
- GSDLoadButton.normal.textColor = new Color(1f, 1f, 1f, 1f);
- GSDLoadButton.normal.background = LoadBtnBG;
- GSDLoadButton.active.background = LoadBtnBGGlow;
- GSDLoadButton.focused.background = LoadBtnBGGlow;
- GSDLoadButton.hover.background = LoadBtnBGGlow;
- GSDLoadButton.fixedHeight = 16f;
- GSDLoadButton.fixedWidth = 128f;
- }
-
- if (GSDMaybeButton == null)
- {
- GSDMaybeButton = new GUIStyle(GUI.skin.button);
- GSDMaybeButton.normal.textColor = new Color(0f, 0f, 0f, 1f);
- }
- }
-
- public override void OnInspectorGUI()
- {
- if (Event.current.type == EventType.ValidateCommand)
- {
- switch (Event.current.commandName)
- {
- case "UndoRedoPerformed":
- TriggerRoadUpdate();
- break;
- }
- }
-
- serializedObject.Update();
-
- bNeedRoadUpdate = false;
- bSetDefaultMats = false;
- //Graphic null checks:
- if (!bHasInit) { Init(); }
-
-
-
- Line();
- EditorGUILayout.BeginHorizontal();
- EditorGUILayout.LabelField(RS.transform.name, EditorStyles.boldLabel);
- if (GUILayout.Button("Update road", GSDLoadButton))
- {
- RS.EditorUpdateMe = true;
- }
-
- EditorGUILayout.EndHorizontal();
-
- EditorGUILayout.LabelField("Hold ctrl and click terrain to add nodes.");
- EditorGUILayout.LabelField("Hold shift and click terrain to insert nodes.");
- EditorGUILayout.LabelField("Select nodes on spline to add objects.");
- EditorGUILayout.LabelField("Road options:");
-
-
- EditorGUILayout.BeginVertical("box");
- EditorGUILayout.BeginHorizontal();
- //Option: Gizmos input:
- t_opt_GizmosEnabled.boolValue = EditorGUILayout.Toggle("Gizmos: ", RS.opt_GizmosEnabled);
- if (GUILayout.Button("Online manual", EditorStyles.miniButton, GUILayout.Width(120f)))
- {
- Application.OpenURL("http://microgsd.com/Support/RoadArchitectManual.aspx");
- }
- EditorGUILayout.EndHorizontal();
-
- //Option: Lane count:
- if (RS.opt_Lanes == 2)
- {
- LanesEnum = tempEnum.Two;
- }
- else if (RS.opt_Lanes == 4)
- {
- LanesEnum = tempEnum.Four;
- }
- else
- {
- LanesEnum = tempEnum.Six;
- }
- tLanesEnum = (tempEnum)EditorGUILayout.Popup("Lanes: ", (int)LanesEnum, tempEnumDescriptions);
- if (tLanesEnum == tempEnum.Two)
- {
- t_opt_Lanes.intValue = 2;
- }
- else if (tLanesEnum == tempEnum.Four)
- {
- t_opt_Lanes.intValue = 4;
- }
- else if (tLanesEnum == tempEnum.Six)
- {
- t_opt_Lanes.intValue = 6;
- }
-
- //Option: Lane and road width:
- EditorGUILayout.BeginHorizontal();
- t_opt_LaneWidth.floatValue = EditorGUILayout.FloatField("Lane width:", RS.opt_LaneWidth);
- if (GUILayout.Button(btnRefreshText, GSDImageButton, GUILayout.Width(16f)))
- {
- t_opt_LaneWidth.floatValue = 5f;
- }
- EditorGUILayout.EndHorizontal();
- EditorGUILayout.LabelField("Road width: " + RS.RoadWidth().ToString("F1") + " meters");
-
- //Option: Shoulders enabled:
- t_opt_bShouldersEnabled.boolValue = EditorGUILayout.Toggle("Shoulders enabled:", RS.opt_bShouldersEnabled);
-
- //Option: Shoulders width:
- if (RS.opt_bShouldersEnabled)
- {
- EditorGUILayout.BeginHorizontal();
- t_opt_ShoulderWidth.floatValue = EditorGUILayout.FloatField("Shoulders width:", RS.opt_ShoulderWidth);
- if (GUILayout.Button(btnRefreshText, GSDImageButton, GUILayout.Width(16f)))
- {
- t_opt_ShoulderWidth.floatValue = 3f;
- }
- EditorGUILayout.EndHorizontal();
- }
-
- //Option: Road definition:
- EditorGUILayout.BeginHorizontal();
- t_opt_RoadDefinition.floatValue = EditorGUILayout.FloatField("Road definition:", RS.opt_RoadDefinition);
- if (GUILayout.Button(btnRefreshText, GSDImageButton, GUILayout.Width(16f)))
- {
- t_opt_RoadDefinition.floatValue = 5f;
- }
- EditorGUILayout.EndHorizontal();
-
- //Option: Use default materials:
- t_opt_UseDefaultMaterials.boolValue = EditorGUILayout.Toggle("Use default materials:", RS.opt_UseDefaultMaterials);
-
- //Dropdown:
- if (RS.opt_UseDefaultMaterials)
- {
- int Old = (int)RS.opt_tRoadMaterialDropdown;
- t_opt_tRoadMaterialDropdown.enumValueIndex = (int)EditorGUILayout.Popup("Road material: ", (int)RS.opt_tRoadMaterialDropdown, RoadMaterialDropdownEnumDesc, GUILayout.Width(250f));
- if (t_opt_tRoadMaterialDropdown.enumValueIndex != Old)
- {
- if (t_opt_tRoadMaterialDropdown.enumValueIndex > 0)
- {
- t_opt_bShouldersEnabled.boolValue = false;
- }
- else
- {
- t_opt_bShouldersEnabled.boolValue = true;
- }
- }
- }
-
- //Option: Max grade enabled:
- t_opt_bMaxGradeEnabled.boolValue = EditorGUILayout.Toggle("Max grade enforced: ", RS.opt_bMaxGradeEnabled);
-
- //Option: Max grade value:
- if (RS.opt_bMaxGradeEnabled)
- {
- EditorGUILayout.BeginHorizontal();
- t_opt_MaxGrade.floatValue = EditorGUILayout.Slider("Max road grade: ", RS.opt_MaxGrade, 0f, 1f);
- if (GUILayout.Button(btnRefreshText, GSDImageButton, GUILayout.Width(16f)))
- {
- t_opt_MaxGrade.floatValue = 0.08f;
- }
- EditorGUILayout.EndHorizontal();
- }
-
- //Mesh colliders:
- if (RS.GSDRS != null)
- {
- t_opt_bUseMeshColliders.boolValue = EditorGUILayout.Toggle("Use mesh colliders: ", RS.opt_bUseMeshColliders);
- }
-
- //Option: Multi-threading option: workaround for UAS submission rules:
- if (RS.GSDRS.opt_bMultithreading != RS.opt_bMultithreading)
- {
- RS.GSDRS.opt_bMultithreading = RS.opt_bMultithreading;
- RS.GSDRS.UpdateAllRoads_MultiThreadOptions();
- }
- if (RS.GSDRS != null)
- {
- t_opt_bMultithreading.boolValue = EditorGUILayout.Toggle("Multithreading: ", RS.GSDRS.opt_bMultithreading);
- }
-
- //Static:
- if (RS.GSDRS != null)
- {
- t_opt_bIsStatic.boolValue = EditorGUILayout.Toggle("Static: ", RS.opt_bIsStatic);
- }
-
- //Used for lightmapping:
- if (RS.GSDRS != null)
- {
- t_opt_bIsLightmapped.boolValue = EditorGUILayout.Toggle("Lightmapped: ", RS.opt_bIsLightmapped);
- }
-
- //Option: Save meshes as unity assets options:
- if (RS.GSDRS.opt_bSaveMeshes != RS.opt_bSaveMeshes)
- {
- RS.GSDRS.opt_bSaveMeshes = RS.opt_bSaveMeshes;
- RS.GSDRS.UpdateAllRoads_SaveMeshesAsAssetsOptions();
- }
- if (RS.GSDRS != null)
- {
- t_opt_bSaveMeshes.boolValue = EditorGUILayout.Toggle("Save mesh assets: ", RS.GSDRS.opt_bSaveMeshes);
- }
- if (RS.GSDRS.opt_bSaveMeshes)
- {
- GUILayout.Label("WARNING: Saving meshes as assets is very slow and can increase road generation time by several minutes.", WarningLabelStyle);
- }
-
- if (GUILayout.Button("Duplicate road", EditorStyles.miniButton, GUILayout.Width(120f)))
- {
- RS.DuplicateRoad();
- }
-
-
- bShowHelpRoad = EditorGUILayout.Foldout(bShowHelpRoad, status);
- if (bShowHelpRoad)
- {
- EditorGUILayout.BeginVertical("box");
- EditorGUILayout.BeginHorizontal();
- EditorGUILayout.LabelField("Road options quick help:", EditorStyles.boldLabel);
- if (GUILayout.Button("Online manual", EditorStyles.miniButton, GUILayout.Width(120f)))
- {
- Application.OpenURL("http://microgsd.com/Support/RoadArchitectManual.aspx");
- }
- EditorGUILayout.EndHorizontal();
- EditorGUILayout.HelpBox(tOnlineHelpDesc, MessageType.Info);
-
- GUILayout.Space(4f); EditorGUILayout.BeginVertical();
- EditorGUILayout.LabelField("Gizmos:", EditorStyles.boldLabel);
- EditorGUILayout.LabelField("Enable or disable most gizmos for this road. Disable mesh collider gizmos via the unity menu if necessary or desired.", EditorStyles.miniLabel);
- EditorGUILayout.EndVertical(); GUILayout.Space(4f); EditorGUILayout.BeginVertical();
- EditorGUILayout.LabelField("Lanes:", EditorStyles.boldLabel);
- EditorGUILayout.LabelField("Select the number of lanes for this road.");
- EditorGUILayout.EndVertical(); GUILayout.Space(4f); EditorGUILayout.BeginVertical();
- EditorGUILayout.LabelField("Lane width:", EditorStyles.boldLabel);
- EditorGUILayout.LabelField("Modify the width per lane, in meters.");
- EditorGUILayout.EndVertical(); GUILayout.Space(4f); EditorGUILayout.BeginVertical();
- EditorGUILayout.LabelField("Road width:", EditorStyles.boldLabel);
- EditorGUILayout.LabelField("Displays the road width without considering shoulders, in meters.");
- EditorGUILayout.EndVertical(); GUILayout.Space(4f); EditorGUILayout.BeginVertical();
- EditorGUILayout.LabelField("Shoulders enabled:", EditorStyles.boldLabel);
- EditorGUILayout.LabelField("Enables or disables shoulders.");
- EditorGUILayout.EndVertical(); GUILayout.Space(4f); EditorGUILayout.BeginVertical();
- EditorGUILayout.LabelField("Shoulders width:", EditorStyles.boldLabel);
- EditorGUILayout.LabelField("Modify the width of shoulders, in meters.");
- EditorGUILayout.EndVertical(); GUILayout.Space(4f); EditorGUILayout.BeginVertical();
- EditorGUILayout.LabelField("Road definition: ", EditorStyles.boldLabel);
- EditorGUILayout.LabelField("The meter spacing between mesh triangles on the road and shoulder.");
- EditorGUILayout.EndVertical(); GUILayout.Space(4f); EditorGUILayout.BeginVertical();
- EditorGUILayout.LabelField("Use default materials: ", EditorStyles.boldLabel);
- EditorGUILayout.LabelField("When enabled will use default materials for the road system, allowing certain aspects of generation to automatically determine the correct materials to utilize.");
- EditorGUILayout.EndVertical(); GUILayout.Space(4f); EditorGUILayout.BeginVertical();
- EditorGUILayout.LabelField("Max grade enforced: ", EditorStyles.boldLabel);
- EditorGUILayout.LabelField("When enabled enforces a maximum grade on a per node basis.");
- EditorGUILayout.EndVertical(); GUILayout.Space(4f); EditorGUILayout.BeginVertical();
- EditorGUILayout.LabelField("Max road grade: ", EditorStyles.boldLabel);
- EditorGUILayout.LabelField("The maximum road grade allowed on a per node basis.");
- EditorGUILayout.EndVertical(); GUILayout.Space(4f); EditorGUILayout.BeginVertical();
- EditorGUILayout.LabelField("Multithreading:", EditorStyles.boldLabel);
- EditorGUILayout.LabelField("When enabled allows for multi-threaded road generation.");
- EditorGUILayout.EndVertical(); GUILayout.Space(4f); EditorGUILayout.BeginVertical();
- EditorGUILayout.LabelField("Save mesh assets:", EditorStyles.boldLabel);
- EditorGUILayout.LabelField("When enabled saves all generated meshes as .asset files.");
- GUILayout.Space(4f);
- EditorGUILayout.BeginHorizontal();
- if (GUILayout.Button(btnRefreshText, GSDImageButton, GUILayout.Width(16f)))
- {
-
- }
- EditorGUILayout.LabelField(" = Resets settings to default.");
- EditorGUILayout.EndHorizontal();
- EditorGUILayout.EndVertical();
- }
- EditorGUILayout.EndVertical();
-
- EditorGUILayout.LabelField("Terrain options:");
- EditorGUILayout.BeginVertical("box");
-
- //Option: Terrain subtraction:
- EditorGUILayout.BeginHorizontal();
- t_opt_TerrainSubtract_Match.floatValue = EditorGUILayout.Slider("Terrain subtraction: ", RS.opt_TerrainSubtract_Match, 0.01f, 1f);
- if (GUILayout.Button(btnRefreshText, GSDImageButton, GUILayout.Width(16f)))
- {
- t_opt_TerrainSubtract_Match.floatValue = 0.01f;
- }
- EditorGUILayout.EndHorizontal();
-
- //Option: Spline magnitude limit:
- EditorGUILayout.BeginHorizontal();
- t_opt_MagnitudeThreshold.floatValue = EditorGUILayout.Slider("Spline magnitude limit: ", RS.opt_MagnitudeThreshold, 128f, 8192f);
- if (GUILayout.Button(btnRefreshText, GSDImageButton, GUILayout.Width(16f)))
- {
- t_opt_MagnitudeThreshold.floatValue = 300f;
- }
- EditorGUILayout.EndHorizontal();
-
- //Option: Height modification
- t_opt_HeightModEnabled.boolValue = EditorGUILayout.Toggle("Height modification: ", RS.opt_HeightModEnabled);
-
- //Option: Active detail removal
- t_opt_DetailModEnabled.boolValue = EditorGUILayout.Toggle("Active detail removal: ", RS.opt_DetailModEnabled);
-
- //Option: Active tree removal
- t_opt_TreeModEnabled.boolValue = EditorGUILayout.Toggle("Active tree removal: ", RS.opt_TreeModEnabled);
-
- //Option: heights width
- if (RS.opt_HeightModEnabled)
- {
- EditorGUILayout.BeginHorizontal();
- t_opt_MatchHeightsDistance.floatValue = EditorGUILayout.Slider("Heights match width: ", RS.opt_MatchHeightsDistance, 0.01f, 512f);
- if (GUILayout.Button(btnRefreshText, GSDImageButton, GUILayout.Width(16f)))
- {
- t_opt_MatchHeightsDistance.floatValue = 50f;
- }
- EditorGUILayout.EndHorizontal();
- }
-
- //Option: details width and height
- if (RS.opt_DetailModEnabled)
- {
- EditorGUILayout.BeginHorizontal();
- t_opt_ClearDetailsDistance.floatValue = EditorGUILayout.Slider("Details clear width: ", RS.opt_ClearDetailsDistance, 0.01f, 512f);
- if (GUILayout.Button(btnRefreshText, GSDImageButton, GUILayout.Width(16f)))
- {
- t_opt_ClearDetailsDistance.floatValue = 30f;
- }
-
- EditorGUILayout.EndHorizontal();
-
- EditorGUILayout.BeginHorizontal();
- t_opt_ClearDetailsDistanceHeight.floatValue = EditorGUILayout.Slider("Details clear height: ", RS.opt_ClearDetailsDistanceHeight, 0.01f, 512f);
- if (GUILayout.Button(btnRefreshText, GSDImageButton, GUILayout.Width(16f)))
- {
- t_opt_ClearDetailsDistanceHeight.floatValue = 5f;
- }
-
- EditorGUILayout.EndHorizontal();
- }
-
- //Option: tree widths and height
- if (RS.opt_TreeModEnabled)
- {
- EditorGUILayout.BeginHorizontal();
- t_opt_ClearTreesDistance.floatValue = EditorGUILayout.Slider("Trees clear width: ", RS.opt_ClearTreesDistance, 0.01f, 512f);
- if (GUILayout.Button(btnRefreshText, GSDImageButton, GUILayout.Width(16f)))
- {
- t_opt_ClearTreesDistance.floatValue = 30f;
- }
- EditorGUILayout.EndHorizontal();
-
- EditorGUILayout.BeginHorizontal();
- t_opt_ClearTreesDistanceHeight.floatValue = EditorGUILayout.Slider("Trees clear height: ", RS.opt_ClearTreesDistanceHeight, 0.01f, 512f);
- if (GUILayout.Button(btnRefreshText, GSDImageButton, GUILayout.Width(16f)))
- {
- t_opt_ClearTreesDistanceHeight.floatValue = 50f;
- }
- EditorGUILayout.EndHorizontal();
- }
-
-
- //Option: terrain history save type:
- EditorGUILayout.BeginHorizontal();
- EditorGUILayout.LabelField("Store terrain history separate from scene:");
- t_opt_SaveTerrainHistoryOnDisk.boolValue = EditorGUILayout.Toggle(RS.opt_SaveTerrainHistoryOnDisk, GUILayout.Width(50f));
- EditorGUILayout.EndHorizontal();
-
- EditorGUILayout.LabelField("Terrain history size: " + RS.TerrainHistoryByteSize);
-
- bShowHelpTerrain = EditorGUILayout.Foldout(bShowHelpTerrain, status);
- if (bShowHelpTerrain)
- {
- EditorGUILayout.BeginVertical("box");
- EditorGUILayout.BeginHorizontal();
- EditorGUILayout.LabelField("Terrain options quick help:", EditorStyles.boldLabel);
- if (GUILayout.Button("Online manual", EditorStyles.miniButton, GUILayout.Width(120f)))
- {
- Application.OpenURL("http://microgsd.com/Support/RoadArchitectManual.aspx");
- }
- EditorGUILayout.EndHorizontal();
- EditorGUILayout.HelpBox(tOnlineHelpDesc, MessageType.Info);
- EditorGUILayout.LabelField("Terrain subtraction: ", EditorStyles.boldLabel);
- EditorGUILayout.LabelField("This value, in meters, will be subtracted from the terrain match height to prevent z-fighting.");
- GUILayout.Space(4f);
- EditorGUILayout.LabelField("Spline magnitude limit: ", EditorStyles.boldLabel);
- EditorGUILayout.LabelField("Limits the magnitude of the spline nodes. Lower limit is better for typical roads with node seperation of around 100 to 300 meters. Higher limits will allow for less tension when using very spread out nodes.");
- GUILayout.Space(4f);
- EditorGUILayout.LabelField("Height Modification:", EditorStyles.boldLabel);
- EditorGUILayout.LabelField("Enables or disables height matching for the terrain.");
- GUILayout.Space(4f);
- EditorGUILayout.LabelField("Active detail removal:", EditorStyles.boldLabel);
- EditorGUILayout.LabelField("Enables or disables active detail removal. Memory intensive on large terrains with large amounts of details. Recommended to not use this option and instead remove details and trees via splat maps with other addons.");
- GUILayout.Space(4f);
- EditorGUILayout.LabelField("Active tree removal:", EditorStyles.boldLabel);
- EditorGUILayout.LabelField("Enables or disables active tree removal. Memory intensive on large terrains with large amounts of trees. Recommended to not use this option and instead remove details and trees via splat maps with other addons.");
- GUILayout.Space(4f);
- EditorGUILayout.LabelField("Heights match width:", EditorStyles.boldLabel);
- EditorGUILayout.LabelField("The distance to the left and right of the road in which terrain heights will be matched to the road.");
- GUILayout.Space(4f);
- EditorGUILayout.LabelField("Details clear width:", EditorStyles.boldLabel);
- EditorGUILayout.LabelField("The distance between the road and detail, width wise, in which details will be removed.");
- GUILayout.Space(4f);
- EditorGUILayout.LabelField("Details clear height:", EditorStyles.boldLabel);
- EditorGUILayout.LabelField("The distance between the road and detail, height wise, in which details will be removed.");
- GUILayout.Space(4f);
- EditorGUILayout.LabelField("Tree clear width:", EditorStyles.boldLabel);
- EditorGUILayout.LabelField("The distance between the road and tree, width wise, in which trees will be removed.");
- GUILayout.Space(4f);
- EditorGUILayout.LabelField("Tree clear height:", EditorStyles.boldLabel);
- EditorGUILayout.LabelField("The distance between the road and tree, height wise, in which trees will be removed.");
- GUILayout.Space(4f);
- EditorGUILayout.LabelField("Store terrain history separate from scene:", EditorStyles.boldLabel);
- EditorGUILayout.LabelField("If enabled, stores the terrain history immediately on disk after use, saving memory while in editor.");
- GUILayout.Space(4f);
- EditorGUILayout.LabelField("Terrain history size:", EditorStyles.boldLabel);
- EditorGUILayout.LabelField("Shows the size, in kilobytes, of the terrain history in memory or on disk.");
- GUILayout.Space(4f);
- EditorGUILayout.BeginHorizontal();
- if (GUILayout.Button(btnRefreshText, GSDImageButton, GUILayout.Width(16f)))
- {
-
- }
- EditorGUILayout.LabelField(" = Resets settings to default.");
- EditorGUILayout.EndHorizontal();
- }
- EditorGUILayout.EndVertical();
-
-
-
- GUILayout.Label("Road and shoulder splitting:");
- EditorGUILayout.BeginVertical("box");
- GUILayout.Space(4f);
-
- //Option: road cuts:
- if (!RS.opt_bDynamicCuts)
- {
- EditorGUILayout.BeginHorizontal();
- t_opt_bRoadCuts.boolValue = EditorGUILayout.Toggle("Auto split road: ", RS.opt_bRoadCuts);
- if (GUILayout.Button(btnRefreshText, GSDImageButton, GUILayout.Width(16f)))
- {
- t_opt_bDynamicCuts.boolValue = false;
- t_opt_bRoadCuts.boolValue = true;
- t_opt_bShoulderCuts.boolValue = true;
- }
- EditorGUILayout.EndHorizontal();
-
- if (RS.opt_bShouldersEnabled)
- {
- t_opt_bShoulderCuts.boolValue = EditorGUILayout.Toggle("Auto split shoulders: ", RS.opt_bShoulderCuts);
- }
- }
- else
- {
- EditorGUILayout.BeginHorizontal();
- EditorGUILayout.LabelField("Manual road splitting: true");
- if (GUILayout.Button(btnRefreshText, GSDImageButton, GUILayout.Width(16f)))
- {
- t_opt_bDynamicCuts.boolValue = false;
- t_opt_bRoadCuts.boolValue = true;
- t_opt_bShoulderCuts.boolValue = true;
- }
- EditorGUILayout.EndHorizontal();
-
- EditorGUILayout.LabelField("Manual shoulder splitting: true");
- }
- t_opt_bDynamicCuts.boolValue = EditorGUILayout.Toggle("Manual splitting: ", RS.opt_bDynamicCuts);
-
-
- bShowCutsHelp = EditorGUILayout.Foldout(bShowCutsHelp, status);
- if (bShowCutsHelp)
- {
- EditorGUILayout.BeginVertical("box");
- EditorGUILayout.BeginHorizontal();
- EditorGUILayout.LabelField("Road splitting quick help:", EditorStyles.boldLabel);
- if (GUILayout.Button("Online manual", EditorStyles.miniButton, GUILayout.Width(120f)))
- {
- Application.OpenURL("http://microgsd.com/Support/RoadArchitectManual.aspx");
- }
- EditorGUILayout.EndHorizontal();
- EditorGUILayout.HelpBox(tOnlineHelpDesc, MessageType.Info);
-
- EditorGUILayout.LabelField("Typically auto-split will be the best choice for performance and other reasons.");
- GUILayout.Space(4f);
- EditorGUILayout.LabelField("Choosing split options will split the road/shoulder up into pieces mirroring the locations of nodes.");
- GUILayout.Space(4f);
- EditorGUILayout.LabelField("Splitting allows for more detailed and flexible road texturing options such as passing sections, other different road lines per section, road debris and more.");
- GUILayout.Space(4f);
- EditorGUILayout.LabelField("Choosing split options may also speed up mesh collider collision calculations if bounds calculations are involved.");
- GUILayout.Space(4f);
-
- EditorGUILayout.LabelField("Which splitting option to choose?", EditorStyles.boldLabel);
- EditorGUILayout.LabelField("Choose no splitting if you desire a single material set for this entire road and your game experiences no collison processing slowdowns from one large mesh collider. This option will create less game objects than automatic and manual splitting.");
- GUILayout.Space(4f);
- EditorGUILayout.LabelField("Choose automatic road and shoulder splitting if you desire multiple materials (such as yellow double lines for certain sections and white dotted for others) for this road and or your game experiences collision processing slowdowns from one large mesh collider.");
- GUILayout.Space(4f);
- EditorGUILayout.LabelField("Choose manual road and shoulder splitting if you desire the same as automatic splitting and desire more freedom over the process. This option will result in less gameobjects and larger mesh colliders when compared to automatic splitting.");
- GUILayout.Space(4f);
-
-
- Line();
- EditorGUILayout.LabelField("Manual splitting information: ");
- GUILayout.Space(4f);
- EditorGUILayout.LabelField("Choosing manual splitting will force the user to select individual nodes to cut instead of the cuts being performed automatically. This option is recommended if bigger mesh colliders do not cause a slowdown in performance, as it lowers the overall gameobject count.");
- GUILayout.Space(4f);
- EditorGUILayout.LabelField("Manual splitting will not split up the mesh colliders like automatic cuts, so the colliders may get large & complex and cost more CPU to process collisions. If this option is chosen, please verify your game's collision processing speed and if you run into long collision processing times split more road sections");
- GUILayout.Space(4f);
- EditorGUILayout.LabelField("Example usages of manual splitting");
- GUILayout.Space(4f);
- EditorGUILayout.LabelField("Example hill: Goal is to have double yellow no passing lines on a two lane road but only while the road is near or on the hill. " +
- "Pick nodes on either sides of the hill and mark both as road cut. Everything between these two nodes will be its own section, " +
- "allowing you to apply double yellow no passing lines for just the hill.");
- GUILayout.Space(4f);
- EditorGUILayout.LabelField("Example mountains: In the mountains, the road is curvy and the grade is high. " +
- "There's a flat straight spot that you want to allow passing in, by marking the road with white dotted passing lines. " +
- "At the beginning of the flat straight section, mark the node as road cut. Now at the end of the flat straight section, mark this node as road cut. " +
- "This will create a road section between the two nodes, allowing you to apply white dotted passing lines for just the flat straight section.");
- GUILayout.Space(4f);
- EditorGUILayout.BeginHorizontal();
- if (GUILayout.Button(btnRefreshText, GSDImageButton, GUILayout.Width(16f)))
- {
-
- }
- EditorGUILayout.LabelField(" = Resets settings to default.");
- EditorGUILayout.EndHorizontal();
- EditorGUILayout.EndVertical();
- }
- else
- {
- GUILayout.Space(4f);
- }
- EditorGUILayout.EndVertical();
-
-
- //Camera:
- EditorGUILayout.LabelField("Editor camera travel:");
- EditorGUILayout.BeginVertical("box");
- EditorGUILayout.BeginHorizontal();
-
- //Option: Editor camera meters per sec
- t_EditorCameraMetersPerSecond.floatValue = EditorGUILayout.Slider("Camera meters/sec:", RS.EditorCameraMetersPerSecond, 1f, 512f);
- if (GUILayout.Button(btnRefreshText, GSDImageButton, GUILayout.Width(16f)))
- {
- t_EditorCameraMetersPerSecond.floatValue = 60f;
- }
- EditorGUILayout.EndHorizontal();
-
- //Option: Editor camera auto rotate:
- t_bEditorCameraRotate.boolValue = EditorGUILayout.Toggle("Camera auto rotate: ", RS.bEditorCameraRotate);
- if (RS.EditorPlayCamera == null)
- {
- RS.EditorCameraSetSingle();
- }
- RS.EditorPlayCamera = (Camera)EditorGUILayout.ObjectField("Editor play camera:", RS.EditorPlayCamera, typeof(Camera), true);
- EditorGUILayout.BeginHorizontal();
- if (GUILayout.Button("Reset", GUILayout.Width(70f)))
- {
- RS.QuitEditorCamera();
- RS.DoEditorCameraLoop();
- }
- if (GUILayout.Button("<<", GUILayout.Width(40f)))
- {
- RS.EditorCameraPos -= 0.1f;
- RS.DoEditorCameraLoop();
- }
- if (RS.bEditorCameraMoving == true)
- {
- if (GUILayout.Button("Pause", GUILayout.Width(70f)))
- {
- RS.bEditorCameraMoving = false;
- }
- }
- else
- {
- if (GUILayout.Button("Play", GUILayout.Width(70f)))
- {
- RS.bEditorCameraMoving = true;
- }
- }
- if (GUILayout.Button(">>", GUILayout.Width(40f)))
- {
- RS.EditorCameraPos += 0.1f;
- RS.DoEditorCameraLoop();
- }
- EditorGUILayout.EndHorizontal();
-
- GUILayout.Space(4);
- bShowCameraHelp = EditorGUILayout.Foldout(bShowCameraHelp, status);
- if (bShowCameraHelp)
- {
- EditorGUILayout.BeginVertical("box");
- EditorGUILayout.BeginHorizontal();
- EditorGUILayout.LabelField("Editor camera quick help:", EditorStyles.boldLabel);
- if (GUILayout.Button("Online manual", EditorStyles.miniButton, GUILayout.Width(120f)))
- {
- Application.OpenURL("http://microgsd.com/Support/RoadArchitectManual.aspx");
- }
- EditorGUILayout.EndHorizontal();
- EditorGUILayout.HelpBox(tOnlineHelpDesc, MessageType.Info);
- EditorGUILayout.LabelField("Use this section to travel along the road while in the editor sceneview.");
- GUILayout.Space(4f);
- EditorGUILayout.LabelField("Camera meters/sec is the speed at which the camera moves along the road.");
- GUILayout.Space(4f);
- EditorGUILayout.LabelField("Auto rotate will automatically rotate the camera to look forward at the current road's tangent. Note: You can still zoom in and out with the camera with this option selected.");
- GUILayout.Space(4f);
- EditorGUILayout.LabelField("Note: Materials act differently in the editor scene view compared to actual gameplay. Try the game camera if the materials are z fighting and having other issues.");
- GUILayout.Space(4f);
- EditorGUILayout.BeginHorizontal();
- if (GUILayout.Button(btnRefreshText, GSDImageButton, GUILayout.Width(16f)))
- {
-
- }
- EditorGUILayout.LabelField(" = Resets settings to default.");
- EditorGUILayout.EndHorizontal();
- EditorGUILayout.EndVertical();
- }
- EditorGUILayout.EndVertical();
-
- GUILayout.Label("Materials:");
- EditorGUILayout.BeginVertical("box");
- //Road material defaults:
-
- EditorGUILayout.BeginHorizontal();
- GUILayout.Label("Road base material(s) defaults:");
- //Option: Set mats to defaults:
- bSetDefaultMats = false;
- if (GUILayout.Button(btnRefreshText, GSDImageButton, GUILayout.Width(16f)))
- {
- bSetDefaultMats = true;
- }
- EditorGUILayout.EndHorizontal();
- // EditorGUILayout.PropertyField (t_RoadMaterial1, new GUIContent (" Mat #1: "));
- // if(RS.RoadMaterial1 != null){ EditorGUILayout.PropertyField (t_RoadMaterial2, new GUIContent (" Mat #2: ")); }
- // if(RS.RoadMaterial2 != null){EditorGUILayout.PropertyField (t_RoadMaterial3, new GUIContent (" Mat #3: ")); }
- // if(RS.RoadMaterial3 != null){EditorGUILayout.PropertyField (t_RoadMaterial4, new GUIContent (" Mat #4: ")); }
-
-
- EditorGUILayout.BeginHorizontal();
- EditorGUILayout.PropertyField(t_RoadMaterial1, new GUIContent(" Mat #1: "));
- if (RS.RoadMaterial1 != null && GUILayout.Button(btnDeleteText, GSDImageButton, GUILayout.Width(16f))) { RS.RoadMaterial1 = null; }
- EditorGUILayout.EndHorizontal();
- if (RS.RoadMaterial1 != null)
- {
- EditorGUILayout.BeginHorizontal();
- EditorGUILayout.PropertyField(t_RoadMaterial2, new GUIContent(" Mat #2: "));
- if (RS.RoadMaterial2 != null && GUILayout.Button(btnDeleteText, GSDImageButton, GUILayout.Width(16f))) { RS.RoadMaterial2 = null; }
- EditorGUILayout.EndHorizontal();
- }
- if (RS.RoadMaterial1 != null && RS.RoadMaterial2 != null)
- {
- EditorGUILayout.BeginHorizontal();
- EditorGUILayout.PropertyField(t_RoadMaterial3, new GUIContent(" Mat #3: "));
- if (RS.RoadMaterial3 != null && GUILayout.Button(btnDeleteText, GSDImageButton, GUILayout.Width(16f))) { RS.RoadMaterial3 = null; }
- EditorGUILayout.EndHorizontal();
- }
- if (RS.RoadMaterial1 != null && RS.RoadMaterial2 != null && RS.RoadMaterial3 != null)
- {
- EditorGUILayout.BeginHorizontal();
- EditorGUILayout.PropertyField(t_RoadMaterial4, new GUIContent(" Mat #4: "));
- if (RS.RoadMaterial4 != null && GUILayout.Button(btnDeleteText, GSDImageButton, GUILayout.Width(16f))) { RS.RoadMaterial4 = null; }
- EditorGUILayout.EndHorizontal();
- }
-
-
-
-
-
-
- // //Road marker material defaults:
- GUILayout.Label("Road marker material(s) defaults:");
- // EditorGUILayout.PropertyField (t_RoadMaterialMarker1, new GUIContent (" Mat #1: "));
- // if(RS.RoadMaterialMarker1 != null){EditorGUILayout.PropertyField (t_RoadMaterialMarker2, new GUIContent (" Mat #2: ")); }
- // if(RS.RoadMaterialMarker2 != null){EditorGUILayout.PropertyField (t_RoadMaterialMarker3, new GUIContent (" Mat #3: ")); }
- // if(RS.RoadMaterialMarker3 != null){EditorGUILayout.PropertyField (t_RoadMaterialMarker4, new GUIContent (" Mat #4: ")); }
-
- EditorGUILayout.BeginHorizontal();
- EditorGUILayout.PropertyField(t_RoadMaterialMarker1, new GUIContent(" Mat #1: "));
- if (RS.RoadMaterialMarker1 != null && GUILayout.Button(btnDeleteText, GSDImageButton, GUILayout.Width(16f))) { RS.RoadMaterialMarker1 = null; }
- EditorGUILayout.EndHorizontal();
- if (RS.RoadMaterialMarker1 != null)
- {
- EditorGUILayout.BeginHorizontal();
- EditorGUILayout.PropertyField(t_RoadMaterialMarker2, new GUIContent(" Mat #2: "));
- if (RS.RoadMaterialMarker2 != null && GUILayout.Button(btnDeleteText, GSDImageButton, GUILayout.Width(16f))) { RS.RoadMaterialMarker2 = null; }
- EditorGUILayout.EndHorizontal();
- }
- if (RS.RoadMaterialMarker1 != null && RS.RoadMaterialMarker2 != null)
- {
- EditorGUILayout.BeginHorizontal();
- EditorGUILayout.PropertyField(t_RoadMaterialMarker3, new GUIContent(" Mat #3: "));
- if (RS.RoadMaterialMarker3 != null && GUILayout.Button(btnDeleteText, GSDImageButton, GUILayout.Width(16f))) { RS.RoadMaterialMarker3 = null; }
- EditorGUILayout.EndHorizontal();
- }
- if (RS.RoadMaterialMarker1 != null && RS.RoadMaterialMarker2 != null && RS.RoadMaterialMarker3 != null)
- {
- EditorGUILayout.BeginHorizontal();
- EditorGUILayout.PropertyField(t_RoadMaterialMarker4, new GUIContent(" Mat #4: "));
- if (RS.RoadMaterialMarker4 != null && GUILayout.Button(btnDeleteText, GSDImageButton, GUILayout.Width(16f))) { RS.RoadMaterialMarker4 = null; }
- EditorGUILayout.EndHorizontal();
- }
-
-
-
-
- // //Shoulder material defaults:
- if (RS.opt_bShouldersEnabled)
- {
- GUILayout.Label("Shoulder base material(s) defaults:");
- // EditorGUILayout.PropertyField (t_ShoulderMaterial1, new GUIContent (" Mat #1: "));
- // if(RS.ShoulderMaterial1 != null){EditorGUILayout.PropertyField (t_ShoulderMaterial2, new GUIContent (" Mat #2: ")); }
- // if(RS.ShoulderMaterial2 != null){EditorGUILayout.PropertyField (t_ShoulderMaterial3, new GUIContent (" Mat #3: ")); }
- // if(RS.ShoulderMaterial3 != null){EditorGUILayout.PropertyField (t_ShoulderMaterial4, new GUIContent (" Mat #4: ")); }
-
- EditorGUILayout.BeginHorizontal();
- EditorGUILayout.PropertyField(t_ShoulderMaterial1, new GUIContent(" Mat #1: "));
- if (RS.ShoulderMaterial1 != null && GUILayout.Button(btnDeleteText, GSDImageButton, GUILayout.Width(16f))) { RS.ShoulderMaterial1 = null; }
- EditorGUILayout.EndHorizontal();
- if (RS.ShoulderMaterial1 != null)
- {
- EditorGUILayout.BeginHorizontal();
- EditorGUILayout.PropertyField(t_ShoulderMaterial2, new GUIContent(" Mat #2: "));
- if (RS.ShoulderMaterial2 != null && GUILayout.Button(btnDeleteText, GSDImageButton, GUILayout.Width(16f))) { RS.ShoulderMaterial2 = null; }
- EditorGUILayout.EndHorizontal();
- }
- if (RS.ShoulderMaterial1 != null && RS.ShoulderMaterial2 != null)
- {
- EditorGUILayout.BeginHorizontal();
- EditorGUILayout.PropertyField(t_ShoulderMaterial3, new GUIContent(" Mat #3: "));
- if (RS.ShoulderMaterial3 != null && GUILayout.Button(btnDeleteText, GSDImageButton, GUILayout.Width(16f))) { RS.ShoulderMaterial3 = null; }
- EditorGUILayout.EndHorizontal();
- }
- if (RS.ShoulderMaterial1 != null && RS.ShoulderMaterial2 != null && RS.ShoulderMaterial3 != null)
- {
- EditorGUILayout.BeginHorizontal();
- EditorGUILayout.PropertyField(t_ShoulderMaterial4, new GUIContent(" Mat #4: "));
- if (RS.ShoulderMaterial4 != null && GUILayout.Button(btnDeleteText, GSDImageButton, GUILayout.Width(16f))) { RS.ShoulderMaterial4 = null; }
- EditorGUILayout.EndHorizontal();
- }
- }
-
-
-
-
- // //Shoulder marker material defaults:
- if (RS.opt_bShouldersEnabled)
- {
- GUILayout.Label("Shoulder marker material(s) defaults:");
- // EditorGUILayout.PropertyField (t_ShoulderMaterialMarker1, new GUIContent (" Mat #1: "));
- // if(RS.ShoulderMaterialMarker1 != null){EditorGUILayout.PropertyField (t_ShoulderMaterialMarker2, new GUIContent (" Mat #2: ")); }
- // if(RS.ShoulderMaterialMarker2 != null){EditorGUILayout.PropertyField (t_ShoulderMaterialMarker3, new GUIContent (" Mat #3: ")); }
- // if(RS.ShoulderMaterialMarker3 != null){EditorGUILayout.PropertyField (t_ShoulderMaterialMarker4, new GUIContent (" Mat #4: ")); }
-
- EditorGUILayout.BeginHorizontal();
- EditorGUILayout.PropertyField(t_ShoulderMaterialMarker1, new GUIContent(" Mat #1: "));
- if (RS.ShoulderMaterialMarker1 != null && GUILayout.Button(btnDeleteText, GSDImageButton, GUILayout.Width(16f))) { RS.ShoulderMaterialMarker1 = null; }
- EditorGUILayout.EndHorizontal();
- if (RS.ShoulderMaterialMarker1 != null)
- {
- EditorGUILayout.BeginHorizontal();
- EditorGUILayout.PropertyField(t_ShoulderMaterialMarker2, new GUIContent(" Mat #2: "));
- if (RS.ShoulderMaterialMarker2 != null && GUILayout.Button(btnDeleteText, GSDImageButton, GUILayout.Width(16f))) { RS.ShoulderMaterialMarker2 = null; }
- EditorGUILayout.EndHorizontal();
- }
- if (RS.ShoulderMaterialMarker1 != null && RS.ShoulderMaterialMarker2 != null)
- {
- EditorGUILayout.BeginHorizontal();
- EditorGUILayout.PropertyField(t_ShoulderMaterialMarker3, new GUIContent(" Mat #3: "));
- if (RS.ShoulderMaterialMarker3 != null && GUILayout.Button(btnDeleteText, GSDImageButton, GUILayout.Width(16f))) { RS.ShoulderMaterialMarker3 = null; }
- EditorGUILayout.EndHorizontal();
- }
- if (RS.ShoulderMaterialMarker1 != null && RS.ShoulderMaterialMarker2 != null && RS.ShoulderMaterialMarker3 != null)
- {
- EditorGUILayout.BeginHorizontal();
- EditorGUILayout.PropertyField(t_ShoulderMaterialMarker4, new GUIContent(" Mat #4: "));
- if (RS.ShoulderMaterialMarker4 != null && GUILayout.Button(btnDeleteText, GSDImageButton, GUILayout.Width(16f))) { RS.ShoulderMaterialMarker4 = null; }
- EditorGUILayout.EndHorizontal();
- }
- }
-
-
-
- //Physics materials:
- GUILayout.Label("Physics materials defaults:");
- //Option: physical road mat:
- // t_RoadPhysicMaterial.serializedObject = (PhysicMaterial)EditorGUILayout.ObjectField(" Road mat: ",RS.RoadPhysicMaterial,typeof(PhysicMaterial),false);
- EditorGUILayout.PropertyField(t_RoadPhysicMaterial, new GUIContent("Road phys mat: "));
-
-
- //Option: physical shoulder mat:
- // t_ShoulderPhysicMaterial.serializedObject = (PhysicMaterial)EditorGUILayout.ObjectField(" Shoulder mat: ",RS.ShoulderPhysicMaterial,typeof(PhysicMaterial),false);
- EditorGUILayout.PropertyField(t_ShoulderPhysicMaterial, new GUIContent("Shoulder phys mat: "));
-
-
- GUILayout.Space(4);
- EditorGUILayout.BeginHorizontal();
- //Option: Apply above materials to entire road:
- EditorGUILayout.LabelField("Apply above materials to entire road:");
- bApplyMatsCheck = EditorGUILayout.Toggle(bApplyMatsCheck, GUILayout.Width(20f));
- if (GUILayout.Button("Apply", EditorStyles.miniButton, GUILayout.Width(60f)))
- {
- if (bApplyMatsCheck)
- {
- t_bApplyMatsCheck = true;
- }
- }
- EditorGUILayout.EndHorizontal();
- EditorGUILayout.LabelField("Applying will overwrite any saved cuts' material(s).");
-
- //Help toggle for materials
- GUILayout.Space(4);
- bShowMatsHelp = EditorGUILayout.Foldout(bShowMatsHelp, status);
- if (bShowMatsHelp)
- {
- EditorGUILayout.BeginVertical("box");
- EditorGUILayout.LabelField("These default materials will be applied by default to their respective generated meshes. If using split roads and or shoulders, you can specific specific materials to use on them (on the mesh renderers of the cuts) and they will be used instead of the default materials listed above.");
- GUILayout.Space(4f);
- EditorGUILayout.LabelField("Road base material is UV mapped on a world vector basis for seamless tiles.");
- GUILayout.Space(4f);
- EditorGUILayout.LabelField("Road marker material is UV mapped to fit roads. Use these materials to place road lines and other road texture details. Note: if using road cuts, these are the materials which will be placed by default at the initial generation.");
- GUILayout.Space(4f);
- EditorGUILayout.LabelField("Shoulder base material is UV mapped on a world vector basis for seamless tiles.");
- GUILayout.Space(4f);
- EditorGUILayout.LabelField("Shoulder marker material is UV mapped on a world vector basis for seamless tiles. For intended use with transparent shadow receiving shaders. Marker materials are applied, optionally, on shoulder cuts.");
- GUILayout.Space(4f);
- EditorGUILayout.LabelField("The physical material for road will be used on all road colliders. The physical material for shoulder will be used on all shoulder colliders. If using road and or shoulder cuts, you can specficy unique physics materials which will be used instead of the default physics materials.");
- GUILayout.Space(4f);
- EditorGUILayout.LabelField("Apply above materials button will clear all saved materials on the roads and all road and shoulder meshes will use the materials listed above.");
- GUILayout.Space(4f);
- EditorGUILayout.BeginHorizontal();
- if (GUILayout.Button(btnRefreshText, GSDImageButton, GUILayout.Width(16f)))
- {
-
- }
- EditorGUILayout.LabelField(" = Resets settings to default.");
- EditorGUILayout.EndHorizontal();
- EditorGUILayout.EndVertical();
- }
- EditorGUILayout.EndVertical();
-
- //Reset terrain history:
- Line();
- EditorGUILayout.BeginHorizontal();
- EditorGUILayout.LabelField("Reset road's terrain history:");
- bResetTH = EditorGUILayout.Toggle(bResetTH, GUILayout.Width(20f));
- if (bResetTH)
- {
- if (GUILayout.Button("Reset") && bResetTH)
- {
- RS.ConstructRoad_ResetTerrainHistory();
- bResetTH = false;
- }
- }
- else
- {
- if (GUILayout.Button("Check to reset", GSDMaybeButton) && bResetTH)
- {
- RS.ConstructRoad_ResetTerrainHistory();
- bResetTH = false;
- }
- }
- EditorGUILayout.EndHorizontal();
-
- if (bResetTH)
- {
- EditorGUILayout.LabelField("WARNING: This option can't be undone! Only reset the terrain history if you have changed terrain resolution data such as heightmap or detail resolutions. A rare event may occur when editing and compiling this addon's scripts that a terrain history reset may be necessary. Treat this reset as a last resort.", WarningLabelStyle);
- }
- GUILayout.Space(6f);
-
-
- EditorGUILayout.LabelField("Statistics:");
- EditorGUILayout.BeginVertical("box");
- EditorGUILayout.LabelField("Length: " + RS.GSDSpline.distance.ToString("F1") + " meters");
- EditorGUILayout.LabelField("Total nodes: " + RS.MostRecentNodeCount.ToString());
- EditorGUILayout.EndVertical();
-
- bool bGizmoChange = false;
- bool bLaneChange = false;
- bool bMultithreadChange = false;
- bool bSaveMeshChange = false;
- bool bTerrainHistoryChange = false;
- bool bEditorCameraSpeedChange = false;
-
- if (GUI.changed)
- {
- //Option pre-handle: Gizmos:
- if (t_opt_GizmosEnabled.boolValue != RS.opt_GizmosEnabled)
- {
- bGizmoChange = true;
- RS.Wireframes_Toggle();
- SceneView.RepaintAll();
- }
- //Option pre-handle: Lane count:
- if (t_opt_Lanes.intValue != RS.opt_Lanes)
- {
- bNeedRoadUpdate = true;
- bLaneChange = true;
- }
-
- //Option pre-handle for multithread and save mesh:
- if (RS.GSDRS != null)
- {
- if (t_opt_bMultithreading.boolValue != RS.GSDRS.opt_bMultithreading)
- {
- RS.GSDRS.opt_bMultithreading = t_opt_bMultithreading.boolValue;
- bMultithreadChange = true;
- }
- if (t_opt_bSaveMeshes.boolValue != RS.GSDRS.opt_bSaveMeshes)
- {
- RS.GSDRS.opt_bSaveMeshes = t_opt_bSaveMeshes.boolValue;
- bSaveMeshChange = true;
- }
- }
-
- //Option pre-handle for terrain history:
- if (t_opt_SaveTerrainHistoryOnDisk.boolValue != RS.opt_SaveTerrainHistoryOnDisk)
- {
- bTerrainHistoryChange = true;
- }
-
- //Option pre-handle for editor camera speed:
- if (!GSDRootUtil.IsApproximately(t_EditorCameraMetersPerSecond.floatValue, RS.EditorCameraMetersPerSecond, 0.001f))
- {
- bEditorCameraSpeedChange = true;
- }
-
- //Apply serialization:
- serializedObject.ApplyModifiedProperties();
-
-
- //Handle after effects:
- if (bGizmoChange)
- {
- RS.Wireframes_Toggle();
- SceneView.RepaintAll();
- }
-
-
- //Option: Lane count:
- if (bLaneChange)
- {
- if (RS.opt_UseDefaultMaterials)
- {
- RS.GSDSpline.ClearAllRoadCuts();
- RS.SetDefaultMats();
- RS.SetAllCutsToCurrentMaterials();
- }
- }
-
- //Option: Multithreading
- if (bMultithreadChange)
- {
- RS.GSDRS.UpdateAllRoads_MultiThreadOptions();
- }
-
- //Option: Save meshes as unity assets options:
- if (bSaveMeshChange)
- {
- RS.GSDRS.UpdateAllRoads_SaveMeshesAsAssetsOptions();
- }
-
- //Option: terrain history save type:
- if (bTerrainHistoryChange)
- {
- if (RS.opt_SaveTerrainHistoryOnDisk)
- {
- RS.ConstructRoad_StoreTerrainHistory(true);
- }
- else
- {
- RS.ConstructRoad_LoadTerrainHistory(true);
- }
- }
-
- //Option: Editor camera meters per sec
- if (bEditorCameraSpeedChange)
- {
- RS.ChangeEditorCameraMetersPerSec();
- }
-
- //Update road:
- if (bNeedRoadUpdate)
- {
- RS.GSDSpline.Setup_Trigger();
- }
-
- //Option: Set mats to defaults:
- if (bSetDefaultMats)
- {
- RS.SetDefaultMats();
- RS.SetAllCutsToCurrentMaterials();
- }
-
- //Option: Apply above materials to entire road:
- if (t_bApplyMatsCheck)
- {
- t_bApplyMatsCheck = false;
- bApplyMatsCheck = false;
- RS.SetAllCutsToCurrentMaterials();
- }
-
- EditorUtility.SetDirty(target);
- }
- }
-
- public void OnSceneGUI()
- {
- Event current = Event.current;
- int controlID = GUIUtility.GetControlID(GetHashCode(), FocusType.Passive);
-
- if (current.alt == true) { return; }
-
- if (Selection.Contains(RS.transform.gameObject) && Selection.objects.Length > 1)
- {
- SetSelectionToRoad();
- }
-
- // Handle Ctrl and Shift when road is selected
- if (Selection.activeGameObject == RS.transform.gameObject)
- {
- RS.Editor_bSelected = true;
- // Only handle MouseMove and MouseDrag events
- if (Event.current.type == EventType.MouseMove || Event.current.type == EventType.MouseDrag)
- {
- if (current.control)
- {
- Ray worldRay = HandleUtility.GUIPointToWorldRay(Event.current.mousePosition);
- RaycastHit hitInfo;
- if (Physics.Raycast(worldRay, out hitInfo))
- {
- /* There used to be a check for whether this was a terrain */
- RS.Editor_MousePos = hitInfo.point;
- RS.Editor_MouseTerrainHit = true;
- if (RS.GSDSpline && RS.GSDSpline.PreviewSpline)
- {
- //Debug.Log("Drawing new node");
- if (RS.GSDSpline.PreviewSpline.mNodes == null || RS.GSDSpline.PreviewSpline.mNodes.Count < 1) { RS.GSDSpline.Setup(); }
- RS.GSDSpline.PreviewSpline.MousePos = hitInfo.point;
- RS.GSDSpline.PreviewSpline.bGizmoDraw = true;
- SceneView.RepaintAll();
- }
- }
-
- GUI.changed = true;
- }
- else if (current.shift)
- {
- Ray worldRay = HandleUtility.GUIPointToWorldRay(Event.current.mousePosition);
- RaycastHit hitInfo;
- if (Physics.Raycast(worldRay, out hitInfo))
- {
- /* Used to check for terrain */
- // if(hitInfo.collider.transform.name.ToLower().Contains("terrain")){
- RS.Editor_MousePos = hitInfo.point;
- RS.Editor_MouseTerrainHit = true;
- if (RS.GSDSpline && RS.GSDSpline.PreviewSplineInsert)
- {
- if (RS.GSDSpline.PreviewSplineInsert.mNodes == null || RS.GSDSpline.PreviewSplineInsert.mNodes.Count < 1) { RS.GSDSpline.PreviewSplineInsert.DetermineInsertNodes(); }
- RS.GSDSpline.PreviewSplineInsert.MousePos = hitInfo.point;
- RS.GSDSpline.PreviewSplineInsert.bGizmoDraw = true;
- RS.GSDSpline.PreviewSplineInsert.UpdateActionNode();
- SceneView.RepaintAll();
- }
- //}else{
- // RS.Editor_MouseTerrainHit = false;
- //}
- }
-
- GUI.changed = true;
- }
- else
- {
- if (RS.Editor_MouseTerrainHit) { RS.Editor_MouseTerrainHit = false; GUI.changed = true; }
- if (RS.GSDSpline && RS.GSDSpline.PreviewSpline)
- {
- //Debug.Log("not drawing new node");
- RS.GSDSpline.PreviewSpline.bGizmoDraw = false;
- }
- if (RS.GSDSpline && RS.GSDSpline.PreviewSplineInsert)
- {
- //Debug.Log("not drawing insert node");
- RS.GSDSpline.PreviewSplineInsert.bGizmoDraw = false;
- }
- }
- }
- }
- else
- {
- RS.Editor_bSelected = false;
- if (RS.GSDSpline.PreviewSpline)
- {
- RS.GSDSpline.PreviewSpline.bGizmoDraw = false;
- }
- }
-
-
-
- if (current.shift && RS.GSDSpline.PreviewSpline != null) { RS.GSDSpline.PreviewSpline.bGizmoDraw = false; }
- bool bUsed = false;
- if (current.control)
- {
- if (Event.current.type == EventType.MouseDown)
- {
- //Left click:
- if (Event.current.button == 0)
- {
- if (RS.Editor_MouseTerrainHit)
- {
- // if((EditorApplication.timeSinceStartup - RS.GSDSpline.EditorOnly_LastNode_TimeSinceStartup) > 0.05){
- // RS.GSDSpline.EditorOnly_LastNode_TimeSinceStartup = EditorApplication.timeSinceStartup;
- Event.current.Use();
- GSDConstruction.CreateNode(RS);
- bUsed = true;
- // }
- }
- else
- {
- Debug.Log("Invalid surface for new node. Must be terrain.");
- }
- }
- }
- }
- else if (current.shift)
- {
- if (Event.current.type == EventType.MouseDown)
- {
- //Left click:
- if (Event.current.button == 0)
- {
- if (RS.Editor_MouseTerrainHit)
- {
- Event.current.Use();
- GSDConstruction.InsertNode(RS);
- bUsed = true;
- }
- else
- {
- Debug.Log("Invalid surface for insertion node. Must be terrain.");
- }
- }
- }
- }
-
-
- if (current.type == EventType.ValidateCommand)
- {
- switch (current.commandName)
- {
- case "UndoRedoPerformed":
- TriggerRoadUpdate();
- break;
- }
- }
-
- if (Selection.activeGameObject == RS.transform.gameObject)
- {
- if (current.keyCode == KeyCode.F5)
- {
- TriggerRoadUpdate();
- }
- }
-
-
-
- if (bUsed)
- {
- SetSelectionToRoad();
- switch (current.type)
- {
- case EventType.Layout:
- HandleUtility.AddDefaultControl(controlID);
- break;
- }
- }
-
- if (GUI.changed)
- {
- EditorUtility.SetDirty(RS);
- }
- }
-
-
- private void TriggerRoadUpdate()
- {
- if (RS != null)
- {
- RS.EditorUpdateMe = true;
- }
- }
-
- void SetSelectionToRoad()
- {
- GameObject[] tObjs = new GameObject[1];
- tObjs[0] = RS.transform.gameObject;
- Selection.objects = tObjs;
- }
-
- #region "Progress bar"
- ///
- /// Creates progress bar.
- ///
- ///
- /// Value of the progress bar.
- ///
- ///
- /// Label of the progress bar.
- ///
- void GSDProgressBar(float tV, string tL)
- {
- // Get a rect for the progress bar using the same margins as a textfield:
- Rect rect = GUILayoutUtility.GetRect(18, 18, "TextField");
- EditorGUI.ProgressBar(rect, tV, tL);
- EditorGUILayout.Space();
- }
- #endregion
-
- void Line()
- {
- GUILayout.Space(4f);
- GUILayout.Box("", GUILayout.ExpandWidth(true), GUILayout.Height(1f)); //Horizontal bar
- GUILayout.Space(4f);
- }
-
- void LineSmall()
- {
- GUILayout.Space(1f);
- GUILayout.Box("", GUILayout.ExpandWidth(true), GUILayout.Height(1f)); //Horizontal bar
- GUILayout.Space(1f);
- }
-
-
-}
+#region "Imports"
+using UnityEngine;
+using UnityEditor;
+using System.Collections;
+using GSD.Roads;
+using GSD;
+#endregion
+
+
+[CustomEditor(typeof(GSDRoad))]
+public class GSDRoadEditor : Editor
+{
+
+ private static string[] RoadMaterialDropdownEnumDesc = new string[]{
+ "Asphalt",
+ "Dirt",
+ "Brick",
+ "Cobblestone"
+ };
+
+
+ protected GSDRoad RS { get { return (GSDRoad) target; } }
+
+ //Serialized properties:
+ SerializedProperty t_opt_GizmosEnabled;
+ SerializedProperty t_opt_Lanes;
+ SerializedProperty t_opt_LaneWidth;
+ SerializedProperty t_opt_bShouldersEnabled;
+ SerializedProperty t_opt_ShoulderWidth;
+ SerializedProperty t_opt_RoadDefinition;
+ SerializedProperty t_opt_UseDefaultMaterials;
+ SerializedProperty t_opt_bMaxGradeEnabled;
+ SerializedProperty t_opt_MaxGrade;
+ SerializedProperty t_opt_bMultithreading;
+ SerializedProperty t_opt_bSaveMeshes;
+ SerializedProperty t_opt_TerrainSubtract_Match;
+ SerializedProperty t_opt_MagnitudeThreshold;
+ SerializedProperty t_opt_HeightModEnabled;
+ SerializedProperty t_opt_DetailModEnabled;
+ SerializedProperty t_opt_TreeModEnabled;
+ SerializedProperty t_opt_MatchHeightsDistance;
+ SerializedProperty t_opt_ClearDetailsDistance;
+ SerializedProperty t_opt_ClearDetailsDistanceHeight;
+ SerializedProperty t_opt_ClearTreesDistance;
+ SerializedProperty t_opt_ClearTreesDistanceHeight;
+ SerializedProperty t_opt_SaveTerrainHistoryOnDisk;
+ SerializedProperty t_opt_bRoadCuts;
+ SerializedProperty t_opt_bDynamicCuts;
+ SerializedProperty t_opt_bShoulderCuts;
+ SerializedProperty t_bEditorCameraRotate;
+ SerializedProperty t_EditorCameraMetersPerSecond;
+ SerializedProperty t_opt_bUseMeshColliders;
+ SerializedProperty t_opt_tRoadMaterialDropdown;
+ SerializedProperty t_opt_bIsStatic;
+ SerializedProperty t_opt_bIsLightmapped;
+
+ SerializedProperty t_RoadMaterial1;
+ SerializedProperty t_RoadMaterial2;
+ SerializedProperty t_RoadMaterial3;
+ SerializedProperty t_RoadMaterial4;
+ SerializedProperty t_RoadMaterialMarker1;
+ SerializedProperty t_RoadMaterialMarker2;
+ SerializedProperty t_RoadMaterialMarker3;
+ SerializedProperty t_RoadMaterialMarker4;
+ SerializedProperty t_ShoulderMaterial1;
+ SerializedProperty t_ShoulderMaterial2;
+ SerializedProperty t_ShoulderMaterial3;
+ SerializedProperty t_ShoulderMaterial4;
+ SerializedProperty t_ShoulderMaterialMarker1;
+ SerializedProperty t_ShoulderMaterialMarker2;
+ SerializedProperty t_ShoulderMaterialMarker3;
+ SerializedProperty t_ShoulderMaterialMarker4;
+ SerializedProperty t_RoadPhysicMaterial;
+ SerializedProperty t_ShoulderPhysicMaterial;
+
+ //Editor only variables:
+ string status = "Show help";
+ const string tOnlineHelpDesc = "Visit the online manual for the most effective help.";
+ bool bShowCutsHelp = false;
+ bool bShowMatsHelp = false;
+ bool bShowHelpRoad = false;
+ bool bShowHelpTerrain = false;
+ bool bShowCameraHelp = false;
+ GUIStyle GSDLoadButton = null;
+ bool bResetTH = false;
+ public enum tempEnum { Two, Four, Six };
+ Texture btnRefreshText = null;
+ Texture btnDeleteText = null;
+ Texture btnRefreshTextReal = null;
+ tempEnum LanesEnum = tempEnum.Two;
+ tempEnum tLanesEnum = tempEnum.Two;
+
+ private static string[] tempEnumDescriptions = new string[]{
+ "Two",
+ "Four",
+ "Six"
+ };
+
+ GUIStyle WarningLabelStyle;
+ Texture2D WarningLabelBG;
+ GUIStyle GSDImageButton = null;
+ GUIStyle GSDMaybeButton = null;
+ bool bHasInit = false;
+ Texture2D LoadBtnBG = null;
+ Texture2D LoadBtnBGGlow = null;
+
+ //Buffers:
+ //float TempChangeChecker = 0f;
+ //bool bMatChange = false;
+ bool bNeedRoadUpdate = false;
+ bool bSetDefaultMats = false;
+ bool bApplyMatsCheck = false;
+ bool t_bApplyMatsCheck = false;
+
+
+ private void OnEnable()
+ {
+ t_opt_GizmosEnabled = serializedObject.FindProperty("opt_GizmosEnabled");
+ t_opt_Lanes = serializedObject.FindProperty("opt_Lanes");
+ t_opt_LaneWidth = serializedObject.FindProperty("opt_LaneWidth");
+ t_opt_bShouldersEnabled = serializedObject.FindProperty("opt_bShouldersEnabled");
+ t_opt_ShoulderWidth = serializedObject.FindProperty("opt_ShoulderWidth");
+ t_opt_RoadDefinition = serializedObject.FindProperty("opt_RoadDefinition");
+ t_opt_UseDefaultMaterials = serializedObject.FindProperty("opt_UseDefaultMaterials");
+ t_opt_bMaxGradeEnabled = serializedObject.FindProperty("opt_bMaxGradeEnabled");
+ t_opt_MaxGrade = serializedObject.FindProperty("opt_MaxGrade");
+ t_opt_bMultithreading = serializedObject.FindProperty("opt_bMultithreading");
+ t_opt_bSaveMeshes = serializedObject.FindProperty("opt_bSaveMeshes");
+ t_opt_TerrainSubtract_Match = serializedObject.FindProperty("opt_TerrainSubtract_Match");
+ t_opt_MagnitudeThreshold = serializedObject.FindProperty("opt_MagnitudeThreshold");
+ t_opt_HeightModEnabled = serializedObject.FindProperty("opt_HeightModEnabled");
+ t_opt_DetailModEnabled = serializedObject.FindProperty("opt_DetailModEnabled");
+ t_opt_TreeModEnabled = serializedObject.FindProperty("opt_TreeModEnabled");
+ t_opt_MatchHeightsDistance = serializedObject.FindProperty("opt_MatchHeightsDistance");
+ t_opt_ClearDetailsDistance = serializedObject.FindProperty("opt_ClearDetailsDistance");
+ t_opt_ClearDetailsDistanceHeight = serializedObject.FindProperty("opt_ClearDetailsDistanceHeight");
+ t_opt_ClearTreesDistance = serializedObject.FindProperty("opt_ClearTreesDistance");
+ t_opt_ClearTreesDistanceHeight = serializedObject.FindProperty("opt_ClearTreesDistanceHeight");
+ t_opt_SaveTerrainHistoryOnDisk = serializedObject.FindProperty("opt_SaveTerrainHistoryOnDisk");
+ t_opt_bRoadCuts = serializedObject.FindProperty("opt_bRoadCuts");
+ t_opt_bDynamicCuts = serializedObject.FindProperty("opt_bDynamicCuts");
+ t_opt_bShoulderCuts = serializedObject.FindProperty("opt_bShoulderCuts");
+ t_bEditorCameraRotate = serializedObject.FindProperty("bEditorCameraRotate");
+ t_EditorCameraMetersPerSecond = serializedObject.FindProperty("EditorCameraMetersPerSecond");
+ t_opt_bUseMeshColliders = serializedObject.FindProperty("opt_bUseMeshColliders");
+ t_opt_tRoadMaterialDropdown = serializedObject.FindProperty("opt_tRoadMaterialDropdown");
+ t_opt_bIsStatic = serializedObject.FindProperty("opt_bIsStatic");
+ t_opt_bIsLightmapped = serializedObject.FindProperty("opt_bIsLightmapped");
+
+ t_RoadMaterial1 = serializedObject.FindProperty("RoadMaterial1");
+ t_RoadMaterial2 = serializedObject.FindProperty("RoadMaterial2");
+ t_RoadMaterial3 = serializedObject.FindProperty("RoadMaterial3");
+ t_RoadMaterial4 = serializedObject.FindProperty("RoadMaterial4");
+ t_RoadMaterialMarker1 = serializedObject.FindProperty("RoadMaterialMarker1");
+ t_RoadMaterialMarker2 = serializedObject.FindProperty("RoadMaterialMarker2");
+ t_RoadMaterialMarker3 = serializedObject.FindProperty("RoadMaterialMarker3");
+ t_RoadMaterialMarker4 = serializedObject.FindProperty("RoadMaterialMarker4");
+ t_ShoulderMaterial1 = serializedObject.FindProperty("ShoulderMaterial1");
+ t_ShoulderMaterial2 = serializedObject.FindProperty("ShoulderMaterial2");
+ t_ShoulderMaterial3 = serializedObject.FindProperty("ShoulderMaterial3");
+ t_ShoulderMaterial4 = serializedObject.FindProperty("ShoulderMaterial4");
+ t_ShoulderMaterialMarker1 = serializedObject.FindProperty("ShoulderMaterialMarker1");
+ t_ShoulderMaterialMarker2 = serializedObject.FindProperty("ShoulderMaterialMarker2");
+ t_ShoulderMaterialMarker3 = serializedObject.FindProperty("ShoulderMaterialMarker3");
+ t_ShoulderMaterialMarker4 = serializedObject.FindProperty("ShoulderMaterialMarker4");
+ t_RoadPhysicMaterial = serializedObject.FindProperty("RoadPhysicMaterial");
+ t_ShoulderPhysicMaterial = serializedObject.FindProperty("ShoulderPhysicMaterial");
+ }
+
+
+ void Init()
+ {
+ bHasInit = true;
+ EditorStyles.label.wordWrap = true;
+
+ if (WarningLabelBG == null)
+ {
+ WarningLabelBG = (Texture2D) AssetDatabase.LoadAssetAtPath(GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Editor/Icons/WarningLabelBG.png", typeof(Texture2D)) as Texture2D;
+ }
+ if (btnRefreshText == null)
+ {
+ btnRefreshText = (Texture) AssetDatabase.LoadAssetAtPath(GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Editor/Icons/refresh2.png", typeof(Texture)) as Texture;
+ }
+ if (btnRefreshTextReal == null)
+ {
+ btnRefreshTextReal = (Texture) AssetDatabase.LoadAssetAtPath(GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Editor/Icons/refresh.png", typeof(Texture)) as Texture;
+ }
+ if (LoadBtnBG == null)
+ {
+ LoadBtnBG = (Texture2D) AssetDatabase.LoadAssetAtPath(GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Editor/Icons/otherbg.png", typeof(Texture2D)) as Texture2D;
+ }
+ if (LoadBtnBGGlow == null)
+ {
+ LoadBtnBGGlow = (Texture2D) AssetDatabase.LoadAssetAtPath(GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Editor/Icons/otherbg2.png", typeof(Texture2D)) as Texture2D;
+ }
+ if (btnDeleteText == null)
+ {
+ btnDeleteText = (Texture) AssetDatabase.LoadAssetAtPath(GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Editor/Icons/delete.png", typeof(Texture)) as Texture;
+ }
+
+ if (WarningLabelStyle == null)
+ {
+ WarningLabelStyle = new GUIStyle(GUI.skin.textArea);
+ WarningLabelStyle.normal.textColor = Color.red;
+ WarningLabelStyle.active.textColor = Color.red;
+ WarningLabelStyle.hover.textColor = Color.red;
+ WarningLabelStyle.normal.background = WarningLabelBG;
+ WarningLabelStyle.active.background = WarningLabelBG;
+ WarningLabelStyle.hover.background = WarningLabelBG;
+ WarningLabelStyle.padding = new RectOffset(8, 8, 8, 8);
+ }
+
+ if (GSDImageButton == null)
+ {
+ GSDImageButton = new GUIStyle(GUI.skin.button);
+ GSDImageButton.contentOffset = new Vector2(0f, 0f);
+ GSDImageButton.border = new RectOffset(0, 0, 0, 0);
+ GSDImageButton.fixedHeight = 16f;
+ GSDImageButton.padding = new RectOffset(0, 0, 0, 0);
+ GSDImageButton.normal.background = null;
+ }
+
+ if (GSDLoadButton == null)
+ {
+ GSDLoadButton = new GUIStyle(GUI.skin.button);
+ GSDLoadButton.contentOffset = new Vector2(0f, 1f);
+ GSDLoadButton.normal.textColor = new Color(1f, 1f, 1f, 1f);
+ GSDLoadButton.normal.background = LoadBtnBG;
+ GSDLoadButton.active.background = LoadBtnBGGlow;
+ GSDLoadButton.focused.background = LoadBtnBGGlow;
+ GSDLoadButton.hover.background = LoadBtnBGGlow;
+ GSDLoadButton.fixedHeight = 16f;
+ GSDLoadButton.fixedWidth = 128f;
+ }
+
+ if (GSDMaybeButton == null)
+ {
+ GSDMaybeButton = new GUIStyle(GUI.skin.button);
+ GSDMaybeButton.normal.textColor = new Color(0f, 0f, 0f, 1f);
+ }
+ }
+
+
+ public override void OnInspectorGUI()
+ {
+ if (Event.current.type == EventType.ValidateCommand)
+ {
+ switch (Event.current.commandName)
+ {
+ case "UndoRedoPerformed":
+ TriggerRoadUpdate();
+ break;
+ }
+ }
+
+ serializedObject.Update();
+
+ bNeedRoadUpdate = false;
+ bSetDefaultMats = false;
+ //Graphic null checks:
+ if (!bHasInit)
+ {
+ Init();
+ }
+
+
+
+ Line();
+ EditorGUILayout.BeginHorizontal();
+ EditorGUILayout.LabelField(RS.transform.name, EditorStyles.boldLabel);
+ if (GUILayout.Button("Update road", GSDLoadButton))
+ {
+ RS.EditorUpdateMe = true;
+ }
+
+ EditorGUILayout.EndHorizontal();
+
+ EditorGUILayout.LabelField("Hold ctrl and click terrain to add nodes.");
+ EditorGUILayout.LabelField("Hold shift and click terrain to insert nodes.");
+ EditorGUILayout.LabelField("Select nodes on spline to add objects.");
+ EditorGUILayout.LabelField("Road options:");
+
+
+ EditorGUILayout.BeginVertical("box");
+ EditorGUILayout.BeginHorizontal();
+ //Option: Gizmos input:
+ t_opt_GizmosEnabled.boolValue = EditorGUILayout.Toggle("Gizmos: ", RS.opt_GizmosEnabled);
+ if (GUILayout.Button("Online manual", EditorStyles.miniButton, GUILayout.Width(120f)))
+ {
+ Application.OpenURL("http://microgsd.com/Support/RoadArchitectManual.aspx");
+ }
+ EditorGUILayout.EndHorizontal();
+
+ //Option: Lane count:
+ if (RS.opt_Lanes == 2)
+ {
+ LanesEnum = tempEnum.Two;
+ }
+ else if (RS.opt_Lanes == 4)
+ {
+ LanesEnum = tempEnum.Four;
+ }
+ else
+ {
+ LanesEnum = tempEnum.Six;
+ }
+ tLanesEnum = (tempEnum) EditorGUILayout.Popup("Lanes: ", (int) LanesEnum, tempEnumDescriptions);
+ if (tLanesEnum == tempEnum.Two)
+ {
+ t_opt_Lanes.intValue = 2;
+ }
+ else if (tLanesEnum == tempEnum.Four)
+ {
+ t_opt_Lanes.intValue = 4;
+ }
+ else if (tLanesEnum == tempEnum.Six)
+ {
+ t_opt_Lanes.intValue = 6;
+ }
+
+ //Option: Lane and road width:
+ EditorGUILayout.BeginHorizontal();
+ t_opt_LaneWidth.floatValue = EditorGUILayout.FloatField("Lane width:", RS.opt_LaneWidth);
+ if (GUILayout.Button(btnRefreshText, GSDImageButton, GUILayout.Width(16f)))
+ {
+ t_opt_LaneWidth.floatValue = 5f;
+ }
+ EditorGUILayout.EndHorizontal();
+ EditorGUILayout.LabelField("Road width: " + RS.RoadWidth().ToString("F1") + " meters");
+
+ //Option: Shoulders enabled:
+ t_opt_bShouldersEnabled.boolValue = EditorGUILayout.Toggle("Shoulders enabled:", RS.opt_bShouldersEnabled);
+
+ //Option: Shoulders width:
+ if (RS.opt_bShouldersEnabled)
+ {
+ EditorGUILayout.BeginHorizontal();
+ t_opt_ShoulderWidth.floatValue = EditorGUILayout.FloatField("Shoulders width:", RS.opt_ShoulderWidth);
+ if (GUILayout.Button(btnRefreshText, GSDImageButton, GUILayout.Width(16f)))
+ {
+ t_opt_ShoulderWidth.floatValue = 3f;
+ }
+ EditorGUILayout.EndHorizontal();
+ }
+
+ //Option: Road definition:
+ EditorGUILayout.BeginHorizontal();
+ t_opt_RoadDefinition.floatValue = EditorGUILayout.FloatField("Road definition:", RS.opt_RoadDefinition);
+ if (GUILayout.Button(btnRefreshText, GSDImageButton, GUILayout.Width(16f)))
+ {
+ t_opt_RoadDefinition.floatValue = 5f;
+ }
+ EditorGUILayout.EndHorizontal();
+
+ //Option: Use default materials:
+ t_opt_UseDefaultMaterials.boolValue = EditorGUILayout.Toggle("Use default materials:", RS.opt_UseDefaultMaterials);
+
+ //Dropdown:
+ if (RS.opt_UseDefaultMaterials)
+ {
+ int Old = (int) RS.opt_tRoadMaterialDropdown;
+ t_opt_tRoadMaterialDropdown.enumValueIndex = (int) EditorGUILayout.Popup("Road material: ", (int) RS.opt_tRoadMaterialDropdown, RoadMaterialDropdownEnumDesc, GUILayout.Width(250f));
+ if (t_opt_tRoadMaterialDropdown.enumValueIndex != Old)
+ {
+ if (t_opt_tRoadMaterialDropdown.enumValueIndex > 0)
+ {
+ t_opt_bShouldersEnabled.boolValue = false;
+ }
+ else
+ {
+ t_opt_bShouldersEnabled.boolValue = true;
+ }
+ }
+ }
+
+ //Option: Max grade enabled:
+ t_opt_bMaxGradeEnabled.boolValue = EditorGUILayout.Toggle("Max grade enforced: ", RS.opt_bMaxGradeEnabled);
+
+ //Option: Max grade value:
+ if (RS.opt_bMaxGradeEnabled)
+ {
+ EditorGUILayout.BeginHorizontal();
+ t_opt_MaxGrade.floatValue = EditorGUILayout.Slider("Max road grade: ", RS.opt_MaxGrade, 0f, 1f);
+ if (GUILayout.Button(btnRefreshText, GSDImageButton, GUILayout.Width(16f)))
+ {
+ t_opt_MaxGrade.floatValue = 0.08f;
+ }
+ EditorGUILayout.EndHorizontal();
+ }
+
+ //Mesh colliders:
+ if (RS.GSDRS != null)
+ {
+ t_opt_bUseMeshColliders.boolValue = EditorGUILayout.Toggle("Use mesh colliders: ", RS.opt_bUseMeshColliders);
+ }
+
+ //Option: Multi-threading option: workaround for UAS submission rules:
+ if (RS.GSDRS.opt_bMultithreading != RS.opt_bMultithreading)
+ {
+ RS.GSDRS.opt_bMultithreading = RS.opt_bMultithreading;
+ RS.GSDRS.UpdateAllRoads_MultiThreadOptions();
+ }
+ if (RS.GSDRS != null)
+ {
+ t_opt_bMultithreading.boolValue = EditorGUILayout.Toggle("Multithreading: ", RS.GSDRS.opt_bMultithreading);
+ }
+
+ //Static:
+ if (RS.GSDRS != null)
+ {
+ t_opt_bIsStatic.boolValue = EditorGUILayout.Toggle("Static: ", RS.opt_bIsStatic);
+ }
+
+ //Used for lightmapping:
+ if (RS.GSDRS != null)
+ {
+ t_opt_bIsLightmapped.boolValue = EditorGUILayout.Toggle("Lightmapped: ", RS.opt_bIsLightmapped);
+ }
+
+ //Option: Save meshes as unity assets options:
+ if (RS.GSDRS.opt_bSaveMeshes != RS.opt_bSaveMeshes)
+ {
+ RS.GSDRS.opt_bSaveMeshes = RS.opt_bSaveMeshes;
+ RS.GSDRS.UpdateAllRoads_SaveMeshesAsAssetsOptions();
+ }
+ if (RS.GSDRS != null)
+ {
+ t_opt_bSaveMeshes.boolValue = EditorGUILayout.Toggle("Save mesh assets: ", RS.GSDRS.opt_bSaveMeshes);
+ }
+ if (RS.GSDRS.opt_bSaveMeshes)
+ {
+ GUILayout.Label("WARNING: Saving meshes as assets is very slow and can increase road generation time by several minutes.", WarningLabelStyle);
+ }
+
+ if (GUILayout.Button("Duplicate road", EditorStyles.miniButton, GUILayout.Width(120f)))
+ {
+ RS.DuplicateRoad();
+ }
+
+
+ bShowHelpRoad = EditorGUILayout.Foldout(bShowHelpRoad, status);
+ if (bShowHelpRoad)
+ {
+ EditorGUILayout.BeginVertical("box");
+ EditorGUILayout.BeginHorizontal();
+ EditorGUILayout.LabelField("Road options quick help:", EditorStyles.boldLabel);
+ if (GUILayout.Button("Online manual", EditorStyles.miniButton, GUILayout.Width(120f)))
+ {
+ Application.OpenURL("http://microgsd.com/Support/RoadArchitectManual.aspx");
+ }
+ EditorGUILayout.EndHorizontal();
+ EditorGUILayout.HelpBox(tOnlineHelpDesc, MessageType.Info);
+
+ GUILayout.Space(4f);
+ EditorGUILayout.BeginVertical();
+ EditorGUILayout.LabelField("Gizmos:", EditorStyles.boldLabel);
+ EditorGUILayout.LabelField("Enable or disable most gizmos for this road. Disable mesh collider gizmos via the unity menu if necessary or desired.", EditorStyles.miniLabel);
+ EditorGUILayout.EndVertical();
+ GUILayout.Space(4f);
+ EditorGUILayout.BeginVertical();
+ EditorGUILayout.LabelField("Lanes:", EditorStyles.boldLabel);
+ EditorGUILayout.LabelField("Select the number of lanes for this road.");
+ EditorGUILayout.EndVertical();
+ GUILayout.Space(4f);
+ EditorGUILayout.BeginVertical();
+ EditorGUILayout.LabelField("Lane width:", EditorStyles.boldLabel);
+ EditorGUILayout.LabelField("Modify the width per lane, in meters.");
+ EditorGUILayout.EndVertical();
+ GUILayout.Space(4f);
+ EditorGUILayout.BeginVertical();
+ EditorGUILayout.LabelField("Road width:", EditorStyles.boldLabel);
+ EditorGUILayout.LabelField("Displays the road width without considering shoulders, in meters.");
+ EditorGUILayout.EndVertical();
+ GUILayout.Space(4f);
+ EditorGUILayout.BeginVertical();
+ EditorGUILayout.LabelField("Shoulders enabled:", EditorStyles.boldLabel);
+ EditorGUILayout.LabelField("Enables or disables shoulders.");
+ EditorGUILayout.EndVertical();
+ GUILayout.Space(4f);
+ EditorGUILayout.BeginVertical();
+ EditorGUILayout.LabelField("Shoulders width:", EditorStyles.boldLabel);
+ EditorGUILayout.LabelField("Modify the width of shoulders, in meters.");
+ EditorGUILayout.EndVertical();
+ GUILayout.Space(4f);
+ EditorGUILayout.BeginVertical();
+ EditorGUILayout.LabelField("Road definition: ", EditorStyles.boldLabel);
+ EditorGUILayout.LabelField("The meter spacing between mesh triangles on the road and shoulder.");
+ EditorGUILayout.EndVertical();
+ GUILayout.Space(4f);
+ EditorGUILayout.BeginVertical();
+ EditorGUILayout.LabelField("Use default materials: ", EditorStyles.boldLabel);
+ EditorGUILayout.LabelField("When enabled will use default materials for the road system, allowing certain aspects of generation to automatically determine the correct materials to utilize.");
+ EditorGUILayout.EndVertical();
+ GUILayout.Space(4f);
+ EditorGUILayout.BeginVertical();
+ EditorGUILayout.LabelField("Max grade enforced: ", EditorStyles.boldLabel);
+ EditorGUILayout.LabelField("When enabled enforces a maximum grade on a per node basis.");
+ EditorGUILayout.EndVertical();
+ GUILayout.Space(4f);
+ EditorGUILayout.BeginVertical();
+ EditorGUILayout.LabelField("Max road grade: ", EditorStyles.boldLabel);
+ EditorGUILayout.LabelField("The maximum road grade allowed on a per node basis.");
+ EditorGUILayout.EndVertical();
+ GUILayout.Space(4f);
+ EditorGUILayout.BeginVertical();
+ EditorGUILayout.LabelField("Multithreading:", EditorStyles.boldLabel);
+ EditorGUILayout.LabelField("When enabled allows for multi-threaded road generation.");
+ EditorGUILayout.EndVertical();
+ GUILayout.Space(4f);
+ EditorGUILayout.BeginVertical();
+ EditorGUILayout.LabelField("Save mesh assets:", EditorStyles.boldLabel);
+ EditorGUILayout.LabelField("When enabled saves all generated meshes as .asset files.");
+ GUILayout.Space(4f);
+ EditorGUILayout.BeginHorizontal();
+ if (GUILayout.Button(btnRefreshText, GSDImageButton, GUILayout.Width(16f)))
+ {
+
+ }
+ EditorGUILayout.LabelField(" = Resets settings to default.");
+ EditorGUILayout.EndHorizontal();
+ EditorGUILayout.EndVertical();
+ }
+ EditorGUILayout.EndVertical();
+
+ EditorGUILayout.LabelField("Terrain options:");
+ EditorGUILayout.BeginVertical("box");
+
+ //Option: Terrain subtraction:
+ EditorGUILayout.BeginHorizontal();
+ t_opt_TerrainSubtract_Match.floatValue = EditorGUILayout.Slider("Terrain subtraction: ", RS.opt_TerrainSubtract_Match, 0.01f, 1f);
+ if (GUILayout.Button(btnRefreshText, GSDImageButton, GUILayout.Width(16f)))
+ {
+ t_opt_TerrainSubtract_Match.floatValue = 0.01f;
+ }
+ EditorGUILayout.EndHorizontal();
+
+ //Option: Spline magnitude limit:
+ EditorGUILayout.BeginHorizontal();
+ t_opt_MagnitudeThreshold.floatValue = EditorGUILayout.Slider("Spline magnitude limit: ", RS.opt_MagnitudeThreshold, 128f, 8192f);
+ if (GUILayout.Button(btnRefreshText, GSDImageButton, GUILayout.Width(16f)))
+ {
+ t_opt_MagnitudeThreshold.floatValue = 300f;
+ }
+ EditorGUILayout.EndHorizontal();
+
+ //Option: Height modification
+ t_opt_HeightModEnabled.boolValue = EditorGUILayout.Toggle("Height modification: ", RS.opt_HeightModEnabled);
+
+ //Option: Active detail removal
+ t_opt_DetailModEnabled.boolValue = EditorGUILayout.Toggle("Active detail removal: ", RS.opt_DetailModEnabled);
+
+ //Option: Active tree removal
+ t_opt_TreeModEnabled.boolValue = EditorGUILayout.Toggle("Active tree removal: ", RS.opt_TreeModEnabled);
+
+ //Option: heights width
+ if (RS.opt_HeightModEnabled)
+ {
+ EditorGUILayout.BeginHorizontal();
+ t_opt_MatchHeightsDistance.floatValue = EditorGUILayout.Slider("Heights match width: ", RS.opt_MatchHeightsDistance, 0.01f, 512f);
+ if (GUILayout.Button(btnRefreshText, GSDImageButton, GUILayout.Width(16f)))
+ {
+ t_opt_MatchHeightsDistance.floatValue = 50f;
+ }
+ EditorGUILayout.EndHorizontal();
+ }
+
+ //Option: details width and height
+ if (RS.opt_DetailModEnabled)
+ {
+ EditorGUILayout.BeginHorizontal();
+ t_opt_ClearDetailsDistance.floatValue = EditorGUILayout.Slider("Details clear width: ", RS.opt_ClearDetailsDistance, 0.01f, 512f);
+ if (GUILayout.Button(btnRefreshText, GSDImageButton, GUILayout.Width(16f)))
+ {
+ t_opt_ClearDetailsDistance.floatValue = 30f;
+ }
+
+ EditorGUILayout.EndHorizontal();
+
+ EditorGUILayout.BeginHorizontal();
+ t_opt_ClearDetailsDistanceHeight.floatValue = EditorGUILayout.Slider("Details clear height: ", RS.opt_ClearDetailsDistanceHeight, 0.01f, 512f);
+ if (GUILayout.Button(btnRefreshText, GSDImageButton, GUILayout.Width(16f)))
+ {
+ t_opt_ClearDetailsDistanceHeight.floatValue = 5f;
+ }
+
+ EditorGUILayout.EndHorizontal();
+ }
+
+ //Option: tree widths and height
+ if (RS.opt_TreeModEnabled)
+ {
+ EditorGUILayout.BeginHorizontal();
+ t_opt_ClearTreesDistance.floatValue = EditorGUILayout.Slider("Trees clear width: ", RS.opt_ClearTreesDistance, 0.01f, 512f);
+ if (GUILayout.Button(btnRefreshText, GSDImageButton, GUILayout.Width(16f)))
+ {
+ t_opt_ClearTreesDistance.floatValue = 30f;
+ }
+ EditorGUILayout.EndHorizontal();
+
+ EditorGUILayout.BeginHorizontal();
+ t_opt_ClearTreesDistanceHeight.floatValue = EditorGUILayout.Slider("Trees clear height: ", RS.opt_ClearTreesDistanceHeight, 0.01f, 512f);
+ if (GUILayout.Button(btnRefreshText, GSDImageButton, GUILayout.Width(16f)))
+ {
+ t_opt_ClearTreesDistanceHeight.floatValue = 50f;
+ }
+ EditorGUILayout.EndHorizontal();
+ }
+
+
+ //Option: terrain history save type:
+ EditorGUILayout.BeginHorizontal();
+ EditorGUILayout.LabelField("Store terrain history separate from scene:");
+ t_opt_SaveTerrainHistoryOnDisk.boolValue = EditorGUILayout.Toggle(RS.opt_SaveTerrainHistoryOnDisk, GUILayout.Width(50f));
+ EditorGUILayout.EndHorizontal();
+
+ EditorGUILayout.LabelField("Terrain history size: " + RS.TerrainHistoryByteSize);
+
+ bShowHelpTerrain = EditorGUILayout.Foldout(bShowHelpTerrain, status);
+ if (bShowHelpTerrain)
+ {
+ EditorGUILayout.BeginVertical("box");
+ EditorGUILayout.BeginHorizontal();
+ EditorGUILayout.LabelField("Terrain options quick help:", EditorStyles.boldLabel);
+ if (GUILayout.Button("Online manual", EditorStyles.miniButton, GUILayout.Width(120f)))
+ {
+ Application.OpenURL("http://microgsd.com/Support/RoadArchitectManual.aspx");
+ }
+ EditorGUILayout.EndHorizontal();
+ EditorGUILayout.HelpBox(tOnlineHelpDesc, MessageType.Info);
+ EditorGUILayout.LabelField("Terrain subtraction: ", EditorStyles.boldLabel);
+ EditorGUILayout.LabelField("This value, in meters, will be subtracted from the terrain match height to prevent z-fighting.");
+ GUILayout.Space(4f);
+ EditorGUILayout.LabelField("Spline magnitude limit: ", EditorStyles.boldLabel);
+ EditorGUILayout.LabelField("Limits the magnitude of the spline nodes. Lower limit is better for typical roads with node seperation of around 100 to 300 meters. Higher limits will allow for less tension when using very spread out nodes.");
+ GUILayout.Space(4f);
+ EditorGUILayout.LabelField("Height Modification:", EditorStyles.boldLabel);
+ EditorGUILayout.LabelField("Enables or disables height matching for the terrain.");
+ GUILayout.Space(4f);
+ EditorGUILayout.LabelField("Active detail removal:", EditorStyles.boldLabel);
+ EditorGUILayout.LabelField("Enables or disables active detail removal. Memory intensive on large terrains with large amounts of details. Recommended to not use this option and instead remove details and trees via splat maps with other addons.");
+ GUILayout.Space(4f);
+ EditorGUILayout.LabelField("Active tree removal:", EditorStyles.boldLabel);
+ EditorGUILayout.LabelField("Enables or disables active tree removal. Memory intensive on large terrains with large amounts of trees. Recommended to not use this option and instead remove details and trees via splat maps with other addons.");
+ GUILayout.Space(4f);
+ EditorGUILayout.LabelField("Heights match width:", EditorStyles.boldLabel);
+ EditorGUILayout.LabelField("The distance to the left and right of the road in which terrain heights will be matched to the road.");
+ GUILayout.Space(4f);
+ EditorGUILayout.LabelField("Details clear width:", EditorStyles.boldLabel);
+ EditorGUILayout.LabelField("The distance between the road and detail, width wise, in which details will be removed.");
+ GUILayout.Space(4f);
+ EditorGUILayout.LabelField("Details clear height:", EditorStyles.boldLabel);
+ EditorGUILayout.LabelField("The distance between the road and detail, height wise, in which details will be removed.");
+ GUILayout.Space(4f);
+ EditorGUILayout.LabelField("Tree clear width:", EditorStyles.boldLabel);
+ EditorGUILayout.LabelField("The distance between the road and tree, width wise, in which trees will be removed.");
+ GUILayout.Space(4f);
+ EditorGUILayout.LabelField("Tree clear height:", EditorStyles.boldLabel);
+ EditorGUILayout.LabelField("The distance between the road and tree, height wise, in which trees will be removed.");
+ GUILayout.Space(4f);
+ EditorGUILayout.LabelField("Store terrain history separate from scene:", EditorStyles.boldLabel);
+ EditorGUILayout.LabelField("If enabled, stores the terrain history immediately on disk after use, saving memory while in editor.");
+ GUILayout.Space(4f);
+ EditorGUILayout.LabelField("Terrain history size:", EditorStyles.boldLabel);
+ EditorGUILayout.LabelField("Shows the size, in kilobytes, of the terrain history in memory or on disk.");
+ GUILayout.Space(4f);
+ EditorGUILayout.BeginHorizontal();
+ if (GUILayout.Button(btnRefreshText, GSDImageButton, GUILayout.Width(16f)))
+ {
+
+ }
+ EditorGUILayout.LabelField(" = Resets settings to default.");
+ EditorGUILayout.EndHorizontal();
+ }
+ EditorGUILayout.EndVertical();
+
+
+
+ GUILayout.Label("Road and shoulder splitting:");
+ EditorGUILayout.BeginVertical("box");
+ GUILayout.Space(4f);
+
+ //Option: road cuts:
+ if (!RS.opt_bDynamicCuts)
+ {
+ EditorGUILayout.BeginHorizontal();
+ t_opt_bRoadCuts.boolValue = EditorGUILayout.Toggle("Auto split road: ", RS.opt_bRoadCuts);
+ if (GUILayout.Button(btnRefreshText, GSDImageButton, GUILayout.Width(16f)))
+ {
+ t_opt_bDynamicCuts.boolValue = false;
+ t_opt_bRoadCuts.boolValue = true;
+ t_opt_bShoulderCuts.boolValue = true;
+ }
+ EditorGUILayout.EndHorizontal();
+
+ if (RS.opt_bShouldersEnabled)
+ {
+ t_opt_bShoulderCuts.boolValue = EditorGUILayout.Toggle("Auto split shoulders: ", RS.opt_bShoulderCuts);
+ }
+ }
+ else
+ {
+ EditorGUILayout.BeginHorizontal();
+ EditorGUILayout.LabelField("Manual road splitting: true");
+ if (GUILayout.Button(btnRefreshText, GSDImageButton, GUILayout.Width(16f)))
+ {
+ t_opt_bDynamicCuts.boolValue = false;
+ t_opt_bRoadCuts.boolValue = true;
+ t_opt_bShoulderCuts.boolValue = true;
+ }
+ EditorGUILayout.EndHorizontal();
+
+ EditorGUILayout.LabelField("Manual shoulder splitting: true");
+ }
+ t_opt_bDynamicCuts.boolValue = EditorGUILayout.Toggle("Manual splitting: ", RS.opt_bDynamicCuts);
+
+
+ bShowCutsHelp = EditorGUILayout.Foldout(bShowCutsHelp, status);
+ if (bShowCutsHelp)
+ {
+ EditorGUILayout.BeginVertical("box");
+ EditorGUILayout.BeginHorizontal();
+ EditorGUILayout.LabelField("Road splitting quick help:", EditorStyles.boldLabel);
+ if (GUILayout.Button("Online manual", EditorStyles.miniButton, GUILayout.Width(120f)))
+ {
+ Application.OpenURL("http://microgsd.com/Support/RoadArchitectManual.aspx");
+ }
+ EditorGUILayout.EndHorizontal();
+ EditorGUILayout.HelpBox(tOnlineHelpDesc, MessageType.Info);
+
+ EditorGUILayout.LabelField("Typically auto-split will be the best choice for performance and other reasons.");
+ GUILayout.Space(4f);
+ EditorGUILayout.LabelField("Choosing split options will split the road/shoulder up into pieces mirroring the locations of nodes.");
+ GUILayout.Space(4f);
+ EditorGUILayout.LabelField("Splitting allows for more detailed and flexible road texturing options such as passing sections, other different road lines per section, road debris and more.");
+ GUILayout.Space(4f);
+ EditorGUILayout.LabelField("Choosing split options may also speed up mesh collider collision calculations if bounds calculations are involved.");
+ GUILayout.Space(4f);
+
+ EditorGUILayout.LabelField("Which splitting option to choose?", EditorStyles.boldLabel);
+ EditorGUILayout.LabelField("Choose no splitting if you desire a single material set for this entire road and your game experiences no collison processing slowdowns from one large mesh collider. This option will create less game objects than automatic and manual splitting.");
+ GUILayout.Space(4f);
+ EditorGUILayout.LabelField("Choose automatic road and shoulder splitting if you desire multiple materials (such as yellow double lines for certain sections and white dotted for others) for this road and or your game experiences collision processing slowdowns from one large mesh collider.");
+ GUILayout.Space(4f);
+ EditorGUILayout.LabelField("Choose manual road and shoulder splitting if you desire the same as automatic splitting and desire more freedom over the process. This option will result in less gameobjects and larger mesh colliders when compared to automatic splitting.");
+ GUILayout.Space(4f);
+
+
+ Line();
+ EditorGUILayout.LabelField("Manual splitting information: ");
+ GUILayout.Space(4f);
+ EditorGUILayout.LabelField("Choosing manual splitting will force the user to select individual nodes to cut instead of the cuts being performed automatically. This option is recommended if bigger mesh colliders do not cause a slowdown in performance, as it lowers the overall gameobject count.");
+ GUILayout.Space(4f);
+ EditorGUILayout.LabelField("Manual splitting will not split up the mesh colliders like automatic cuts, so the colliders may get large & complex and cost more CPU to process collisions. If this option is chosen, please verify your game's collision processing speed and if you run into long collision processing times split more road sections");
+ GUILayout.Space(4f);
+ EditorGUILayout.LabelField("Example usages of manual splitting");
+ GUILayout.Space(4f);
+ EditorGUILayout.LabelField("Example hill: Goal is to have double yellow no passing lines on a two lane road but only while the road is near or on the hill. " +
+ "Pick nodes on either sides of the hill and mark both as road cut. Everything between these two nodes will be its own section, " +
+ "allowing you to apply double yellow no passing lines for just the hill.");
+ GUILayout.Space(4f);
+ EditorGUILayout.LabelField("Example mountains: In the mountains, the road is curvy and the grade is high. " +
+ "There's a flat straight spot that you want to allow passing in, by marking the road with white dotted passing lines. " +
+ "At the beginning of the flat straight section, mark the node as road cut. Now at the end of the flat straight section, mark this node as road cut. " +
+ "This will create a road section between the two nodes, allowing you to apply white dotted passing lines for just the flat straight section.");
+ GUILayout.Space(4f);
+ EditorGUILayout.BeginHorizontal();
+ if (GUILayout.Button(btnRefreshText, GSDImageButton, GUILayout.Width(16f)))
+ {
+
+ }
+ EditorGUILayout.LabelField(" = Resets settings to default.");
+ EditorGUILayout.EndHorizontal();
+ EditorGUILayout.EndVertical();
+ }
+ else
+ {
+ GUILayout.Space(4f);
+ }
+ EditorGUILayout.EndVertical();
+
+
+ //Camera:
+ EditorGUILayout.LabelField("Editor camera travel:");
+ EditorGUILayout.BeginVertical("box");
+ EditorGUILayout.BeginHorizontal();
+
+ //Option: Editor camera meters per sec
+ t_EditorCameraMetersPerSecond.floatValue = EditorGUILayout.Slider("Camera meters/sec:", RS.EditorCameraMetersPerSecond, 1f, 512f);
+ if (GUILayout.Button(btnRefreshText, GSDImageButton, GUILayout.Width(16f)))
+ {
+ t_EditorCameraMetersPerSecond.floatValue = 60f;
+ }
+ EditorGUILayout.EndHorizontal();
+
+ //Option: Editor camera auto rotate:
+ t_bEditorCameraRotate.boolValue = EditorGUILayout.Toggle("Camera auto rotate: ", RS.bEditorCameraRotate);
+ if (RS.EditorPlayCamera == null)
+ {
+ RS.EditorCameraSetSingle();
+ }
+ RS.EditorPlayCamera = (Camera) EditorGUILayout.ObjectField("Editor play camera:", RS.EditorPlayCamera, typeof(Camera), true);
+ EditorGUILayout.BeginHorizontal();
+ if (GUILayout.Button("Reset", GUILayout.Width(70f)))
+ {
+ RS.QuitEditorCamera();
+ RS.DoEditorCameraLoop();
+ }
+ if (GUILayout.Button("<<", GUILayout.Width(40f)))
+ {
+ RS.EditorCameraPos -= 0.1f;
+ RS.DoEditorCameraLoop();
+ }
+ if (RS.bEditorCameraMoving == true)
+ {
+ if (GUILayout.Button("Pause", GUILayout.Width(70f)))
+ {
+ RS.bEditorCameraMoving = false;
+ }
+ }
+ else
+ {
+ if (GUILayout.Button("Play", GUILayout.Width(70f)))
+ {
+ RS.bEditorCameraMoving = true;
+ }
+ }
+ if (GUILayout.Button(">>", GUILayout.Width(40f)))
+ {
+ RS.EditorCameraPos += 0.1f;
+ RS.DoEditorCameraLoop();
+ }
+ EditorGUILayout.EndHorizontal();
+
+ GUILayout.Space(4);
+ bShowCameraHelp = EditorGUILayout.Foldout(bShowCameraHelp, status);
+ if (bShowCameraHelp)
+ {
+ EditorGUILayout.BeginVertical("box");
+ EditorGUILayout.BeginHorizontal();
+ EditorGUILayout.LabelField("Editor camera quick help:", EditorStyles.boldLabel);
+ if (GUILayout.Button("Online manual", EditorStyles.miniButton, GUILayout.Width(120f)))
+ {
+ Application.OpenURL("http://microgsd.com/Support/RoadArchitectManual.aspx");
+ }
+ EditorGUILayout.EndHorizontal();
+ EditorGUILayout.HelpBox(tOnlineHelpDesc, MessageType.Info);
+ EditorGUILayout.LabelField("Use this section to travel along the road while in the editor sceneview.");
+ GUILayout.Space(4f);
+ EditorGUILayout.LabelField("Camera meters/sec is the speed at which the camera moves along the road.");
+ GUILayout.Space(4f);
+ EditorGUILayout.LabelField("Auto rotate will automatically rotate the camera to look forward at the current road's tangent. Note: You can still zoom in and out with the camera with this option selected.");
+ GUILayout.Space(4f);
+ EditorGUILayout.LabelField("Note: Materials act differently in the editor scene view compared to actual gameplay. Try the game camera if the materials are z fighting and having other issues.");
+ GUILayout.Space(4f);
+ EditorGUILayout.BeginHorizontal();
+ if (GUILayout.Button(btnRefreshText, GSDImageButton, GUILayout.Width(16f)))
+ {
+
+ }
+ EditorGUILayout.LabelField(" = Resets settings to default.");
+ EditorGUILayout.EndHorizontal();
+ EditorGUILayout.EndVertical();
+ }
+ EditorGUILayout.EndVertical();
+
+ GUILayout.Label("Materials:");
+ EditorGUILayout.BeginVertical("box");
+ //Road material defaults:
+
+ EditorGUILayout.BeginHorizontal();
+ GUILayout.Label("Road base material(s) defaults:");
+ //Option: Set mats to defaults:
+ bSetDefaultMats = false;
+ if (GUILayout.Button(btnRefreshText, GSDImageButton, GUILayout.Width(16f)))
+ {
+ bSetDefaultMats = true;
+ }
+ EditorGUILayout.EndHorizontal();
+ // EditorGUILayout.PropertyField (t_RoadMaterial1, new GUIContent (" Mat #1: "));
+ // if(RS.RoadMaterial1 != null){ EditorGUILayout.PropertyField (t_RoadMaterial2, new GUIContent (" Mat #2: ")); }
+ // if(RS.RoadMaterial2 != null){EditorGUILayout.PropertyField (t_RoadMaterial3, new GUIContent (" Mat #3: ")); }
+ // if(RS.RoadMaterial3 != null){EditorGUILayout.PropertyField (t_RoadMaterial4, new GUIContent (" Mat #4: ")); }
+
+
+ EditorGUILayout.BeginHorizontal();
+ EditorGUILayout.PropertyField(t_RoadMaterial1, new GUIContent(" Mat #1: "));
+ if (RS.RoadMaterial1 != null && GUILayout.Button(btnDeleteText, GSDImageButton, GUILayout.Width(16f)))
+ {
+ RS.RoadMaterial1 = null; }
+ EditorGUILayout.EndHorizontal();
+ if (RS.RoadMaterial1 != null)
+ {
+ EditorGUILayout.BeginHorizontal();
+ EditorGUILayout.PropertyField(t_RoadMaterial2, new GUIContent(" Mat #2: "));
+ if (RS.RoadMaterial2 != null && GUILayout.Button(btnDeleteText, GSDImageButton, GUILayout.Width(16f)))
+ { RS.RoadMaterial2 = null; }
+ EditorGUILayout.EndHorizontal();
+ }
+ if (RS.RoadMaterial1 != null && RS.RoadMaterial2 != null)
+ {
+ EditorGUILayout.BeginHorizontal();
+ EditorGUILayout.PropertyField(t_RoadMaterial3, new GUIContent(" Mat #3: "));
+ if (RS.RoadMaterial3 != null && GUILayout.Button(btnDeleteText, GSDImageButton, GUILayout.Width(16f)))
+ { RS.RoadMaterial3 = null; }
+ EditorGUILayout.EndHorizontal();
+ }
+ if (RS.RoadMaterial1 != null && RS.RoadMaterial2 != null && RS.RoadMaterial3 != null)
+ {
+ EditorGUILayout.BeginHorizontal();
+ EditorGUILayout.PropertyField(t_RoadMaterial4, new GUIContent(" Mat #4: "));
+ if (RS.RoadMaterial4 != null && GUILayout.Button(btnDeleteText, GSDImageButton, GUILayout.Width(16f)))
+ { RS.RoadMaterial4 = null; }
+ EditorGUILayout.EndHorizontal();
+ }
+
+
+
+
+ // //Road marker material defaults:
+ GUILayout.Label("Road marker material(s) defaults:");
+ // EditorGUILayout.PropertyField (t_RoadMaterialMarker1, new GUIContent (" Mat #1: "));
+ // if(RS.RoadMaterialMarker1 != null){EditorGUILayout.PropertyField (t_RoadMaterialMarker2, new GUIContent (" Mat #2: ")); }
+ // if(RS.RoadMaterialMarker2 != null){EditorGUILayout.PropertyField (t_RoadMaterialMarker3, new GUIContent (" Mat #3: ")); }
+ // if(RS.RoadMaterialMarker3 != null){EditorGUILayout.PropertyField (t_RoadMaterialMarker4, new GUIContent (" Mat #4: ")); }
+
+ EditorGUILayout.BeginHorizontal();
+ EditorGUILayout.PropertyField(t_RoadMaterialMarker1, new GUIContent(" Mat #1: "));
+ if (RS.RoadMaterialMarker1 != null && GUILayout.Button(btnDeleteText, GSDImageButton, GUILayout.Width(16f)))
+ {
+ RS.RoadMaterialMarker1 = null; }
+ EditorGUILayout.EndHorizontal();
+ if (RS.RoadMaterialMarker1 != null)
+ {
+ EditorGUILayout.BeginHorizontal();
+ EditorGUILayout.PropertyField(t_RoadMaterialMarker2, new GUIContent(" Mat #2: "));
+ if (RS.RoadMaterialMarker2 != null && GUILayout.Button(btnDeleteText, GSDImageButton, GUILayout.Width(16f)))
+ {
+ RS.RoadMaterialMarker2 = null; }
+ EditorGUILayout.EndHorizontal();
+ }
+ if (RS.RoadMaterialMarker1 != null && RS.RoadMaterialMarker2 != null)
+ {
+ EditorGUILayout.BeginHorizontal();
+ EditorGUILayout.PropertyField(t_RoadMaterialMarker3, new GUIContent(" Mat #3: "));
+ if (RS.RoadMaterialMarker3 != null && GUILayout.Button(btnDeleteText, GSDImageButton, GUILayout.Width(16f)))
+ {
+ RS.RoadMaterialMarker3 = null; }
+ EditorGUILayout.EndHorizontal();
+ }
+ if (RS.RoadMaterialMarker1 != null && RS.RoadMaterialMarker2 != null && RS.RoadMaterialMarker3 != null)
+ {
+ EditorGUILayout.BeginHorizontal();
+ EditorGUILayout.PropertyField(t_RoadMaterialMarker4, new GUIContent(" Mat #4: "));
+ if (RS.RoadMaterialMarker4 != null && GUILayout.Button(btnDeleteText, GSDImageButton, GUILayout.Width(16f)))
+ {
+ RS.RoadMaterialMarker4 = null; }
+ EditorGUILayout.EndHorizontal();
+ }
+
+
+
+
+ // //Shoulder material defaults:
+ if (RS.opt_bShouldersEnabled)
+ {
+ GUILayout.Label("Shoulder base material(s) defaults:");
+ // EditorGUILayout.PropertyField (t_ShoulderMaterial1, new GUIContent (" Mat #1: "));
+ // if(RS.ShoulderMaterial1 != null){EditorGUILayout.PropertyField (t_ShoulderMaterial2, new GUIContent (" Mat #2: ")); }
+ // if(RS.ShoulderMaterial2 != null){EditorGUILayout.PropertyField (t_ShoulderMaterial3, new GUIContent (" Mat #3: ")); }
+ // if(RS.ShoulderMaterial3 != null){EditorGUILayout.PropertyField (t_ShoulderMaterial4, new GUIContent (" Mat #4: ")); }
+
+ EditorGUILayout.BeginHorizontal();
+ EditorGUILayout.PropertyField(t_ShoulderMaterial1, new GUIContent(" Mat #1: "));
+ if (RS.ShoulderMaterial1 != null && GUILayout.Button(btnDeleteText, GSDImageButton, GUILayout.Width(16f)))
+ {
+ RS.ShoulderMaterial1 = null; }
+ EditorGUILayout.EndHorizontal();
+ if (RS.ShoulderMaterial1 != null)
+ {
+ EditorGUILayout.BeginHorizontal();
+ EditorGUILayout.PropertyField(t_ShoulderMaterial2, new GUIContent(" Mat #2: "));
+ if (RS.ShoulderMaterial2 != null && GUILayout.Button(btnDeleteText, GSDImageButton, GUILayout.Width(16f)))
+ { RS.ShoulderMaterial2 = null; }
+ EditorGUILayout.EndHorizontal();
+ }
+ if (RS.ShoulderMaterial1 != null && RS.ShoulderMaterial2 != null)
+ {
+ EditorGUILayout.BeginHorizontal();
+ EditorGUILayout.PropertyField(t_ShoulderMaterial3, new GUIContent(" Mat #3: "));
+ if (RS.ShoulderMaterial3 != null && GUILayout.Button(btnDeleteText, GSDImageButton, GUILayout.Width(16f)))
+ {
+ RS.ShoulderMaterial3 = null; }
+ EditorGUILayout.EndHorizontal();
+ }
+ if (RS.ShoulderMaterial1 != null && RS.ShoulderMaterial2 != null && RS.ShoulderMaterial3 != null)
+ {
+ EditorGUILayout.BeginHorizontal();
+ EditorGUILayout.PropertyField(t_ShoulderMaterial4, new GUIContent(" Mat #4: "));
+ if (RS.ShoulderMaterial4 != null && GUILayout.Button(btnDeleteText, GSDImageButton, GUILayout.Width(16f)))
+ {
+ RS.ShoulderMaterial4 = null; }
+ EditorGUILayout.EndHorizontal();
+ }
+ }
+
+
+
+
+ // //Shoulder marker material defaults:
+ if (RS.opt_bShouldersEnabled)
+ {
+ GUILayout.Label("Shoulder marker material(s) defaults:");
+ // EditorGUILayout.PropertyField (t_ShoulderMaterialMarker1, new GUIContent (" Mat #1: "));
+ // if(RS.ShoulderMaterialMarker1 != null){EditorGUILayout.PropertyField (t_ShoulderMaterialMarker2, new GUIContent (" Mat #2: ")); }
+ // if(RS.ShoulderMaterialMarker2 != null){EditorGUILayout.PropertyField (t_ShoulderMaterialMarker3, new GUIContent (" Mat #3: ")); }
+ // if(RS.ShoulderMaterialMarker3 != null){EditorGUILayout.PropertyField (t_ShoulderMaterialMarker4, new GUIContent (" Mat #4: ")); }
+
+ EditorGUILayout.BeginHorizontal();
+ EditorGUILayout.PropertyField(t_ShoulderMaterialMarker1, new GUIContent(" Mat #1: "));
+ if (RS.ShoulderMaterialMarker1 != null && GUILayout.Button(btnDeleteText, GSDImageButton, GUILayout.Width(16f)))
+ {
+ RS.ShoulderMaterialMarker1 = null; }
+ EditorGUILayout.EndHorizontal();
+ if (RS.ShoulderMaterialMarker1 != null)
+ {
+ EditorGUILayout.BeginHorizontal();
+ EditorGUILayout.PropertyField(t_ShoulderMaterialMarker2, new GUIContent(" Mat #2: "));
+ if (RS.ShoulderMaterialMarker2 != null && GUILayout.Button(btnDeleteText, GSDImageButton, GUILayout.Width(16f)))
+ { RS.ShoulderMaterialMarker2 = null; }
+ EditorGUILayout.EndHorizontal();
+ }
+ if (RS.ShoulderMaterialMarker1 != null && RS.ShoulderMaterialMarker2 != null)
+ {
+ EditorGUILayout.BeginHorizontal();
+ EditorGUILayout.PropertyField(t_ShoulderMaterialMarker3, new GUIContent(" Mat #3: "));
+ if (RS.ShoulderMaterialMarker3 != null && GUILayout.Button(btnDeleteText, GSDImageButton, GUILayout.Width(16f)))
+ {
+ RS.ShoulderMaterialMarker3 = null; }
+ EditorGUILayout.EndHorizontal();
+ }
+ if (RS.ShoulderMaterialMarker1 != null && RS.ShoulderMaterialMarker2 != null && RS.ShoulderMaterialMarker3 != null)
+ {
+ EditorGUILayout.BeginHorizontal();
+ EditorGUILayout.PropertyField(t_ShoulderMaterialMarker4, new GUIContent(" Mat #4: "));
+ if (RS.ShoulderMaterialMarker4 != null && GUILayout.Button(btnDeleteText, GSDImageButton, GUILayout.Width(16f)))
+ {
+ RS.ShoulderMaterialMarker4 = null; }
+ EditorGUILayout.EndHorizontal();
+ }
+ }
+
+
+
+ //Physics materials:
+ GUILayout.Label("Physics materials defaults:");
+ //Option: physical road mat:
+ // t_RoadPhysicMaterial.serializedObject = (PhysicMaterial)EditorGUILayout.ObjectField(" Road mat: ",RS.RoadPhysicMaterial,typeof(PhysicMaterial),false);
+ EditorGUILayout.PropertyField(t_RoadPhysicMaterial, new GUIContent("Road phys mat: "));
+
+
+ //Option: physical shoulder mat:
+ // t_ShoulderPhysicMaterial.serializedObject = (PhysicMaterial)EditorGUILayout.ObjectField(" Shoulder mat: ",RS.ShoulderPhysicMaterial,typeof(PhysicMaterial),false);
+ EditorGUILayout.PropertyField(t_ShoulderPhysicMaterial, new GUIContent("Shoulder phys mat: "));
+
+
+ GUILayout.Space(4);
+ EditorGUILayout.BeginHorizontal();
+ //Option: Apply above materials to entire road:
+ EditorGUILayout.LabelField("Apply above materials to entire road:");
+ bApplyMatsCheck = EditorGUILayout.Toggle(bApplyMatsCheck, GUILayout.Width(20f));
+ if (GUILayout.Button("Apply", EditorStyles.miniButton, GUILayout.Width(60f)))
+ {
+ if (bApplyMatsCheck)
+ {
+ t_bApplyMatsCheck = true;
+ }
+ }
+ EditorGUILayout.EndHorizontal();
+ EditorGUILayout.LabelField("Applying will overwrite any saved cuts' material(s).");
+
+ //Help toggle for materials
+ GUILayout.Space(4);
+ bShowMatsHelp = EditorGUILayout.Foldout(bShowMatsHelp, status);
+ if (bShowMatsHelp)
+ {
+ EditorGUILayout.BeginVertical("box");
+ EditorGUILayout.LabelField("These default materials will be applied by default to their respective generated meshes. If using split roads and or shoulders, you can specific specific materials to use on them (on the mesh renderers of the cuts) and they will be used instead of the default materials listed above.");
+ GUILayout.Space(4f);
+ EditorGUILayout.LabelField("Road base material is UV mapped on a world vector basis for seamless tiles.");
+ GUILayout.Space(4f);
+ EditorGUILayout.LabelField("Road marker material is UV mapped to fit roads. Use these materials to place road lines and other road texture details. Note: if using road cuts, these are the materials which will be placed by default at the initial generation.");
+ GUILayout.Space(4f);
+ EditorGUILayout.LabelField("Shoulder base material is UV mapped on a world vector basis for seamless tiles.");
+ GUILayout.Space(4f);
+ EditorGUILayout.LabelField("Shoulder marker material is UV mapped on a world vector basis for seamless tiles. For intended use with transparent shadow receiving shaders. Marker materials are applied, optionally, on shoulder cuts.");
+ GUILayout.Space(4f);
+ EditorGUILayout.LabelField("The physical material for road will be used on all road colliders. The physical material for shoulder will be used on all shoulder colliders. If using road and or shoulder cuts, you can specficy unique physics materials which will be used instead of the default physics materials.");
+ GUILayout.Space(4f);
+ EditorGUILayout.LabelField("Apply above materials button will clear all saved materials on the roads and all road and shoulder meshes will use the materials listed above.");
+ GUILayout.Space(4f);
+ EditorGUILayout.BeginHorizontal();
+ if (GUILayout.Button(btnRefreshText, GSDImageButton, GUILayout.Width(16f)))
+ {
+
+ }
+ EditorGUILayout.LabelField(" = Resets settings to default.");
+ EditorGUILayout.EndHorizontal();
+ EditorGUILayout.EndVertical();
+ }
+ EditorGUILayout.EndVertical();
+
+ //Reset terrain history:
+ Line();
+ EditorGUILayout.BeginHorizontal();
+ EditorGUILayout.LabelField("Reset road's terrain history:");
+ bResetTH = EditorGUILayout.Toggle(bResetTH, GUILayout.Width(20f));
+ if (bResetTH)
+ {
+ if (GUILayout.Button("Reset") && bResetTH)
+ {
+ RS.ConstructRoad_ResetTerrainHistory();
+ bResetTH = false;
+ }
+ }
+ else
+ {
+ if (GUILayout.Button("Check to reset", GSDMaybeButton) && bResetTH)
+ {
+ RS.ConstructRoad_ResetTerrainHistory();
+ bResetTH = false;
+ }
+ }
+ EditorGUILayout.EndHorizontal();
+
+ if (bResetTH)
+ {
+ EditorGUILayout.LabelField("WARNING: This option can't be undone! Only reset the terrain history if you have changed terrain resolution data such as heightmap or detail resolutions. A rare event may occur when editing and compiling this addon's scripts that a terrain history reset may be necessary. Treat this reset as a last resort.", WarningLabelStyle);
+ }
+ GUILayout.Space(6f);
+
+
+ EditorGUILayout.LabelField("Statistics:");
+ EditorGUILayout.BeginVertical("box");
+ EditorGUILayout.LabelField("Length: " + RS.GSDSpline.distance.ToString("F1") + " meters");
+ EditorGUILayout.LabelField("Total nodes: " + RS.MostRecentNodeCount.ToString());
+ EditorGUILayout.EndVertical();
+
+ bool bGizmoChange = false;
+ bool bLaneChange = false;
+ bool bMultithreadChange = false;
+ bool bSaveMeshChange = false;
+ bool bTerrainHistoryChange = false;
+ bool bEditorCameraSpeedChange = false;
+
+ if (GUI.changed)
+ {
+ //Option pre-handle: Gizmos:
+ if (t_opt_GizmosEnabled.boolValue != RS.opt_GizmosEnabled)
+ {
+ bGizmoChange = true;
+ RS.Wireframes_Toggle();
+ SceneView.RepaintAll();
+ }
+ //Option pre-handle: Lane count:
+ if (t_opt_Lanes.intValue != RS.opt_Lanes)
+ {
+ bNeedRoadUpdate = true;
+ bLaneChange = true;
+ }
+
+ //Option pre-handle for multithread and save mesh:
+ if (RS.GSDRS != null)
+ {
+ if (t_opt_bMultithreading.boolValue != RS.GSDRS.opt_bMultithreading)
+ {
+ RS.GSDRS.opt_bMultithreading = t_opt_bMultithreading.boolValue;
+ bMultithreadChange = true;
+ }
+ if (t_opt_bSaveMeshes.boolValue != RS.GSDRS.opt_bSaveMeshes)
+ {
+ RS.GSDRS.opt_bSaveMeshes = t_opt_bSaveMeshes.boolValue;
+ bSaveMeshChange = true;
+ }
+ }
+
+ //Option pre-handle for terrain history:
+ if (t_opt_SaveTerrainHistoryOnDisk.boolValue != RS.opt_SaveTerrainHistoryOnDisk)
+ {
+ bTerrainHistoryChange = true;
+ }
+
+ //Option pre-handle for editor camera speed:
+ if (!GSDRootUtil.IsApproximately(t_EditorCameraMetersPerSecond.floatValue, RS.EditorCameraMetersPerSecond, 0.001f))
+ {
+ bEditorCameraSpeedChange = true;
+ }
+
+ //Apply serialization:
+ serializedObject.ApplyModifiedProperties();
+
+
+ //Handle after effects:
+ if (bGizmoChange)
+ {
+ RS.Wireframes_Toggle();
+ SceneView.RepaintAll();
+ }
+
+
+ //Option: Lane count:
+ if (bLaneChange)
+ {
+ if (RS.opt_UseDefaultMaterials)
+ {
+ RS.GSDSpline.ClearAllRoadCuts();
+ RS.SetDefaultMats();
+ RS.SetAllCutsToCurrentMaterials();
+ }
+ }
+
+ //Option: Multithreading
+ if (bMultithreadChange)
+ {
+ RS.GSDRS.UpdateAllRoads_MultiThreadOptions();
+ }
+
+ //Option: Save meshes as unity assets options:
+ if (bSaveMeshChange)
+ {
+ RS.GSDRS.UpdateAllRoads_SaveMeshesAsAssetsOptions();
+ }
+
+ //Option: terrain history save type:
+ if (bTerrainHistoryChange)
+ {
+ if (RS.opt_SaveTerrainHistoryOnDisk)
+ {
+ RS.ConstructRoad_StoreTerrainHistory(true);
+ }
+ else
+ {
+ RS.ConstructRoad_LoadTerrainHistory(true);
+ }
+ }
+
+ //Option: Editor camera meters per sec
+ if (bEditorCameraSpeedChange)
+ {
+ RS.ChangeEditorCameraMetersPerSec();
+ }
+
+ //Update road:
+ if (bNeedRoadUpdate)
+ {
+ RS.GSDSpline.Setup_Trigger();
+ }
+
+ //Option: Set mats to defaults:
+ if (bSetDefaultMats)
+ {
+ RS.SetDefaultMats();
+ RS.SetAllCutsToCurrentMaterials();
+ }
+
+ //Option: Apply above materials to entire road:
+ if (t_bApplyMatsCheck)
+ {
+ t_bApplyMatsCheck = false;
+ bApplyMatsCheck = false;
+ RS.SetAllCutsToCurrentMaterials();
+ }
+
+ EditorUtility.SetDirty(target);
+ }
+ }
+
+
+ public void OnSceneGUI()
+ {
+ Event current = Event.current;
+ int controlID = GUIUtility.GetControlID(GetHashCode(), FocusType.Passive);
+
+ if (current.alt == true)
+ {
+ return;
+ }
+
+ if (Selection.Contains(RS.transform.gameObject) && Selection.objects.Length > 1)
+ {
+ SetSelectionToRoad();
+ }
+
+ // Handle Ctrl and Shift when road is selected
+ if (Selection.activeGameObject == RS.transform.gameObject)
+ {
+ RS.Editor_bSelected = true;
+ // Only handle MouseMove and MouseDrag events
+ if (Event.current.type == EventType.MouseMove || Event.current.type == EventType.MouseDrag)
+ {
+ if (current.control)
+ {
+ Ray worldRay = HandleUtility.GUIPointToWorldRay(Event.current.mousePosition);
+ RaycastHit hitInfo;
+ if (Physics.Raycast(worldRay, out hitInfo))
+ {
+ /* There used to be a check for whether this was a terrain */
+ RS.Editor_MousePos = hitInfo.point;
+ RS.Editor_MouseTerrainHit = true;
+ if (RS.GSDSpline && RS.GSDSpline.PreviewSpline)
+ {
+ //Debug.Log("Drawing new node");
+ if (RS.GSDSpline.PreviewSpline.mNodes == null || RS.GSDSpline.PreviewSpline.mNodes.Count < 1)
+ {
+ RS.GSDSpline.Setup(); }
+ RS.GSDSpline.PreviewSpline.MousePos = hitInfo.point;
+ RS.GSDSpline.PreviewSpline.bGizmoDraw = true;
+ SceneView.RepaintAll();
+ }
+ }
+
+ GUI.changed = true;
+ }
+ else if (current.shift)
+ {
+ Ray worldRay = HandleUtility.GUIPointToWorldRay(Event.current.mousePosition);
+ RaycastHit hitInfo;
+ if (Physics.Raycast(worldRay, out hitInfo))
+ {
+ /* Used to check for terrain */
+ // if(hitInfo.collider.transform.name.ToLower().Contains("terrain")){
+ RS.Editor_MousePos = hitInfo.point;
+ RS.Editor_MouseTerrainHit = true;
+ if (RS.GSDSpline && RS.GSDSpline.PreviewSplineInsert)
+ {
+ if (RS.GSDSpline.PreviewSplineInsert.mNodes == null || RS.GSDSpline.PreviewSplineInsert.mNodes.Count < 1)
+ {
+ RS.GSDSpline.PreviewSplineInsert.DetermineInsertNodes(); }
+ RS.GSDSpline.PreviewSplineInsert.MousePos = hitInfo.point;
+ RS.GSDSpline.PreviewSplineInsert.bGizmoDraw = true;
+ RS.GSDSpline.PreviewSplineInsert.UpdateActionNode();
+ SceneView.RepaintAll();
+ }
+ //}else{
+ // RS.Editor_MouseTerrainHit = false;
+ //}
+ }
+
+ GUI.changed = true;
+ }
+ else
+ {
+ if (RS.Editor_MouseTerrainHit)
+ {
+ RS.Editor_MouseTerrainHit = false;
+ GUI.changed = true;
+ }
+ if (RS.GSDSpline && RS.GSDSpline.PreviewSpline)
+ {
+ //Debug.Log("not drawing new node");
+ RS.GSDSpline.PreviewSpline.bGizmoDraw = false;
+ }
+ if (RS.GSDSpline && RS.GSDSpline.PreviewSplineInsert)
+ {
+ //Debug.Log("not drawing insert node");
+ RS.GSDSpline.PreviewSplineInsert.bGizmoDraw = false;
+ }
+ }
+ }
+ }
+ else
+ {
+ RS.Editor_bSelected = false;
+ if (RS.GSDSpline.PreviewSpline)
+ {
+ RS.GSDSpline.PreviewSpline.bGizmoDraw = false;
+ }
+ }
+
+
+
+ if (current.shift && RS.GSDSpline.PreviewSpline != null)
+ {
+ RS.GSDSpline.PreviewSpline.bGizmoDraw = false;
+ }
+ bool bUsed = false;
+ if (current.control)
+ {
+ if (Event.current.type == EventType.MouseDown)
+ {
+ //Left click:
+ if (Event.current.button == 0)
+ {
+ if (RS.Editor_MouseTerrainHit)
+ {
+ // if((EditorApplication.timeSinceStartup - RS.GSDSpline.EditorOnly_LastNode_TimeSinceStartup) > 0.05){
+ // RS.GSDSpline.EditorOnly_LastNode_TimeSinceStartup = EditorApplication.timeSinceStartup;
+ Event.current.Use();
+ GSDConstruction.CreateNode(RS);
+ bUsed = true;
+ // }
+ }
+ else
+ {
+ Debug.Log("Invalid surface for new node. Must be terrain.");
+ }
+ }
+ }
+ }
+ else if (current.shift)
+ {
+ if (Event.current.type == EventType.MouseDown)
+ {
+ //Left click:
+ if (Event.current.button == 0)
+ {
+ if (RS.Editor_MouseTerrainHit)
+ {
+ Event.current.Use();
+ GSDConstruction.InsertNode(RS);
+ bUsed = true;
+ }
+ else
+ {
+ Debug.Log("Invalid surface for insertion node. Must be terrain.");
+ }
+ }
+ }
+ }
+
+
+ if (current.type == EventType.ValidateCommand)
+ {
+ switch (current.commandName)
+ {
+ case "UndoRedoPerformed":
+ TriggerRoadUpdate();
+ break;
+ }
+ }
+
+ if (Selection.activeGameObject == RS.transform.gameObject)
+ {
+ if (current.keyCode == KeyCode.F5)
+ {
+ TriggerRoadUpdate();
+ }
+ }
+
+
+
+ if (bUsed)
+ {
+ SetSelectionToRoad();
+ switch (current.type)
+ {
+ case EventType.Layout:
+ HandleUtility.AddDefaultControl(controlID);
+ break;
+ }
+ }
+
+ if (GUI.changed)
+ {
+ EditorUtility.SetDirty(RS);
+ }
+ }
+
+
+ private void TriggerRoadUpdate()
+ {
+ if (RS != null)
+ {
+ RS.EditorUpdateMe = true;
+ }
+ }
+
+
+ void SetSelectionToRoad()
+ {
+ GameObject[] tObjs = new GameObject[1];
+ tObjs[0] = RS.transform.gameObject;
+ Selection.objects = tObjs;
+ }
+
+
+ #region "Progress bar"
+ ///
+ /// Creates progress bar.
+ ///
+ ///
+ /// Value of the progress bar.
+ ///
+ ///
+ /// Label of the progress bar.
+ ///
+ void GSDProgressBar(float tV, string tL)
+ {
+ // Get a rect for the progress bar using the same margins as a textfield:
+ Rect rect = GUILayoutUtility.GetRect(18, 18, "TextField");
+ EditorGUI.ProgressBar(rect, tV, tL);
+ EditorGUILayout.Space();
+ }
+ #endregion
+
+
+ // FH_Tag Optimizable
+ void Line()
+ {
+ GUILayout.Space(4f);
+ GUILayout.Box("", GUILayout.ExpandWidth(true), GUILayout.Height(1f)); //Horizontal bar
+ GUILayout.Space(4f);
+ }
+
+
+ void LineSmall()
+ {
+ GUILayout.Space(1f);
+ GUILayout.Box("", GUILayout.ExpandWidth(true), GUILayout.Height(1f)); //Horizontal bar
+ GUILayout.Space(1f);
+ }
+ // FH_Tag Optimizable
+}
\ No newline at end of file
diff --git a/Editor/GSDRoadIntersectionEditor.cs b/Editor/GSDRoadIntersectionEditor.cs
index 36e938a4..ff15efe1 100755
--- a/Editor/GSDRoadIntersectionEditor.cs
+++ b/Editor/GSDRoadIntersectionEditor.cs
@@ -1,1035 +1,1221 @@
-using UnityEngine;
-using UnityEditor;
-using System.Collections.Generic;
-using GSD;
-
-[CustomEditor(typeof(GSDRoadIntersection))]
-public class GSDRoadIntersectionEditor : Editor
-{
- protected GSDRoadIntersection tInter { get { return (GSDRoadIntersection)target; } }
-
- SerializedProperty t_opt_AutoUpdateIntersections;
- SerializedProperty t_bDrawGizmo;
- SerializedProperty t_bLeftTurnYieldOnGreen;
- SerializedProperty t_opt_FixedTime_RegularLightLength;
- SerializedProperty t_opt_FixedTime_LeftTurnLightLength;
- SerializedProperty t_opt_FixedTime_AllRedLightLength;
- SerializedProperty t_opt_FixedTime_YellowLightLength;
- SerializedProperty t_bTrafficPoleStreetLight;
- SerializedProperty t_bTrafficLightGray;
- SerializedProperty t_bRegularPoleAlignment;
- SerializedProperty t_bLightsEnabled;
- SerializedProperty t_StreetLight_Range;
- SerializedProperty t_StreetLight_Intensity;
- SerializedProperty t_StreetLight_Color;
- SerializedProperty t_ScalingSense;
- SerializedProperty t_GradeMod;
- SerializedProperty t_bUseDefaultMaterials;
- SerializedProperty t_MarkerCenter1;
- SerializedProperty t_MarkerCenter2;
- SerializedProperty t_MarkerCenter3;
- SerializedProperty t_MarkerExt_Stretch1;
- SerializedProperty t_MarkerExt_Stretch2;
- SerializedProperty t_MarkerExt_Stretch3;
- SerializedProperty t_MarkerExt_Tiled1;
- SerializedProperty t_MarkerExt_Tiled2;
- SerializedProperty t_MarkerExt_Tiled3;
- SerializedProperty t_Lane0Mat1;
- SerializedProperty t_Lane0Mat2;
- SerializedProperty t_Lane1Mat1;
- SerializedProperty t_Lane1Mat2;
- SerializedProperty t_Lane2Mat1;
- SerializedProperty t_Lane2Mat2;
- SerializedProperty t_Lane3Mat1;
- SerializedProperty t_Lane3Mat2;
- SerializedProperty t_rType;
- SerializedProperty t_iStopType;
- SerializedProperty t_lType;
-
- #region "Editor only variables"
- //Editor only variables
- const bool bDebug = false;
- bool bShowMarkerStretch = false;
- bool bShowMarkerTiled = false;
- bool bShowMarkerCenter = false;
- bool bShowTLSense = false;
- bool bShowTLPole = false;
- bool bShowLightHelp = false;
- bool bShowLanes = false;
- bool bGradeCorrect = false;
- bool bShowDefaultMatHelp = false;
- bool bShowHelpLeftTurnGreen = false;
- string status = "Show help";
-
- GUIStyle GSDImageButton = null;
- Texture btnRefreshText = null;
- Texture btnDeleteText = null;
-
- private static string[] rTypeDescriptions = new string[]{
- "No turn lanes",
- "Left turn lane only",
- "Both left and right turn lanes"
- };
-
- private static string[] rTypeDescriptions_3Way = new string[]{
- "No turn lanes",
- "Left turn lane only"
- };
-
- private static string[] iStopTypeEnumDescriptions = new string[]{
- "Stop signs",
- "Traffic lights",
- "None"
-// "Traffic lights #2"
- };
-
- private static string[] iTrafficLightSequenceTypeDesc = new string[]{
- "Fixed time",
- "Other"
- };
-
- const string HelpText1 = "Each material added is rendered on top of the previous. Combine with transparent shaders which accept shadows to allow for easy marking.";
-
- //Checkers:
- Texture2D LoadBtnBG = null;
- Texture2D LoadBtnBGGlow = null;
-
- GUIStyle GSDLoadButton = null;
- bool bHasInit = false;
- #endregion
-
- private void OnEnable()
- {
- t_opt_AutoUpdateIntersections = serializedObject.FindProperty("opt_AutoUpdateIntersections");
- t_bDrawGizmo = serializedObject.FindProperty("bDrawGizmo");
- t_bLeftTurnYieldOnGreen = serializedObject.FindProperty("bLeftTurnYieldOnGreen");
- t_opt_FixedTime_RegularLightLength = serializedObject.FindProperty("opt_FixedTime_RegularLightLength");
- t_opt_FixedTime_LeftTurnLightLength = serializedObject.FindProperty("opt_FixedTime_LeftTurnLightLength");
- t_opt_FixedTime_AllRedLightLength = serializedObject.FindProperty("opt_FixedTime_AllRedLightLength");
- t_opt_FixedTime_YellowLightLength = serializedObject.FindProperty("opt_FixedTime_YellowLightLength");
- t_bTrafficPoleStreetLight = serializedObject.FindProperty("bTrafficPoleStreetLight");
- t_bTrafficLightGray = serializedObject.FindProperty("bTrafficLightGray");
- t_bRegularPoleAlignment = serializedObject.FindProperty("bRegularPoleAlignment");
- t_bLightsEnabled = serializedObject.FindProperty("bLightsEnabled");
- t_StreetLight_Range = serializedObject.FindProperty("StreetLight_Range");
- t_StreetLight_Intensity = serializedObject.FindProperty("StreetLight_Intensity");
- t_StreetLight_Color = serializedObject.FindProperty("StreetLight_Color");
- t_ScalingSense = serializedObject.FindProperty("ScalingSense");
- t_GradeMod = serializedObject.FindProperty("GradeMod");
- t_bUseDefaultMaterials = serializedObject.FindProperty("bUseDefaultMaterials");
- t_MarkerCenter1 = serializedObject.FindProperty("MarkerCenter1");
- t_MarkerCenter2 = serializedObject.FindProperty("MarkerCenter2");
- t_MarkerCenter3 = serializedObject.FindProperty("MarkerCenter3");
- t_MarkerExt_Stretch1 = serializedObject.FindProperty("MarkerExt_Stretch1");
- t_MarkerExt_Stretch2 = serializedObject.FindProperty("MarkerExt_Stretch2");
- t_MarkerExt_Stretch3 = serializedObject.FindProperty("MarkerExt_Stretch3");
- t_MarkerExt_Tiled1 = serializedObject.FindProperty("MarkerExt_Tiled1");
- t_MarkerExt_Tiled2 = serializedObject.FindProperty("MarkerExt_Tiled2");
- t_MarkerExt_Tiled3 = serializedObject.FindProperty("MarkerExt_Tiled3");
- t_Lane0Mat1 = serializedObject.FindProperty("Lane0Mat1");
- t_Lane0Mat2 = serializedObject.FindProperty("Lane0Mat2");
- t_Lane1Mat1 = serializedObject.FindProperty("Lane1Mat1");
- t_Lane1Mat2 = serializedObject.FindProperty("Lane1Mat2");
- t_Lane2Mat1 = serializedObject.FindProperty("Lane2Mat1");
- t_Lane2Mat2 = serializedObject.FindProperty("Lane2Mat2");
- t_Lane3Mat1 = serializedObject.FindProperty("Lane3Mat1");
- t_Lane3Mat2 = serializedObject.FindProperty("Lane3Mat2");
- t_rType = serializedObject.FindProperty("rType");
- t_iStopType = serializedObject.FindProperty("iStopType");
- t_lType = serializedObject.FindProperty("lType");
- }
-
- public override void OnInspectorGUI()
- {
- if (Event.current.type == EventType.ValidateCommand)
- {
- switch (Event.current.commandName)
- {
- case "UndoRedoPerformed":
- TriggerRoadUpdate(true);
- break;
- }
- }
-
- serializedObject.Update();
-
- //Graphic null checks:
- if (!bHasInit) { Init(); }
-
- Line();
- EditorGUILayout.BeginHorizontal();
- {
- GSDRoad road1 = tInter.Node1.GSDSpline.transform.parent.GetComponent();
- GSDRoad road2 = tInter.Node2.GSDSpline.transform.parent.GetComponent();
- EditorGUILayout.LabelField("First road: " + road1.name + " node: " + tInter.Node1.name);
- EditorGUILayout.LabelField("Second road: " + road2.name + " node: " + tInter.Node2.name);
- }
- EditorGUILayout.EndHorizontal();
- Line();
- EditorGUILayout.BeginHorizontal();
- EditorGUILayout.LabelField("Intersection options", EditorStyles.boldLabel);
- if (GUILayout.Button("Update intersection", GSDLoadButton))
- {
- TriggerRoadUpdate(true);
- }
- EditorGUILayout.EndHorizontal();
-
- //Option: Auto update:
- t_opt_AutoUpdateIntersections.boolValue = EditorGUILayout.Toggle("Auto-update:", tInter.opt_AutoUpdateIntersections);
-
- //Option: Gizmo:
- t_bDrawGizmo.boolValue = EditorGUILayout.Toggle("Gizmo:", tInter.bDrawGizmo);
-
- //UI:
- EditorGUILayout.BeginHorizontal();
- if (tInter.iType == GSDRoadIntersection.IntersectionTypeEnum.ThreeWay)
- {
- EditorGUILayout.LabelField("Intersection type: 3 way");
- }
- else
- {
- EditorGUILayout.LabelField("Intersection type: 4 way");
- }
- if (GUILayout.Button("Online manual", EditorStyles.miniButton, GUILayout.Width(120f)))
- {
- Application.OpenURL("http://microgsd.com/Support/RoadArchitectManual.aspx");
- }
- EditorGUILayout.EndHorizontal();
- Line();
- EditorGUILayout.BeginVertical();
- if (GUILayout.Button("Access objects on first road node"))
- {
- Selection.objects = new Object[1] { tInter.Node1 };
- }
- if (GUILayout.Button("Access objects on second road node"))
- {
- Selection.objects = new Object[1] { tInter.Node2 };
- }
- EditorGUILayout.EndVertical();
- //Option: Intersection turn lane options
- Line();
- EditorGUILayout.LabelField("Intersection turn lane options:");
- if (tInter.iType == GSDRoadIntersection.IntersectionTypeEnum.ThreeWay)
- {
- t_rType.enumValueIndex = (int)EditorGUILayout.Popup((int)tInter.rType, rTypeDescriptions_3Way);
- }
- else
- {
- t_rType.enumValueIndex = (int)EditorGUILayout.Popup((int)tInter.rType, rTypeDescriptions);
- }
-
- //Option: Left yield on green:
- if (tInter.rType != GSDRoadIntersection.RoadTypeEnum.NoTurnLane)
- {
- t_bLeftTurnYieldOnGreen.boolValue = EditorGUILayout.Toggle("Left yield on green: ", tInter.bLeftTurnYieldOnGreen);
-
- bShowHelpLeftTurnGreen = EditorGUILayout.Foldout(bShowHelpLeftTurnGreen, status);
- if (bShowHelpLeftTurnGreen)
- {
- EditorGUILayout.BeginVertical("box");
- EditorGUILayout.LabelField("Left yield on green: If checked, replaces the standard 3-light left turn light with a five-light yield on green left turn signal structure and sign.");
- EditorGUILayout.EndVertical();
- }
- }
- Line();
-
-
- //Option: Intersection stop type:
- t_iStopType.enumValueIndex = (int)EditorGUILayout.Popup("Intersection stop type:", (int)tInter.iStopType, iStopTypeEnumDescriptions);
-
-
- if (tInter.iStopType == GSDRoadIntersection.iStopTypeEnum.TrafficLight1 || tInter.iStopType == GSDRoadIntersection.iStopTypeEnum.TrafficLight2)
- {
- //Option: Traffic light timing type:
- t_lType.enumValueIndex = (int)EditorGUILayout.Popup("Traffic light timing:", (int)tInter.lType, iTrafficLightSequenceTypeDesc);
-
- //Options: Traffic fixed light timings:
- if (tInter.lType == GSDRoadIntersection.LightTypeEnum.Timed)
- {
- EditorGUILayout.LabelField("Traffic light fixed time lengths (in seconds):");
- EditorGUILayout.BeginHorizontal();
- t_opt_FixedTime_RegularLightLength.floatValue = EditorGUILayout.Slider("Green length: ", tInter.opt_FixedTime_RegularLightLength, 0.1f, 180f);
- if (GUILayout.Button(btnRefreshText, GSDImageButton, GUILayout.Width(16f))) { t_opt_FixedTime_RegularLightLength.floatValue = 30f; }
- EditorGUILayout.EndHorizontal();
-
- if (tInter.rType != GSDRoadIntersection.RoadTypeEnum.NoTurnLane)
- {
- EditorGUILayout.BeginHorizontal();
- t_opt_FixedTime_LeftTurnLightLength.floatValue = EditorGUILayout.Slider("Left turn only length: ", tInter.opt_FixedTime_LeftTurnLightLength, 0.1f, 180f);
- if (GUILayout.Button(btnRefreshText, GSDImageButton, GUILayout.Width(16f))) { t_opt_FixedTime_LeftTurnLightLength.floatValue = 10f; }
- EditorGUILayout.EndHorizontal();
- }
-
- EditorGUILayout.BeginHorizontal();
- t_opt_FixedTime_AllRedLightLength.floatValue = EditorGUILayout.Slider("All red length: ", tInter.opt_FixedTime_AllRedLightLength, 0.1f, 180f);
- if (GUILayout.Button(btnRefreshText, GSDImageButton, GUILayout.Width(16f))) { t_opt_FixedTime_AllRedLightLength.floatValue = 1f; }
- EditorGUILayout.EndHorizontal();
-
- EditorGUILayout.BeginHorizontal();
- t_opt_FixedTime_YellowLightLength.floatValue = EditorGUILayout.Slider("Yellow light length: ", tInter.opt_FixedTime_YellowLightLength, 0.1f, 180f);
- if (GUILayout.Button(btnRefreshText, GSDImageButton, GUILayout.Width(16f))) { t_opt_FixedTime_YellowLightLength.floatValue = 3f; }
- EditorGUILayout.EndHorizontal();
- }
- }
-
-
- if (tInter.iStopType == GSDRoadIntersection.iStopTypeEnum.TrafficLight1 || tInter.iStopType == GSDRoadIntersection.iStopTypeEnum.TrafficLight2)
- {
- //Option: Traffic light poles:
- Line();
- EditorGUILayout.LabelField("Traffic light poles:");
- t_bTrafficPoleStreetLight.boolValue = EditorGUILayout.Toggle("Street lights: ", tInter.bTrafficPoleStreetLight);
-
- //Option: Traffic light pole gray color:
- t_bTrafficLightGray.boolValue = EditorGUILayout.Toggle("Gray color: ", tInter.bTrafficLightGray);
-
- //Option: Normal pole alignment:
- t_bRegularPoleAlignment.boolValue = EditorGUILayout.Toggle("Normal pole alignment: ", tInter.bRegularPoleAlignment);
- bShowTLPole = EditorGUILayout.Foldout(bShowTLPole, status);
- if (bShowTLPole)
- {
- EditorGUILayout.BeginVertical("box");
- EditorGUILayout.LabelField("Street lights: If checked, attaches street lights to each intersection pole. Point lights optional and can be manipulated in the next option segment.");
- GUILayout.Space(4f);
- EditorGUILayout.LabelField("Gray color: If checked, sets the traffic light pole base materials to gray galvanized steel. If unchecked the material used is black metal paint.");
- GUILayout.Space(4f);
- EditorGUILayout.LabelField("Normal pole alignment: Recommended to keep this option on unless abnormal twisting of light objects is occurring. Turn this option off if the roads immediately surrounding your intersection are curved at extreme angles and cause irregular twisting of the traffic light objects. Turning this option off will attempt to align the poles perpendicular to the adjacent relevant road without any part existing over the main intersection bounds.");
- EditorGUILayout.EndVertical();
- }
-
- //Option: Point lights enabled:
- Line();
- EditorGUILayout.BeginHorizontal();
- EditorGUILayout.LabelField("Point lights:");
- EditorGUILayout.EndHorizontal();
- t_bLightsEnabled.boolValue = EditorGUILayout.Toggle(" Point lights enabled: ", tInter.bLightsEnabled);
-
- //Options: Street point light options:
- if (tInter.bTrafficPoleStreetLight)
- {
- //Option: Street light range:
- EditorGUILayout.BeginHorizontal();
- t_StreetLight_Range.floatValue = EditorGUILayout.Slider(" Street light range: ", tInter.StreetLight_Range, 1f, 128f);
- if (GUILayout.Button(btnRefreshText, GSDImageButton, GUILayout.Width(16f)))
- {
- t_StreetLight_Range.floatValue = 30f;
- }
- EditorGUILayout.EndHorizontal();
-
- //Option: Street light intensity:
- EditorGUILayout.BeginHorizontal();
- t_StreetLight_Intensity.floatValue = EditorGUILayout.Slider(" Street light intensity: ", tInter.StreetLight_Intensity, 0f, 8f);
- if (GUILayout.Button(btnRefreshText, GSDImageButton, GUILayout.Width(16f)))
- {
- t_StreetLight_Intensity.floatValue = 1f;
- }
- EditorGUILayout.EndHorizontal();
-
- //Option: Street light color:
- EditorGUILayout.BeginHorizontal();
- t_StreetLight_Color.colorValue = EditorGUILayout.ColorField(" Street light color: ", tInter.StreetLight_Color);
- if (GUILayout.Button(btnRefreshText, GSDImageButton, GUILayout.Width(16f)))
- {
- t_StreetLight_Color.colorValue = new Color(1f, 0.7451f, 0.27451f, 1f); ;
- }
- EditorGUILayout.EndHorizontal();
- }
- bShowLightHelp = EditorGUILayout.Foldout(bShowLightHelp, status);
- if (bShowLightHelp)
- {
- EditorGUILayout.BeginVertical("box");
- EditorGUILayout.LabelField("Point lights: Enabled means that point lights for the traffic lights (and street lights, if enabled) will be turned on. This is accessible via script \"bLightsEnabled\"");
-
- GUILayout.Space(4f);
- EditorGUILayout.LabelField("If street pole lights enabled: Street light range, intensity and color: These settings directly correlate to the standard point light settings.");
-
- GUILayout.Space(4f);
- EditorGUILayout.BeginHorizontal();
- if (GUILayout.Button(btnRefreshText, GSDImageButton, GUILayout.Width(16f)))
- {
-
- }
- EditorGUILayout.LabelField(" = Resets settings to default.");
- EditorGUILayout.EndHorizontal();
- EditorGUILayout.EndVertical();
- }
- Line();
-
- //Option: Traffic light scaling sensitivity:
- EditorGUILayout.LabelField("Traffic light scaling sensitivity: *Does not auto-update");
- EditorGUILayout.BeginHorizontal();
- t_ScalingSense.floatValue = EditorGUILayout.Slider(tInter.ScalingSense, 0f, 200f);
- if (GUILayout.Button(btnRefreshText, GSDImageButton, GUILayout.Width(16f)))
- {
- t_ScalingSense.floatValue = 170f;
- }
- EditorGUILayout.EndHorizontal(); GUILayout.Space(4f);
- EditorGUILayout.BeginHorizontal();
- bShowTLSense = EditorGUILayout.Foldout(bShowTLSense, status);
- if (GUILayout.Button("Manually update intersection", EditorStyles.miniButton, GUILayout.Width(170f)))
- {
- TriggerRoadUpdate(true);
- }
- EditorGUILayout.EndHorizontal();
- if (bShowTLSense)
- {
- EditorGUILayout.BeginVertical("box");
- EditorGUILayout.LabelField("Increasing this value will increase the scaling sensitivity relative to the size of the intersection. Higher scaling value = bigger traffic lights at further distances. Default value is 170.");
- GUILayout.Space(4f);
- EditorGUILayout.BeginHorizontal();
- if (GUILayout.Button(btnRefreshText, GSDImageButton, GUILayout.Width(16f)))
- {
-
- }
- EditorGUILayout.LabelField(" = Resets settings to default.");
- EditorGUILayout.EndHorizontal();
- EditorGUILayout.EndVertical();
- }
- GUILayout.Space(4f);
- }
-
- //Option: Grade correction modifier:
- Line();
- EditorGUILayout.BeginHorizontal();
- EditorGUILayout.LabelField("Grade correction factor: *Does not auto-update");
- EditorGUILayout.EndHorizontal();
- EditorGUILayout.BeginHorizontal();
- t_GradeMod.floatValue = EditorGUILayout.Slider(tInter.GradeMod, 0.01f, 2f);
- if (GUILayout.Button(btnRefreshText, GSDImageButton, GUILayout.Width(16f)))
- {
- t_GradeMod.floatValue = 0.375f;
- }
- EditorGUILayout.EndHorizontal();
- EditorGUILayout.BeginHorizontal();
- bGradeCorrect = EditorGUILayout.Foldout(bGradeCorrect, status);
- if (GUILayout.Button("Manually update intersection", EditorStyles.miniButton, GUILayout.Width(170f)))
- {
- tInter.UpdateRoads();
- }
- EditorGUILayout.EndHorizontal();
- if (bGradeCorrect)
- {
- EditorGUILayout.BeginVertical("box");
- EditorGUILayout.LabelField("If using extreme road grades immediately surrounding the intersection, terrain height matching errors may occur at the point of road expansion leading to the intersection.");
- EditorGUILayout.LabelField("Raise this value if you see terrain poking through the road at the road expansion areas.");
- EditorGUILayout.LabelField("Lower this value if you are not using road mesh colliders and notice dips at the expansion points.");
- EditorGUILayout.LabelField("Default value is 0.375 meters, which is the maximum value for a linear range of 0% to 20% grade.");
- EditorGUILayout.LabelField("Recommended to keep grades and angles small leading up to intersections.");
- GUILayout.Space(4f);
- EditorGUILayout.BeginHorizontal();
- if (GUILayout.Button(btnRefreshText, GSDImageButton, GUILayout.Width(16f)))
- {
-
- }
- EditorGUILayout.LabelField(" = Resets settings to default.");
- EditorGUILayout.EndHorizontal();
- EditorGUILayout.EndVertical();
- }
-
- //Option: Use default materials:
- Line();
- t_bUseDefaultMaterials.boolValue = EditorGUILayout.Toggle("Use default materials:", tInter.bUseDefaultMaterials);
- bShowDefaultMatHelp = EditorGUILayout.Foldout(bShowDefaultMatHelp, status);
- if (bShowDefaultMatHelp)
- {
- EditorGUILayout.BeginVertical("box");
- EditorGUILayout.LabelField("Checking this option will reset all materials for this intersection and use the default intersection materials that come with this addon.");
- EditorGUILayout.EndVertical();
- }
-
-
- Line();
- EditorGUILayout.BeginHorizontal();
- EditorGUILayout.LabelField("Center marker material(s):");
- if (GUILayout.Button(btnRefreshText, GSDImageButton, GUILayout.Width(16f)))
- {
- tInter.ResetMaterials_Center();
- }
- EditorGUILayout.EndHorizontal(); GUILayout.Space(4f);
- //Options: Center materials:
- // EditorGUILayout.BeginHorizontal();
- // EditorGUILayout.PropertyField (t_MarkerCenter1, new GUIContent ("Center material #1:"));
- // if(tInter.MarkerCenter1 != null && GUILayout.Button(btnDeleteText,GSDImageButton,GUILayout.Width(16f))){ t_MarkerCenter1 = null; }
- // EditorGUILayout.EndHorizontal();
- // if(tInter.MarkerCenter1 != null){
- // EditorGUILayout.BeginHorizontal();
- // EditorGUILayout.PropertyField (t_MarkerCenter2, new GUIContent ("Center material #2:"));
- // if(tInter.MarkerCenter2 != null && GUILayout.Button(btnDeleteText,GSDImageButton,GUILayout.Width(16f))){ t_MarkerCenter2 = null; }
- // EditorGUILayout.EndHorizontal();
- // if(tInter.MarkerCenter2 != null){
- // EditorGUILayout.BeginHorizontal();
- // EditorGUILayout.PropertyField (t_MarkerCenter3, new GUIContent ("Center material #3:"));
- // if(tInter.MarkerCenter3 != null && GUILayout.Button(btnDeleteText,GSDImageButton,GUILayout.Width(16f))){ t_MarkerCenter3 = null; }
- // EditorGUILayout.EndHorizontal();
- // }
- // }
-
- EditorGUILayout.BeginHorizontal();
- EditorGUILayout.PropertyField(t_MarkerCenter1, new GUIContent(" Mat #1: "));
- if (tInter.MarkerCenter1 != null && GUILayout.Button(btnDeleteText, GSDImageButton, GUILayout.Width(16f))) { tInter.MarkerCenter1 = null; }
- EditorGUILayout.EndHorizontal();
-
- if (tInter.MarkerCenter1 != null)
- {
- EditorGUILayout.BeginHorizontal();
- EditorGUILayout.PropertyField(t_MarkerCenter2, new GUIContent(" Mat #2: "));
- if (tInter.MarkerCenter2 != null && GUILayout.Button(btnDeleteText, GSDImageButton, GUILayout.Width(16f))) { tInter.MarkerCenter2 = null; }
- EditorGUILayout.EndHorizontal();
- }
- if (tInter.MarkerCenter2 != null && tInter.MarkerCenter1 != null)
- {
- EditorGUILayout.BeginHorizontal();
- EditorGUILayout.PropertyField(t_MarkerCenter3, new GUIContent(" Mat #3: "));
- if (tInter.MarkerCenter3 != null && GUILayout.Button(btnDeleteText, GSDImageButton, GUILayout.Width(16f))) { tInter.MarkerCenter3 = null; }
- EditorGUILayout.EndHorizontal();
- }
-
- bShowMarkerCenter = EditorGUILayout.Foldout(bShowMarkerCenter, status);
- if (bShowMarkerCenter)
- {
- EditorGUILayout.BeginVertical("box");
- EditorGUILayout.LabelField("Center marker materials require transparent shaders. Covers the center area of the intersection. Displayed in order #1 on bottom to #4 on top. Combine with transparent shaders which accept shadows to allow for easy marking.");
- DoDefaultHelpMat();
- DoDeleteHelpMat();
- EditorGUILayout.EndVertical();
- }
- Line();
-
- //Options: Marker ext stretched materials:
- EditorGUILayout.BeginHorizontal();
- EditorGUILayout.LabelField("Exterior fitted marker material(s):");
- if (GUILayout.Button(btnRefreshText, GSDImageButton, GUILayout.Width(16f)))
- {
- tInter.ResetMaterials_Ext_Stretched();
- }
- EditorGUILayout.EndHorizontal();
-
- EditorGUILayout.BeginHorizontal();
- EditorGUILayout.PropertyField(t_MarkerExt_Stretch1, new GUIContent(" Mat #1: "));
- if (tInter.MarkerExt_Stretch1 != null && GUILayout.Button(btnDeleteText, GSDImageButton, GUILayout.Width(16f))) { tInter.MarkerExt_Stretch1 = null; }
- EditorGUILayout.EndHorizontal();
-
- if (tInter.MarkerExt_Stretch1 != null)
- {
- EditorGUILayout.BeginHorizontal();
- EditorGUILayout.PropertyField(t_MarkerExt_Stretch2, new GUIContent(" Mat #2: "));
- if (tInter.MarkerExt_Stretch2 != null && GUILayout.Button(btnDeleteText, GSDImageButton, GUILayout.Width(16f))) { tInter.MarkerExt_Stretch2 = null; }
- EditorGUILayout.EndHorizontal();
- }
- if (tInter.MarkerExt_Stretch2 != null && tInter.MarkerExt_Stretch1 != null)
- {
- EditorGUILayout.BeginHorizontal();
- EditorGUILayout.PropertyField(t_MarkerExt_Stretch3, new GUIContent(" Mat #3: "));
- if (tInter.MarkerExt_Stretch3 != null && GUILayout.Button(btnDeleteText, GSDImageButton, GUILayout.Width(16f))) { tInter.MarkerExt_Stretch3 = null; }
- EditorGUILayout.EndHorizontal();
- }
-
- bShowMarkerStretch = EditorGUILayout.Foldout(bShowMarkerStretch, status);
- if (bShowMarkerStretch)
- {
- EditorGUILayout.BeginVertical("box");
- EditorGUILayout.LabelField("Fitted marker materials require transparent shaders. Covers the exterior area of the intersection with the UV's stretched to match at a 1:1 ratio. Should be use for intersection markings and any visual effects like dirt." + HelpText1);
- DoDefaultHelpMat();
- DoDeleteHelpMat();
- EditorGUILayout.EndVertical();
- }
- Line();
-
- //Options: Marker ext tiled materials:
- EditorGUILayout.BeginHorizontal();
- EditorGUILayout.LabelField("Exterior tiled marker material(s):");
- if (GUILayout.Button(btnRefreshText, GSDImageButton, GUILayout.Width(16f)))
- {
- tInter.ResetMaterials_Ext_Tiled();
- }
- EditorGUILayout.EndHorizontal(); GUILayout.Space(4f);
-
- EditorGUILayout.BeginHorizontal();
- EditorGUILayout.PropertyField(t_MarkerExt_Tiled1, new GUIContent(" Mat #1: "));
- if (tInter.MarkerExt_Tiled1 != null && GUILayout.Button(btnDeleteText, GSDImageButton, GUILayout.Width(16f))) { tInter.MarkerExt_Tiled1 = null; }
- EditorGUILayout.EndHorizontal();
-
- if (tInter.MarkerExt_Tiled1 != null)
- {
- EditorGUILayout.BeginHorizontal();
- EditorGUILayout.PropertyField(t_MarkerExt_Tiled2, new GUIContent(" Mat #2: "));
- if (tInter.MarkerExt_Tiled2 != null && GUILayout.Button(btnDeleteText, GSDImageButton, GUILayout.Width(16f))) { tInter.MarkerExt_Tiled2 = null; }
- EditorGUILayout.EndHorizontal();
- }
- if (tInter.MarkerExt_Tiled2 != null && tInter.MarkerExt_Tiled1 != null)
- {
- EditorGUILayout.BeginHorizontal();
- EditorGUILayout.PropertyField(t_MarkerExt_Tiled3, new GUIContent(" Mat #3: "));
- if (tInter.MarkerExt_Tiled3 != null && GUILayout.Button(btnDeleteText, GSDImageButton, GUILayout.Width(16f))) { tInter.MarkerExt_Tiled3 = null; }
- EditorGUILayout.EndHorizontal();
- }
-
- bShowMarkerTiled = EditorGUILayout.Foldout(bShowMarkerTiled, status);
- if (bShowMarkerTiled)
- {
- EditorGUILayout.BeginVertical("box");
- EditorGUILayout.LabelField("Covers the exterior area of the intersection with the UV's tiled matching world coordinates. Tiled and used for road pavement textures. UV coordinates will match up seamlessly with road pavement." + HelpText1);
- DoDefaultHelpMat();
- DoDeleteHelpMat();
- EditorGUILayout.EndVertical();
- }
- Line();
-
- //Option: Lane section 0:
- EditorGUILayout.BeginHorizontal();
- EditorGUILayout.LabelField("Lanes marker materials:");
- if (GUILayout.Button(btnRefreshText, GSDImageButton, GUILayout.Width(16f)))
- {
- tInter.ResetMaterials_Lanes();
- }
- EditorGUILayout.EndHorizontal(); GUILayout.Space(4f);
-
- EditorGUILayout.BeginHorizontal();
- EditorGUILayout.PropertyField(t_Lane0Mat1, new GUIContent("Lane section 0 mat #1:"));
- if (tInter.Lane0Mat1 != null && GUILayout.Button(btnDeleteText, GSDImageButton, GUILayout.Width(16f))) { tInter.Lane0Mat1 = null; }
- EditorGUILayout.EndHorizontal();
- if (tInter.Lane0Mat1 != null)
- {
- EditorGUILayout.BeginHorizontal();
- EditorGUILayout.PropertyField(t_Lane0Mat2, new GUIContent("Lane section 0 mat #2:"));
- if (tInter.Lane0Mat2 != null && GUILayout.Button(btnDeleteText, GSDImageButton, GUILayout.Width(16f))) { tInter.Lane0Mat2 = null; }
- EditorGUILayout.EndHorizontal();
- }
-
-
- //Option: Lane section 1:
- EditorGUILayout.BeginHorizontal();
- EditorGUILayout.PropertyField(t_Lane1Mat1, new GUIContent("Lane section 1 mat #1:"));
- if (tInter.Lane1Mat1 != null && GUILayout.Button(btnDeleteText, GSDImageButton, GUILayout.Width(16f))) { tInter.Lane1Mat1 = null; }
- EditorGUILayout.EndHorizontal();
- if (tInter.Lane1Mat1 != null)
- {
- EditorGUILayout.BeginHorizontal();
- EditorGUILayout.PropertyField(t_Lane1Mat2, new GUIContent("Lane section 1 mat #2:"));
- if (tInter.Lane1Mat2 != null && GUILayout.Button(btnDeleteText, GSDImageButton, GUILayout.Width(16f))) { tInter.Lane1Mat2 = null; }
- EditorGUILayout.EndHorizontal();
- }
-
- //Option: Lane section 2:
- if (tInter.rType == GSDRoadIntersection.RoadTypeEnum.BothTurnLanes || tInter.rType == GSDRoadIntersection.RoadTypeEnum.TurnLane)
- {
- EditorGUILayout.BeginHorizontal();
- EditorGUILayout.PropertyField(t_Lane2Mat1, new GUIContent("Lane section 2 mat #1:"));
- if (tInter.Lane2Mat1 != null && GUILayout.Button(btnDeleteText, GSDImageButton, GUILayout.Width(16f))) { tInter.Lane2Mat1 = null; }
- EditorGUILayout.EndHorizontal();
- if (tInter.Lane2Mat1 != null)
- {
- EditorGUILayout.BeginHorizontal();
- EditorGUILayout.PropertyField(t_Lane2Mat2, new GUIContent("Lane section 2 mat #2:"));
- if (tInter.Lane2Mat2 != null && GUILayout.Button(btnDeleteText, GSDImageButton, GUILayout.Width(16f))) { tInter.Lane2Mat2 = null; }
- EditorGUILayout.EndHorizontal();
- }
- }
- GUILayout.Space(4f);
-
- //Option: Lane section 3:
- if (tInter.rType == GSDRoadIntersection.RoadTypeEnum.BothTurnLanes)
- {
- EditorGUILayout.BeginHorizontal();
- EditorGUILayout.PropertyField(t_Lane3Mat1, new GUIContent("Lane section 3 mat #1:"));
- if (tInter.Lane3Mat1 != null && GUILayout.Button(btnDeleteText, GSDImageButton, GUILayout.Width(16f))) { tInter.Lane3Mat1 = null; }
- EditorGUILayout.EndHorizontal();
- if (tInter.Lane3Mat1 != null)
- {
- EditorGUILayout.BeginHorizontal();
- EditorGUILayout.PropertyField(t_Lane3Mat2, new GUIContent("Lane section 3 mat #2:"));
- if (tInter.Lane3Mat2 != null && GUILayout.Button(btnDeleteText, GSDImageButton, GUILayout.Width(16f))) { tInter.Lane3Mat2 = null; }
- EditorGUILayout.EndHorizontal();
- }
- }
- bShowLanes = EditorGUILayout.Foldout(bShowLanes, status);
- if (bShowLanes)
- {
- EditorGUILayout.BeginVertical("box");
- EditorGUILayout.LabelField("Covers individual lane sections in the intersection. Used for high-definition line marking.");
- EditorGUILayout.LabelField("Lane section 0 = Left side of the intersection where oncoming traffic travels. Use lane texture which matches the number of lanes used on the road system, with a white left line and a yellow right line.");
-
- if (tInter.rType == GSDRoadIntersection.RoadTypeEnum.BothTurnLanes)
- {
- EditorGUILayout.LabelField("Lane section 1 = Left turn lane. Use a single lane texture with a yellow left line and a white right line.");
- EditorGUILayout.LabelField("Lane section 2 = Right outgoing traffic lane. Use lane texture which matches the number of lanes used on the road system with a white right line.");
- EditorGUILayout.LabelField("Lane section 3 = Right turn lane. Use a single lane texture with a white right line.");
- }
- else if (tInter.rType == GSDRoadIntersection.RoadTypeEnum.TurnLane)
- {
- EditorGUILayout.LabelField("Lane section 1 = Left turn lane. Use a single lane texture with a yellow left line and a white right line.");
- EditorGUILayout.LabelField("Lane section 2 = Right outgoing traffic lane. Use lane texture which matches the number of lanes used on the road system with a white right line.");
- }
- else if (tInter.rType == GSDRoadIntersection.RoadTypeEnum.NoTurnLane)
- {
- EditorGUILayout.LabelField("Lane section 1 = Right outgoing traffic lane. Use lane texture which matches the number of lanes used on the road system with a white right line.");
- }
-
- EditorGUILayout.LabelField(HelpText1);
- DoDefaultHelpMat();
- DoDeleteHelpMat();
- EditorGUILayout.EndVertical();
- }
- Line();
-
- // if(bDebug){
- // Line();
- // EditorGUILayout.LabelField("Debug");
- // if(tInter.Node1 != null){ EditorGUILayout.LabelField(" Node1: " + tInter.Node1.transform.name); } else { EditorGUILayout.LabelField(" Node1: null"); }
- // if(tInter.Node2 != null){ EditorGUILayout.LabelField(" Node2: " + tInter.Node2.transform.name); } else { EditorGUILayout.LabelField(" Node2: null"); }
- // if(tInter.Node1 != null){ EditorGUILayout.LabelField(" UID1: " + tInter.Node1.UID); } else { EditorGUILayout.LabelField(" UID1: null"); }
- // if(tInter.Node2 != null){ EditorGUILayout.LabelField(" UID2: " + tInter.Node2.UID); } else { EditorGUILayout.LabelField(" UID2: null"); }
- // EditorGUILayout.LabelField(" Same spline: " + tInter.bSameSpline);
- // EditorGUILayout.LabelField(" bFlipped: " + tInter.bFlipped);
- // EditorGUILayout.LabelField(" IgnoreSide: " + tInter.IgnoreSide);
- // EditorGUILayout.LabelField(" IgnoreCorner: " + tInter.IgnoreCorner);
- //
- // if(tInter.iStopType == GSDRoadIntersection.iStopTypeEnum.TrafficLight1 || tInter.iStopType == GSDRoadIntersection.iStopTypeEnum.TrafficLight2){
- // if(tInter.LightsRR != null){ EditorGUILayout.LabelField(" LightsRR: " + tInter.LightsRR); } else { EditorGUILayout.LabelField(" LightsRR: null"); }
- // if(tInter.LightsRR != null || tInter.LightsRR.MR_Main != null){ EditorGUILayout.LabelField(" MR_Main: " + tInter.LightsRR.MR_Main); } else { EditorGUILayout.LabelField(" LightsRR.MR_Main: null"); }
- // if(tInter.LightsRR != null || tInter.LightsRR.MR_Left != null){ EditorGUILayout.LabelField(" MR_Left: " + tInter.LightsRR.MR_Left); } else { EditorGUILayout.LabelField(" LightsRR.MR_Left: null"); }
- // if(tInter.LightsRR != null || tInter.LightsRR.MR_Right != null){ EditorGUILayout.LabelField(" MR_Right: " + tInter.LightsRR.MR_Right); } else { EditorGUILayout.LabelField(" LightsRR.MR_Right: null"); }
- // if(tInter.LightsRL != null){ EditorGUILayout.LabelField(" LightsRL: " + tInter.LightsRL); } else { EditorGUILayout.LabelField(" LightsRL: null"); }
- // if(tInter.LightsLL != null){ EditorGUILayout.LabelField(" LightsLL: " + tInter.LightsLL); } else { EditorGUILayout.LabelField(" LightsLL: null"); }
- // if(tInter.LightsLR != null){ EditorGUILayout.LabelField(" LightsLR: " + tInter.LightsLR); } else { EditorGUILayout.LabelField(" LightsLR: null"); }
- // }
- // Line();
- // }
-
-
- //Set change bools:
- bool bToggleTrafficLightPoleColor = false;
- bool bTogglePointLights = false;
- bool bGizmoChange = false;
- bool bMatChange = false;
- bool bRoadUpdate = false;
-
- if (GUI.changed)
- {
- //Option: Gizmo:
- if (t_bDrawGizmo.boolValue != tInter.bDrawGizmo)
- {
- bGizmoChange = true;
- }
-
- //Option: Intersection turn lane options
- if ((int)tInter.rType != t_rType.enumValueIndex)
- {
- bMatChange = true;
- bRoadUpdate = true;
- }
-
- //Option: Left yield on green:
- if (t_bLeftTurnYieldOnGreen.boolValue != tInter.bLeftTurnYieldOnGreen)
- {
- bRoadUpdate = true;
- }
-
- //Option: Intersection stop type:
- if (t_iStopType.enumValueIndex != (int)tInter.iStopType)
- {
- bRoadUpdate = true;
- }
-
- //Option: Traffic light poles:
- if (t_bTrafficPoleStreetLight.boolValue != tInter.bTrafficPoleStreetLight)
- {
- bRoadUpdate = true;
- }
-
- //Option: Traffic light pole gray color:
- if (t_bTrafficLightGray.boolValue != tInter.bTrafficLightGray)
- {
- bToggleTrafficLightPoleColor = true;
- }
-
- //Option: Normal pole alignment:
- if (t_bRegularPoleAlignment.boolValue != tInter.bRegularPoleAlignment)
- {
- bRoadUpdate = true;
- }
-
- //Option: Point lights enabled:
- if (t_bLightsEnabled.boolValue != tInter.bLightsEnabled)
- {
- bTogglePointLights = true;
- }
-
- //Option: Street light range:
- if (!GSDRootUtil.IsApproximately(t_StreetLight_Range.floatValue, tInter.StreetLight_Range, 0.01f))
- {
- bTogglePointLights = true;
- }
-
- //Option: Street light intensity:
- if (!GSDRootUtil.IsApproximately(t_StreetLight_Intensity.floatValue, tInter.StreetLight_Intensity, 0.01f))
- {
- bTogglePointLights = true;
- }
-
- //Option: Street light color:
- if (t_StreetLight_Color.colorValue != tInter.StreetLight_Color)
- {
- bTogglePointLights = true;
- }
-
- //Option: Use default materials:
- if (t_bUseDefaultMaterials.boolValue != tInter.bUseDefaultMaterials)
- {
- bMatChange = true;
- }
-
- if (t_MarkerCenter1 == null || t_MarkerCenter1.objectReferenceValue == null) { tInter.MarkerCenter1 = null; }
- if (t_MarkerCenter2 == null || t_MarkerCenter2.objectReferenceValue == null) { tInter.MarkerCenter2 = null; }
- if (t_MarkerCenter3 == null || t_MarkerCenter3.objectReferenceValue == null) { tInter.MarkerCenter3 = null; }
- if (t_MarkerExt_Stretch1 == null || t_MarkerExt_Stretch1.objectReferenceValue == null) { tInter.MarkerExt_Stretch1 = null; }
- if (t_MarkerExt_Stretch2 == null || t_MarkerExt_Stretch2.objectReferenceValue == null) { tInter.MarkerExt_Stretch2 = null; }
- if (t_MarkerExt_Stretch3 == null || t_MarkerExt_Stretch3.objectReferenceValue == null) { tInter.MarkerExt_Stretch3 = null; }
- if (t_MarkerExt_Tiled1 == null || t_MarkerExt_Tiled1.objectReferenceValue == null) { tInter.MarkerExt_Tiled1 = null; }
- if (t_MarkerExt_Tiled2 == null || t_MarkerExt_Tiled2.objectReferenceValue == null) { tInter.MarkerExt_Tiled2 = null; }
- if (t_MarkerExt_Tiled3 == null || t_MarkerExt_Tiled3.objectReferenceValue == null) { tInter.MarkerExt_Tiled3 = null; }
- if (t_Lane0Mat1 == null || t_Lane0Mat1.objectReferenceValue == null) { tInter.Lane0Mat1 = null; }
- if (t_Lane0Mat2 == null || t_Lane0Mat2.objectReferenceValue == null) { tInter.Lane0Mat2 = null; }
- if (t_Lane1Mat1 == null || t_Lane1Mat1.objectReferenceValue == null) { tInter.Lane1Mat1 = null; }
- if (t_Lane1Mat2 == null || t_Lane1Mat2.objectReferenceValue == null) { tInter.Lane1Mat2 = null; }
- if (t_Lane2Mat1 == null || t_Lane2Mat1.objectReferenceValue == null) { tInter.Lane2Mat1 = null; }
- if (t_Lane2Mat2 == null || t_Lane2Mat2.objectReferenceValue == null) { tInter.Lane2Mat2 = null; }
- if (t_Lane3Mat1 == null || t_Lane3Mat1.objectReferenceValue == null) { tInter.Lane3Mat1 = null; }
- if (t_Lane3Mat2 == null || t_Lane3Mat2.objectReferenceValue == null) { tInter.Lane3Mat2 = null; }
-
- if (tInter.MarkerCenter1 != null && t_MarkerCenter1.objectReferenceValue != tInter.MarkerCenter1) { bMatChange = true; }
- if (tInter.MarkerCenter2 != null && t_MarkerCenter2.objectReferenceValue != tInter.MarkerCenter2) { bMatChange = true; }
- if (tInter.MarkerCenter3 != null && t_MarkerCenter3.objectReferenceValue != tInter.MarkerCenter3) { bMatChange = true; }
- if (tInter.MarkerExt_Stretch1 != null && t_MarkerExt_Stretch1.objectReferenceValue != tInter.MarkerExt_Stretch1) { bMatChange = true; }
- if (tInter.MarkerExt_Stretch2 != null && t_MarkerExt_Stretch2.objectReferenceValue != tInter.MarkerExt_Stretch2) { bMatChange = true; }
- if (tInter.MarkerExt_Stretch3 != null && t_MarkerExt_Stretch3.objectReferenceValue != tInter.MarkerExt_Stretch3) { bMatChange = true; }
- if (tInter.MarkerExt_Tiled1 != null && t_MarkerExt_Tiled1.objectReferenceValue != tInter.MarkerExt_Tiled1) { bMatChange = true; }
- if (tInter.MarkerExt_Tiled2 != null && t_MarkerExt_Tiled2.objectReferenceValue != tInter.MarkerExt_Tiled2) { bMatChange = true; }
- if (tInter.MarkerExt_Tiled3 != null && t_MarkerExt_Tiled3.objectReferenceValue != tInter.MarkerExt_Tiled3) { bMatChange = true; }
- if (tInter.Lane0Mat1 != null && t_Lane0Mat1.objectReferenceValue != tInter.Lane0Mat1) { bMatChange = true; }
- if (tInter.Lane0Mat2 != null && t_Lane0Mat2.objectReferenceValue != tInter.Lane0Mat2) { bMatChange = true; }
- if (tInter.Lane1Mat1 != null && t_Lane1Mat1.objectReferenceValue != tInter.Lane1Mat1) { bMatChange = true; }
- if (tInter.Lane1Mat2 != null && t_Lane1Mat2.objectReferenceValue != tInter.Lane1Mat2) { bMatChange = true; }
- if (tInter.Lane2Mat1 != null && t_Lane2Mat1.objectReferenceValue != tInter.Lane2Mat1) { bMatChange = true; }
- if (tInter.Lane2Mat2 != null && t_Lane2Mat2.objectReferenceValue != tInter.Lane2Mat2) { bMatChange = true; }
- if (tInter.Lane3Mat1 != null && t_Lane3Mat1.objectReferenceValue != tInter.Lane3Mat1) { bMatChange = true; }
- if (tInter.Lane3Mat2 != null && t_Lane3Mat2.objectReferenceValue != tInter.Lane3Mat2) { bMatChange = true; }
-
-
- //Apply changes:
- serializedObject.ApplyModifiedProperties();
-
-
- //Apply secondary effects:
- if (bGizmoChange)
- {
- MeshRenderer[] tMRs = tInter.transform.GetComponentsInChildren();
- int tCount = tMRs.Length;
- for (int i = 0; i < tCount; i++)
- {
- //EditorUtility.SetSelectedWireframeHidden(tMRs[i], !tInter.bDrawGizmo);
- EditorUtility.SetSelectedRenderState(tMRs[i], tInter.bDrawGizmo ? EditorSelectedRenderState.Wireframe : EditorSelectedRenderState.Hidden);
-
- }
- SceneView.RepaintAll();
- }
-
- if (bTogglePointLights)
- {
- tInter.TogglePointLights(tInter.bLightsEnabled);
- }
-
- if (bToggleTrafficLightPoleColor)
- {
- tInter.ToggleTrafficLightPoleColor();
- }
-
- if (bMatChange)
- {
- tInter.UpdateMaterials();
- if (tInter.bUseDefaultMaterials)
- {
- tInter.ResetMaterials_All();
- }
- }
-
- if (bRoadUpdate)
- {
- TriggerRoadUpdate();
- }
-
- EditorUtility.SetDirty(tInter);
- }
- }
-
- public void OnSceneGUI()
- {
- Event current = Event.current;
- int controlID = GUIUtility.GetControlID(GetHashCode(), FocusType.Passive);
-
- // if (Event.current.type == EventType.MouseDrag && Event.current.button == 0){
- // //Update relevant splines:
- // tInter.Node1.GSDSpline.Setup();
- // if(!tInter.bSameSpline){
- // tInter.Node2.GSDSpline.Setup();
- // }
- // bMouseDragHasProcessed = false;
- // }
- //
- // if(Event.current.type == EventType.MouseUp && Event.current.button == 0){
- // if(!bMouseDragHasProcessed){
- // tInter.Node1.transform.position = tInter.transform.position;
- // tInter.Node2.transform.position = tInter.transform.position;
- // tInter.StartCoroutine(TriggerRoadUpdate());
- // }
- // bMouseDragHasProcessed = true;
- // }
-
- if (Event.current.type == EventType.MouseUp && Event.current.button == 0)
- {
- if (tInter.transform.position != tInter.Node1.transform.position)
- {
- tInter.Node1.transform.position = tInter.transform.position;
- tInter.Node2.transform.position = tInter.transform.position;
- tInter.Height = tInter.transform.position.y;
- TriggerRoadUpdate();
- }
- }
-
-
-
- if (current.type == EventType.ValidateCommand)
- {
- switch (current.commandName)
- {
- case "UndoRedoPerformed":
- TriggerRoadUpdate(true);
- break;
- }
- }
-
- if (current.type == EventType.MouseDown)
- {
- return;
- }
-
- if (Selection.activeGameObject == tInter.transform.gameObject)
- {
- if (current.keyCode == KeyCode.F5)
- {
- if (tInter != null && tInter.Node1 != null && tInter.Node2 != null)
- {
- TriggerRoadUpdate();
- }
- }
- }
-
- // switch(current.type){
- // case EventType.layout:
- //// if(current.type != EventType.MouseDown){
- // HandleUtility.AddDefaultControl(controlID);
- //// }
- // break;
- //
- // }
-
- if (controlID == 1)
- {
- //Do nothing
- }
- if (GUI.changed) { EditorUtility.SetDirty(tInter); }
- }
-
- private void TriggerRoadUpdate(bool bForce = false)
- {
- if (!bForce && !tInter.opt_AutoUpdateIntersections) { return; }
-
- if (tInter != null && tInter.Node1 != null && tInter.Node2 != null)
- {
- if (!tInter.Node1.GSDSpline.tRoad.Editor_bIsConstructing && !tInter.Node2.GSDSpline.tRoad.Editor_bIsConstructing)
- {
- if (!tInter.bSameSpline)
- {
- tInter.Node1.GSDSpline.tRoad.PiggyBacks = new GSDSplineC[1];
- tInter.Node1.GSDSpline.tRoad.PiggyBacks[0] = tInter.Node2.GSDSpline;
- }
- tInter.Node1.GSDSpline.tRoad.EditorUpdateMe = true;
- }
- }
- }
-
- void Init()
- {
- EditorStyles.label.wordWrap = true;
- bHasInit = true;
- if (btnRefreshText == null)
- {
- btnRefreshText = (Texture)AssetDatabase.LoadAssetAtPath(GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Editor/Icons/refresh2.png", typeof(Texture)) as Texture;
- }
- if (btnDeleteText == null)
- {
- btnDeleteText = (Texture)AssetDatabase.LoadAssetAtPath(GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Editor/Icons/delete.png", typeof(Texture)) as Texture;
- }
- if (LoadBtnBG == null)
- {
- LoadBtnBG = (Texture2D)AssetDatabase.LoadAssetAtPath(GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Editor/Icons/otherbg.png", typeof(Texture2D)) as Texture2D;
- }
- if (LoadBtnBGGlow == null)
- {
- LoadBtnBGGlow = (Texture2D)AssetDatabase.LoadAssetAtPath(GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Editor/Icons/otherbg2.png", typeof(Texture2D)) as Texture2D;
- }
-
- if (GSDImageButton == null)
- {
- GSDImageButton = new GUIStyle(GUI.skin.button);
- GSDImageButton.contentOffset = new Vector2(0f, 0f);
- GSDImageButton.border = new RectOffset(0, 0, 0, 0);
- GSDImageButton.fixedHeight = 16f;
- GSDImageButton.padding = new RectOffset(0, 0, 0, 0);
- GSDImageButton.normal.background = null;
- }
- if (GSDLoadButton == null)
- {
- GSDLoadButton = new GUIStyle(GUI.skin.button);
- GSDLoadButton.contentOffset = new Vector2(0f, 1f);
- GSDLoadButton.normal.textColor = new Color(1f, 1f, 1f, 1f);
- GSDLoadButton.normal.background = LoadBtnBG;
- GSDLoadButton.active.background = LoadBtnBGGlow;
- GSDLoadButton.focused.background = LoadBtnBGGlow;
- GSDLoadButton.hover.background = LoadBtnBGGlow;
- GSDLoadButton.fixedHeight = 16f;
- GSDLoadButton.fixedWidth = 128f;
- }
- }
-
- void DoDefaultHelpMat()
- {
- GUILayout.Space(4f);
- EditorGUILayout.BeginHorizontal();
- if (GUILayout.Button(btnRefreshText, GSDImageButton, GUILayout.Width(16f)))
- {
-
- }
- EditorGUILayout.LabelField(" = Resets material(s) to default materials.");
- EditorGUILayout.EndHorizontal();
- }
-
- void DoDeleteHelpMat()
- {
- GUILayout.Space(4f);
- EditorGUILayout.BeginHorizontal();
- if (GUILayout.Button(btnDeleteText, GSDImageButton, GUILayout.Width(16f)))
- {
-
- }
- EditorGUILayout.LabelField(" = Removes material(s) from intersection.");
- EditorGUILayout.EndHorizontal();
- }
-
- void Line()
- {
- GUILayout.Space(4f);
- GUILayout.Box("", GUILayout.ExpandWidth(true), GUILayout.Height(1)); //Horizontal bar
- GUILayout.Space(4f);
- }
+#region "Imports"
+using UnityEngine;
+using UnityEditor;
+using System.Collections.Generic;
+using GSD;
+#endregion
+
+
+[CustomEditor(typeof(GSDRoadIntersection))]
+public class GSDRoadIntersectionEditor : Editor
+{
+ protected GSDRoadIntersection tInter { get { return (GSDRoadIntersection) target; } }
+
+ SerializedProperty t_opt_AutoUpdateIntersections;
+ SerializedProperty t_bDrawGizmo;
+ SerializedProperty t_bLeftTurnYieldOnGreen;
+ SerializedProperty t_opt_FixedTime_RegularLightLength;
+ SerializedProperty t_opt_FixedTime_LeftTurnLightLength;
+ SerializedProperty t_opt_FixedTime_AllRedLightLength;
+ SerializedProperty t_opt_FixedTime_YellowLightLength;
+ SerializedProperty t_bTrafficPoleStreetLight;
+ SerializedProperty t_bTrafficLightGray;
+ SerializedProperty t_bRegularPoleAlignment;
+ SerializedProperty t_bLightsEnabled;
+ SerializedProperty t_StreetLight_Range;
+ SerializedProperty t_StreetLight_Intensity;
+ SerializedProperty t_StreetLight_Color;
+ SerializedProperty t_ScalingSense;
+ SerializedProperty t_GradeMod;
+ SerializedProperty t_bUseDefaultMaterials;
+ SerializedProperty t_MarkerCenter1;
+ SerializedProperty t_MarkerCenter2;
+ SerializedProperty t_MarkerCenter3;
+ SerializedProperty t_MarkerExt_Stretch1;
+ SerializedProperty t_MarkerExt_Stretch2;
+ SerializedProperty t_MarkerExt_Stretch3;
+ SerializedProperty t_MarkerExt_Tiled1;
+ SerializedProperty t_MarkerExt_Tiled2;
+ SerializedProperty t_MarkerExt_Tiled3;
+ SerializedProperty t_Lane0Mat1;
+ SerializedProperty t_Lane0Mat2;
+ SerializedProperty t_Lane1Mat1;
+ SerializedProperty t_Lane1Mat2;
+ SerializedProperty t_Lane2Mat1;
+ SerializedProperty t_Lane2Mat2;
+ SerializedProperty t_Lane3Mat1;
+ SerializedProperty t_Lane3Mat2;
+ SerializedProperty t_rType;
+ SerializedProperty t_iStopType;
+ SerializedProperty t_lType;
+
+
+ #region "Editor only variables"
+ //Editor only variables
+ const bool bDebug = false;
+ bool bShowMarkerStretch = false;
+ bool bShowMarkerTiled = false;
+ bool bShowMarkerCenter = false;
+ bool bShowTLSense = false;
+ bool bShowTLPole = false;
+ bool bShowLightHelp = false;
+ bool bShowLanes = false;
+ bool bGradeCorrect = false;
+ bool bShowDefaultMatHelp = false;
+ bool bShowHelpLeftTurnGreen = false;
+ string status = "Show help";
+
+ GUIStyle GSDImageButton = null;
+ Texture btnRefreshText = null;
+ Texture btnDeleteText = null;
+
+
+ private static string[] rTypeDescriptions = new string[]{
+ "No turn lanes",
+ "Left turn lane only",
+ "Both left and right turn lanes"
+ };
+
+
+ private static string[] rTypeDescriptions_3Way = new string[]{
+ "No turn lanes",
+ "Left turn lane only"
+ };
+
+
+ private static string[] iStopTypeEnumDescriptions = new string[]{
+ "Stop signs",
+ "Traffic lights",
+ "None"
+// "Traffic lights #2"
+ };
+
+
+ private static string[] iTrafficLightSequenceTypeDesc = new string[]{
+ "Fixed time",
+ "Other"
+ };
+
+
+ const string HelpText1 = "Each material added is rendered on top of the previous. Combine with transparent shaders which accept shadows to allow for easy marking.";
+
+ //Checkers:
+ Texture2D LoadBtnBG = null;
+ Texture2D LoadBtnBGGlow = null;
+
+ GUIStyle GSDLoadButton = null;
+ bool bHasInit = false;
+ #endregion
+
+
+ private void OnEnable()
+ {
+ t_opt_AutoUpdateIntersections = serializedObject.FindProperty("opt_AutoUpdateIntersections");
+ t_bDrawGizmo = serializedObject.FindProperty("bDrawGizmo");
+ t_bLeftTurnYieldOnGreen = serializedObject.FindProperty("bLeftTurnYieldOnGreen");
+ t_opt_FixedTime_RegularLightLength = serializedObject.FindProperty("opt_FixedTime_RegularLightLength");
+ t_opt_FixedTime_LeftTurnLightLength = serializedObject.FindProperty("opt_FixedTime_LeftTurnLightLength");
+ t_opt_FixedTime_AllRedLightLength = serializedObject.FindProperty("opt_FixedTime_AllRedLightLength");
+ t_opt_FixedTime_YellowLightLength = serializedObject.FindProperty("opt_FixedTime_YellowLightLength");
+ t_bTrafficPoleStreetLight = serializedObject.FindProperty("bTrafficPoleStreetLight");
+ t_bTrafficLightGray = serializedObject.FindProperty("bTrafficLightGray");
+ t_bRegularPoleAlignment = serializedObject.FindProperty("bRegularPoleAlignment");
+ t_bLightsEnabled = serializedObject.FindProperty("bLightsEnabled");
+ t_StreetLight_Range = serializedObject.FindProperty("StreetLight_Range");
+ t_StreetLight_Intensity = serializedObject.FindProperty("StreetLight_Intensity");
+ t_StreetLight_Color = serializedObject.FindProperty("StreetLight_Color");
+ t_ScalingSense = serializedObject.FindProperty("ScalingSense");
+ t_GradeMod = serializedObject.FindProperty("GradeMod");
+ t_bUseDefaultMaterials = serializedObject.FindProperty("bUseDefaultMaterials");
+ t_MarkerCenter1 = serializedObject.FindProperty("MarkerCenter1");
+ t_MarkerCenter2 = serializedObject.FindProperty("MarkerCenter2");
+ t_MarkerCenter3 = serializedObject.FindProperty("MarkerCenter3");
+ t_MarkerExt_Stretch1 = serializedObject.FindProperty("MarkerExt_Stretch1");
+ t_MarkerExt_Stretch2 = serializedObject.FindProperty("MarkerExt_Stretch2");
+ t_MarkerExt_Stretch3 = serializedObject.FindProperty("MarkerExt_Stretch3");
+ t_MarkerExt_Tiled1 = serializedObject.FindProperty("MarkerExt_Tiled1");
+ t_MarkerExt_Tiled2 = serializedObject.FindProperty("MarkerExt_Tiled2");
+ t_MarkerExt_Tiled3 = serializedObject.FindProperty("MarkerExt_Tiled3");
+ t_Lane0Mat1 = serializedObject.FindProperty("Lane0Mat1");
+ t_Lane0Mat2 = serializedObject.FindProperty("Lane0Mat2");
+ t_Lane1Mat1 = serializedObject.FindProperty("Lane1Mat1");
+ t_Lane1Mat2 = serializedObject.FindProperty("Lane1Mat2");
+ t_Lane2Mat1 = serializedObject.FindProperty("Lane2Mat1");
+ t_Lane2Mat2 = serializedObject.FindProperty("Lane2Mat2");
+ t_Lane3Mat1 = serializedObject.FindProperty("Lane3Mat1");
+ t_Lane3Mat2 = serializedObject.FindProperty("Lane3Mat2");
+ t_rType = serializedObject.FindProperty("rType");
+ t_iStopType = serializedObject.FindProperty("iStopType");
+ t_lType = serializedObject.FindProperty("lType");
+ }
+
+
+ public override void OnInspectorGUI()
+ {
+ if (Event.current.type == EventType.ValidateCommand)
+ {
+ switch (Event.current.commandName)
+ {
+ case "UndoRedoPerformed":
+ TriggerRoadUpdate(true);
+ break;
+ }
+ }
+
+ serializedObject.Update();
+
+ //Graphic null checks:
+ if (!bHasInit)
+ {
+ Init();
+ }
+
+ Line();
+ EditorGUILayout.BeginHorizontal();
+ {
+ GSDRoad road1 = tInter.Node1.GSDSpline.transform.parent.GetComponent();
+ GSDRoad road2 = tInter.Node2.GSDSpline.transform.parent.GetComponent();
+ EditorGUILayout.LabelField("First road: " + road1.name + " node: " + tInter.Node1.name);
+ EditorGUILayout.LabelField("Second road: " + road2.name + " node: " + tInter.Node2.name);
+ }
+ EditorGUILayout.EndHorizontal();
+ Line();
+ EditorGUILayout.BeginHorizontal();
+ EditorGUILayout.LabelField("Intersection options", EditorStyles.boldLabel);
+ if (GUILayout.Button("Update intersection", GSDLoadButton))
+ {
+ TriggerRoadUpdate(true);
+ }
+ EditorGUILayout.EndHorizontal();
+
+ //Option: Auto update:
+ t_opt_AutoUpdateIntersections.boolValue = EditorGUILayout.Toggle("Auto-update:", tInter.opt_AutoUpdateIntersections);
+
+ //Option: Gizmo:
+ t_bDrawGizmo.boolValue = EditorGUILayout.Toggle("Gizmo:", tInter.bDrawGizmo);
+
+ //UI:
+ EditorGUILayout.BeginHorizontal();
+ if (tInter.iType == GSDRoadIntersection.IntersectionTypeEnum.ThreeWay)
+ {
+ EditorGUILayout.LabelField("Intersection type: 3 way");
+ }
+ else
+ {
+ EditorGUILayout.LabelField("Intersection type: 4 way");
+ }
+ if (GUILayout.Button("Online manual", EditorStyles.miniButton, GUILayout.Width(120f)))
+ {
+ Application.OpenURL("http://microgsd.com/Support/RoadArchitectManual.aspx");
+ }
+ EditorGUILayout.EndHorizontal();
+ Line();
+ EditorGUILayout.BeginVertical();
+ if (GUILayout.Button("Access objects on first road node"))
+ {
+ Selection.objects = new Object[1] { tInter.Node1 };
+ }
+ if (GUILayout.Button("Access objects on second road node"))
+ {
+ Selection.objects = new Object[1] { tInter.Node2 };
+ }
+ EditorGUILayout.EndVertical();
+ //Option: Intersection turn lane options
+ Line();
+ EditorGUILayout.LabelField("Intersection turn lane options:");
+ if (tInter.iType == GSDRoadIntersection.IntersectionTypeEnum.ThreeWay)
+ {
+ t_rType.enumValueIndex = (int) EditorGUILayout.Popup((int) tInter.rType, rTypeDescriptions_3Way);
+ }
+ else
+ {
+ t_rType.enumValueIndex = (int) EditorGUILayout.Popup((int) tInter.rType, rTypeDescriptions);
+ }
+
+ //Option: Left yield on green:
+ if (tInter.rType != GSDRoadIntersection.RoadTypeEnum.NoTurnLane)
+ {
+ t_bLeftTurnYieldOnGreen.boolValue = EditorGUILayout.Toggle("Left yield on green: ", tInter.bLeftTurnYieldOnGreen);
+
+ bShowHelpLeftTurnGreen = EditorGUILayout.Foldout(bShowHelpLeftTurnGreen, status);
+ if (bShowHelpLeftTurnGreen)
+ {
+ EditorGUILayout.BeginVertical("box");
+ EditorGUILayout.LabelField("Left yield on green: If checked, replaces the standard 3-light left turn light with a five-light yield on green left turn signal structure and sign.");
+ EditorGUILayout.EndVertical();
+ }
+ }
+ Line();
+
+
+ //Option: Intersection stop type:
+ t_iStopType.enumValueIndex = (int) EditorGUILayout.Popup("Intersection stop type:", (int) tInter.iStopType, iStopTypeEnumDescriptions);
+
+
+ if (tInter.iStopType == GSDRoadIntersection.iStopTypeEnum.TrafficLight1 || tInter.iStopType == GSDRoadIntersection.iStopTypeEnum.TrafficLight2)
+ {
+ //Option: Traffic light timing type:
+ t_lType.enumValueIndex = (int) EditorGUILayout.Popup("Traffic light timing:", (int) tInter.lType, iTrafficLightSequenceTypeDesc);
+
+ //Options: Traffic fixed light timings:
+ if (tInter.lType == GSDRoadIntersection.LightTypeEnum.Timed)
+ {
+ EditorGUILayout.LabelField("Traffic light fixed time lengths (in seconds):");
+ EditorGUILayout.BeginHorizontal();
+ t_opt_FixedTime_RegularLightLength.floatValue = EditorGUILayout.Slider("Green length: ", tInter.opt_FixedTime_RegularLightLength, 0.1f, 180f);
+ if (GUILayout.Button(btnRefreshText, GSDImageButton, GUILayout.Width(16f)))
+ {
+ t_opt_FixedTime_RegularLightLength.floatValue = 30f;
+ }
+ EditorGUILayout.EndHorizontal();
+
+ if (tInter.rType != GSDRoadIntersection.RoadTypeEnum.NoTurnLane)
+ {
+ EditorGUILayout.BeginHorizontal();
+ t_opt_FixedTime_LeftTurnLightLength.floatValue = EditorGUILayout.Slider("Left turn only length: ", tInter.opt_FixedTime_LeftTurnLightLength, 0.1f, 180f);
+ if (GUILayout.Button(btnRefreshText, GSDImageButton, GUILayout.Width(16f)))
+ {
+ t_opt_FixedTime_LeftTurnLightLength.floatValue = 10f;
+ }
+ EditorGUILayout.EndHorizontal();
+ }
+
+ EditorGUILayout.BeginHorizontal();
+ t_opt_FixedTime_AllRedLightLength.floatValue = EditorGUILayout.Slider("All red length: ", tInter.opt_FixedTime_AllRedLightLength, 0.1f, 180f);
+ if (GUILayout.Button(btnRefreshText, GSDImageButton, GUILayout.Width(16f)))
+ {
+ t_opt_FixedTime_AllRedLightLength.floatValue = 1f;
+ }
+ EditorGUILayout.EndHorizontal();
+
+ EditorGUILayout.BeginHorizontal();
+ t_opt_FixedTime_YellowLightLength.floatValue = EditorGUILayout.Slider("Yellow light length: ", tInter.opt_FixedTime_YellowLightLength, 0.1f, 180f);
+ if (GUILayout.Button(btnRefreshText, GSDImageButton, GUILayout.Width(16f)))
+ {
+ t_opt_FixedTime_YellowLightLength.floatValue = 3f;
+ }
+ EditorGUILayout.EndHorizontal();
+ }
+ }
+
+
+ if (tInter.iStopType == GSDRoadIntersection.iStopTypeEnum.TrafficLight1 || tInter.iStopType == GSDRoadIntersection.iStopTypeEnum.TrafficLight2)
+ {
+ //Option: Traffic light poles:
+ Line();
+ EditorGUILayout.LabelField("Traffic light poles:");
+ t_bTrafficPoleStreetLight.boolValue = EditorGUILayout.Toggle("Street lights: ", tInter.bTrafficPoleStreetLight);
+
+ //Option: Traffic light pole gray color:
+ t_bTrafficLightGray.boolValue = EditorGUILayout.Toggle("Gray color: ", tInter.bTrafficLightGray);
+
+ //Option: Normal pole alignment:
+ t_bRegularPoleAlignment.boolValue = EditorGUILayout.Toggle("Normal pole alignment: ", tInter.bRegularPoleAlignment);
+ bShowTLPole = EditorGUILayout.Foldout(bShowTLPole, status);
+ if (bShowTLPole)
+ {
+ EditorGUILayout.BeginVertical("box");
+ EditorGUILayout.LabelField("Street lights: If checked, attaches street lights to each intersection pole. Point lights optional and can be manipulated in the next option segment.");
+ GUILayout.Space(4f);
+ EditorGUILayout.LabelField("Gray color: If checked, sets the traffic light pole base materials to gray galvanized steel. If unchecked the material used is black metal paint.");
+ GUILayout.Space(4f);
+ EditorGUILayout.LabelField("Normal pole alignment: Recommended to keep this option on unless abnormal twisting of light objects is occurring. Turn this option off if the roads immediately surrounding your intersection are curved at extreme angles and cause irregular twisting of the traffic light objects. Turning this option off will attempt to align the poles perpendicular to the adjacent relevant road without any part existing over the main intersection bounds.");
+ EditorGUILayout.EndVertical();
+ }
+
+ //Option: Point lights enabled:
+ Line();
+ EditorGUILayout.BeginHorizontal();
+ EditorGUILayout.LabelField("Point lights:");
+ EditorGUILayout.EndHorizontal();
+ t_bLightsEnabled.boolValue = EditorGUILayout.Toggle(" Point lights enabled: ", tInter.bLightsEnabled);
+
+ //Options: Street point light options:
+ if (tInter.bTrafficPoleStreetLight)
+ {
+ //Option: Street light range:
+ EditorGUILayout.BeginHorizontal();
+ t_StreetLight_Range.floatValue = EditorGUILayout.Slider(" Street light range: ", tInter.StreetLight_Range, 1f, 128f);
+ if (GUILayout.Button(btnRefreshText, GSDImageButton, GUILayout.Width(16f)))
+ {
+ t_StreetLight_Range.floatValue = 30f;
+ }
+ EditorGUILayout.EndHorizontal();
+
+ //Option: Street light intensity:
+ EditorGUILayout.BeginHorizontal();
+ t_StreetLight_Intensity.floatValue = EditorGUILayout.Slider(" Street light intensity: ", tInter.StreetLight_Intensity, 0f, 8f);
+ if (GUILayout.Button(btnRefreshText, GSDImageButton, GUILayout.Width(16f)))
+ {
+ t_StreetLight_Intensity.floatValue = 1f;
+ }
+ EditorGUILayout.EndHorizontal();
+
+ //Option: Street light color:
+ EditorGUILayout.BeginHorizontal();
+ t_StreetLight_Color.colorValue = EditorGUILayout.ColorField(" Street light color: ", tInter.StreetLight_Color);
+ if (GUILayout.Button(btnRefreshText, GSDImageButton, GUILayout.Width(16f)))
+ {
+ t_StreetLight_Color.colorValue = new Color(1f, 0.7451f, 0.27451f, 1f);
+ ;
+ }
+ EditorGUILayout.EndHorizontal();
+ }
+ bShowLightHelp = EditorGUILayout.Foldout(bShowLightHelp, status);
+ if (bShowLightHelp)
+ {
+ EditorGUILayout.BeginVertical("box");
+ EditorGUILayout.LabelField("Point lights: Enabled means that point lights for the traffic lights (and street lights, if enabled) will be turned on. This is accessible via script \"bLightsEnabled\"");
+
+ GUILayout.Space(4f);
+ EditorGUILayout.LabelField("If street pole lights enabled: Street light range, intensity and color: These settings directly correlate to the standard point light settings.");
+
+ GUILayout.Space(4f);
+ EditorGUILayout.BeginHorizontal();
+ if (GUILayout.Button(btnRefreshText, GSDImageButton, GUILayout.Width(16f)))
+ {
+
+ }
+ EditorGUILayout.LabelField(" = Resets settings to default.");
+ EditorGUILayout.EndHorizontal();
+ EditorGUILayout.EndVertical();
+ }
+ Line();
+
+ //Option: Traffic light scaling sensitivity:
+ EditorGUILayout.LabelField("Traffic light scaling sensitivity: *Does not auto-update");
+ EditorGUILayout.BeginHorizontal();
+ t_ScalingSense.floatValue = EditorGUILayout.Slider(tInter.ScalingSense, 0f, 200f);
+ if (GUILayout.Button(btnRefreshText, GSDImageButton, GUILayout.Width(16f)))
+ {
+ t_ScalingSense.floatValue = 170f;
+ }
+ EditorGUILayout.EndHorizontal();
+ GUILayout.Space(4f);
+ EditorGUILayout.BeginHorizontal();
+ bShowTLSense = EditorGUILayout.Foldout(bShowTLSense, status);
+ if (GUILayout.Button("Manually update intersection", EditorStyles.miniButton, GUILayout.Width(170f)))
+ {
+ TriggerRoadUpdate(true);
+ }
+ EditorGUILayout.EndHorizontal();
+ if (bShowTLSense)
+ {
+ EditorGUILayout.BeginVertical("box");
+ EditorGUILayout.LabelField("Increasing this value will increase the scaling sensitivity relative to the size of the intersection. Higher scaling value = bigger traffic lights at further distances. Default value is 170.");
+ GUILayout.Space(4f);
+ EditorGUILayout.BeginHorizontal();
+ if (GUILayout.Button(btnRefreshText, GSDImageButton, GUILayout.Width(16f)))
+ {
+
+ }
+ EditorGUILayout.LabelField(" = Resets settings to default.");
+ EditorGUILayout.EndHorizontal();
+ EditorGUILayout.EndVertical();
+ }
+ GUILayout.Space(4f);
+ }
+
+ //Option: Grade correction modifier:
+ Line();
+ EditorGUILayout.BeginHorizontal();
+ EditorGUILayout.LabelField("Grade correction factor: *Does not auto-update");
+ EditorGUILayout.EndHorizontal();
+ EditorGUILayout.BeginHorizontal();
+ t_GradeMod.floatValue = EditorGUILayout.Slider(tInter.GradeMod, 0.01f, 2f);
+ if (GUILayout.Button(btnRefreshText, GSDImageButton, GUILayout.Width(16f)))
+ {
+ t_GradeMod.floatValue = 0.375f;
+ }
+ EditorGUILayout.EndHorizontal();
+ EditorGUILayout.BeginHorizontal();
+ bGradeCorrect = EditorGUILayout.Foldout(bGradeCorrect, status);
+ if (GUILayout.Button("Manually update intersection", EditorStyles.miniButton, GUILayout.Width(170f)))
+ {
+ tInter.UpdateRoads();
+ }
+ EditorGUILayout.EndHorizontal();
+ if (bGradeCorrect)
+ {
+ EditorGUILayout.BeginVertical("box");
+ EditorGUILayout.LabelField("If using extreme road grades immediately surrounding the intersection, terrain height matching errors may occur at the point of road expansion leading to the intersection.");
+ EditorGUILayout.LabelField("Raise this value if you see terrain poking through the road at the road expansion areas.");
+ EditorGUILayout.LabelField("Lower this value if you are not using road mesh colliders and notice dips at the expansion points.");
+ EditorGUILayout.LabelField("Default value is 0.375 meters, which is the maximum value for a linear range of 0% to 20% grade.");
+ EditorGUILayout.LabelField("Recommended to keep grades and angles small leading up to intersections.");
+ GUILayout.Space(4f);
+ EditorGUILayout.BeginHorizontal();
+ if (GUILayout.Button(btnRefreshText, GSDImageButton, GUILayout.Width(16f)))
+ {
+
+ }
+ EditorGUILayout.LabelField(" = Resets settings to default.");
+ EditorGUILayout.EndHorizontal();
+ EditorGUILayout.EndVertical();
+ }
+
+ //Option: Use default materials:
+ Line();
+ t_bUseDefaultMaterials.boolValue = EditorGUILayout.Toggle("Use default materials:", tInter.bUseDefaultMaterials);
+ bShowDefaultMatHelp = EditorGUILayout.Foldout(bShowDefaultMatHelp, status);
+ if (bShowDefaultMatHelp)
+ {
+ EditorGUILayout.BeginVertical("box");
+ EditorGUILayout.LabelField("Checking this option will reset all materials for this intersection and use the default intersection materials that come with this addon.");
+ EditorGUILayout.EndVertical();
+ }
+
+
+ Line();
+ EditorGUILayout.BeginHorizontal();
+ EditorGUILayout.LabelField("Center marker material(s):");
+ if (GUILayout.Button(btnRefreshText, GSDImageButton, GUILayout.Width(16f)))
+ {
+ tInter.ResetMaterials_Center();
+ }
+ EditorGUILayout.EndHorizontal();
+ GUILayout.Space(4f);
+ //Options: Center materials:
+ // EditorGUILayout.BeginHorizontal();
+ // EditorGUILayout.PropertyField (t_MarkerCenter1, new GUIContent ("Center material #1:"));
+ // if(tInter.MarkerCenter1 != null && GUILayout.Button(btnDeleteText,GSDImageButton,GUILayout.Width(16f))){ t_MarkerCenter1 = null; }
+ // EditorGUILayout.EndHorizontal();
+ // if(tInter.MarkerCenter1 != null){
+ // EditorGUILayout.BeginHorizontal();
+ // EditorGUILayout.PropertyField (t_MarkerCenter2, new GUIContent ("Center material #2:"));
+ // if(tInter.MarkerCenter2 != null && GUILayout.Button(btnDeleteText,GSDImageButton,GUILayout.Width(16f))){ t_MarkerCenter2 = null; }
+ // EditorGUILayout.EndHorizontal();
+ // if(tInter.MarkerCenter2 != null){
+ // EditorGUILayout.BeginHorizontal();
+ // EditorGUILayout.PropertyField (t_MarkerCenter3, new GUIContent ("Center material #3:"));
+ // if(tInter.MarkerCenter3 != null && GUILayout.Button(btnDeleteText,GSDImageButton,GUILayout.Width(16f))){ t_MarkerCenter3 = null; }
+ // EditorGUILayout.EndHorizontal();
+ // }
+ // }
+
+ EditorGUILayout.BeginHorizontal();
+ EditorGUILayout.PropertyField(t_MarkerCenter1, new GUIContent(" Mat #1: "));
+ if (tInter.MarkerCenter1 != null && GUILayout.Button(btnDeleteText, GSDImageButton, GUILayout.Width(16f)))
+ { tInter.MarkerCenter1 = null; }
+ EditorGUILayout.EndHorizontal();
+
+ if (tInter.MarkerCenter1 != null)
+ {
+ EditorGUILayout.BeginHorizontal();
+ EditorGUILayout.PropertyField(t_MarkerCenter2, new GUIContent(" Mat #2: "));
+ if (tInter.MarkerCenter2 != null && GUILayout.Button(btnDeleteText, GSDImageButton, GUILayout.Width(16f)))
+ { tInter.MarkerCenter2 = null; }
+ EditorGUILayout.EndHorizontal();
+ }
+ if (tInter.MarkerCenter2 != null && tInter.MarkerCenter1 != null)
+ {
+ EditorGUILayout.BeginHorizontal();
+ EditorGUILayout.PropertyField(t_MarkerCenter3, new GUIContent(" Mat #3: "));
+ if (tInter.MarkerCenter3 != null && GUILayout.Button(btnDeleteText, GSDImageButton, GUILayout.Width(16f)))
+ { tInter.MarkerCenter3 = null; }
+ EditorGUILayout.EndHorizontal();
+ }
+
+ bShowMarkerCenter = EditorGUILayout.Foldout(bShowMarkerCenter, status);
+ if (bShowMarkerCenter)
+ {
+ EditorGUILayout.BeginVertical("box");
+ EditorGUILayout.LabelField("Center marker materials require transparent shaders. Covers the center area of the intersection. Displayed in order #1 on bottom to #4 on top. Combine with transparent shaders which accept shadows to allow for easy marking.");
+ DoDefaultHelpMat();
+ DoDeleteHelpMat();
+ EditorGUILayout.EndVertical();
+ }
+ Line();
+
+ //Options: Marker ext stretched materials:
+ EditorGUILayout.BeginHorizontal();
+ EditorGUILayout.LabelField("Exterior fitted marker material(s):");
+ if (GUILayout.Button(btnRefreshText, GSDImageButton, GUILayout.Width(16f)))
+ {
+ tInter.ResetMaterials_Ext_Stretched();
+ }
+ EditorGUILayout.EndHorizontal();
+
+ EditorGUILayout.BeginHorizontal();
+ EditorGUILayout.PropertyField(t_MarkerExt_Stretch1, new GUIContent(" Mat #1: "));
+ if (tInter.MarkerExt_Stretch1 != null && GUILayout.Button(btnDeleteText, GSDImageButton, GUILayout.Width(16f)))
+ {
+ tInter.MarkerExt_Stretch1 = null;
+ }
+ EditorGUILayout.EndHorizontal();
+
+ if (tInter.MarkerExt_Stretch1 != null)
+ {
+ EditorGUILayout.BeginHorizontal();
+ EditorGUILayout.PropertyField(t_MarkerExt_Stretch2, new GUIContent(" Mat #2: "));
+ if (tInter.MarkerExt_Stretch2 != null && GUILayout.Button(btnDeleteText, GSDImageButton, GUILayout.Width(16f)))
+ {
+ tInter.MarkerExt_Stretch2 = null;
+ }
+ EditorGUILayout.EndHorizontal();
+ }
+ if (tInter.MarkerExt_Stretch2 != null && tInter.MarkerExt_Stretch1 != null)
+ {
+ EditorGUILayout.BeginHorizontal();
+ EditorGUILayout.PropertyField(t_MarkerExt_Stretch3, new GUIContent(" Mat #3: "));
+ if (tInter.MarkerExt_Stretch3 != null && GUILayout.Button(btnDeleteText, GSDImageButton, GUILayout.Width(16f)))
+ {
+ tInter.MarkerExt_Stretch3 = null;
+ }
+ EditorGUILayout.EndHorizontal();
+ }
+
+ bShowMarkerStretch = EditorGUILayout.Foldout(bShowMarkerStretch, status);
+ if (bShowMarkerStretch)
+ {
+ EditorGUILayout.BeginVertical("box");
+ EditorGUILayout.LabelField("Fitted marker materials require transparent shaders. Covers the exterior area of the intersection with the UV's stretched to match at a 1:1 ratio. Should be use for intersection markings and any visual effects like dirt." + HelpText1);
+ DoDefaultHelpMat();
+ DoDeleteHelpMat();
+ EditorGUILayout.EndVertical();
+ }
+ Line();
+
+ //Options: Marker ext tiled materials:
+ EditorGUILayout.BeginHorizontal();
+ EditorGUILayout.LabelField("Exterior tiled marker material(s):");
+ if (GUILayout.Button(btnRefreshText, GSDImageButton, GUILayout.Width(16f)))
+ {
+ tInter.ResetMaterials_Ext_Tiled();
+ }
+ EditorGUILayout.EndHorizontal();
+ GUILayout.Space(4f);
+
+ EditorGUILayout.BeginHorizontal();
+ EditorGUILayout.PropertyField(t_MarkerExt_Tiled1, new GUIContent(" Mat #1: "));
+ if (tInter.MarkerExt_Tiled1 != null && GUILayout.Button(btnDeleteText, GSDImageButton, GUILayout.Width(16f)))
+ {
+ tInter.MarkerExt_Tiled1 = null;
+ }
+ EditorGUILayout.EndHorizontal();
+
+ if (tInter.MarkerExt_Tiled1 != null)
+ {
+ EditorGUILayout.BeginHorizontal();
+ EditorGUILayout.PropertyField(t_MarkerExt_Tiled2, new GUIContent(" Mat #2: "));
+ if (tInter.MarkerExt_Tiled2 != null && GUILayout.Button(btnDeleteText, GSDImageButton, GUILayout.Width(16f)))
+ {
+ tInter.MarkerExt_Tiled2 = null;
+ }
+ EditorGUILayout.EndHorizontal();
+ }
+ if (tInter.MarkerExt_Tiled2 != null && tInter.MarkerExt_Tiled1 != null)
+ {
+ EditorGUILayout.BeginHorizontal();
+ EditorGUILayout.PropertyField(t_MarkerExt_Tiled3, new GUIContent(" Mat #3: "));
+ if (tInter.MarkerExt_Tiled3 != null && GUILayout.Button(btnDeleteText, GSDImageButton, GUILayout.Width(16f)))
+ {
+ tInter.MarkerExt_Tiled3 = null;
+ }
+ EditorGUILayout.EndHorizontal();
+ }
+
+ bShowMarkerTiled = EditorGUILayout.Foldout(bShowMarkerTiled, status);
+ if (bShowMarkerTiled)
+ {
+ EditorGUILayout.BeginVertical("box");
+ EditorGUILayout.LabelField("Covers the exterior area of the intersection with the UV's tiled matching world coordinates. Tiled and used for road pavement textures. UV coordinates will match up seamlessly with road pavement." + HelpText1);
+ DoDefaultHelpMat();
+ DoDeleteHelpMat();
+ EditorGUILayout.EndVertical();
+ }
+ Line();
+
+ //Option: Lane section 0:
+ EditorGUILayout.BeginHorizontal();
+ EditorGUILayout.LabelField("Lanes marker materials:");
+ if (GUILayout.Button(btnRefreshText, GSDImageButton, GUILayout.Width(16f)))
+ {
+ tInter.ResetMaterials_Lanes();
+ }
+ EditorGUILayout.EndHorizontal();
+ GUILayout.Space(4f);
+
+ EditorGUILayout.BeginHorizontal();
+ EditorGUILayout.PropertyField(t_Lane0Mat1, new GUIContent("Lane section 0 mat #1:"));
+ if (tInter.Lane0Mat1 != null && GUILayout.Button(btnDeleteText, GSDImageButton, GUILayout.Width(16f)))
+ {
+ tInter.Lane0Mat1 = null;
+ }
+ EditorGUILayout.EndHorizontal();
+ if (tInter.Lane0Mat1 != null)
+ {
+ EditorGUILayout.BeginHorizontal();
+ EditorGUILayout.PropertyField(t_Lane0Mat2, new GUIContent("Lane section 0 mat #2:"));
+ if (tInter.Lane0Mat2 != null && GUILayout.Button(btnDeleteText, GSDImageButton, GUILayout.Width(16f)))
+ {
+ tInter.Lane0Mat2 = null;
+ }
+ EditorGUILayout.EndHorizontal();
+ }
+
+
+ //Option: Lane section 1:
+ EditorGUILayout.BeginHorizontal();
+ EditorGUILayout.PropertyField(t_Lane1Mat1, new GUIContent("Lane section 1 mat #1:"));
+ if (tInter.Lane1Mat1 != null && GUILayout.Button(btnDeleteText, GSDImageButton, GUILayout.Width(16f)))
+ {
+ tInter.Lane1Mat1 = null;
+ }
+ EditorGUILayout.EndHorizontal();
+ if (tInter.Lane1Mat1 != null)
+ {
+ EditorGUILayout.BeginHorizontal();
+ EditorGUILayout.PropertyField(t_Lane1Mat2, new GUIContent("Lane section 1 mat #2:"));
+ if (tInter.Lane1Mat2 != null && GUILayout.Button(btnDeleteText, GSDImageButton, GUILayout.Width(16f)))
+ { tInter.Lane1Mat2 = null; }
+ EditorGUILayout.EndHorizontal();
+ }
+
+ //Option: Lane section 2:
+ if (tInter.rType == GSDRoadIntersection.RoadTypeEnum.BothTurnLanes || tInter.rType == GSDRoadIntersection.RoadTypeEnum.TurnLane)
+ {
+ EditorGUILayout.BeginHorizontal();
+ EditorGUILayout.PropertyField(t_Lane2Mat1, new GUIContent("Lane section 2 mat #1:"));
+ if (tInter.Lane2Mat1 != null && GUILayout.Button(btnDeleteText, GSDImageButton, GUILayout.Width(16f)))
+ {
+ tInter.Lane2Mat1 = null;
+ }
+ EditorGUILayout.EndHorizontal();
+ if (tInter.Lane2Mat1 != null)
+ {
+ EditorGUILayout.BeginHorizontal();
+ EditorGUILayout.PropertyField(t_Lane2Mat2, new GUIContent("Lane section 2 mat #2:"));
+ if (tInter.Lane2Mat2 != null && GUILayout.Button(btnDeleteText, GSDImageButton, GUILayout.Width(16f)))
+ { tInter.Lane2Mat2 = null; }
+ EditorGUILayout.EndHorizontal();
+ }
+ }
+ GUILayout.Space(4f);
+
+ //Option: Lane section 3:
+ if (tInter.rType == GSDRoadIntersection.RoadTypeEnum.BothTurnLanes)
+ {
+ EditorGUILayout.BeginHorizontal();
+ EditorGUILayout.PropertyField(t_Lane3Mat1, new GUIContent("Lane section 3 mat #1:"));
+ if (tInter.Lane3Mat1 != null && GUILayout.Button(btnDeleteText, GSDImageButton, GUILayout.Width(16f)))
+ {
+ tInter.Lane3Mat1 = null;
+ }
+ EditorGUILayout.EndHorizontal();
+ if (tInter.Lane3Mat1 != null)
+ {
+ EditorGUILayout.BeginHorizontal();
+ EditorGUILayout.PropertyField(t_Lane3Mat2, new GUIContent("Lane section 3 mat #2:"));
+ if (tInter.Lane3Mat2 != null && GUILayout.Button(btnDeleteText, GSDImageButton, GUILayout.Width(16f)))
+ {
+ tInter.Lane3Mat2 = null;
+ }
+ EditorGUILayout.EndHorizontal();
+ }
+ }
+ bShowLanes = EditorGUILayout.Foldout(bShowLanes, status);
+ if (bShowLanes)
+ {
+ EditorGUILayout.BeginVertical("box");
+ EditorGUILayout.LabelField("Covers individual lane sections in the intersection. Used for high-definition line marking.");
+ EditorGUILayout.LabelField("Lane section 0 = Left side of the intersection where oncoming traffic travels. Use lane texture which matches the number of lanes used on the road system, with a white left line and a yellow right line.");
+
+ if (tInter.rType == GSDRoadIntersection.RoadTypeEnum.BothTurnLanes)
+ {
+ EditorGUILayout.LabelField("Lane section 1 = Left turn lane. Use a single lane texture with a yellow left line and a white right line.");
+ EditorGUILayout.LabelField("Lane section 2 = Right outgoing traffic lane. Use lane texture which matches the number of lanes used on the road system with a white right line.");
+ EditorGUILayout.LabelField("Lane section 3 = Right turn lane. Use a single lane texture with a white right line.");
+ }
+ else if (tInter.rType == GSDRoadIntersection.RoadTypeEnum.TurnLane)
+ {
+ EditorGUILayout.LabelField("Lane section 1 = Left turn lane. Use a single lane texture with a yellow left line and a white right line.");
+ EditorGUILayout.LabelField("Lane section 2 = Right outgoing traffic lane. Use lane texture which matches the number of lanes used on the road system with a white right line.");
+ }
+ else if (tInter.rType == GSDRoadIntersection.RoadTypeEnum.NoTurnLane)
+ {
+ EditorGUILayout.LabelField("Lane section 1 = Right outgoing traffic lane. Use lane texture which matches the number of lanes used on the road system with a white right line.");
+ }
+
+ EditorGUILayout.LabelField(HelpText1);
+ DoDefaultHelpMat();
+ DoDeleteHelpMat();
+ EditorGUILayout.EndVertical();
+ }
+ Line();
+
+ // if(bDebug){
+ // Line();
+ // EditorGUILayout.LabelField("Debug");
+ // if(tInter.Node1 != null){ EditorGUILayout.LabelField(" Node1: " + tInter.Node1.transform.name); } else { EditorGUILayout.LabelField(" Node1: null"); }
+ // if(tInter.Node2 != null){ EditorGUILayout.LabelField(" Node2: " + tInter.Node2.transform.name); } else { EditorGUILayout.LabelField(" Node2: null"); }
+ // if(tInter.Node1 != null){ EditorGUILayout.LabelField(" UID1: " + tInter.Node1.UID); } else { EditorGUILayout.LabelField(" UID1: null"); }
+ // if(tInter.Node2 != null){ EditorGUILayout.LabelField(" UID2: " + tInter.Node2.UID); } else { EditorGUILayout.LabelField(" UID2: null"); }
+ // EditorGUILayout.LabelField(" Same spline: " + tInter.bSameSpline);
+ // EditorGUILayout.LabelField(" bFlipped: " + tInter.bFlipped);
+ // EditorGUILayout.LabelField(" IgnoreSide: " + tInter.IgnoreSide);
+ // EditorGUILayout.LabelField(" IgnoreCorner: " + tInter.IgnoreCorner);
+ //
+ // if(tInter.iStopType == GSDRoadIntersection.iStopTypeEnum.TrafficLight1 || tInter.iStopType == GSDRoadIntersection.iStopTypeEnum.TrafficLight2){
+ // if(tInter.LightsRR != null){ EditorGUILayout.LabelField(" LightsRR: " + tInter.LightsRR); } else { EditorGUILayout.LabelField(" LightsRR: null"); }
+ // if(tInter.LightsRR != null || tInter.LightsRR.MR_Main != null){ EditorGUILayout.LabelField(" MR_Main: " + tInter.LightsRR.MR_Main); } else { EditorGUILayout.LabelField(" LightsRR.MR_Main: null"); }
+ // if(tInter.LightsRR != null || tInter.LightsRR.MR_Left != null){ EditorGUILayout.LabelField(" MR_Left: " + tInter.LightsRR.MR_Left); } else { EditorGUILayout.LabelField(" LightsRR.MR_Left: null"); }
+ // if(tInter.LightsRR != null || tInter.LightsRR.MR_Right != null){ EditorGUILayout.LabelField(" MR_Right: " + tInter.LightsRR.MR_Right); } else { EditorGUILayout.LabelField(" LightsRR.MR_Right: null"); }
+ // if(tInter.LightsRL != null){ EditorGUILayout.LabelField(" LightsRL: " + tInter.LightsRL); } else { EditorGUILayout.LabelField(" LightsRL: null"); }
+ // if(tInter.LightsLL != null){ EditorGUILayout.LabelField(" LightsLL: " + tInter.LightsLL); } else { EditorGUILayout.LabelField(" LightsLL: null"); }
+ // if(tInter.LightsLR != null){ EditorGUILayout.LabelField(" LightsLR: " + tInter.LightsLR); } else { EditorGUILayout.LabelField(" LightsLR: null"); }
+ // }
+ // Line();
+ // }
+
+
+ //Set change bools:
+ bool bToggleTrafficLightPoleColor = false;
+ bool bTogglePointLights = false;
+ bool bGizmoChange = false;
+ bool bMatChange = false;
+ bool bRoadUpdate = false;
+
+ if (GUI.changed)
+ {
+ //Option: Gizmo:
+ if (t_bDrawGizmo.boolValue != tInter.bDrawGizmo)
+ {
+ bGizmoChange = true;
+ }
+
+ //Option: Intersection turn lane options
+ if ((int) tInter.rType != t_rType.enumValueIndex)
+ {
+ bMatChange = true;
+ bRoadUpdate = true;
+ }
+
+ //Option: Left yield on green:
+ if (t_bLeftTurnYieldOnGreen.boolValue != tInter.bLeftTurnYieldOnGreen)
+ {
+ bRoadUpdate = true;
+ }
+
+ //Option: Intersection stop type:
+ if (t_iStopType.enumValueIndex != (int) tInter.iStopType)
+ {
+ bRoadUpdate = true;
+ }
+
+ //Option: Traffic light poles:
+ if (t_bTrafficPoleStreetLight.boolValue != tInter.bTrafficPoleStreetLight)
+ {
+ bRoadUpdate = true;
+ }
+
+ //Option: Traffic light pole gray color:
+ if (t_bTrafficLightGray.boolValue != tInter.bTrafficLightGray)
+ {
+ bToggleTrafficLightPoleColor = true;
+ }
+
+ //Option: Normal pole alignment:
+ if (t_bRegularPoleAlignment.boolValue != tInter.bRegularPoleAlignment)
+ {
+ bRoadUpdate = true;
+ }
+
+ //Option: Point lights enabled:
+ if (t_bLightsEnabled.boolValue != tInter.bLightsEnabled)
+ {
+ bTogglePointLights = true;
+ }
+
+ //Option: Street light range:
+ if (!GSDRootUtil.IsApproximately(t_StreetLight_Range.floatValue, tInter.StreetLight_Range, 0.01f))
+ {
+ bTogglePointLights = true;
+ }
+
+ //Option: Street light intensity:
+ if (!GSDRootUtil.IsApproximately(t_StreetLight_Intensity.floatValue, tInter.StreetLight_Intensity, 0.01f))
+ {
+ bTogglePointLights = true;
+ }
+
+ //Option: Street light color:
+ if (t_StreetLight_Color.colorValue != tInter.StreetLight_Color)
+ {
+ bTogglePointLights = true;
+ }
+
+ //Option: Use default materials:
+ if (t_bUseDefaultMaterials.boolValue != tInter.bUseDefaultMaterials)
+ {
+ bMatChange = true;
+ }
+
+ if (t_MarkerCenter1 == null || t_MarkerCenter1.objectReferenceValue == null)
+ {
+ tInter.MarkerCenter1 = null;
+ }
+ if (t_MarkerCenter2 == null || t_MarkerCenter2.objectReferenceValue == null)
+ {
+ tInter.MarkerCenter2 = null;
+ }
+ if (t_MarkerCenter3 == null || t_MarkerCenter3.objectReferenceValue == null)
+ {
+ tInter.MarkerCenter3 = null;
+ }
+ if (t_MarkerExt_Stretch1 == null || t_MarkerExt_Stretch1.objectReferenceValue == null)
+ {
+ tInter.MarkerExt_Stretch1 = null;
+ }
+ if (t_MarkerExt_Stretch2 == null || t_MarkerExt_Stretch2.objectReferenceValue == null)
+ {
+ tInter.MarkerExt_Stretch2 = null;
+ }
+ if (t_MarkerExt_Stretch3 == null || t_MarkerExt_Stretch3.objectReferenceValue == null)
+ {
+ tInter.MarkerExt_Stretch3 = null;
+ }
+ if (t_MarkerExt_Tiled1 == null || t_MarkerExt_Tiled1.objectReferenceValue == null)
+ {
+ tInter.MarkerExt_Tiled1 = null;
+ }
+ if (t_MarkerExt_Tiled2 == null || t_MarkerExt_Tiled2.objectReferenceValue == null)
+ {
+ tInter.MarkerExt_Tiled2 = null;
+ }
+ if (t_MarkerExt_Tiled3 == null || t_MarkerExt_Tiled3.objectReferenceValue == null)
+ {
+ tInter.MarkerExt_Tiled3 = null;
+ }
+ if (t_Lane0Mat1 == null || t_Lane0Mat1.objectReferenceValue == null)
+ {
+ tInter.Lane0Mat1 = null;
+ }
+ if (t_Lane0Mat2 == null || t_Lane0Mat2.objectReferenceValue == null)
+ {
+ tInter.Lane0Mat2 = null;
+ }
+ if (t_Lane1Mat1 == null || t_Lane1Mat1.objectReferenceValue == null)
+ {
+ tInter.Lane1Mat1 = null;
+ }
+ if (t_Lane1Mat2 == null || t_Lane1Mat2.objectReferenceValue == null)
+ {
+ tInter.Lane1Mat2 = null;
+ }
+ if (t_Lane2Mat1 == null || t_Lane2Mat1.objectReferenceValue == null)
+ {
+ tInter.Lane2Mat1 = null;
+ }
+ if (t_Lane2Mat2 == null || t_Lane2Mat2.objectReferenceValue == null)
+ {
+ tInter.Lane2Mat2 = null;
+ }
+ if (t_Lane3Mat1 == null || t_Lane3Mat1.objectReferenceValue == null)
+ {
+ tInter.Lane3Mat1 = null;
+ }
+ if (t_Lane3Mat2 == null || t_Lane3Mat2.objectReferenceValue == null)
+ {
+ tInter.Lane3Mat2 = null;
+ }
+
+ if (tInter.MarkerCenter1 != null && t_MarkerCenter1.objectReferenceValue != tInter.MarkerCenter1)
+ {
+ bMatChange = true;
+ }
+ if (tInter.MarkerCenter2 != null && t_MarkerCenter2.objectReferenceValue != tInter.MarkerCenter2)
+ {
+ bMatChange = true;
+ }
+ if (tInter.MarkerCenter3 != null && t_MarkerCenter3.objectReferenceValue != tInter.MarkerCenter3)
+ {
+ bMatChange = true;
+ }
+ if (tInter.MarkerExt_Stretch1 != null && t_MarkerExt_Stretch1.objectReferenceValue != tInter.MarkerExt_Stretch1)
+ {
+ bMatChange = true;
+ }
+ if (tInter.MarkerExt_Stretch2 != null && t_MarkerExt_Stretch2.objectReferenceValue != tInter.MarkerExt_Stretch2)
+ {
+ bMatChange = true;
+ }
+ if (tInter.MarkerExt_Stretch3 != null && t_MarkerExt_Stretch3.objectReferenceValue != tInter.MarkerExt_Stretch3)
+ {
+ bMatChange = true;
+ }
+ if (tInter.MarkerExt_Tiled1 != null && t_MarkerExt_Tiled1.objectReferenceValue != tInter.MarkerExt_Tiled1)
+ {
+ bMatChange = true;
+ }
+ if (tInter.MarkerExt_Tiled2 != null && t_MarkerExt_Tiled2.objectReferenceValue != tInter.MarkerExt_Tiled2)
+ {
+ bMatChange = true;
+ }
+ if (tInter.MarkerExt_Tiled3 != null && t_MarkerExt_Tiled3.objectReferenceValue != tInter.MarkerExt_Tiled3)
+ {
+ bMatChange = true;
+ }
+ if (tInter.Lane0Mat1 != null && t_Lane0Mat1.objectReferenceValue != tInter.Lane0Mat1)
+ {
+ bMatChange = true;
+ }
+ if (tInter.Lane0Mat2 != null && t_Lane0Mat2.objectReferenceValue != tInter.Lane0Mat2)
+ {
+ bMatChange = true;
+ }
+ if (tInter.Lane1Mat1 != null && t_Lane1Mat1.objectReferenceValue != tInter.Lane1Mat1)
+ {
+ bMatChange = true;
+ }
+ if (tInter.Lane1Mat2 != null && t_Lane1Mat2.objectReferenceValue != tInter.Lane1Mat2)
+ {
+ bMatChange = true;
+ }
+ if (tInter.Lane2Mat1 != null && t_Lane2Mat1.objectReferenceValue != tInter.Lane2Mat1)
+ {
+ bMatChange = true;
+ }
+ if (tInter.Lane2Mat2 != null && t_Lane2Mat2.objectReferenceValue != tInter.Lane2Mat2)
+ {
+ bMatChange = true;
+ }
+ if (tInter.Lane3Mat1 != null && t_Lane3Mat1.objectReferenceValue != tInter.Lane3Mat1)
+ {
+ bMatChange = true;
+ }
+ if (tInter.Lane3Mat2 != null && t_Lane3Mat2.objectReferenceValue != tInter.Lane3Mat2)
+ {
+ bMatChange = true;
+ }
+
+
+ //Apply changes:
+ serializedObject.ApplyModifiedProperties();
+
+
+ //Apply secondary effects:
+ if (bGizmoChange)
+ {
+ MeshRenderer[] tMRs = tInter.transform.GetComponentsInChildren();
+ int tCount = tMRs.Length;
+ for (int i = 0; i < tCount; i++)
+ {
+ //EditorUtility.SetSelectedWireframeHidden(tMRs[i], !tInter.bDrawGizmo);
+ EditorUtility.SetSelectedRenderState(tMRs[i], tInter.bDrawGizmo ? EditorSelectedRenderState.Wireframe : EditorSelectedRenderState.Hidden);
+
+ }
+ SceneView.RepaintAll();
+ }
+
+ if (bTogglePointLights)
+ {
+ tInter.TogglePointLights(tInter.bLightsEnabled);
+ }
+
+ if (bToggleTrafficLightPoleColor)
+ {
+ tInter.ToggleTrafficLightPoleColor();
+ }
+
+ if (bMatChange)
+ {
+ tInter.UpdateMaterials();
+ if (tInter.bUseDefaultMaterials)
+ {
+ tInter.ResetMaterials_All();
+ }
+ }
+
+ if (bRoadUpdate)
+ {
+ TriggerRoadUpdate();
+ }
+
+ EditorUtility.SetDirty(tInter);
+ }
+ }
+
+
+ public void OnSceneGUI()
+ {
+ Event current = Event.current;
+ int controlID = GUIUtility.GetControlID(GetHashCode(), FocusType.Passive);
+
+ // if (Event.current.type == EventType.MouseDrag && Event.current.button == 0){
+ // //Update relevant splines:
+ // tInter.Node1.GSDSpline.Setup();
+ // if(!tInter.bSameSpline){
+ // tInter.Node2.GSDSpline.Setup();
+ // }
+ // bMouseDragHasProcessed = false;
+ // }
+ //
+ // if(Event.current.type == EventType.MouseUp && Event.current.button == 0){
+ // if(!bMouseDragHasProcessed){
+ // tInter.Node1.transform.position = tInter.transform.position;
+ // tInter.Node2.transform.position = tInter.transform.position;
+ // tInter.StartCoroutine(TriggerRoadUpdate());
+ // }
+ // bMouseDragHasProcessed = true;
+ // }
+
+ if (Event.current.type == EventType.MouseUp && Event.current.button == 0)
+ {
+ if (tInter.transform.position != tInter.Node1.transform.position)
+ {
+ tInter.Node1.transform.position = tInter.transform.position;
+ tInter.Node2.transform.position = tInter.transform.position;
+ tInter.Height = tInter.transform.position.y;
+ TriggerRoadUpdate();
+ }
+ }
+
+
+
+ if (current.type == EventType.ValidateCommand)
+ {
+ switch (current.commandName)
+ {
+ case "UndoRedoPerformed":
+ TriggerRoadUpdate(true);
+ break;
+ }
+ }
+
+ if (current.type == EventType.MouseDown)
+ {
+ return;
+ }
+
+ if (Selection.activeGameObject == tInter.transform.gameObject)
+ {
+ if (current.keyCode == KeyCode.F5)
+ {
+ if (tInter != null && tInter.Node1 != null && tInter.Node2 != null)
+ {
+ TriggerRoadUpdate();
+ }
+ }
+ }
+
+ // switch(current.type){
+ // case EventType.layout:
+ //// if(current.type != EventType.MouseDown){
+ // HandleUtility.AddDefaultControl(controlID);
+ //// }
+ // break;
+ //
+ // }
+
+ if (controlID == 1)
+ {
+ //Do nothing
+ }
+ if (GUI.changed)
+ {
+ EditorUtility.SetDirty(tInter);
+ }
+ }
+
+
+ private void TriggerRoadUpdate(bool bForce = false)
+ {
+ if (!bForce && !tInter.opt_AutoUpdateIntersections)
+ {
+ return;
+ }
+
+ if (tInter != null && tInter.Node1 != null && tInter.Node2 != null)
+ {
+ if (!tInter.Node1.GSDSpline.tRoad.Editor_bIsConstructing && !tInter.Node2.GSDSpline.tRoad.Editor_bIsConstructing)
+ {
+ if (!tInter.bSameSpline)
+ {
+ tInter.Node1.GSDSpline.tRoad.PiggyBacks = new GSDSplineC[1];
+ tInter.Node1.GSDSpline.tRoad.PiggyBacks[0] = tInter.Node2.GSDSpline;
+ }
+ tInter.Node1.GSDSpline.tRoad.EditorUpdateMe = true;
+ }
+ }
+ }
+
+
+ void Init()
+ {
+ EditorStyles.label.wordWrap = true;
+ bHasInit = true;
+ if (btnRefreshText == null)
+ {
+ btnRefreshText = (Texture) AssetDatabase.LoadAssetAtPath(GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Editor/Icons/refresh2.png", typeof(Texture)) as Texture;
+ }
+ if (btnDeleteText == null)
+ {
+ btnDeleteText = (Texture) AssetDatabase.LoadAssetAtPath(GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Editor/Icons/delete.png", typeof(Texture)) as Texture;
+ }
+ if (LoadBtnBG == null)
+ {
+ LoadBtnBG = (Texture2D) AssetDatabase.LoadAssetAtPath(GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Editor/Icons/otherbg.png", typeof(Texture2D)) as Texture2D;
+ }
+ if (LoadBtnBGGlow == null)
+ {
+ LoadBtnBGGlow = (Texture2D) AssetDatabase.LoadAssetAtPath(GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Editor/Icons/otherbg2.png", typeof(Texture2D)) as Texture2D;
+ }
+
+ if (GSDImageButton == null)
+ {
+ GSDImageButton = new GUIStyle(GUI.skin.button);
+ GSDImageButton.contentOffset = new Vector2(0f, 0f);
+ GSDImageButton.border = new RectOffset(0, 0, 0, 0);
+ GSDImageButton.fixedHeight = 16f;
+ GSDImageButton.padding = new RectOffset(0, 0, 0, 0);
+ GSDImageButton.normal.background = null;
+ }
+ if (GSDLoadButton == null)
+ {
+ GSDLoadButton = new GUIStyle(GUI.skin.button);
+ GSDLoadButton.contentOffset = new Vector2(0f, 1f);
+ GSDLoadButton.normal.textColor = new Color(1f, 1f, 1f, 1f);
+ GSDLoadButton.normal.background = LoadBtnBG;
+ GSDLoadButton.active.background = LoadBtnBGGlow;
+ GSDLoadButton.focused.background = LoadBtnBGGlow;
+ GSDLoadButton.hover.background = LoadBtnBGGlow;
+ GSDLoadButton.fixedHeight = 16f;
+ GSDLoadButton.fixedWidth = 128f;
+ }
+ }
+
+
+ void DoDefaultHelpMat()
+ {
+ GUILayout.Space(4f);
+ EditorGUILayout.BeginHorizontal();
+ if (GUILayout.Button(btnRefreshText, GSDImageButton, GUILayout.Width(16f)))
+ {
+
+ }
+ EditorGUILayout.LabelField(" = Resets material(s) to default materials.");
+ EditorGUILayout.EndHorizontal();
+ }
+
+
+ void DoDeleteHelpMat()
+ {
+ GUILayout.Space(4f);
+ EditorGUILayout.BeginHorizontal();
+ if (GUILayout.Button(btnDeleteText, GSDImageButton, GUILayout.Width(16f)))
+ {
+
+ }
+ EditorGUILayout.LabelField(" = Removes material(s) from intersection.");
+ EditorGUILayout.EndHorizontal();
+ }
+
+
+ void Line()
+ {
+ GUILayout.Space(4f);
+ GUILayout.Box("", GUILayout.ExpandWidth(true), GUILayout.Height(1)); //Horizontal bar
+ GUILayout.Space(4f);
+ }
}
\ No newline at end of file
diff --git a/Editor/GSDRoadSystemEditor.cs b/Editor/GSDRoadSystemEditor.cs
index 0d04ce48..483b0473 100755
--- a/Editor/GSDRoadSystemEditor.cs
+++ b/Editor/GSDRoadSystemEditor.cs
@@ -1,352 +1,377 @@
-using UnityEngine;
-using UnityEditor;
-using System.Collections.Generic;
-using GSD;
-[CustomEditor(typeof(GSDRoadSystem))]
-public class GSDRoadSystemEditor : Editor
-{
- //Main target for this editor file:
- protected GSDRoadSystem GSDRS { get { return (GSDRoadSystem)target; } }
-
- //Serialized properties:
- SerializedProperty bTempMultithreading;
- SerializedProperty bTempSaveMeshAssets;
-
- //Editor only variables:
- bool bUpdateGlobal_Multithread = false;
- bool bUpdateGlobal_SaveMesh = false;
-
- // //Editor only camera variables:
- // GSDRoadIntersection[] tInters = null;
- // int tInterIndex = 0;
- // GSDSplineN[] tBridges = null;
- // int tBridgesIndex = 0;
- // bool bHasBridgeInit = false;
- // bool bHasInterInit = false;
- // bool bHasDoneEither = false;
- // bool bFlipEditorCamera = false;
- // float CameraZoomFactor = 1f;
- // float CameraHeightOffset = 1f;
- // bool bCameraCustomRot = false;
- // Vector3 CameraCustomRot = new Vector3(0.5f,0f,-0.5f);
-
- //Editor only graphic variables:
- Texture2D LoadBtnBG = null;
- Texture2D LoadBtnBGGlow = null;
- GUIStyle WarningLabelStyle;
- Texture2D WarningLabelBG;
- GUIStyle GSDLoadButton = null;
-
- private void OnEnable()
- {
- bTempMultithreading = serializedObject.FindProperty("opt_bMultithreading");
- bTempSaveMeshAssets = serializedObject.FindProperty("opt_bSaveMeshes");
- }
-
- public override void OnInspectorGUI()
- {
- serializedObject.Update();
-
- bUpdateGlobal_Multithread = false;
- bUpdateGlobal_SaveMesh = false;
- EditorStyles.label.wordWrap = true;
- InitChecks();
-
- //Add road button:
- Line();
- if (GUILayout.Button("Add road", GSDLoadButton, GUILayout.Width(128f)))
- {// || GUILayout.Button(btnLoadText,GSDImageButton,GUILayout.Width(16f))){
- Selection.activeObject = GSDRS.AddRoad();
- }
- Line();
-
- //Multi-threading input:
- EditorGUILayout.BeginHorizontal();
- bTempMultithreading.boolValue = EditorGUILayout.Toggle("Multi-threading enabled", GSDRS.opt_bMultithreading);
- if (bTempMultithreading.boolValue != GSDRS.opt_bMultithreading) { bUpdateGlobal_Multithread = true; }
-
- //Update all roads button:
- if (GUILayout.Button("Update all roads", EditorStyles.miniButton, GUILayout.Width(120f)))
- {
- GSDRS.UpdateAllRoads();
- }
- EditorGUILayout.EndHorizontal();
-
- //Save mesh assets input:
- bTempSaveMeshAssets.boolValue = EditorGUILayout.Toggle("Save mesh assets: ", GSDRS.opt_bSaveMeshes);
- if (bTempSaveMeshAssets.boolValue != GSDRS.opt_bSaveMeshes) { bUpdateGlobal_SaveMesh = true; }
- if (GSDRS.opt_bSaveMeshes || bTempSaveMeshAssets.boolValue)
- {
- GUILayout.Label("WARNING: Saving meshes as assets is very slow and can increase road generation time by several minutes.", WarningLabelStyle);
- }
-
- //Online manual button:
- GUILayout.Space(4f);
- if (GUILayout.Button("Online manual", EditorStyles.miniButton, GUILayout.Width(120f)))
- {
- Application.OpenURL("http://microgsd.com/Support/RoadArchitectManual.aspx");
- }
-
- if (GSDRS.EditorPlayCamera == null)
- {
- GSDRS.EditorCameraSetSingle();
- }
- Line();
-
- // bHasDoneEither = false;
-
- // //View intersection
- // DoInter();
-
- //View bridges
- // DoBridges();
- // if(bHasDoneEither){
- // EditorGUILayout.LabelField("* Hotkeys only function when this RoadArchitectSystem object is selected", EditorStyles.miniLabel);
- // }
-
- //Hotkey check:
- DoHotKeyCheck();
-
- if (GUI.changed)
- {
- serializedObject.ApplyModifiedProperties();
-
- //Multithreading global change:
- if (bUpdateGlobal_Multithread)
- {
- GSDRS.UpdateAllRoads_MultiThreadOptions();
- }
-
- //Save mesh assets global change:
- if (bUpdateGlobal_SaveMesh)
- {
- GSDRS.UpdateAllRoads_SaveMeshesAsAssetsOptions();
- }
- }
- }
-
- void InitChecks()
- {
- if (WarningLabelBG == null)
- {
- WarningLabelBG = (Texture2D)AssetDatabase.LoadAssetAtPath(GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Editor/Icons/WarningLabelBG.png", typeof(Texture2D)) as Texture2D;
- }
- if (LoadBtnBG == null)
- {
- LoadBtnBG = (Texture2D)AssetDatabase.LoadAssetAtPath(GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Editor/Icons/otherbg.png", typeof(Texture2D)) as Texture2D;
- }
- if (LoadBtnBGGlow == null)
- {
- LoadBtnBGGlow = (Texture2D)AssetDatabase.LoadAssetAtPath(GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Editor/Icons/otherbg2.png", typeof(Texture2D)) as Texture2D;
- }
-
- if (GSDLoadButton == null)
- {
- GSDLoadButton = new GUIStyle(GUI.skin.button);
- GSDLoadButton.contentOffset = new Vector2(0f, 1f);
- GSDLoadButton.normal.textColor = new Color(1f, 1f, 1f, 1f);
- GSDLoadButton.normal.background = LoadBtnBG;
- GSDLoadButton.active.background = LoadBtnBGGlow;
- GSDLoadButton.focused.background = LoadBtnBGGlow;
- GSDLoadButton.hover.background = LoadBtnBGGlow;
- GSDLoadButton.fixedHeight = 16f;
- GSDLoadButton.fixedWidth = 128f;
- GSDLoadButton.padding = new RectOffset(0, 0, 0, 0);
- }
-
- if (WarningLabelStyle == null)
- {
- WarningLabelStyle = new GUIStyle(GUI.skin.textArea);
- WarningLabelStyle.normal.textColor = Color.red;
- WarningLabelStyle.active.textColor = Color.red;
- WarningLabelStyle.hover.textColor = Color.red;
- WarningLabelStyle.normal.background = WarningLabelBG;
- WarningLabelStyle.active.background = WarningLabelBG;
- WarningLabelStyle.hover.background = WarningLabelBG;
- WarningLabelStyle.padding = new RectOffset(8, 8, 8, 8);
- }
- }
-
- // void DoInter(){
- // //View intersection
- // if(!bHasInterInit){
- // bHasInterInit = true;
- // tInters = (GSDRoadIntersection[])GameObject.FindObjectsOfType(typeof(GSDRoadIntersection));
- // if(tInters == null || tInters.Length < 1){
- // tInterIndex = -1;
- // tInters = null;
- // }
- // }
- // if(tInters != null && tInters.Length > 0 && tInterIndex > -1){
- // EditorGUILayout.BeginHorizontal();
- // if(GUILayout.Button("View next intersection",GUILayout.Width(150f))){
- // IncrementIntersection();
- // }
- // EditorGUILayout.LabelField("Hotkey K");
- // EditorGUILayout.EndHorizontal();
- // bHasDoneEither = true;
- // }
- // }
- //
- // void IncrementIntersection(){
- // if(tInters != null && tInters.Length > 0){
- // tInterIndex+=1;
- // if(tInterIndex >= tInters.Length){ tInterIndex = 0; }
- // ShowIntersection(tInterIndex);
- // }
- // }
- //
- // void DoBridges(){
- // //View bridges
- // if(!bHasBridgeInit){
- // bHasBridgeInit = true;
- // GSDSplineN[] tSplineN = (GSDSplineN[])GameObject.FindObjectsOfType(typeof(GSDSplineN));
- // List tSplineNList = new List();
- // foreach(GSDSplineN tNode in tSplineN){
- // if(tNode.bIsBridgeStart && tNode.bIsBridgeMatched){
- // tSplineNList.Add(tNode);
- // }
- // }
- // tBridges = tSplineNList.ToArray();
- // tBridgesIndex = 0;
- // if(tBridges == null || tBridges.Length < 1){
- // tBridgesIndex = -1;
- // tBridges = null;
- // }
- // }
- //
- // if(tBridges != null && tBridges.Length > 0 && tBridgesIndex > -1){
- // EditorGUILayout.BeginHorizontal();
- // if(GUILayout.Button("View next bridge",GUILayout.Width(150f))){
- // IncrementBridge();
- // }
- // EditorGUILayout.LabelField("Hotkey L");
- // EditorGUILayout.EndHorizontal();
- // if(EditorApplication.isPlaying){
- // bool bChangeChecker = EditorGUILayout.Toggle("Flip camera Y:",bFlipEditorCamera);
- // if(bChangeChecker != bFlipEditorCamera){
- // bFlipEditorCamera = bChangeChecker;
- // ShowBridge(tBridgesIndex);
- // }
- // }
- //
- // if(EditorApplication.isPlaying){
- // float ChangeChecker = EditorGUILayout.Slider("Zoom factor:",CameraZoomFactor,0.02f,10f);
- // if(!GSDRootUtil.IsApproximately(ChangeChecker,CameraZoomFactor,0.001f)){
- // CameraZoomFactor = ChangeChecker;
- // ShowBridge(tBridgesIndex);
- // }
- // ChangeChecker = EditorGUILayout.Slider("Height offset:",CameraHeightOffset,0f,8f);
- // if(!GSDRootUtil.IsApproximately(ChangeChecker,CameraHeightOffset,0.001f)){
- // CameraHeightOffset = ChangeChecker;
- // ShowBridge(tBridgesIndex);
- // }
- //
- // bool bChangeChecker = EditorGUILayout.Toggle("Custom camera rot:",bCameraCustomRot);
- // if(bChangeChecker != bCameraCustomRot){
- // bCameraCustomRot = bChangeChecker;
- // ShowBridge(tBridgesIndex);
- // }
- // if(bCameraCustomRot){
- // Vector3 vChangeChecker = default(Vector3);
- // vChangeChecker.x = EditorGUILayout.Slider("Rotation X:",CameraCustomRot.x,-1f,1f);
- // vChangeChecker.z = EditorGUILayout.Slider("Rotation Z:",CameraCustomRot.z,-1f,1f);
- //
- // if(vChangeChecker != CameraCustomRot){
- // CameraCustomRot = vChangeChecker;
- // ShowBridge(tBridgesIndex);
- // }
- // }
- // }
- //
- // bHasDoneEither = true;
- // }
- // }
- //
- // void IncrementBridge(){
- // if(tBridges != null && tBridges.Length > 0){
- // tBridgesIndex+=1;
- // if(tBridgesIndex >= tBridges.Length){ tBridgesIndex = 0; }
- // ShowBridge(tBridgesIndex);
- // }
- // }
- //
- // void ShowIntersection(int i){
- // if(EditorApplication.isPlaying && GSDRS.EditorPlayCamera != null){
- // GSDRS.EditorPlayCamera.transform.position = tInters[i].transform.position + new Vector3(-40f,20f,-40f);
- // GSDRS.EditorPlayCamera.transform.rotation = Quaternion.LookRotation(tInters[i].transform.position - (tInters[i].transform.position + new Vector3(-40f,20f,-40f)));
- // }else{
- // SceneView.lastActiveSceneView.pivot = tInters[i].transform.position;
- // SceneView.lastActiveSceneView.Repaint();
- // }
- // }
- //
- // void ShowBridge(int i){
- // if(EditorApplication.isPlaying && GSDRS.EditorPlayCamera != null){
- // Vector3 tBridgePos = ((tBridges[i].pos - tBridges[i].BridgeCounterpartNode.pos)*0.5f)+tBridges[i].BridgeCounterpartNode.pos;
- // float tBridgeLength = Vector3.Distance(tBridges[i].pos,tBridges[i].BridgeCounterpartNode.pos);
- //
- // //Rotation:
- // Vector3 tCameraRot = Vector3.Cross((tBridges[i].pos - tBridges[i].BridgeCounterpartNode.pos),Vector3.up);
- // if(bCameraCustomRot){
- // tCameraRot = CameraCustomRot;
- // }else{
- // tCameraRot = tCameraRot.normalized;
- // }
- //
- // //Calc offset:
- // Vector3 tBridgeOffset = tCameraRot * (tBridgeLength * 0.5f * CameraZoomFactor);
- //
- // //Height offset:
- // tBridgeOffset.y = Mathf.Lerp(20f,120f,(tBridgeLength*0.001f)) * CameraZoomFactor * CameraHeightOffset;
- //
- // GSDRS.EditorPlayCamera.transform.position = tBridgePos + tBridgeOffset;
- // GSDRS.EditorPlayCamera.transform.rotation = Quaternion.LookRotation(tBridgePos - (tBridgePos + tBridgeOffset));
- // }else{
- // SceneView.lastActiveSceneView.pivot = tBridges[i].transform.position;
- // SceneView.lastActiveSceneView.Repaint();
- // }
- // }
-
- void Line()
- {
- GUILayout.Space(4f);
- GUILayout.Box("", GUILayout.ExpandWidth(true), GUILayout.Height(1)); //Horizontal bar
- GUILayout.Space(4f);
- }
-
- // bool bCtrl = false;
- public void OnSceneGUI()
- {
- DoHotKeyCheck();
- }
-
- void DoHotKeyCheck()
- {
- bool bUsed = false;
- Event current = Event.current;
- int controlID = GUIUtility.GetControlID(GetHashCode(), FocusType.Passive);
-
- // if(current.type == EventType.KeyDown){
- // if(current.keyCode == KeyCode.K){
- // IncrementIntersection();
- // bUsed = true;
- // }else if(current.keyCode == KeyCode.L){
- // IncrementBridge();
- // bUsed = true;
- // }
- // }
-
- if (bUsed)
- {
- switch (current.type)
- {
- case EventType.Layout:
- HandleUtility.AddDefaultControl(controlID);
- break;
- }
- }
-
- if (GUI.changed) { EditorUtility.SetDirty(GSDRS); }
- }
+#region Imports
+using UnityEngine;
+using UnityEditor;
+using System.Collections.Generic;
+using GSD;
+#endregion
+
+
+[CustomEditor(typeof(GSDRoadSystem))]
+public class GSDRoadSystemEditor : Editor
+{
+ //Main target for this editor file:
+ protected GSDRoadSystem GSDRS { get { return (GSDRoadSystem) target; } }
+
+ //Serialized properties:
+ SerializedProperty bTempMultithreading;
+ SerializedProperty bTempSaveMeshAssets;
+
+ //Editor only variables:
+ bool bUpdateGlobal_Multithread = false;
+ bool bUpdateGlobal_SaveMesh = false;
+
+ // //Editor only camera variables:
+ // GSDRoadIntersection[] tInters = null;
+ // int tInterIndex = 0;
+ // GSDSplineN[] tBridges = null;
+ // int tBridgesIndex = 0;
+ // bool bHasBridgeInit = false;
+ // bool bHasInterInit = false;
+ // bool bHasDoneEither = false;
+ // bool bFlipEditorCamera = false;
+ // float CameraZoomFactor = 1f;
+ // float CameraHeightOffset = 1f;
+ // bool bCameraCustomRot = false;
+ // Vector3 CameraCustomRot = new Vector3(0.5f,0f,-0.5f);
+
+ //Editor only graphic variables:
+ Texture2D LoadBtnBG = null;
+ Texture2D LoadBtnBGGlow = null;
+ GUIStyle WarningLabelStyle;
+ Texture2D WarningLabelBG;
+ GUIStyle GSDLoadButton = null;
+
+
+ private void OnEnable()
+ {
+ bTempMultithreading = serializedObject.FindProperty("opt_bMultithreading");
+ bTempSaveMeshAssets = serializedObject.FindProperty("opt_bSaveMeshes");
+ }
+
+
+ public override void OnInspectorGUI()
+ {
+ serializedObject.Update();
+
+ bUpdateGlobal_Multithread = false;
+ bUpdateGlobal_SaveMesh = false;
+ EditorStyles.label.wordWrap = true;
+ InitChecks();
+
+ //Add road button:
+ Line();
+ if (GUILayout.Button("Add road", GSDLoadButton, GUILayout.Width(128f)))
+ {// || GUILayout.Button(btnLoadText,GSDImageButton,GUILayout.Width(16f))){
+ Selection.activeObject = GSDRS.AddRoad();
+ }
+ Line();
+
+ //Multi-threading input:
+ EditorGUILayout.BeginHorizontal();
+ bTempMultithreading.boolValue = EditorGUILayout.Toggle("Multi-threading enabled", GSDRS.opt_bMultithreading);
+ if (bTempMultithreading.boolValue != GSDRS.opt_bMultithreading)
+ {
+ bUpdateGlobal_Multithread = true;
+ }
+
+ //Update all roads button:
+ if (GUILayout.Button("Update all roads", EditorStyles.miniButton, GUILayout.Width(120f)))
+ {
+ GSDRS.UpdateAllRoads();
+ }
+ EditorGUILayout.EndHorizontal();
+
+ //Save mesh assets input:
+ bTempSaveMeshAssets.boolValue = EditorGUILayout.Toggle("Save mesh assets: ", GSDRS.opt_bSaveMeshes);
+ if (bTempSaveMeshAssets.boolValue != GSDRS.opt_bSaveMeshes)
+ {
+ bUpdateGlobal_SaveMesh = true;
+ }
+ if (GSDRS.opt_bSaveMeshes || bTempSaveMeshAssets.boolValue)
+ {
+ GUILayout.Label("WARNING: Saving meshes as assets is very slow and can increase road generation time by several minutes.", WarningLabelStyle);
+ }
+
+ //Online manual button:
+ GUILayout.Space(4f);
+ if (GUILayout.Button("Online manual", EditorStyles.miniButton, GUILayout.Width(120f)))
+ {
+ Application.OpenURL("http://microgsd.com/Support/RoadArchitectManual.aspx");
+ }
+
+ if (GSDRS.EditorPlayCamera == null)
+ {
+ GSDRS.EditorCameraSetSingle();
+ }
+ Line();
+
+ // bHasDoneEither = false;
+
+ // //View intersection
+ // DoInter();
+
+ //View bridges
+ // DoBridges();
+ // if(bHasDoneEither){
+ // EditorGUILayout.LabelField("* Hotkeys only function when this RoadArchitectSystem object is selected", EditorStyles.miniLabel);
+ // }
+
+ //Hotkey check:
+ DoHotKeyCheck();
+
+ if (GUI.changed)
+ {
+ serializedObject.ApplyModifiedProperties();
+
+ //Multithreading global change:
+ if (bUpdateGlobal_Multithread)
+ {
+ GSDRS.UpdateAllRoads_MultiThreadOptions();
+ }
+
+ //Save mesh assets global change:
+ if (bUpdateGlobal_SaveMesh)
+ {
+ GSDRS.UpdateAllRoads_SaveMeshesAsAssetsOptions();
+ }
+ }
+ }
+
+
+ void InitChecks()
+ {
+ if (WarningLabelBG == null)
+ {
+ WarningLabelBG = (Texture2D) AssetDatabase.LoadAssetAtPath(GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Editor/Icons/WarningLabelBG.png", typeof(Texture2D)) as Texture2D;
+ }
+ if (LoadBtnBG == null)
+ {
+ LoadBtnBG = (Texture2D) AssetDatabase.LoadAssetAtPath(GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Editor/Icons/otherbg.png", typeof(Texture2D)) as Texture2D;
+ }
+ if (LoadBtnBGGlow == null)
+ {
+ LoadBtnBGGlow = (Texture2D) AssetDatabase.LoadAssetAtPath(GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Editor/Icons/otherbg2.png", typeof(Texture2D)) as Texture2D;
+ }
+
+ if (GSDLoadButton == null)
+ {
+ GSDLoadButton = new GUIStyle(GUI.skin.button);
+ GSDLoadButton.contentOffset = new Vector2(0f, 1f);
+ GSDLoadButton.normal.textColor = new Color(1f, 1f, 1f, 1f);
+ GSDLoadButton.normal.background = LoadBtnBG;
+ GSDLoadButton.active.background = LoadBtnBGGlow;
+ GSDLoadButton.focused.background = LoadBtnBGGlow;
+ GSDLoadButton.hover.background = LoadBtnBGGlow;
+ GSDLoadButton.fixedHeight = 16f;
+ GSDLoadButton.fixedWidth = 128f;
+ GSDLoadButton.padding = new RectOffset(0, 0, 0, 0);
+ }
+
+ if (WarningLabelStyle == null)
+ {
+ WarningLabelStyle = new GUIStyle(GUI.skin.textArea);
+ WarningLabelStyle.normal.textColor = Color.red;
+ WarningLabelStyle.active.textColor = Color.red;
+ WarningLabelStyle.hover.textColor = Color.red;
+ WarningLabelStyle.normal.background = WarningLabelBG;
+ WarningLabelStyle.active.background = WarningLabelBG;
+ WarningLabelStyle.hover.background = WarningLabelBG;
+ WarningLabelStyle.padding = new RectOffset(8, 8, 8, 8);
+ }
+ }
+
+
+ // void DoInter(){
+ // //View intersection
+ // if(!bHasInterInit){
+ // bHasInterInit = true;
+ // tInters = (GSDRoadIntersection[])GameObject.FindObjectsOfType(typeof(GSDRoadIntersection));
+ // if(tInters == null || tInters.Length < 1){
+ // tInterIndex = -1;
+ // tInters = null;
+ // }
+ // }
+ // if(tInters != null && tInters.Length > 0 && tInterIndex > -1){
+ // EditorGUILayout.BeginHorizontal();
+ // if(GUILayout.Button("View next intersection",GUILayout.Width(150f))){
+ // IncrementIntersection();
+ // }
+ // EditorGUILayout.LabelField("Hotkey K");
+ // EditorGUILayout.EndHorizontal();
+ // bHasDoneEither = true;
+ // }
+ // }
+ //
+ //
+ // void IncrementIntersection(){
+ // if(tInters != null && tInters.Length > 0){
+ // tInterIndex+=1;
+ // if(tInterIndex >= tInters.Length){ tInterIndex = 0; }
+ // ShowIntersection(tInterIndex);
+ // }
+ // }
+ //
+ //
+ // void DoBridges(){
+ // //View bridges
+ // if(!bHasBridgeInit){
+ // bHasBridgeInit = true;
+ // GSDSplineN[] tSplineN = (GSDSplineN[])GameObject.FindObjectsOfType(typeof(GSDSplineN));
+ // List tSplineNList = new List();
+ // foreach(GSDSplineN tNode in tSplineN){
+ // if(tNode.bIsBridgeStart && tNode.bIsBridgeMatched){
+ // tSplineNList.Add(tNode);
+ // }
+ // }
+ // tBridges = tSplineNList.ToArray();
+ // tBridgesIndex = 0;
+ // if(tBridges == null || tBridges.Length < 1){
+ // tBridgesIndex = -1;
+ // tBridges = null;
+ // }
+ // }
+ //
+ // if(tBridges != null && tBridges.Length > 0 && tBridgesIndex > -1){
+ // EditorGUILayout.BeginHorizontal();
+ // if(GUILayout.Button("View next bridge",GUILayout.Width(150f))){
+ // IncrementBridge();
+ // }
+ // EditorGUILayout.LabelField("Hotkey L");
+ // EditorGUILayout.EndHorizontal();
+ // if(EditorApplication.isPlaying){
+ // bool bChangeChecker = EditorGUILayout.Toggle("Flip camera Y:",bFlipEditorCamera);
+ // if(bChangeChecker != bFlipEditorCamera){
+ // bFlipEditorCamera = bChangeChecker;
+ // ShowBridge(tBridgesIndex);
+ // }
+ // }
+ //
+ // if(EditorApplication.isPlaying){
+ // float ChangeChecker = EditorGUILayout.Slider("Zoom factor:",CameraZoomFactor,0.02f,10f);
+ // if(!GSDRootUtil.IsApproximately(ChangeChecker,CameraZoomFactor,0.001f)){
+ // CameraZoomFactor = ChangeChecker;
+ // ShowBridge(tBridgesIndex);
+ // }
+ // ChangeChecker = EditorGUILayout.Slider("Height offset:",CameraHeightOffset,0f,8f);
+ // if(!GSDRootUtil.IsApproximately(ChangeChecker,CameraHeightOffset,0.001f)){
+ // CameraHeightOffset = ChangeChecker;
+ // ShowBridge(tBridgesIndex);
+ // }
+ //
+ // bool bChangeChecker = EditorGUILayout.Toggle("Custom camera rot:",bCameraCustomRot);
+ // if(bChangeChecker != bCameraCustomRot){
+ // bCameraCustomRot = bChangeChecker;
+ // ShowBridge(tBridgesIndex);
+ // }
+ // if(bCameraCustomRot){
+ // Vector3 vChangeChecker = default(Vector3);
+ // vChangeChecker.x = EditorGUILayout.Slider("Rotation X:",CameraCustomRot.x,-1f,1f);
+ // vChangeChecker.z = EditorGUILayout.Slider("Rotation Z:",CameraCustomRot.z,-1f,1f);
+ //
+ // if(vChangeChecker != CameraCustomRot){
+ // CameraCustomRot = vChangeChecker;
+ // ShowBridge(tBridgesIndex);
+ // }
+ // }
+ // }
+ //
+ // bHasDoneEither = true;
+ // }
+ // }
+ //
+ //
+ // void IncrementBridge(){
+ // if(tBridges != null && tBridges.Length > 0){
+ // tBridgesIndex+=1;
+ // if(tBridgesIndex >= tBridges.Length){ tBridgesIndex = 0; }
+ // ShowBridge(tBridgesIndex);
+ // }
+ // }
+ //
+ //
+ // void ShowIntersection(int i){
+ // if(EditorApplication.isPlaying && GSDRS.EditorPlayCamera != null){
+ // GSDRS.EditorPlayCamera.transform.position = tInters[i].transform.position + new Vector3(-40f,20f,-40f);
+ // GSDRS.EditorPlayCamera.transform.rotation = Quaternion.LookRotation(tInters[i].transform.position - (tInters[i].transform.position + new Vector3(-40f,20f,-40f)));
+ // }else{
+ // SceneView.lastActiveSceneView.pivot = tInters[i].transform.position;
+ // SceneView.lastActiveSceneView.Repaint();
+ // }
+ // }
+ //
+ //
+ // void ShowBridge(int i){
+ // if(EditorApplication.isPlaying && GSDRS.EditorPlayCamera != null){
+ // Vector3 tBridgePos = ((tBridges[i].pos - tBridges[i].BridgeCounterpartNode.pos)*0.5f)+tBridges[i].BridgeCounterpartNode.pos;
+ // float tBridgeLength = Vector3.Distance(tBridges[i].pos,tBridges[i].BridgeCounterpartNode.pos);
+ //
+ // //Rotation:
+ // Vector3 tCameraRot = Vector3.Cross((tBridges[i].pos - tBridges[i].BridgeCounterpartNode.pos),Vector3.up);
+ // if(bCameraCustomRot){
+ // tCameraRot = CameraCustomRot;
+ // }else{
+ // tCameraRot = tCameraRot.normalized;
+ // }
+ //
+ // //Calc offset:
+ // Vector3 tBridgeOffset = tCameraRot * (tBridgeLength * 0.5f * CameraZoomFactor);
+ //
+ // //Height offset:
+ // tBridgeOffset.y = Mathf.Lerp(20f,120f,(tBridgeLength*0.001f)) * CameraZoomFactor * CameraHeightOffset;
+ //
+ // GSDRS.EditorPlayCamera.transform.position = tBridgePos + tBridgeOffset;
+ // GSDRS.EditorPlayCamera.transform.rotation = Quaternion.LookRotation(tBridgePos - (tBridgePos + tBridgeOffset));
+ // }else{
+ // SceneView.lastActiveSceneView.pivot = tBridges[i].transform.position;
+ // SceneView.lastActiveSceneView.Repaint();
+ // }
+ // }
+
+
+ void Line()
+ {
+ GUILayout.Space(4f);
+ GUILayout.Box("", GUILayout.ExpandWidth(true), GUILayout.Height(1)); //Horizontal bar
+ GUILayout.Space(4f);
+ }
+
+
+ // bool bCtrl = false;
+ public void OnSceneGUI()
+ {
+ DoHotKeyCheck();
+ }
+
+
+ void DoHotKeyCheck()
+ {
+ bool bUsed = false;
+ Event current = Event.current;
+ int controlID = GUIUtility.GetControlID(GetHashCode(), FocusType.Passive);
+
+ // if(current.type == EventType.KeyDown){
+ // if(current.keyCode == KeyCode.K){
+ // IncrementIntersection();
+ // bUsed = true;
+ // }else if(current.keyCode == KeyCode.L){
+ // IncrementBridge();
+ // bUsed = true;
+ // }
+ // }
+
+ if (bUsed)
+ {
+ switch (current.type)
+ {
+ case EventType.Layout:
+ HandleUtility.AddDefaultControl(controlID);
+ break;
+ }
+ }
+
+ if (GUI.changed)
+ {
+ EditorUtility.SetDirty(GSDRS);
+ }
+ }
}
\ No newline at end of file
diff --git a/Editor/GSDRoadSystemEditorMenu.cs b/Editor/GSDRoadSystemEditorMenu.cs
index 3a267e53..87f02c66 100755
--- a/Editor/GSDRoadSystemEditorMenu.cs
+++ b/Editor/GSDRoadSystemEditorMenu.cs
@@ -1,124 +1,133 @@
-using UnityEngine;
-using UnityEditor;
-
-public class GSDRoadSystemEditorMenu : ScriptableObject
-{
- private const bool bRoadTestCubes = false;
-
- ///
- /// Creates the road system.
- ///
- [MenuItem("Window/Road Architect/Create road system")]
- public static void CreateRoadSystem()
- {
- Object[] tObj = GameObject.FindObjectsOfType(typeof(GSDRoadSystem));
- int i = (tObj.Length + 1);
- tObj = null;
-
- GameObject tRoadSystemObj = new GameObject("RoadArchitectSystem" + i.ToString());
- GSDRoadSystem tRoadSystem = tRoadSystemObj.AddComponent(); //Add road system component.
- tRoadSystem.AddRoad(true);//Add road for new road system.
-
- GameObject IntersectionsMasterObject = new GameObject("Intersections");
- IntersectionsMasterObject.transform.parent = tRoadSystemObj.transform;
- }
-
- ///
- /// Add road to gameobject. Not sure if this is necessary.
- ///
- [MenuItem("Window/Road Architect/Add road")]
- public static void AddRoad()
- {
- Object[] tObjs = GameObject.FindObjectsOfType(typeof(GSDRoadSystem));
- if (tObjs != null && tObjs.Length == 0)
- {
- CreateRoadSystem();
- return;
- }
- else
- {
- GSDRoadSystem GSDRS = (GSDRoadSystem)tObjs[0];
- Selection.activeGameObject = GSDRS.AddRoad();
- }
- }
-
- ///
- /// Updates all roads. Used when things get out of sync.
- ///
- [MenuItem("Window/Road Architect/Update All Roads")]
- public static void UpdateAllRoads()
- {
- GSDRoad[] tRoadObjs = (GSDRoad[])GameObject.FindObjectsOfType(typeof(GSDRoad));
-
- int RoadCount = tRoadObjs.Length;
-
- GSDRoad tRoad = null;
- GSDSplineC[] tPiggys = null;
- if (RoadCount > 1)
- {
- tPiggys = new GSDSplineC[RoadCount - 1];
- }
-
- for (int h = 0; h < RoadCount; h++)
- {
- tRoad = tRoadObjs[h];
- if (h > 0)
- {
- tPiggys[h - 1] = tRoad.GSDSpline;
- }
- }
-
- tRoad = tRoadObjs[0];
- if (tPiggys != null && tPiggys.Length > 0)
- {
- tRoad.PiggyBacks = tPiggys;
- }
- tRoad.UpdateRoad();
- }
-
- ///
- /// Show the help screen.
- ///
- [MenuItem("Window/Road Architect/Help")]
- public static void GSDRoadsHelp()
- {
- GSDHelpWindow tHelp = EditorWindow.GetWindow();
- tHelp.Initialize();
- }
-
- ///
- /// WARNING: Only call this on an empty scene that has some terrains on it. MicroGSD LLC is not responsbile for data loss if this function is called by user.
- ///
- [MenuItem("Window/Road Architect/Testing/Run all unit tests (caution)")]
- public static void TestProgram()
- {
- GSD.Roads.GSDUnitTests.RoadArchitectUnitTests();
- }
-
- ///
- /// WARNING: Only call this on an empty scene that has some terrains on it. MicroGSD LLC is not responsbile for data loss if this function is called by user.
- ///
- [MenuItem("Window/Road Architect/Testing/Clean up tests (caution)")]
- public static void TestCleanup()
- {
- GSD.Roads.GSDUnitTests.CleanupTests();
- }
-
-
-
- ///
- /// Get code line count for RA project.
- ///
- [MenuItem("Window/Road Architect/Testing/Get line count of RA")]
- public static void testCodeCount()
- {
- string mainDir = Application.dataPath + "/RoadArchitect/";
- string[] files = System.IO.Directory.GetFiles(mainDir, "*.cs", System.IO.SearchOption.AllDirectories);
- int lineCount = 0;
- foreach (string s in files)
- {
- lineCount += System.IO.File.ReadAllLines(s).Length;
- }
- Debug.Log(string.Format("{0:n0}", lineCount) + " lines of code in Road Architect.");
- }
+#region "Imports"
+using UnityEngine;
+using UnityEditor;
+#endregion
+
+
+public class GSDRoadSystemEditorMenu : ScriptableObject
+{
+ private const bool bRoadTestCubes = false;
+
+
+ ///
+ /// Creates the road system.
+ ///
+ [MenuItem("Window/Road Architect/Create road system")]
+ public static void CreateRoadSystem()
+ {
+ Object[] tObj = GameObject.FindObjectsOfType(typeof(GSDRoadSystem));
+ int i = (tObj.Length + 1);
+ tObj = null;
+
+ GameObject tRoadSystemObj = new GameObject("RoadArchitectSystem" + i.ToString());
+ GSDRoadSystem tRoadSystem = tRoadSystemObj.AddComponent(); //Add road system component.
+ tRoadSystem.AddRoad(true);//Add road for new road system.
+
+ GameObject IntersectionsMasterObject = new GameObject("Intersections");
+ IntersectionsMasterObject.transform.parent = tRoadSystemObj.transform;
+ }
+
+
+ ///
+ /// Add road to gameobject. Not sure if this is necessary.
+ ///
+ [MenuItem("Window/Road Architect/Add road")]
+ public static void AddRoad()
+ {
+ Object[] tObjs = GameObject.FindObjectsOfType(typeof(GSDRoadSystem));
+ if (tObjs != null && tObjs.Length == 0)
+ {
+ CreateRoadSystem();
+ return;
+ }
+ else
+ {
+ GSDRoadSystem GSDRS = (GSDRoadSystem) tObjs[0];
+ Selection.activeGameObject = GSDRS.AddRoad();
+ }
+ }
+
+
+ ///
+ /// Updates all roads. Used when things get out of sync.
+ ///
+ [MenuItem("Window/Road Architect/Update All Roads")]
+ public static void UpdateAllRoads()
+ {
+ GSDRoad[] tRoadObjs = (GSDRoad[]) GameObject.FindObjectsOfType(typeof(GSDRoad));
+
+ int RoadCount = tRoadObjs.Length;
+
+ GSDRoad tRoad = null;
+ GSDSplineC[] tPiggys = null;
+ if (RoadCount > 1)
+ {
+ tPiggys = new GSDSplineC[RoadCount - 1];
+ }
+
+ for (int h = 0; h < RoadCount; h++)
+ {
+ tRoad = tRoadObjs[h];
+ if (h > 0)
+ {
+ tPiggys[h - 1] = tRoad.GSDSpline;
+ }
+ }
+
+ tRoad = tRoadObjs[0];
+ if (tPiggys != null && tPiggys.Length > 0)
+ {
+ tRoad.PiggyBacks = tPiggys;
+ }
+ tRoad.UpdateRoad();
+ }
+
+
+ ///
+ /// Show the help screen.
+ ///
+ [MenuItem("Window/Road Architect/Help")]
+ public static void GSDRoadsHelp()
+ {
+ GSDHelpWindow tHelp = EditorWindow.GetWindow();
+ tHelp.Initialize();
+ }
+
+
+ ///
+ /// WARNING: Only call this on an empty scene that has some terrains on it. MicroGSD LLC is not responsbile for data loss if this function is called by user.
+ ///
+ [MenuItem("Window/Road Architect/Testing/Run all unit tests (caution)")]
+ public static void TestProgram()
+ {
+ GSD.Roads.GSDUnitTests.RoadArchitectUnitTests();
+ }
+
+
+ ///
+ /// WARNING: Only call this on an empty scene that has some terrains on it. MicroGSD LLC is not responsbile for data loss if this function is called by user.
+ ///
+ [MenuItem("Window/Road Architect/Testing/Clean up tests (caution)")]
+ public static void TestCleanup()
+ {
+ GSD.Roads.GSDUnitTests.CleanupTests();
+ }
+
+
+
+ ///
+ /// Get code line count for RA project.
+ ///
+ [MenuItem("Window/Road Architect/Testing/Get line count of RA")]
+ public static void testCodeCount()
+ {
+ string mainDir = Application.dataPath + "/RoadArchitect/";
+ string[] files = System.IO.Directory.GetFiles(mainDir, "*.cs", System.IO.SearchOption.AllDirectories);
+ int lineCount = 0;
+ foreach (string s in files)
+ {
+ lineCount += System.IO.File.ReadAllLines(s).Length;
+ }
+ Debug.Log(string.Format("{0:n0}", lineCount) + " lines of code in Road Architect.");
+ }
}
\ No newline at end of file
diff --git a/Editor/GSDSaveWindow.cs b/Editor/GSDSaveWindow.cs
index c0fa3b18..dd5e2dbb 100755
--- a/Editor/GSDSaveWindow.cs
+++ b/Editor/GSDSaveWindow.cs
@@ -1,316 +1,336 @@
-#region "Imports"
-using UnityEngine;
-using UnityEditor;
-using System.Collections;
-using System.Collections.Generic;
-using System.Text.RegularExpressions;
-using GSD;
-#endregion
-public class GSDSaveWindow : EditorWindow
-{
- public enum WindowTypeEnum
- {
- Extrusion,
- Edge,
- BridgeWizard
- };
- WindowTypeEnum tWindowType = WindowTypeEnum.Extrusion;
-
- Texture2D temp2D = null;
- Texture2D temp2D_2 = null;
- string ThumbString = "";
- string Desc = "";
- string tFilename = "DefaultName";
- string tDisplayName = "DefaultName";
- string tDisplayName2 = "";
- string TitleText = "";
- // string tPath = "";
- bool bFileExists = false;
- bool bIsBridge = false;
- // bool bIsDefault = false;
-
- GSD.Roads.Splination.SplinatedMeshMaker[] tSMMs = null;
- GSD.Roads.EdgeObjects.EdgeObjectMaker[] tEOMs = null;
- const int titleLabelHeight = 20;
-
- string xPath = "";
-
- void OnGUI()
- {
- GUILayout.Space(4f);
- EditorGUILayout.LabelField(TitleText, EditorStyles.boldLabel);
-
- temp2D_2 = (Texture2D)EditorGUILayout.ObjectField("Square thumb (optional):", temp2D, typeof(Texture2D), false);
- if (temp2D_2 != temp2D)
- {
- temp2D = temp2D_2;
- ThumbString = AssetDatabase.GetAssetPath(temp2D);
- }
-
- if (xPath.Length < 5)
- {
- xPath = GSDRootUtil.Dir_GetLibrary();
- }
-
- EditorGUILayout.LabelField("Short description (optional):");
- Desc = EditorGUILayout.TextArea(Desc, GUILayout.Height(40f));
- tDisplayName2 = EditorGUILayout.TextField("Display name:", tDisplayName);
- if (string.Compare(tDisplayName2, tDisplayName) != 0)
- {
- tDisplayName = tDisplayName2;
- SanitizeFilename();
-
- if (tWindowType == WindowTypeEnum.Edge)
- {
-
-
- if (System.IO.File.Exists(xPath + "EOM" + tFilename + ".gsd"))
- {
- bFileExists = true;
- }
- else
- {
- bFileExists = false;
- }
- }
- else if (tWindowType == WindowTypeEnum.Extrusion)
- {
- if (System.IO.File.Exists(xPath + "ESO" + tFilename + ".gsd"))
- {
- bFileExists = true;
- }
- else
- {
- bFileExists = false;
- }
- }
- else
- {
- if (System.IO.File.Exists(xPath + "B/" + tFilename + ".gsd"))
- {
- bFileExists = true;
- }
- else
- {
- bFileExists = false;
- }
- }
- }
-
-
- if (bFileExists)
- {
- EditorGUILayout.LabelField("File exists already!", EditorStyles.miniLabel);
- if (tWindowType == WindowTypeEnum.Edge)
- {
- EditorGUILayout.LabelField(xPath + "EOM" + tFilename + ".gsd", EditorStyles.miniLabel);
- }
- else if (tWindowType == WindowTypeEnum.Extrusion)
- {
- EditorGUILayout.LabelField(xPath + "ESO" + tFilename + ".gsd", EditorStyles.miniLabel);
- }
- else
- {
- EditorGUILayout.LabelField(xPath + "B/" + tFilename + ".gsd", EditorStyles.miniLabel);
- }
- }
- else
- {
- if (tWindowType == WindowTypeEnum.Edge)
- {
- EditorGUILayout.LabelField(xPath + "EOM" + tFilename + ".gsd", EditorStyles.miniLabel);
- }
- else if (tWindowType == WindowTypeEnum.Extrusion)
- {
- EditorGUILayout.LabelField(xPath + "ESO" + tFilename + ".gsd", EditorStyles.miniLabel);
- }
- else
- {
- EditorGUILayout.LabelField(xPath + "B/" + tFilename + ".gsd", EditorStyles.miniLabel);
- }
- }
-
- GUILayout.Space(4f);
-
- bIsBridge = EditorGUILayout.Toggle("Is bridge related:", bIsBridge);
- // GUILayout.Space(4f);
- // bIsDefault = EditorGUILayout.Toggle("Is GSD:",bIsDefault);
- GUILayout.Space(8f);
- EditorGUILayout.BeginHorizontal();
- if (GUILayout.Button("Cancel"))
- {
- Close();
- }
- if (tWindowType == WindowTypeEnum.Extrusion)
- {
- DoExtrusion();
- }
- else if (tWindowType == WindowTypeEnum.Edge)
- {
- DoEdgeObject();
- }
- else if (tWindowType == WindowTypeEnum.BridgeWizard)
- {
- DoBridge();
- }
-
- EditorGUILayout.EndHorizontal();
- }
-
- void DoExtrusion()
- {
- if (GUILayout.Button("Save extrusion"))
- {
- SanitizeFilename();
- tSMMs[0].bIsBridge = bIsBridge;
- tSMMs[0].ThumbString = ThumbString;
- tSMMs[0].Desc = Desc;
- tSMMs[0].DisplayName = tDisplayName;
- tSMMs[0].SaveToLibrary(tFilename, false);
- Close();
- }
- }
-
- void DoEdgeObject()
- {
- if (GUILayout.Button("Save edge object"))
- {
- SanitizeFilename();
- tEOMs[0].bIsBridge = bIsBridge;
- tEOMs[0].ThumbString = ThumbString;
- tEOMs[0].Desc = Desc;
- tEOMs[0].DisplayName = tDisplayName;
- tEOMs[0].SaveToLibrary(tFilename, false);
- Close();
- }
- }
-
- void DoBridge()
- {
- if (GUILayout.Button("Save group"))
- {
- SanitizeFilename();
- GSD.Roads.GSDRoadUtil.WizardObject WO = new GSD.Roads.GSDRoadUtil.WizardObject();
- WO.ThumbString = ThumbString;
- WO.Desc = Desc;
- WO.DisplayName = tDisplayName;
- WO.FileName = tFilename;
- WO.bIsBridge = bIsBridge;
- WO.bIsDefault = false;
-
- GSD.Roads.GSDRoadUtil.SaveNodeObjects(ref tSMMs, ref tEOMs, ref WO);
- Close();
- }
- }
-
- void SanitizeFilename()
- {
- Regex rgx = new Regex("[^a-zA-Z0-9 -]");
- tFilename = rgx.Replace(tDisplayName, "");
- tFilename = tFilename.Replace(" ", "-");
- tFilename = tFilename.Replace("_", "-");
- }
-
- #region "Init"
- public void Initialize(ref Rect tRect, WindowTypeEnum _tWindowType, GSDSplineN tNode, GSD.Roads.Splination.SplinatedMeshMaker SMM = null, GSD.Roads.EdgeObjects.EdgeObjectMaker EOM = null)
- {
- int Rheight = 300;
- int Rwidth = 360;
- float Rx = ((float)tRect.width / 2f) - ((float)Rwidth / 2f) + tRect.x;
- float Ry = ((float)tRect.height / 2f) - ((float)Rheight / 2f) + tRect.y;
-
- if (Rx < 0) { Rx = tRect.x; }
- if (Ry < 0) { Ry = tRect.y; }
- if (Rx > (tRect.width + tRect.x)) { Rx = tRect.x; }
- if (Ry > (tRect.height + tRect.y)) { Ry = tRect.y; }
-
- Rect fRect = new Rect(Rx, Ry, Rwidth, Rheight);
-
- if (fRect.width < 300)
- {
- fRect.width = 300;
- fRect.x = tRect.x;
- }
- if (fRect.height < 300)
- {
- fRect.height = 300;
- fRect.y = tRect.y;
- }
-
- position = fRect;
- tWindowType = _tWindowType;
- Show();
- titleContent.text = "Save";
- if (tWindowType == WindowTypeEnum.Extrusion)
- {
- TitleText = "Save extrusion";
- tSMMs = new GSD.Roads.Splination.SplinatedMeshMaker[1];
- tSMMs[0] = SMM;
- if (SMM != null)
- {
- tFilename = SMM.tName;
- tDisplayName = tFilename;
- }
- }
- else if (tWindowType == WindowTypeEnum.Edge)
- {
- TitleText = "Save edge object";
- tEOMs = new GSD.Roads.EdgeObjects.EdgeObjectMaker[1];
- tEOMs[0] = EOM;
- if (EOM != null)
- {
- tFilename = EOM.tName;
- tDisplayName = tFilename;
- }
- }
- else if (tWindowType == WindowTypeEnum.BridgeWizard)
- {
- bIsBridge = true;
- tSMMs = tNode.SplinatedObjects.ToArray();
- tEOMs = tNode.EdgeObjects.ToArray();
- TitleText = "Save group";
- tFilename = "Group" + Random.Range(0, 10000).ToString();
- tDisplayName = tFilename;
- }
-
- if (xPath.Length < 5)
- {
- xPath = GSDRootUtil.Dir_GetLibrary();
- }
-
- if (tWindowType == WindowTypeEnum.Edge)
- {
- if (System.IO.File.Exists(xPath + "EOM" + tFilename + ".gsd"))
- {
- bFileExists = true;
- }
- else
- {
- bFileExists = false;
- }
- }
- else if (tWindowType == WindowTypeEnum.Extrusion)
- {
- if (System.IO.File.Exists(xPath + "ESO" + tFilename + ".gsd"))
- {
- bFileExists = true;
- }
- else
- {
- bFileExists = false;
- }
- }
- else
- {
- if (System.IO.File.Exists(xPath + "B/" + tFilename + ".gsd"))
- {
- bFileExists = true;
- }
- else
- {
- bFileExists = false;
- }
- }
- }
- #endregion
+#region "Imports"
+using UnityEngine;
+using UnityEditor;
+using System.Collections;
+using System.Collections.Generic;
+using System.Text.RegularExpressions;
+using GSD;
+#endregion
+
+
+public class GSDSaveWindow : EditorWindow
+{
+ public enum WindowTypeEnum
+ {
+ Extrusion,
+ Edge,
+ BridgeWizard
+ };
+ WindowTypeEnum tWindowType = WindowTypeEnum.Extrusion;
+
+ Texture2D temp2D = null;
+ Texture2D temp2D_2 = null;
+ string ThumbString = "";
+ string Desc = "";
+ string tFilename = "DefaultName";
+ string tDisplayName = "DefaultName";
+ string tDisplayName2 = "";
+ string TitleText = "";
+ // string tPath = "";
+ bool bFileExists = false;
+ bool bIsBridge = false;
+ // bool bIsDefault = false;
+
+ GSD.Roads.Splination.SplinatedMeshMaker[] tSMMs = null;
+ GSD.Roads.EdgeObjects.EdgeObjectMaker[] tEOMs = null;
+ const int titleLabelHeight = 20;
+
+ string xPath = "";
+
+
+ void OnGUI()
+ {
+ GUILayout.Space(4f);
+ EditorGUILayout.LabelField(TitleText, EditorStyles.boldLabel);
+
+ temp2D_2 = (Texture2D) EditorGUILayout.ObjectField("Square thumb (optional):", temp2D, typeof(Texture2D), false);
+ if (temp2D_2 != temp2D)
+ {
+ temp2D = temp2D_2;
+ ThumbString = AssetDatabase.GetAssetPath(temp2D);
+ }
+
+ if (xPath.Length < 5)
+ {
+ xPath = GSDRootUtil.Dir_GetLibrary();
+ }
+
+ EditorGUILayout.LabelField("Short description (optional):");
+ Desc = EditorGUILayout.TextArea(Desc, GUILayout.Height(40f));
+ tDisplayName2 = EditorGUILayout.TextField("Display name:", tDisplayName);
+ if (string.Compare(tDisplayName2, tDisplayName) != 0)
+ {
+ tDisplayName = tDisplayName2;
+ SanitizeFilename();
+
+ if (tWindowType == WindowTypeEnum.Edge)
+ {
+
+
+ if (System.IO.File.Exists(xPath + "EOM" + tFilename + ".gsd"))
+ {
+ bFileExists = true;
+ }
+ else
+ {
+ bFileExists = false;
+ }
+ }
+ else if (tWindowType == WindowTypeEnum.Extrusion)
+ {
+ if (System.IO.File.Exists(xPath + "ESO" + tFilename + ".gsd"))
+ {
+ bFileExists = true;
+ }
+ else
+ {
+ bFileExists = false;
+ }
+ }
+ else
+ {
+ if (System.IO.File.Exists(xPath + "B/" + tFilename + ".gsd"))
+ {
+ bFileExists = true;
+ }
+ else
+ {
+ bFileExists = false;
+ }
+ }
+ }
+
+
+ if (bFileExists)
+ {
+ EditorGUILayout.LabelField("File exists already!", EditorStyles.miniLabel);
+ if (tWindowType == WindowTypeEnum.Edge)
+ {
+ EditorGUILayout.LabelField(xPath + "EOM" + tFilename + ".gsd", EditorStyles.miniLabel);
+ }
+ else if (tWindowType == WindowTypeEnum.Extrusion)
+ {
+ EditorGUILayout.LabelField(xPath + "ESO" + tFilename + ".gsd", EditorStyles.miniLabel);
+ }
+ else
+ {
+ EditorGUILayout.LabelField(xPath + "B/" + tFilename + ".gsd", EditorStyles.miniLabel);
+ }
+ }
+ else
+ {
+ if (tWindowType == WindowTypeEnum.Edge)
+ {
+ EditorGUILayout.LabelField(xPath + "EOM" + tFilename + ".gsd", EditorStyles.miniLabel);
+ }
+ else if (tWindowType == WindowTypeEnum.Extrusion)
+ {
+ EditorGUILayout.LabelField(xPath + "ESO" + tFilename + ".gsd", EditorStyles.miniLabel);
+ }
+ else
+ {
+ EditorGUILayout.LabelField(xPath + "B/" + tFilename + ".gsd", EditorStyles.miniLabel);
+ }
+ }
+
+ GUILayout.Space(4f);
+
+ bIsBridge = EditorGUILayout.Toggle("Is bridge related:", bIsBridge);
+ // GUILayout.Space(4f);
+ // bIsDefault = EditorGUILayout.Toggle("Is GSD:",bIsDefault);
+ GUILayout.Space(8f);
+ EditorGUILayout.BeginHorizontal();
+ if (GUILayout.Button("Cancel"))
+ {
+ Close();
+ }
+ if (tWindowType == WindowTypeEnum.Extrusion)
+ {
+ DoExtrusion();
+ }
+ else if (tWindowType == WindowTypeEnum.Edge)
+ {
+ DoEdgeObject();
+ }
+ else if (tWindowType == WindowTypeEnum.BridgeWizard)
+ {
+ DoBridge();
+ }
+
+ EditorGUILayout.EndHorizontal();
+ }
+
+
+ void DoExtrusion()
+ {
+ if (GUILayout.Button("Save extrusion"))
+ {
+ SanitizeFilename();
+ tSMMs[0].bIsBridge = bIsBridge;
+ tSMMs[0].ThumbString = ThumbString;
+ tSMMs[0].Desc = Desc;
+ tSMMs[0].DisplayName = tDisplayName;
+ tSMMs[0].SaveToLibrary(tFilename, false);
+ Close();
+ }
+ }
+
+
+ void DoEdgeObject()
+ {
+ if (GUILayout.Button("Save edge object"))
+ {
+ SanitizeFilename();
+ tEOMs[0].bIsBridge = bIsBridge;
+ tEOMs[0].ThumbString = ThumbString;
+ tEOMs[0].Desc = Desc;
+ tEOMs[0].DisplayName = tDisplayName;
+ tEOMs[0].SaveToLibrary(tFilename, false);
+ Close();
+ }
+ }
+
+
+ void DoBridge()
+ {
+ if (GUILayout.Button("Save group"))
+ {
+ SanitizeFilename();
+ GSD.Roads.GSDRoadUtil.WizardObject WO = new GSD.Roads.GSDRoadUtil.WizardObject();
+ WO.ThumbString = ThumbString;
+ WO.Desc = Desc;
+ WO.DisplayName = tDisplayName;
+ WO.FileName = tFilename;
+ WO.bIsBridge = bIsBridge;
+ WO.bIsDefault = false;
+
+ GSD.Roads.GSDRoadUtil.SaveNodeObjects(ref tSMMs, ref tEOMs, ref WO);
+ Close();
+ }
+ }
+
+
+ void SanitizeFilename()
+ {
+ Regex rgx = new Regex("[^a-zA-Z0-9 -]");
+ tFilename = rgx.Replace(tDisplayName, "");
+ tFilename = tFilename.Replace(" ", "-");
+ tFilename = tFilename.Replace("_", "-");
+ }
+
+
+ #region "Init"
+ public void Initialize(ref Rect tRect, WindowTypeEnum _tWindowType, GSDSplineN tNode, GSD.Roads.Splination.SplinatedMeshMaker SMM = null, GSD.Roads.EdgeObjects.EdgeObjectMaker EOM = null)
+ {
+ int Rheight = 300;
+ int Rwidth = 360;
+ float Rx = ((float) tRect.width / 2f) - ((float) Rwidth / 2f) + tRect.x;
+ float Ry = ((float) tRect.height / 2f) - ((float) Rheight / 2f) + tRect.y;
+
+ if (Rx < 0)
+ {
+ Rx = tRect.x;
+ }
+ if (Ry < 0)
+ {
+ Ry = tRect.y;
+ }
+ if (Rx > (tRect.width + tRect.x))
+ {
+ Rx = tRect.x;
+ }
+ if (Ry > (tRect.height + tRect.y))
+ {
+ Ry = tRect.y;
+ }
+
+ Rect fRect = new Rect(Rx, Ry, Rwidth, Rheight);
+
+ if (fRect.width < 300)
+ {
+ fRect.width = 300;
+ fRect.x = tRect.x;
+ }
+ if (fRect.height < 300)
+ {
+ fRect.height = 300;
+ fRect.y = tRect.y;
+ }
+
+ position = fRect;
+ tWindowType = _tWindowType;
+ Show();
+ titleContent.text = "Save";
+ if (tWindowType == WindowTypeEnum.Extrusion)
+ {
+ TitleText = "Save extrusion";
+ tSMMs = new GSD.Roads.Splination.SplinatedMeshMaker[1];
+ tSMMs[0] = SMM;
+ if (SMM != null)
+ {
+ tFilename = SMM.tName;
+ tDisplayName = tFilename;
+ }
+ }
+ else if (tWindowType == WindowTypeEnum.Edge)
+ {
+ TitleText = "Save edge object";
+ tEOMs = new GSD.Roads.EdgeObjects.EdgeObjectMaker[1];
+ tEOMs[0] = EOM;
+ if (EOM != null)
+ {
+ tFilename = EOM.tName;
+ tDisplayName = tFilename;
+ }
+ }
+ else if (tWindowType == WindowTypeEnum.BridgeWizard)
+ {
+ bIsBridge = true;
+ tSMMs = tNode.SplinatedObjects.ToArray();
+ tEOMs = tNode.EdgeObjects.ToArray();
+ TitleText = "Save group";
+ tFilename = "Group" + Random.Range(0, 10000).ToString();
+ tDisplayName = tFilename;
+ }
+
+ if (xPath.Length < 5)
+ {
+ xPath = GSDRootUtil.Dir_GetLibrary();
+ }
+
+ if (tWindowType == WindowTypeEnum.Edge)
+ {
+ if (System.IO.File.Exists(xPath + "EOM" + tFilename + ".gsd"))
+ {
+ bFileExists = true;
+ }
+ else
+ {
+ bFileExists = false;
+ }
+ }
+ else if (tWindowType == WindowTypeEnum.Extrusion)
+ {
+ if (System.IO.File.Exists(xPath + "ESO" + tFilename + ".gsd"))
+ {
+ bFileExists = true;
+ }
+ else
+ {
+ bFileExists = false;
+ }
+ }
+ else
+ {
+ if (System.IO.File.Exists(xPath + "B/" + tFilename + ".gsd"))
+ {
+ bFileExists = true;
+ }
+ else
+ {
+ bFileExists = false;
+ }
+ }
+ }
+ #endregion
}
\ No newline at end of file
diff --git a/Editor/GSDSplineCEditor.cs b/Editor/GSDSplineCEditor.cs
index 8170d930..53e1b0da 100755
--- a/Editor/GSDSplineCEditor.cs
+++ b/Editor/GSDSplineCEditor.cs
@@ -1,23 +1,31 @@
-#region "Imports"
-using UnityEngine;
-using UnityEditor;
-[CustomEditor(typeof(GSDSplineC))]
-#endregion
-public class GSDSplineCEditor : Editor
-{
- protected GSDSplineC tSpline { get { return (GSDSplineC)target; } }
-
- int browseNode = 0;
- public override void OnInspectorGUI()
- {
- EditorGUILayout.BeginHorizontal();
- EditorGUILayout.LabelField("Browse to node:", EditorStyles.boldLabel);
- browseNode = EditorGUILayout.IntField(browseNode);
- if (GUILayout.Button("Browse"))
- {
- if (browseNode < tSpline.mNodes.Count)
- Selection.objects = new Object[1] { tSpline.mNodes[browseNode] };
- }
- EditorGUILayout.EndHorizontal();
- }
+#region "Imports"
+using UnityEngine;
+using UnityEditor;
+#endregion
+
+
+[CustomEditor(typeof(GSDSplineC))]
+public class GSDSplineCEditor : Editor
+{
+ protected GSDSplineC tSpline { get { return (GSDSplineC) target; } }
+
+ int browseNode = 0;
+
+
+ public override void OnInspectorGUI()
+ {
+ #region NodeBrowser
+ EditorGUILayout.BeginHorizontal();
+ EditorGUILayout.LabelField("Browse to node:", EditorStyles.boldLabel);
+ browseNode = EditorGUILayout.IntField(browseNode);
+ if (GUILayout.Button("Browse"))
+ {
+ if (browseNode < tSpline.mNodes.Count)
+ {
+ Selection.objects = new Object[1] { tSpline.mNodes[browseNode] };
+ }
+ }
+ EditorGUILayout.EndHorizontal();
+ #endregion
+ }
}
\ No newline at end of file
diff --git a/Editor/GSDSplineFEditor.cs b/Editor/GSDSplineFEditor.cs
index 3ed4a5f8..6d2610b6 100755
--- a/Editor/GSDSplineFEditor.cs
+++ b/Editor/GSDSplineFEditor.cs
@@ -1,14 +1,17 @@
-#region "Imports"
-using UnityEngine;
-using UnityEditor;
-[CustomEditor(typeof(GSDSplineF))]
-#endregion
-public class GSDSplineFEditor : Editor
-{
- protected GSDSplineF tSpline { get { return (GSDSplineF)target; } }
-
- public override void OnInspectorGUI()
- {
- //Intentionally left empty.
- }
+#region "Imports"
+using UnityEngine;
+using UnityEditor;
+#endregion
+
+
+[CustomEditor(typeof(GSDSplineF))]
+public class GSDSplineFEditor : Editor
+{
+ protected GSDSplineF tSpline { get { return (GSDSplineF) target; } }
+
+
+ public override void OnInspectorGUI()
+ {
+ //Intentionally left empty.
+ }
}
\ No newline at end of file
diff --git a/Editor/GSDSplineIEditor.cs b/Editor/GSDSplineIEditor.cs
index 70e109ce..fde8c0cb 100755
--- a/Editor/GSDSplineIEditor.cs
+++ b/Editor/GSDSplineIEditor.cs
@@ -1,14 +1,17 @@
-#region "Imports"
-using UnityEngine;
-using UnityEditor;
-[CustomEditor(typeof(GSDSplineI))]
-#endregion
-public class GSDSplineIEditor : Editor
-{
- protected GSDSplineI tSpline { get { return (GSDSplineI)target; } }
-
- public override void OnInspectorGUI()
- {
- //Intentionally left empty.
- }
+#region "Imports"
+using UnityEngine;
+using UnityEditor;
+#endregion
+
+
+[CustomEditor(typeof(GSDSplineI))]
+public class GSDSplineIEditor : Editor
+{
+ protected GSDSplineI tSpline { get { return (GSDSplineI) target; } }
+
+
+ public override void OnInspectorGUI()
+ {
+ //Intentionally left empty.
+ }
}
\ No newline at end of file
diff --git a/Editor/GSDSplineNEditor.cs b/Editor/GSDSplineNEditor.cs
index b83e5e56..67513624 100755
--- a/Editor/GSDSplineNEditor.cs
+++ b/Editor/GSDSplineNEditor.cs
@@ -1,2336 +1,2609 @@
-#region "Imports"
-using UnityEngine;
-using UnityEditor;
-using System.Collections;
-using System.Collections.Generic;
-using GSD;
-[CustomEditor(typeof(GSDSplineN))]
-#endregion
-
-//=====================================================
-//== NOTE THAT CUSTOM SERIALIZATION IS USED HERE ==
-//== SOLELY TO COMPLY WITH UNDO REQUIREMENTS ==
-//=====================================================
-
-public class GSDSplineNEditor : Editor
-{
- #region "Vars"
- protected GSDSplineN tNode { get { return (GSDSplineN)target; } }
- const string tOnlineHelpDesc = "Visit the online manual for the most effective help.";
- bool bMouseDragHasProcessed = true;
- int eCount = -1;
- int currentCount = 0;
- public bool bSplinatedObjectHelp = false;
- public bool bEdgeObjectHelp = false;
- bool bRemoveAll = false;
- float HorizRoadMax = 0;
-
- //Button icons:
- Texture btnDeleteText = null;
- Texture btnCopyText = null;
- Texture btnSaveText = null;
- Texture btnLoadText = null;
- Texture btnExtrudeText = null;
- Texture btnEdgeText = null;
- Texture btnHelpText = null;
- Texture btnRefreshText = null;
- Texture btnDefaultText = null;
- Texture2D LoadBtnBG = null;
- Texture2D GSDTextAreaBG = null;
- Texture2D LoadBtnBGGlow = null;
- Texture2D ManualBG = null;
-
- public bool bLoadingEOS = false;
- public int LoadingEOSIndex = 0;
- public List LoadingEOSNames = null;
- public List LoadingEOSPaths = null;
-
- public bool bLoadingEOM = false;
- public int LoadingEOMIndex = 0;
- public List LoadingEOMNames = null;
- public List LoadingEOMPaths = null;
-
- //Checkers:
- // float ChangeChecker = -1f;
- // bool bChangeChecker = false;
- // Vector3 vChangeChecker = default(Vector3);
- // GameObject tObj = null;
- // Material tMat = null;
- GSD.Roads.Splination.SplinatedMeshMaker SMM = null;
-
-
-
-
- public enum EndObjectsDefaultsEnum
- {
- None,
- WarningSign1_Static,
- WarningSign2_Static,
- Atten_Static,
- Barrel1_Static,
- Barrel1_Rigid,
- Barrel3_Static,
- Barrel3_Rigid,
- Barrel7_Static,
- Barrel7_Rigid
- };
- EndObjectsDefaultsEnum tEndObjectAdd = EndObjectsDefaultsEnum.None;
-
- private static string[] EndObjectsDefaultsEnumDesc = new string[]{
- "Quick add",
- "WarningSign1",
- "WarningSign2",
- "Attenuator",
- "1 Sand barrel Static",
- "1 Sand barrel Rigid",
- "3 Sand barrels Static",
- "3 Sand barrels Rigid",
- "7 Sand barrels Static",
- "7 Sand barrels Rigid"
- };
-
- public enum SMMDefaultsEnum
- {
- None, Custom,
- KRail,
- WBeamR,
- WBeamL,
- Railing1,
- Railing2,
- Railing3,
- Railing4,
- RailingBase05m,
- RailingBase1m
- };
- SMMDefaultsEnum tSMMQuickAdd = SMMDefaultsEnum.None;
-
- public enum BridgeTopBaseDefaultsEnum
- {
- None,
- BaseExact,
- Base1MOver,
- Base2MOver,
- Base3MDeep,
- };
- BridgeTopBaseDefaultsEnum tBridgeTopBaseQuickAdd = BridgeTopBaseDefaultsEnum.None;
-
- public enum BridgeBottomBaseDefaultsEnum
- {
- None,
- BridgeBase6,
- BridgeBase7,
- BridgeBase8,
- BridgeBaseGrid,
- BridgeSteel,
- BridgeBase2,
- BridgeBase3,
- BridgeBase4,
- BridgeBase5,
- };
- BridgeBottomBaseDefaultsEnum tBridgeBottomBaseQuickAdd = BridgeBottomBaseDefaultsEnum.None;
-
- public enum BridgeWizardDefaultsEnum
- {
- None,
- ArchBridge12m,
- ArchBridge24m,
- ArchBridge48m,
- SuspensionBridgeSmall,
- SuspensionBridgeLarge,
- CausewayBridge1,
- CausewayBridge2,
- CausewayBridge3,
- CausewayBridge4,
- ArchBridge1,
- ArchBridge2,
- ArchBridge3,
- GridBridge,
- SteelBeamBridge
- };
- // BridgeWizardDefaultsEnum tBridgeWizardQuickAdd = BridgeWizardDefaultsEnum.None;
-
-
- public enum HorizMatchingDefaultsEnum
- {
- None,
- MatchCenter,
- MatchRoadLeft,
- MatchShoulderLeft,
- MatchRoadRight,
- MatchShoulderRight
- };
- HorizMatchingDefaultsEnum tHorizMatching = HorizMatchingDefaultsEnum.None;
-
- public enum EOMDefaultsEnum { None, Custom, StreetLightSingle, StreetLightDouble };
-
- //GSD.Roads.Splination.CollisionTypeEnum tCollisionTypeSpline = GSD.Roads.Splination.CollisionTypeEnum.SimpleMeshTriangle;
- //GSD.Roads.Splination.RepeatUVTypeEnum tRepeatUVType = GSD.Roads.Splination.RepeatUVTypeEnum.None;
- GSD.Roads.EdgeObjects.EdgeObjectMaker EOM = null;
-
- private static string[] TheAxisDescriptions_Spline = new string[]{
- "X axis",
- "Z axis"
- };
-
- private static string[] RepeatUVTypeDescriptions_Spline = new string[]{
- "None",
- "X axis",
- "Y axis"
- };
-
- private static string[] TheCollisionTypeEnumDescSpline = new string[]{
- "None",
- "Simple triangle",
- "Simple trapezoid",
- "Meshfilter collision mesh",
- "Straight line box collider"
- };
-
- private string[] HorizMatchSubTypeDescriptions;
- #endregion
-
- GUIStyle GSDImageButton = null;
- GUIStyle GSDLoadButton = null;
- GUIStyle GSDManualButton = null;
- GUIStyle GSDUrl = null;
-
- bool bSceneRectSet = false;
- Rect tSceneRect = default(Rect);
- bool bHasInit = false;
-
- //Buffers:
- // bool t_opt_GizmosEnabled = false;
- bool t_opt_GizmosEnabled = false;
- bool t_bIsBridgeStart = false;
- bool t_bIsBridgeEnd = false;
- bool t_bRoadCut = false;
-
- void Init()
- {
- bHasInit = true;
- EditorStyles.label.wordWrap = true;
- EditorStyles.miniLabel.wordWrap = true;
-
- if (btnDeleteText == null)
- {
- btnDeleteText = (Texture)AssetDatabase.LoadAssetAtPath(GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Editor/Icons/delete.png", typeof(Texture)) as Texture;
- }
- if (btnCopyText == null)
- {
- btnCopyText = (Texture)AssetDatabase.LoadAssetAtPath(GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Editor/Icons/copy.png", typeof(Texture)) as Texture;
- }
- if (btnLoadText == null)
- {
- btnLoadText = (Texture)AssetDatabase.LoadAssetAtPath(GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Editor/Icons/load.png", typeof(Texture)) as Texture;
- }
- if (btnSaveText == null)
- {
- btnSaveText = (Texture)AssetDatabase.LoadAssetAtPath(GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Editor/Icons/save.png", typeof(Texture)) as Texture;
- }
- if (btnExtrudeText == null)
- {
- btnExtrudeText = (Texture)AssetDatabase.LoadAssetAtPath(GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Editor/Icons/extrude.png", typeof(Texture)) as Texture;
- }
- if (btnEdgeText == null)
- {
- btnEdgeText = (Texture)AssetDatabase.LoadAssetAtPath(GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Editor/Icons/edge.png", typeof(Texture)) as Texture;
- }
- if (btnHelpText == null)
- {
- btnHelpText = (Texture)AssetDatabase.LoadAssetAtPath(GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Editor/Icons/help.png", typeof(Texture)) as Texture;
- }
- if (GSDTextAreaBG == null)
- {
- GSDTextAreaBG = (Texture2D)AssetDatabase.LoadAssetAtPath(GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Editor/Icons/popupbg.png", typeof(Texture2D)) as Texture2D;
- }
- if (LoadBtnBG == null)
- {
- LoadBtnBG = (Texture2D)AssetDatabase.LoadAssetAtPath(GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Editor/Icons/loadbg.png", typeof(Texture2D)) as Texture2D;
- }
- if (LoadBtnBGGlow == null)
- {
- LoadBtnBGGlow = (Texture2D)AssetDatabase.LoadAssetAtPath(GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Editor/Icons/loadbgglow.png", typeof(Texture2D)) as Texture2D;
- }
- if (ManualBG == null)
- {
- ManualBG = (Texture2D)AssetDatabase.LoadAssetAtPath(GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Editor/Icons/manualbg.png", typeof(Texture2D)) as Texture2D;
- }
- if (btnRefreshText == null)
- {
- btnRefreshText = (Texture)AssetDatabase.LoadAssetAtPath(GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Editor/Icons/refresh.png", typeof(Texture)) as Texture;
- }
- if (btnDefaultText == null)
- {
- btnDefaultText = (Texture)AssetDatabase.LoadAssetAtPath(GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Editor/Icons/refresh2.png", typeof(Texture)) as Texture;
- }
-
- if (GSDImageButton == null)
- {
- GSDImageButton = new GUIStyle(GUI.skin.button);
- GSDImageButton.contentOffset = new Vector2(0f, -2f);
- GSDImageButton.border = new RectOffset(0, 0, 0, 0);
- GSDImageButton.fixedHeight = 16f;
- GSDImageButton.padding = new RectOffset(0, 0, 0, 0);
- GSDImageButton.normal.background = null;
- }
-
- if (GSDLoadButton == null)
- {
- GSDLoadButton = new GUIStyle(GUI.skin.button);
- GSDLoadButton.contentOffset = new Vector2(0f, 1f);
- GSDLoadButton.normal.textColor = new Color(1f, 1f, 1f, 1f);
- GSDLoadButton.normal.background = LoadBtnBG;
- GSDLoadButton.active.background = LoadBtnBGGlow;
- GSDLoadButton.focused.background = LoadBtnBGGlow;
- GSDLoadButton.hover.background = LoadBtnBGGlow;
- GSDLoadButton.fixedHeight = 16f;
- GSDLoadButton.fixedWidth = 128f;
- GSDLoadButton.padding = new RectOffset(0, 35, 0, 0);
- }
-
- if (GSDManualButton == null)
- {
- GSDManualButton = new GUIStyle(GUI.skin.button);
- GSDManualButton.contentOffset = new Vector2(0f, 1f);
- GSDManualButton.normal.textColor = new Color(1f, 1f, 1f, 1f);
- GSDManualButton.normal.background = ManualBG;
- GSDManualButton.fixedHeight = 16f;
- GSDManualButton.fixedWidth = 128f;
- }
-
- if (GSDUrl == null)
- {
- GSDUrl = new GUIStyle(GUI.skin.button);
- GSDUrl.normal.textColor = new Color(0.5f, 1f, 0.5f, 1f);
- }
-
- float tRoadWidthHalf = tNode.GSDSpline.tRoad.RoadWidth() * 0.5f;
- HorizMatchSubTypeDescriptions = new string[6];
- HorizMatchSubTypeDescriptions[0] = "Select preset";
- HorizMatchSubTypeDescriptions[1] = "Match center: 0 meters";
- HorizMatchSubTypeDescriptions[2] = "Match road left edge: -" + tRoadWidthHalf.ToString("F1") + " meters";
- HorizMatchSubTypeDescriptions[4] = "Match road right edge: " + tRoadWidthHalf.ToString("F1") + " meters";
-
- if (tNode.GSDSpline.tRoad.opt_bShouldersEnabled)
- {
- HorizMatchSubTypeDescriptions[3] = "Match shoulder left edge: -" + (tRoadWidthHalf + tNode.GSDSpline.tRoad.opt_ShoulderWidth).ToString("F1") + " meters";
- HorizMatchSubTypeDescriptions[5] = "Match shoulder right edge: " + (tRoadWidthHalf + tNode.GSDSpline.tRoad.opt_ShoulderWidth).ToString("F1") + " meters";
- }
- else
- {
- HorizMatchSubTypeDescriptions[2] = "Match shoulder left edge: -" + tRoadWidthHalf.ToString("F1") + " meters";
- HorizMatchSubTypeDescriptions[4] = "Match shoulder right edge: " + tRoadWidthHalf.ToString("F1") + " meters";
- }
-
- HorizRoadMax = tNode.GSDSpline.tRoad.RoadWidth() * 20;
- }
-
- GSDSplineN iNode1 = null;
- GSDSplineN iNode2 = null;
- bool bCreateIntersection = false;
- public override void OnInspectorGUI()
- {
- if (Event.current.type == EventType.ValidateCommand)
- {
- switch (Event.current.commandName)
- {
- case "UndoRedoPerformed":
- UpdateSplineObjects_OnUndo();
- break;
- }
- }
-
- if (Event.current.type != EventType.Layout && bCreateIntersection)
- {
- bCreateIntersection = false;
- Selection.activeGameObject = GSD.Roads.GSDIntersections.CreateIntersection(iNode1, iNode2);
- return;
- }
-
-
- if (Event.current.type != EventType.Layout && tNode.bQuitGUI)
- {
- tNode.bQuitGUI = false;
- return;
- }
-
- //Graphic null checks:
- if (!bHasInit) { Init(); }
-
- Line();
-
- EditorGUILayout.BeginHorizontal();
- EditorGUILayout.LabelField(tNode.EditorDisplayString, EditorStyles.boldLabel);
-
- if (GUILayout.Button("Online manual", EditorStyles.miniButton, GUILayout.Width(128f)))
- {
- Application.OpenURL("http://microgsd.com/Support/RoadArchitectManual.aspx");
- }
- EditorGUILayout.EndHorizontal();
-
- //Option: Gizmo options, Convoluted due to submission compliance for undo rules:
- if (tNode.GSDSpline.tRoad.opt_GizmosEnabled != tNode.opt_GizmosEnabled)
- {
- tNode.GSDSpline.tRoad.opt_GizmosEnabled = tNode.opt_GizmosEnabled;
- tNode.GSDSpline.tRoad.UpdateGizmoOptions();
- tNode.GSDSpline.tRoad.Wireframes_Toggle();
- }
- t_opt_GizmosEnabled = EditorGUILayout.Toggle("Gizmos: ", tNode.GSDSpline.tRoad.opt_GizmosEnabled);
-
- //Option: Manual road cut:
- if (tNode.idOnSpline > 0 && tNode.idOnSpline < (tNode.GSDSpline.GetNodeCount() - 1) && !tNode.bIsIntersection && !tNode.bSpecialEndNode)
- { // && !cNode.bIsBridge_PreNode && !cNode.bIsBridge_PostNode){
- if (tNode.GSDSpline.tRoad.opt_bDynamicCuts)
- {
- Line();
- t_bRoadCut = EditorGUILayout.Toggle("Cut road at this node: ", tNode.bRoadCut);
- }
- Line();
- }
-
- //Option: Bridge options
- bool bDidBridge = false;
- if (!tNode.bIsEndPoint)
- {
- //Bridge start:
- if (!tNode.bIsBridgeEnd && tNode.CanBridgeStart())
- {
- t_bIsBridgeStart = EditorGUILayout.Toggle(" Bridge start", tNode.bIsBridgeStart);
- bDidBridge = true;
- }
- //Bridge end:
- if (!tNode.bIsBridgeStart && tNode.CanBridgeEnd())
- {
- t_bIsBridgeEnd = EditorGUILayout.Toggle(" Bridge end", tNode.bIsBridgeEnd);
- bDidBridge = true;
- }
-
- if (bDidBridge)
- {
- Line();
- }
- }
-
- if ((Selection.objects.Length == 1 && Selection.objects[0] is GSDSplineN) || (tNode.SpecialNodeCounterpart == null && !tNode.bSpecialRoadConnPrimary))
- {
- //Do extrusion and edge objects overview:
- DoExtAndEdgeOverview();
- }
- else
- {
- EditorGUILayout.BeginHorizontal();
- if (GUILayout.Button("Road objects"))
- {
- Selection.objects = new Object[1] { tNode.SpecialNodeCounterpart };
- }
- EditorGUILayout.EndHorizontal();
- }
-
- if (tNode.bSpecialRoadConnPrimary)
- {
- EditorGUILayout.BeginHorizontal();
- EditorGUILayout.LabelField("Road connection:", EditorStyles.boldLabel);
- EditorGUILayout.EndHorizontal();
- EditorGUILayout.BeginVertical();
- if (GUILayout.Button("Update road connection"))
- {
- GSDSplineN tNode1 = tNode.OriginalConnectionNodes[0];
- GSDSplineN tNode2 = tNode.OriginalConnectionNodes[1];
- tNode.SpecialNodeCounterpart.BreakConnection();
- tNode.GSDSpline.tRoad.UpdateRoad();
- tNode1.GSDSpline.ActivateEndNodeConnection(tNode1, tNode2);
- }
- if (GUILayout.Button("Break road connection"))
- {
- tNode.SpecialNodeCounterpart.BreakConnection();
- }
- if (GUILayout.Button("Access objects on other node"))
- {
- Selection.objects = new Object[] { tNode.SpecialNodeCounterpart };
- }
- EditorGUILayout.EndVertical();
- if (tNode.SpecialNodeCounterpart != null)
- {
- EditorGUILayout.LabelField(tNode.SpecialNodeCounterpart.GSDSpline.tRoad.transform.name + " to " + tNode.SpecialNodeCounterpart.SpecialNodeCounterpart.GSDSpline.tRoad.transform.name);
- }
- EditorGUILayout.LabelField("To break this road connection, click the \"Break road connection\" button.");
- Line();
- }
-
- //Statistics:
- DoStats();
- EditorGUILayout.EndVertical();
-
- if (GUI.changed)
- {
- //Set snapshot for undo:
-
- Undo.RecordObject(tNode, "Modify node");
-
- //Option: Gizmo options, Convoluted due to submission compliance for undo rules:
- if (t_opt_GizmosEnabled != tNode.GSDSpline.tRoad.opt_GizmosEnabled)
- {
- tNode.GSDSpline.tRoad.opt_GizmosEnabled = t_opt_GizmosEnabled;
- tNode.GSDSpline.tRoad.UpdateGizmoOptions();
- tNode.GSDSpline.tRoad.Wireframes_Toggle();
- SceneView.RepaintAll();
- }
-
- //Option: Manual cut:
- if (tNode.idOnSpline > 0 && tNode.idOnSpline < (tNode.GSDSpline.GetNodeCount() - 1) && !tNode.bIsIntersection && !tNode.bSpecialEndNode)
- { // && !cNode.bIsBridge_PreNode && !cNode.bIsBridge_PostNode){
- if (tNode.GSDSpline.tRoad.opt_bDynamicCuts)
- {
- if (t_bRoadCut != tNode.bRoadCut)
- {
- tNode.bRoadCut = t_bRoadCut;
- }
- }
- }
-
- //Option: Bridge options
- //Bridge start:
- if (!tNode.bIsEndPoint)
- {
- if (!tNode.bIsBridgeEnd && tNode.CanBridgeStart())
- {
- if (t_bIsBridgeStart != tNode.bIsBridgeStart)
- {
- tNode.bIsBridgeStart = t_bIsBridgeStart;
- tNode.BridgeToggleStart();
- }
- }
- }
- //Bridge end:
- if (!tNode.bIsEndPoint)
- {
- if (!tNode.bIsBridgeStart && tNode.CanBridgeEnd())
- {
- if (t_bIsBridgeEnd != tNode.bIsBridgeEnd)
- {
- tNode.bIsBridgeEnd = t_bIsBridgeEnd;
- tNode.BridgeToggleEnd();
- }
- }
- }
-
- UpdateSplineObjects();
- UpdateEdgeObjects();
-
- EditorUtility.SetDirty(target);
- }
- }
-
- void OnSelectionChanged()
- {
- Repaint();
- }
-
- //GUIStyle SectionBG;
-
- void DoExtAndEdgeOverview()
- {
- EditorGUILayout.BeginHorizontal();
- EditorGUILayout.LabelField("Extrusion & edge objects", EditorStyles.boldLabel);
- EditorGUILayout.LabelField("");
- EditorGUILayout.EndHorizontal();
-
- EditorGUILayout.BeginHorizontal();
- if (bEdgeObjectHelp)
- {
- bEdgeObjectHelp = EditorGUILayout.Foldout(bEdgeObjectHelp, "Hide quick help");
- }
- else
- {
- bEdgeObjectHelp = EditorGUILayout.Foldout(bEdgeObjectHelp, "Show quick help");
- }
- EditorGUILayout.LabelField("");
-
- if (GUILayout.Button("Save group", EditorStyles.miniButton, GUILayout.Width(108f)) || GUILayout.Button(btnSaveText, GSDImageButton, GUILayout.Width(16f)))
- {
- GSDSaveWindow tSave = EditorWindow.GetWindow();
- if (tNode.bIsBridge)
- {
- tSave.Initialize(ref tSceneRect, GSDSaveWindow.WindowTypeEnum.BridgeWizard, tNode);
- }
- else
- {
- tSave.Initialize(ref tSceneRect, GSDSaveWindow.WindowTypeEnum.BridgeWizard, tNode);
- }
- }
- EditorGUILayout.EndHorizontal();
- GUILayout.Space(4f);
-
- EditorGUILayout.BeginHorizontal();
- EditorGUILayout.LabelField("");
- if (GUILayout.Button("Open Wizard", GSDLoadButton, GUILayout.Width(128f)))
- {// || GUILayout.Button(btnLoadText,GSDImageButton,GUILayout.Width(16f))){
- GSDWizard tWiz = EditorWindow.GetWindow();
- if (tSceneRect.x < 0) { tSceneRect.x = 0f; }
- if (tSceneRect.y < 0) { tSceneRect.y = 0f; }
- tWiz.xRect = tSceneRect;
- if (tNode.bIsBridgeStart)
- {
- tWiz.Initialize(GSDWizard.WindowTypeEnum.BridgeComplete, tNode);
- }
- else
- {
- tWiz.Initialize(GSDWizard.WindowTypeEnum.Extrusion, tNode);
- }
- }
- EditorGUILayout.EndHorizontal();
- GUILayout.Space(4f);
-
- if (bEdgeObjectHelp)
- {
- EditorGUILayout.BeginVertical("box");
- EditorGUILayout.BeginHorizontal();
- if (GUILayout.Button(btnExtrudeText, GSDImageButton, GUILayout.Width(32f))) { }
- EditorGUILayout.LabelField("= Extrusion objects", EditorStyles.miniLabel);
- EditorGUILayout.LabelField("");
- EditorGUILayout.EndHorizontal();
- EditorGUILayout.LabelField("Railings, bridge pieces, center dividers and other connected objects.", EditorStyles.miniLabel);
- EditorGUILayout.EndVertical();
-
- EditorGUILayout.BeginVertical("box");
- EditorGUILayout.BeginHorizontal();
- if (GUILayout.Button(btnEdgeText, GSDImageButton, GUILayout.Width(32f))) { }
- EditorGUILayout.LabelField("= Edge objects", EditorStyles.miniLabel);
- EditorGUILayout.LabelField("");
- EditorGUILayout.EndHorizontal();
- EditorGUILayout.LabelField("Signs, street lights, bridge pillars and other unconnected road objects.", EditorStyles.miniLabel);
- EditorGUILayout.EndVertical();
-
- EditorGUILayout.BeginVertical("box");
- EditorGUILayout.BeginHorizontal();
- if (GUILayout.Button(btnSaveText, GSDImageButton, GUILayout.Width(16f))) { }
- EditorGUILayout.LabelField("= Saves object config to library for use on other nodes.", EditorStyles.miniLabel);
- EditorGUILayout.EndHorizontal();
- EditorGUILayout.EndVertical();
-
- EditorGUILayout.BeginVertical("box");
- EditorGUILayout.BeginHorizontal();
- if (GUILayout.Button(btnCopyText, GSDImageButton, GUILayout.Width(16f))) { }
- EditorGUILayout.LabelField("= Duplicates object onto current node.", EditorStyles.miniLabel);
- EditorGUILayout.EndHorizontal();
- EditorGUILayout.EndVertical();
-
- EditorGUILayout.BeginVertical("box");
- EditorGUILayout.BeginHorizontal();
- if (GUILayout.Button(btnDeleteText, GSDImageButton, GUILayout.Width(16f))) { }
- EditorGUILayout.LabelField("= Deletes object.", EditorStyles.miniLabel);
- EditorGUILayout.EndHorizontal();
- EditorGUILayout.EndVertical();
-
- EditorGUILayout.BeginVertical("box");
- EditorGUILayout.BeginHorizontal();
- if (GUILayout.Button(btnRefreshText, GSDImageButton, GUILayout.Width(16f))) { }
- EditorGUILayout.LabelField("= Refreshes object.", EditorStyles.miniLabel);
- EditorGUILayout.EndHorizontal();
- EditorGUILayout.EndVertical();
-
- EditorGUILayout.BeginVertical("box");
- EditorGUILayout.BeginHorizontal();
- if (GUILayout.Button(btnDefaultText, GSDImageButton, GUILayout.Width(16f))) { }
- EditorGUILayout.LabelField("= Resets setting(s) to default.", EditorStyles.miniLabel);
- EditorGUILayout.EndHorizontal();
- EditorGUILayout.EndVertical();
-
- Line();
- }
- currentCount = 0;
-
- GUILayout.Space(2f);
-
-
- //Splinated objects:
- DoSplineObjects();
-
- //Edge Objects:
- DoEdgeObjects();
-
- GUILayout.Space(4f);
- EditorGUILayout.BeginHorizontal();
- EditorGUILayout.LabelField("");
- if (GUILayout.Button("Add custom extrusion object", EditorStyles.miniButton))
- {
- tNode.AddSplinatedObject();
- }
- EditorGUILayout.EndHorizontal();
- GUILayout.Space(4f);
- EditorGUILayout.BeginHorizontal();
- EditorGUILayout.LabelField("");
- if (GUILayout.Button("Add custom edge object", EditorStyles.miniButton))
- {
- tNode.AddEdgeObject();
- }
- EditorGUILayout.EndHorizontal();
-
- if (tNode.SplinatedObjects.Count > 20 || tNode.EdgeObjects.Count > 20)
- {
- EditorGUILayout.BeginHorizontal();
- EditorGUILayout.LabelField("");
- bRemoveAll = EditorGUILayout.Toggle(bRemoveAll, GUILayout.Width(20f));
- if (GUILayout.Button("Remove all", EditorStyles.miniButton, GUILayout.Width(100f)))
- {
- if (bRemoveAll)
- {
- tNode.RemoveAllSplinatedObjects();
- tNode.RemoveAllEdgeObjects();
- bRemoveAll = false;
- }
- }
-
- EditorGUILayout.EndHorizontal();
- }
- Line();
- }
-
- void DoStats()
- {
- EditorGUILayout.LabelField("Statistics:");
- EditorGUILayout.BeginVertical("box");
- EditorGUILayout.LabelField("Grade to next node: " + tNode.GradeToNext);
- EditorGUILayout.LabelField("Grade to prev node: " + tNode.GradeToPrev);
- EditorGUILayout.LabelField("Distance from start: " + tNode.tDist.ToString("F3") + " meters");
- EditorGUILayout.LabelField("% of spline: " + ((tNode.tDist / tNode.GSDSpline.distance) * 100f).ToString("F2") + "%");
- EditorGUILayout.LabelField("Parameter: " + tNode.tTime);
- EditorGUILayout.LabelField("Tangent: " + tNode.tangent);
- EditorGUILayout.LabelField("POS: " + tNode.pos);
- EditorGUILayout.LabelField("ID on spline: " + tNode.idOnSpline);
- EditorGUILayout.LabelField("Is intersection node: " + tNode.bIsIntersection);
- EditorGUILayout.LabelField("Is end node: " + tNode.bIsEndPoint);
- EditorGUILayout.LabelField("Is bridge start: " + tNode.bIsBridgeStart);
- EditorGUILayout.LabelField("Is bridge end: " + tNode.bIsBridgeEnd);
- EditorGUILayout.LabelField("Road: " + tNode.GSDSpline.tRoad.transform.name);
- EditorGUILayout.LabelField("System: " + tNode.GSDSpline.tRoad.GSDRS.transform.name);
- EditorGUILayout.SelectableLabel("UID: " + tNode.UID);
- }
-
- public void DoSplineObjects()
- {
- if (!tNode.CanSplinate()) { return; }
- if (tNode.SplinatedObjects == null) { tNode.SplinatedObjects = new List(); }
- eCount = tNode.SplinatedObjects.Count;
-
- SMM = null;
- eCount = tNode.SplinatedObjects.Count;
- if (eCount == 0) { }
-
- for (int i = 0; i < tNode.SplinatedObjects.Count; i++)
- {
- currentCount += 1;
- SMM = tNode.SplinatedObjects[i];
- if (SMM.EM == null)
- {
- SMM.EM = new GSD.Roads.Splination.SplinatedMeshMaker.SplinatedMeshEditorMaker();
- }
- SMM.EM.Setup(SMM);
-
- //GSD.Roads.Splination.AxisTypeEnum tAxisTypeSpline = GSD.Roads.Splination.AxisTypeEnum.Z;
-
- EditorGUILayout.BeginVertical("TextArea");
-
- if (SMM.bNeedsUpdate) { SMM.Setup(true); }
-
-
- EditorGUILayout.BeginHorizontal();
-
- SMM.bToggle = EditorGUILayout.Foldout(SMM.bToggle, "#" + currentCount.ToString() + ": " + SMM.tName);
-
- if (GUILayout.Button(btnExtrudeText, GSDImageButton, GUILayout.Width(32f)))
- {
-
- }
-
- if (GUILayout.Button(btnRefreshText, GSDImageButton, GUILayout.Width(16f)))
- {
- SMM.Setup();
- }
- if (GUILayout.Button(btnSaveText, GSDImageButton, GUILayout.Width(16f)))
- {
- GSDSaveWindow tSave = EditorWindow.GetWindow();
- tSave.Initialize(ref tSceneRect, GSDSaveWindow.WindowTypeEnum.Extrusion, tNode, SMM);
- }
- if (GUILayout.Button(btnCopyText, GSDImageButton, GUILayout.Width(16f)))
- {
- Undo.RecordObject(tNode, "Copy");
- tNode.CopySplinatedObject(ref SMM);
- EditorUtility.SetDirty(tNode);
- }
- if (GUILayout.Button(btnDeleteText, GSDImageButton, GUILayout.Width(16f)))
- {
- Undo.RecordObject(tNode, "Delete");
- tNode.RemoveSplinatedObject(i);
- EditorUtility.SetDirty(tNode);
- }
- EditorGUILayout.EndHorizontal();
- if (!SMM.bToggle) { EditorGUILayout.EndVertical(); continue; }
-
- GUILayout.Space(8f);
- EditorGUILayout.BeginHorizontal();
- EditorGUILayout.LabelField("General options:");
- if (GUILayout.Button("Online manual", EditorStyles.miniButton, GUILayout.Width(120f)))
- {
- Application.OpenURL("http://microgsd.com/Support/RoadArchitectManual.aspx");
- }
- EditorGUILayout.EndHorizontal();
-
- EditorGUILayout.BeginVertical("box");
-
- //Name:
- SMM.EM.tName = EditorGUILayout.TextField("Name:", SMM.tName);
-
- //Game object (prefab):
- SMM.EM.CurrentSplination = (GameObject)EditorGUILayout.ObjectField("Prefab:", SMM.CurrentSplination, typeof(GameObject), false);
-
- //Game object (prefab start cap):
- SMM.EM.CurrentSplinationCap1 = (GameObject)EditorGUILayout.ObjectField("Prefab start cap:", SMM.CurrentSplinationCap1, typeof(GameObject), false);
- //Prefab start cap height offset:
- if (SMM.CurrentSplinationCap1 != null)
- {
- SMM.EM.CapHeightOffset1 = EditorGUILayout.FloatField(" Height offset:", SMM.CapHeightOffset1);
- }
-
- //Game object (prefab end cap):
- SMM.EM.CurrentSplinationCap2 = (GameObject)EditorGUILayout.ObjectField("Prefab end cap:", SMM.CurrentSplinationCap2, typeof(GameObject), false);
- //Prefab end cap height offset:
- if (SMM.CurrentSplinationCap2 != null)
- {
- SMM.EM.CapHeightOffset2 = EditorGUILayout.FloatField(" Height offset:", SMM.CapHeightOffset2);
- }
-
- //Material overrides:
- SMM.EM.bMaterialOverride = EditorGUILayout.Toggle("Material override: ", SMM.bMaterialOverride);
- if (SMM.bMaterialOverride)
- {
- SMM.EM.SplinatedMaterial1 = (Material)EditorGUILayout.ObjectField("Override mat #1: ", SMM.SplinatedMaterial1, typeof(Material), false);
- SMM.EM.SplinatedMaterial2 = (Material)EditorGUILayout.ObjectField("Override mat #2: ", SMM.SplinatedMaterial2, typeof(Material), false);
- }
-
- //Axis:
- SMM.EM.Axis = (GSD.Roads.Splination.AxisTypeEnum)EditorGUILayout.Popup("Extrusion axis: ", (int)SMM.Axis, TheAxisDescriptions_Spline, GUILayout.Width(250f));
-
- //Start time:
- if (SMM.StartTime < tNode.MinSplination) { SMM.StartTime = tNode.MinSplination; }
- if (SMM.EndTime > tNode.MaxSplination) { SMM.EndTime = tNode.MaxSplination; }
- EditorGUILayout.BeginHorizontal();
- SMM.EM.StartTime = EditorGUILayout.Slider("Start param: ", SMM.StartTime, tNode.MinSplination, tNode.MaxSplination - 0.01f);
- if (GUILayout.Button("match node", EditorStyles.miniButton, GUILayout.Width(80f)))
- {
- SMM.EM.StartTime = tNode.tTime;
- }
- if (SMM.EM.StartTime >= SMM.EM.EndTime) { SMM.EM.EndTime = (SMM.EM.StartTime + 0.01f); }
- EditorGUILayout.EndHorizontal();
-
- //End time:
- EditorGUILayout.BeginHorizontal();
- SMM.EM.EndTime = EditorGUILayout.Slider("End param: ", SMM.EndTime, SMM.StartTime, tNode.MaxSplination);
- if (GUILayout.Button("match next", EditorStyles.miniButton, GUILayout.Width(80f)))
- {
- SMM.EM.EndTime = tNode.NextTime;
- }
- if (SMM.EM.StartTime >= SMM.EM.EndTime) { SMM.EM.EndTime = (SMM.EM.StartTime + 0.01f); }
- EditorGUILayout.EndHorizontal();
-
- //Straight line options:
- if (tNode.IsStraight())
- {
- if (!SMM.bIsStretch)
- {
- SMM.EM.bIsStretch = EditorGUILayout.Toggle("Straight line stretch:", SMM.bIsStretch);
- }
- else
- {
- EditorGUILayout.BeginVertical("box");
- SMM.EM.bIsStretch = EditorGUILayout.Toggle("Straight line stretch:", SMM.bIsStretch);
-
- //Stretch_UVThreshold:
- SMM.EM.Stretch_UVThreshold = EditorGUILayout.Slider("UV stretch threshold:", SMM.Stretch_UVThreshold, 0.01f, 0.5f);
-
- //UV repeats:
- SMM.EM.RepeatUVType = (GSD.Roads.Splination.RepeatUVTypeEnum)EditorGUILayout.Popup("UV stretch axis: ", (int)SMM.RepeatUVType, RepeatUVTypeDescriptions_Spline, GUILayout.Width(250f));
- EditorGUILayout.EndVertical();
- }
- }
- else
- {
- SMM.EM.bIsStretch = false;
- }
-
-
- SMM.EM.bTrimStart = EditorGUILayout.Toggle("Trim start:", SMM.bTrimStart);
- SMM.EM.bTrimEnd = EditorGUILayout.Toggle("Trim end:", SMM.bTrimEnd);
-
- //Static option:
- SMM.EM.bStatic = EditorGUILayout.Toggle("Static: ", SMM.bStatic);
-
- //Splination method
- // SMM.EM.bMatchRoadIncrements = EditorGUILayout.Toggle("Match road increments: ",SMM.bMatchRoadIncrements);
- SMM.EM.bMatchTerrain = EditorGUILayout.Toggle("Match ground: ", SMM.bMatchTerrain);
-
- //Vector min/max threshold:
- EditorGUILayout.BeginHorizontal();
- SMM.EM.MinMaxMod = EditorGUILayout.Slider("Vertex min/max threshold: ", SMM.MinMaxMod, 0.01f, 0.2f);
- if (GUILayout.Button(btnDefaultText, GSDImageButton, GUILayout.Width(16f)))
- {
- SMM.EM.MinMaxMod = 0.05f;
- }
- EditorGUILayout.EndHorizontal();
-
- //Vertex matching precision:
- EditorGUILayout.BeginHorizontal();
- SMM.EM.VertexMatchingPrecision = EditorGUILayout.Slider("Vertex matching precision: ", SMM.VertexMatchingPrecision, 0f, 0.01f);
- if (GUILayout.Button(btnDefaultText, GSDImageButton, GUILayout.Width(16f)))
- {
- SMM.EM.VertexMatchingPrecision = 0.005f;
- }
- EditorGUILayout.EndHorizontal();
-
- //UV repeats:
- if (!SMM.bIsStretch)
- {
- SMM.EM.RepeatUVType = (GSD.Roads.Splination.RepeatUVTypeEnum)EditorGUILayout.Popup("UV repeat axis: ", (int)SMM.RepeatUVType, RepeatUVTypeDescriptions_Spline, GUILayout.Width(250f));
- }
-
- if (SMM.bMatchRoadDefinition)
- {
- EditorGUILayout.BeginVertical("TextArea");
- EditorGUILayout.BeginHorizontal();
- SMM.EM.bMatchRoadDefinition = EditorGUILayout.Toggle("Match road definition: ", SMM.bMatchRoadDefinition);
- if (GUILayout.Button(btnDefaultText, GSDImageButton, GUILayout.Width(16f)))
- {
- SMM.EM.bMatchRoadDefinition = false;
- }
- EditorGUILayout.EndHorizontal();
- if (SMM.bMatchRoadDefinition)
- {
- EditorGUILayout.LabelField(" Only use this option if object length doesn't match the road definition.", EditorStyles.miniLabel);
- EditorGUILayout.LabelField(" Matching road definition requires a UV repeat type.", EditorStyles.miniLabel);
- EditorGUILayout.LabelField(" If the material fails to scale properly, try flipping the Y rotation.", EditorStyles.miniLabel);
- }
- //Flip rotation option:
- SMM.EM.bFlipRotation = EditorGUILayout.Toggle(" Flip Y rotation: ", SMM.bFlipRotation);
- EditorGUILayout.EndVertical();
- }
- else
- {
- EditorGUILayout.BeginHorizontal();
- SMM.EM.bMatchRoadDefinition = EditorGUILayout.Toggle("Match road definition: ", SMM.bMatchRoadDefinition);
- if (GUILayout.Button(btnDefaultText, GSDImageButton, GUILayout.Width(16f)))
- {
- SMM.EM.bMatchRoadDefinition = false;
- }
- EditorGUILayout.EndHorizontal();
- }
- EditorGUILayout.EndVertical();
-
- //Vertical offset:
- EditorGUILayout.LabelField("Vertical options:");
- EditorGUILayout.BeginVertical("box");
- EditorGUILayout.BeginHorizontal();
- SMM.EM.VerticalRaise = EditorGUILayout.Slider("Vertical raise magnitude:", SMM.VerticalRaise, -512f, 512f);
- if (GUILayout.Button(btnDefaultText, GSDImageButton, GUILayout.Width(16f)))
- {
- SMM.EM.VerticalRaise = 0f;
- }
- EditorGUILayout.EndHorizontal();
-
- //Vertical curve:
- if (SMM.VerticalCurve == null || SMM.VerticalCurve.keys.Length < 2) { EnforceCurve(ref SMM.VerticalCurve); }
- EditorGUILayout.BeginHorizontal();
- SMM.EM.VerticalCurve = EditorGUILayout.CurveField("Curve: ", SMM.VerticalCurve);
- if (GUILayout.Button(btnDefaultText, GSDImageButton, GUILayout.Width(16f)))
- {
- ResetCurve(ref SMM.EM.VerticalCurve);
- }
- EditorGUILayout.EndHorizontal();
- EditorGUILayout.EndVertical();
-
- //Horizontal offsets:
- SMM.EM.HorizontalSep = SMM.HorizontalSep;
- EditorGUILayout.LabelField("Horizontal offset options:");
- EditorGUILayout.BeginVertical("box");
- tHorizMatching = HorizMatchingDefaultsEnum.None;
- tHorizMatching = (HorizMatchingDefaultsEnum)EditorGUILayout.Popup((int)tHorizMatching, HorizMatchSubTypeDescriptions, GUILayout.Width(100f));
- if (tHorizMatching != HorizMatchingDefaultsEnum.None)
- {
- if (tHorizMatching == HorizMatchingDefaultsEnum.MatchCenter)
- {
- SMM.EM.HorizontalSep = 0f;
- }
- else if (tHorizMatching == HorizMatchingDefaultsEnum.MatchRoadLeft)
- {
- SMM.EM.HorizontalSep = (tNode.GSDSpline.tRoad.RoadWidth() / 2) * -1;
- }
- else if (tHorizMatching == HorizMatchingDefaultsEnum.MatchShoulderLeft)
- {
- SMM.EM.HorizontalSep = ((tNode.GSDSpline.tRoad.RoadWidth() / 2) + tNode.GSDSpline.tRoad.opt_ShoulderWidth) * -1;
- }
- else if (tHorizMatching == HorizMatchingDefaultsEnum.MatchRoadRight)
- {
- SMM.EM.HorizontalSep = (tNode.GSDSpline.tRoad.RoadWidth() / 2);
- }
- else if (tHorizMatching == HorizMatchingDefaultsEnum.MatchShoulderRight)
- {
- SMM.EM.HorizontalSep = (tNode.GSDSpline.tRoad.RoadWidth() / 2) + tNode.GSDSpline.tRoad.opt_ShoulderWidth;
- }
- tHorizMatching = HorizMatchingDefaultsEnum.None;
- }
- EditorGUILayout.BeginHorizontal();
- SMM.EM.HorizontalSep = EditorGUILayout.Slider("Horiz offset magnitude:", SMM.EM.HorizontalSep, (-1f * HorizRoadMax), HorizRoadMax);
- if (GUILayout.Button(btnDefaultText, GSDImageButton, GUILayout.Width(16f)))
- {
- SMM.EM.HorizontalSep = 0f;
- }
- EditorGUILayout.EndHorizontal();
-
- //Horizontal curve:
- if (SMM.HorizontalCurve == null || SMM.HorizontalCurve.keys.Length < 2) { EnforceCurve(ref SMM.HorizontalCurve); }
-
- EditorGUILayout.BeginHorizontal();
- SMM.EM.HorizontalCurve = EditorGUILayout.CurveField("Curve: ", SMM.HorizontalCurve);
- if (GUILayout.Button(btnDefaultText, GSDImageButton, GUILayout.Width(16f)))
- {
- ResetCurve(ref SMM.EM.HorizontalCurve);
- }
- EditorGUILayout.EndHorizontal();
- EditorGUILayout.EndVertical();
-
- //Vertical cutoff:
- EditorGUILayout.LabelField("Vertical cutoff:");
- EditorGUILayout.BeginVertical("box");
- SMM.EM.bVerticalCutoff = EditorGUILayout.Toggle("Height cutoff enabled:", SMM.bVerticalCutoff);
- if (SMM.bVerticalCutoff)
- {
- SMM.EM.bVerticalCutoff_MatchZero = EditorGUILayout.Toggle("Match spline height:", SMM.bVerticalCutoff_MatchZero);
- SMM.EM.bVerticalCutoffDownwards = EditorGUILayout.Toggle("Cut direction toggle:", SMM.bVerticalCutoffDownwards);
- SMM.EM.VerticalCutoff = EditorGUILayout.Slider("Height cut offset: ", SMM.VerticalCutoff, -50f, 50f);
- SMM.EM.bVerticalMeshCutoff_OppositeDir = EditorGUILayout.Toggle("Opposite dir mesh cut:", SMM.bVerticalMeshCutoff_OppositeDir);
- SMM.EM.VerticalMeshCutoffOffset = EditorGUILayout.Slider("Mesh cut offset: ", SMM.VerticalMeshCutoffOffset, -5f, 5f);
- }
- EditorGUILayout.EndVertical();
-
- //End type:
- EditorGUILayout.LabelField("Extrusion ending options:");
- EditorGUILayout.BeginVertical("box");
- SMM.EM.bStartDown = EditorGUILayout.Toggle("Push start down:", SMM.bStartDown);
- SMM.EM.bEndDown = EditorGUILayout.Toggle("Push end down:", SMM.bEndDown);
- if (SMM.bStartDown)
- {
- SMM.EM.bStartTypeDownOverride = EditorGUILayout.Toggle("Override start down value: ", SMM.bStartTypeDownOverride);
- if (SMM.bStartTypeDownOverride)
- {
- SMM.EM.StartTypeDownOverride = EditorGUILayout.Slider("Downward movement: ", SMM.StartTypeDownOverride, -10f, 10f);
- }
- }
- if (SMM.bEndDown)
- {
- SMM.EM.bEndTypeDownOverride = EditorGUILayout.Toggle("Override end down value: ", SMM.bEndTypeDownOverride);
- if (SMM.bEndTypeDownOverride)
- {
- SMM.EM.EndTypeDownOverride = EditorGUILayout.Slider("Downward movement: ", SMM.EndTypeDownOverride, -10f, 10f);
- }
- }
- EditorGUILayout.EndVertical();
-
- //Start and end objects:
- EditorGUILayout.LabelField("Start & end objects:");
- EditorGUILayout.BeginVertical("box");
- //End cap custom match start:
- SMM.EM.bEndCapCustomMatchStart = EditorGUILayout.Toggle("Match objects to ends:", SMM.bEndCapCustomMatchStart);
-
- //End objects match ground:
- SMM.EM.bEndObjectsMatchGround = EditorGUILayout.Toggle("Force origins to ground:", SMM.bEndObjectsMatchGround);
-
- //Start cap:
- EditorGUILayout.BeginVertical("box");
- EditorGUILayout.BeginHorizontal();
- EditorGUILayout.LabelField("Start object:");
- tEndObjectAdd = (EndObjectsDefaultsEnum)EditorGUILayout.Popup((int)tEndObjectAdd, EndObjectsDefaultsEnumDesc);
- if (tEndObjectAdd != EndObjectsDefaultsEnum.None)
- {
- SMM.EM.EndCapStart = GetEndObjectQuickAdd();
- tEndObjectAdd = EndObjectsDefaultsEnum.None;
- }
- EditorGUILayout.EndHorizontal();
-
-
- SMM.EM.EndCapStart = (GameObject)EditorGUILayout.ObjectField("Prefab:", SMM.EndCapStart, typeof(GameObject), false);
- if (SMM.EndCapStart != null)
- {
- SMM.EM.EndCapCustomOffsetStart = EditorGUILayout.Vector3Field("Position offset:", SMM.EndCapCustomOffsetStart);
- SMM.EM.EndCapCustomRotOffsetStart = EditorGUILayout.Vector3Field("Rotation offset:", SMM.EndCapCustomRotOffsetStart);
- }
- EditorGUILayout.EndVertical();
-
- //End cap:
- EditorGUILayout.BeginVertical("box");
- EditorGUILayout.BeginHorizontal();
- EditorGUILayout.LabelField("End object:");
- tEndObjectAdd = (EndObjectsDefaultsEnum)EditorGUILayout.Popup((int)tEndObjectAdd, EndObjectsDefaultsEnumDesc);
- if (tEndObjectAdd != EndObjectsDefaultsEnum.None)
- {
- SMM.EM.EndCapEnd = GetEndObjectQuickAdd();
- SMM.EM.EndCapCustomRotOffsetEnd = new Vector3(0f, 180f, 0f);
- tEndObjectAdd = EndObjectsDefaultsEnum.None;
- }
- EditorGUILayout.EndHorizontal();
-
-
- SMM.EM.EndCapEnd = (GameObject)EditorGUILayout.ObjectField("Prefab:", SMM.EndCapEnd, typeof(GameObject), false);
- if (SMM.EndCapEnd != null)
- {
- SMM.EM.EndCapCustomOffsetEnd = EditorGUILayout.Vector3Field("Position offset:", SMM.EndCapCustomOffsetEnd);
- SMM.EM.EndCapCustomRotOffsetEnd = EditorGUILayout.Vector3Field("Rotation offset:", SMM.EndCapCustomRotOffsetEnd);
- }
- EditorGUILayout.EndVertical();
-
- EditorGUILayout.EndVertical();
-
- //Collision:
- EditorGUILayout.LabelField("Collision options:");
- EditorGUILayout.BeginVertical("box");
- SMM.EM.CollisionType = (GSD.Roads.Splination.CollisionTypeEnum)EditorGUILayout.Popup("Collision type: ", (int)SMM.CollisionType, TheCollisionTypeEnumDescSpline, GUILayout.Width(320f));
- //Mesh collison convex option
- if (SMM.CollisionType != GSD.Roads.Splination.CollisionTypeEnum.None && SMM.CollisionType != GSD.Roads.Splination.CollisionTypeEnum.BoxCollision)
- {
- SMM.EM.bCollisionConvex = EditorGUILayout.Toggle(" Convex: ", SMM.bCollisionConvex);
- SMM.EM.bCollisionTrigger = EditorGUILayout.Toggle(" Trigger: ", SMM.bCollisionTrigger);
- }
-
- if (SMM.CollisionType == GSD.Roads.Splination.CollisionTypeEnum.SimpleMeshTriangle || SMM.CollisionType == GSD.Roads.Splination.CollisionTypeEnum.SimpleMeshTrapezoid)
- {
- SMM.EM.bSimpleCollisionAutomatic = EditorGUILayout.Toggle(" Automatic simple collision: ", SMM.bSimpleCollisionAutomatic);
- }
- //If not automatic simple collisions:
- if (!SMM.bSimpleCollisionAutomatic)
- {
- if (SMM.CollisionType == GSD.Roads.Splination.CollisionTypeEnum.SimpleMeshTriangle)
- {
- SMM.EM.CollisionTriBL = SMM.CollisionTriBL;
- SMM.EM.CollisionTriBR = SMM.CollisionTriBR;
- SMM.EM.CollisionTriT = SMM.CollisionTriT;
-
- EditorGUILayout.LabelField("Bottom left:");
- SMM.EM.CollisionTriBL.x = EditorGUILayout.Slider(" x-axis: ", SMM.CollisionTriBL.x, SMM.mMinX - 5f, SMM.mMaxX + 5f);
- SMM.EM.CollisionTriBL.y = EditorGUILayout.Slider(" y-axis: ", SMM.CollisionTriBL.y, SMM.mMinY - 5f, SMM.mMaxY + 5f);
- SMM.EM.CollisionTriBL.z = EditorGUILayout.Slider(" z-axis: ", SMM.CollisionTriBL.z, SMM.mMinZ - 5f, SMM.mMaxZ + 5f);
-
- EditorGUILayout.LabelField("Bottom right:");
- SMM.EM.CollisionTriBR.x = EditorGUILayout.Slider(" x-axis: ", SMM.CollisionTriBR.x, SMM.mMinX - 5f, SMM.mMaxX + 5f);
- SMM.EM.CollisionTriBR.y = EditorGUILayout.Slider(" y-axis: ", SMM.CollisionTriBR.y, SMM.mMinY - 5f, SMM.mMaxY + 5f);
- SMM.EM.CollisionTriBR.z = EditorGUILayout.Slider(" z-axis: ", SMM.CollisionTriBR.z, SMM.mMinZ - 5f, SMM.mMaxZ + 5f);
-
- EditorGUILayout.LabelField("Top:");
- SMM.EM.CollisionTriT.x = EditorGUILayout.Slider(" x-axis: ", SMM.CollisionTriT.x, SMM.mMinX - 5f, SMM.mMaxX + 5f);
- SMM.EM.CollisionTriT.y = EditorGUILayout.Slider(" y-axis: ", SMM.CollisionTriT.y, SMM.mMinY - 5f, SMM.mMaxY + 5f);
- SMM.EM.CollisionTriT.z = EditorGUILayout.Slider(" z-axis: ", SMM.CollisionTriT.z, SMM.mMinZ - 5f, SMM.mMaxZ + 5f);
-
- }
- else if (SMM.CollisionType == GSD.Roads.Splination.CollisionTypeEnum.SimpleMeshTrapezoid)
- {
- SMM.EM.CollisionBoxBL = EditorGUILayout.Vector3Field(" Bottom left:", SMM.CollisionBoxBL);
- SMM.EM.CollisionBoxBR = EditorGUILayout.Vector3Field(" Bottom right:", SMM.CollisionBoxBR);
- SMM.EM.CollisionBoxTL = EditorGUILayout.Vector3Field(" Top left:", SMM.CollisionBoxTL);
- SMM.EM.CollisionBoxTR = EditorGUILayout.Vector3Field(" Top right:", SMM.CollisionBoxTR);
- }
- }
-
- if (SMM.CollisionType == GSD.Roads.Splination.CollisionTypeEnum.BoxCollision)
- {
- SMM.EM.StretchBC_LocOffset = EditorGUILayout.Vector3Field("Box collider center offset:", SMM.StretchBC_LocOffset);
- SMM.EM.bBCFlipX = EditorGUILayout.Toggle("Flip center X:", SMM.bBCFlipX);
- SMM.EM.bBCFlipZ = EditorGUILayout.Toggle("Flip center Z:", SMM.bBCFlipZ);
-
-
- SMM.EM.bStretchSize = EditorGUILayout.Toggle("Box collider size edit:", SMM.bStretchSize);
- if (SMM.bStretchSize)
- {
- SMM.EM.StretchBC_Size = EditorGUILayout.Vector3Field("Size:", SMM.StretchBC_Size);
- }
- else
- {
- EditorGUILayout.LabelField("Size:", SMM.StretchBC_Size.ToString());
- }
- }
- EditorGUILayout.EndVertical();
-
-
- EditorGUILayout.LabelField("Rotation options:");
- EditorGUILayout.BeginVertical("box");
-
- //Custom rotation:
- SMM.EM.CustomRotation = SMM.CustomRotation;
- //EOM.CustomRotation = EditorGUILayout.Vector3Field("Custom rotation: ",EOM.CustomRotation);
- EditorGUILayout.BeginHorizontal();
- //Flip rotation option:
- if (SMM.EM.bFlipRotation != SMM.bFlipRotation)
- {
- SMM.EM.bFlipRotation = EditorGUILayout.Toggle("Flip Y rotation: ", SMM.EM.bFlipRotation);
- }
- else
- {
- SMM.EM.bFlipRotation = EditorGUILayout.Toggle("Flip Y rotation: ", SMM.bFlipRotation);
- }
-
-
- // if(GUILayout.Button("Reset custom rotation",EditorStyles.miniButton,GUILayout.Width(160f))){
- // SMM.CustomRotation = new Vector3(0f,0f,0f);
- // }
- if (GUILayout.Button(btnDefaultText, GSDImageButton, GUILayout.Width(16f)))
- {
- SMM.EM.CustomRotation = new Vector3(0f, 0f, 0f);
- }
- EditorGUILayout.EndHorizontal();
- // SMM.EM.CustomRotation = EditorGUILayout.Vector3Field("",SMM.CustomRotation);
- // SMM.EM.CustomRotation.x = EditorGUILayout.Slider("x-axis: ",SMM.CustomRotation.x,-360f,360f);
- // SMM.EM.CustomRotation.y = EditorGUILayout.Slider("y-axis: ",SMM.CustomRotation.y,-360f,360f);
- // SMM.EM.CustomRotation.z = EditorGUILayout.Slider("z-axis: ",SMM.CustomRotation.z,-360f,360f);
- EditorGUILayout.EndVertical();
- EditorGUILayout.EndVertical();
-
-
- EditorGUILayout.LabelField("Deprecated options:");
- EditorGUILayout.BeginVertical("box");
- SMM.EM.bExactSplination = EditorGUILayout.Toggle("Directional extrusion: ", SMM.bExactSplination);
-
- EditorGUILayout.EndVertical();
- BigLine();
- BigLine();
- }
- }
-
- public void UpdateSplineObjects()
- {
- if (!tNode.CanSplinate()) { return; }
- if (tNode.SplinatedObjects == null) { tNode.SplinatedObjects = new List(); }
- eCount = tNode.SplinatedObjects.Count;
- for (int i = 0; i < eCount; i++)
- {
- SMM = tNode.SplinatedObjects[i];
- if (SMM.EM != null)
- {
- if (!SMM.EM.IsEqualToSMM(SMM))
- {
- SMM.EM.LoadToSMM(SMM);
-
- SMM.UpdatePositions();
- if (SMM.EM.bIsStretch != SMM.bIsStretch)
- {
- if (SMM.bIsStretch)
- {
- SMM.CollisionType = GSD.Roads.Splination.CollisionTypeEnum.BoxCollision;
- SMM.bMatchRoadDefinition = false;
- SMM.bMatchTerrain = false;
- SMM.bCollisionConvex = false;
- SMM.bStartDown = false;
- SMM.bEndDown = false;
- SMM.bVerticalCutoff = false;
- SMM.bExactSplination = false;
- SMM.bEndTypeDownOverride = false;
- }
- }
-
- SMM.Setup(true);
- // Debug.Log ("Setup SMM");
- }
- }
- }
- }
-
- public void UpdateSplineObjects_OnUndo()
- {
- if (!tNode.CanSplinate()) { return; }
- if (tNode.SplinatedObjects == null) { tNode.SplinatedObjects = new List(); }
-
- //Destroy all children:
- for (int i = tNode.transform.childCount - 1; i >= 0; i--)
- {
- Object.DestroyImmediate(tNode.transform.GetChild(i).gameObject);
- }
-
- //Re-setup the SMM:
- eCount = tNode.SplinatedObjects.Count;
- for (int i = 0; i < eCount; i++)
- {
- SMM = tNode.SplinatedObjects[i];
- SMM.UpdatePositions();
- //if(SMM.bIsStretch != SMM.bIsStretch){
- if (SMM.bIsStretch)
- {
- SMM.CollisionType = GSD.Roads.Splination.CollisionTypeEnum.BoxCollision;
- SMM.bMatchRoadDefinition = false;
- SMM.bMatchTerrain = false;
- SMM.bCollisionConvex = false;
- SMM.bStartDown = false;
- SMM.bEndDown = false;
- SMM.bVerticalCutoff = false;
- SMM.bExactSplination = false;
- SMM.bEndTypeDownOverride = false;
- }
- //}
- SMM.Setup(true);
- }
-
- UpdateEdgeObjects_OnUndo();
- }
-
- public void DoEdgeObjects()
- {
- if (!tNode.CanSplinate()) { return; }
-
- if (tNode.EdgeObjects == null)
- {
- tNode.EdgeObjects = new List();
- }
- eCount = tNode.EdgeObjects.Count;
-
- EOM = null;
-
- for (int i = 0; i < tNode.EdgeObjects.Count; i++)
- {
- EOM = tNode.EdgeObjects[i];
- if (EOM.EM == null)
- {
- EOM.EM = new GSD.Roads.EdgeObjects.EdgeObjectMaker.EdgeObjectEditorMaker();
- }
- EOM.EM.Setup(EOM);
-
- currentCount += 1;
- EditorGUILayout.BeginVertical("TextArea");
-
-
- if (EOM.bNeedsUpdate) { EOM.Setup(); }
- EOM.bNeedsUpdate = false;
-
- EditorGUILayout.BeginHorizontal();
-
- EOM.bToggle = EditorGUILayout.Foldout(EOM.bToggle, "#" + currentCount.ToString() + ": " + EOM.tName);
-
- if (GUILayout.Button(btnEdgeText, GSDImageButton, GUILayout.Width(32f)))
- {
-
- }
- if (GUILayout.Button(btnRefreshText, GSDImageButton, GUILayout.Width(16f)))
- {
- EOM.Setup();
- }
- if (GUILayout.Button(btnSaveText, GSDImageButton, GUILayout.Width(16f)))
- {
- GSDSaveWindow tSave = EditorWindow.GetWindow();
- tSave.Initialize(ref tSceneRect, GSDSaveWindow.WindowTypeEnum.Edge, tNode, null, EOM);
- }
-
- if (GUILayout.Button(btnCopyText, GSDImageButton, GUILayout.Width(16f)))
- {
- Undo.RecordObject(tNode, "Copy");
- tNode.CopyEdgeObject(i);
- EditorUtility.SetDirty(tNode);
- }
- if (GUILayout.Button(btnDeleteText, GSDImageButton, GUILayout.Width(16f)))
- {
- Undo.RecordObject(tNode, "Delete");
- tNode.RemoveEdgeObject(i);
- EditorUtility.SetDirty(tNode);
- }
- EditorGUILayout.EndHorizontal();
-
- if (!EOM.bToggle) { EditorGUILayout.EndVertical(); continue; }
-
- GUILayout.Space(8f);
- EditorGUILayout.BeginHorizontal();
- EditorGUILayout.LabelField("General options:");
- if (GUILayout.Button("Online manual", EditorStyles.miniButton, GUILayout.Width(120f)))
- {
- Application.OpenURL("http://microgsd.com/Support/RoadArchitectManual.aspx");
- }
- EditorGUILayout.EndHorizontal();
-
- EditorGUILayout.BeginVertical("box");
- //Name:
- EOM.EM.tName = EditorGUILayout.TextField("Name: ", EOM.tName);
-
- //Edge object:
- EOM.EM.EdgeObject = (GameObject)EditorGUILayout.ObjectField("Edge object: ", EOM.EdgeObject, typeof(GameObject), false);
- if (EOM.EM.EdgeObject != EOM.EdgeObject)
- {
- EOM.bEdgeSignLabelInit = false;
- EOM.bEdgeSignLabel = false;
- }
-
- //Material override:
- EOM.EM.bMaterialOverride = EditorGUILayout.Toggle("Material override: ", EOM.bMaterialOverride);
- if (!EOM.bMaterialOverride)
- {
- EOM.EM.EdgeMaterial1 = null;
- EOM.EM.EdgeMaterial2 = null;
- }
-
- if (!EOM.bEdgeSignLabelInit && EOM.EM.EdgeObject != null)
- {
- EOM.bEdgeSignLabel = false;
- if (string.CompareOrdinal(EOM.EM.EdgeObject.name, "GSDSignDiamond") == 0)
- {
- EOM.bEdgeSignLabel = true;
- EOM.EdgeSignLabel = "GSDFedSign-diamond";
-
- }
- else if (string.CompareOrdinal(EOM.EM.EdgeObject.name, "GSDSignSquare-Small") == 0)
- {
- EOM.bEdgeSignLabel = true;
- EOM.EdgeSignLabel = "GSDFedSign-Square";
- }
- else if (string.CompareOrdinal(EOM.EM.EdgeObject.name, "GSDSignSquare") == 0)
- {
- EOM.bEdgeSignLabel = true;
- EOM.EdgeSignLabel = "GSDFedSign-Square";
-
- }
- else if (string.CompareOrdinal(EOM.EM.EdgeObject.name, "GSDSign988-Small") == 0)
- {
- EOM.bEdgeSignLabel = true;
- EOM.EdgeSignLabel = "GSDFedSign-988";
- }
- else if (string.CompareOrdinal(EOM.EM.EdgeObject.name, "GSDSign988") == 0)
- {
- EOM.bEdgeSignLabel = true;
- EOM.EdgeSignLabel = "GSDFedSign-988";
-
- }
- else if (string.CompareOrdinal(EOM.EM.EdgeObject.name, "GSDSign861-Small") == 0)
- {
- EOM.bEdgeSignLabel = true;
- EOM.EdgeSignLabel = "GSDFedSign-861";
- }
- else if (string.CompareOrdinal(EOM.EM.EdgeObject.name, "GSDSign861") == 0)
- {
- EOM.bEdgeSignLabel = true;
- EOM.EdgeSignLabel = "GSDFedSign-861";
-
- }
- else if (string.CompareOrdinal(EOM.EM.EdgeObject.name, "GSDSign617-Small") == 0)
- {
- EOM.bEdgeSignLabel = true;
- EOM.EdgeSignLabel = "GSDFedSign-617";
- }
- else if (string.CompareOrdinal(EOM.EM.EdgeObject.name, "GSDSign617") == 0)
- {
- EOM.bEdgeSignLabel = true;
- EOM.EdgeSignLabel = "GSDFedSign-617";
-
- }
- else if (string.CompareOrdinal(EOM.EM.EdgeObject.name, "GSDSign396") == 0)
- {
- EOM.bEdgeSignLabel = true;
- EOM.EdgeSignLabel = "GSDFedSign-396";
-
- }
- else if (string.CompareOrdinal(EOM.EM.EdgeObject.name, "GSDSign330") == 0)
- {
- EOM.bEdgeSignLabel = true;
- EOM.EdgeSignLabel = "GSDFedSign-330";
- }
- }
-
- if (EOM.bMaterialOverride)
- {
- if (EOM.bEdgeSignLabel)
- {
- EditorGUILayout.TextField("Material search term: ", EOM.EdgeSignLabel);
- }
-
- EOM.EM.EdgeMaterial1 = (Material)EditorGUILayout.ObjectField("Override mat #1: ", EOM.EdgeMaterial1, typeof(Material), false);
- EOM.EM.EdgeMaterial2 = (Material)EditorGUILayout.ObjectField("Override mat #2: ", EOM.EdgeMaterial2, typeof(Material), false);
- }
-
- if (EOM.bSingle)
- {
- EOM.EM.bCombineMesh = false;
- }
- else
- {
- EOM.EM.bCombineMesh = EditorGUILayout.Toggle("Combine meshes: ", EOM.bCombineMesh);
-
- if (EOM.bCombineMesh)
- {
- EOM.EM.bCombineMeshCollider = EditorGUILayout.Toggle("Combined mesh collider: ", EOM.bCombineMeshCollider);
- }
- }
-
- EOM.EM.bSingle = EditorGUILayout.Toggle("Single object only: ", EOM.bSingle);
- if (EOM.EM.bSingle != EOM.bSingle)
- {
- EOM.EM.EndTime = tNode.NextTime;
- // EOM.EM.EndPos = tNode.GSDSpline.GetSplineValue(EOM.EM.EndTime,false);
- EOM.EM.SinglePosition = tNode.tTime + 0.025f;
- if (EOM.EM.bSingle)
- {
- EOM.EM.bCombineMesh = false;
- }
- }
-
- if (EOM.bSingle)
- {
- EOM.EM.SinglePosition = EditorGUILayout.Slider("Single location: ", EOM.SinglePosition, tNode.tTime, 1f);
-
- if (tNode.bIsBridgeStart && tNode.bIsBridgeMatched)
- {
- EOM.EM.SingleOnlyBridgePercent = EditorGUILayout.Slider("Bridge %: ", EOM.SingleOnlyBridgePercent, 0f, 1f);
- if (!GSDRootUtil.IsApproximately(EOM.SingleOnlyBridgePercent, EOM.EM.SingleOnlyBridgePercent, 0.001f))
- {
- EOM.EM.SingleOnlyBridgePercent = Mathf.Clamp(EOM.EM.SingleOnlyBridgePercent, 0f, 1f);
- float tDist = (EOM.EM.SingleOnlyBridgePercent * (tNode.BridgeCounterpartNode.tDist - tNode.tDist) + tNode.tDist);
- EOM.EM.SinglePosition = tNode.GSDSpline.TranslateDistBasedToParam(tDist);
- }
- }
- }
-
- EOM.EM.bStatic = EditorGUILayout.Toggle("Static: ", EOM.bStatic);
- EOM.EM.bMatchTerrain = EditorGUILayout.Toggle("Match ground height: ", EOM.bMatchTerrain);
-
- if (!EOM.bSingle)
- {
- EOM.EM.MeterSep = EditorGUILayout.Slider("Dist between objects: ", EOM.MeterSep, 1f, 256f);
- }
-
- EOM.EM.bStartMatchRoadDefinition = EditorGUILayout.Toggle("Match road definition: ", EOM.bStartMatchRoadDefinition);
- if (EOM.bStartMatchRoadDefinition)
- {
- EOM.EM.StartMatchRoadDef = EditorGUILayout.Slider("Position fine tuning: ", EOM.StartMatchRoadDef, 0f, 1f);
- if (!GSDRootUtil.IsApproximately(EOM.EM.StartMatchRoadDef, EOM.StartMatchRoadDef, 0.001f))
- {
- EOM.EM.StartMatchRoadDef = Mathf.Clamp(EOM.EM.StartMatchRoadDef, 0f, 1f);
- }
- }
-
- if (!EOM.bSingle)
- {
- if (EOM.EM.StartTime < tNode.MinSplination) { EOM.EM.StartTime = tNode.MinSplination; }
- if (EOM.EM.EndTime > tNode.MaxSplination) { EOM.EM.EndTime = tNode.MaxSplination; }
-
- EditorGUILayout.BeginHorizontal();
- EOM.EM.StartTime = EditorGUILayout.Slider("Start param: ", EOM.StartTime, tNode.MinSplination, EOM.EndTime);
- if (EOM.EM.EndTime < EOM.EM.StartTime)
- {
- EOM.EM.EndTime = Mathf.Clamp(EOM.StartTime + 0.01f, 0f, 1f);
- }
- if (GUILayout.Button("match node", EditorStyles.miniButton, GUILayout.Width(80f)))
- {
- EOM.EM.StartTime = tNode.tTime;
- }
- EditorGUILayout.EndHorizontal();
-
- EditorGUILayout.BeginHorizontal();
- EOM.EM.EndTime = EditorGUILayout.Slider("End param: ", EOM.EndTime, EOM.StartTime, tNode.MaxSplination);
- if (EOM.EM.StartTime > EOM.EM.EndTime)
- {
- EOM.EM.StartTime = Mathf.Clamp(EOM.EndTime - 0.01f, 0f, 1f);
- }
- if (GUILayout.Button("match next", EditorStyles.miniButton, GUILayout.Width(80f)))
- {
- EOM.EM.EndTime = tNode.NextTime;
- }
- EditorGUILayout.EndHorizontal();
- }
-
- EditorGUILayout.EndVertical();
-
- //Vertical offset:
- EditorGUILayout.LabelField("Vertical options:");
- EditorGUILayout.BeginVertical("box");
-
- EditorGUILayout.BeginHorizontal();
- EOM.EM.VerticalRaise = EditorGUILayout.Slider("Vertical raise magnitude:", EOM.VerticalRaise, -512f, 512f);
- if (GUILayout.Button(btnDefaultText, GSDImageButton, GUILayout.Width(16f)))
- {
- EOM.EM.VerticalRaise = 0f;
- }
- EditorGUILayout.EndHorizontal();
-
- if (EOM.VerticalCurve == null || EOM.VerticalCurve.keys.Length < 2) { EnforceCurve(ref EOM.VerticalCurve); }
- EditorGUILayout.BeginHorizontal();
- EOM.EM.VerticalCurve = EditorGUILayout.CurveField("Curve: ", EOM.VerticalCurve);
- if (GUILayout.Button(btnDefaultText, GSDImageButton, GUILayout.Width(16f)))
- {
- ResetCurve(ref EOM.EM.VerticalCurve);
- }
- EditorGUILayout.EndHorizontal();
- EditorGUILayout.EndVertical();
-
- //Horizontal offsets:
- EditorGUILayout.LabelField("Horizontal offset options:");
- EditorGUILayout.BeginVertical("box");
- tHorizMatching = HorizMatchingDefaultsEnum.None;
- tHorizMatching = (HorizMatchingDefaultsEnum)EditorGUILayout.Popup((int)tHorizMatching, HorizMatchSubTypeDescriptions, GUILayout.Width(100f));
- if (tHorizMatching != HorizMatchingDefaultsEnum.None)
- {
- if (tHorizMatching == HorizMatchingDefaultsEnum.MatchCenter)
- {
- EOM.EM.HorizontalSep = 0f;
- }
- else if (tHorizMatching == HorizMatchingDefaultsEnum.MatchRoadLeft)
- {
- EOM.EM.HorizontalSep = (tNode.GSDSpline.tRoad.RoadWidth() * 0.5f) * -1;
- }
- else if (tHorizMatching == HorizMatchingDefaultsEnum.MatchShoulderLeft)
- {
- if (tNode.GSDSpline.tRoad.opt_bShouldersEnabled)
- {
- EOM.EM.HorizontalSep = ((tNode.GSDSpline.tRoad.RoadWidth() * 0.5f) + tNode.GSDSpline.tRoad.opt_ShoulderWidth) * -1;
- }
- else
- {
- EOM.EM.HorizontalSep = ((tNode.GSDSpline.tRoad.RoadWidth() * 0.5f)) * -1;
- }
- }
- else if (tHorizMatching == HorizMatchingDefaultsEnum.MatchRoadRight)
- {
- EOM.EM.HorizontalSep = (tNode.GSDSpline.tRoad.RoadWidth() * 0.5f);
- }
- else if (tHorizMatching == HorizMatchingDefaultsEnum.MatchShoulderRight)
- {
- if (tNode.GSDSpline.tRoad.opt_bShouldersEnabled)
- {
- EOM.EM.HorizontalSep = (tNode.GSDSpline.tRoad.RoadWidth() * 0.5f) + tNode.GSDSpline.tRoad.opt_ShoulderWidth;
- }
- else
- {
- EOM.EM.HorizontalSep = (tNode.GSDSpline.tRoad.RoadWidth() * 0.5f);
- }
- }
- tHorizMatching = HorizMatchingDefaultsEnum.None;
- }
- if (!GSDRootUtil.IsApproximately(EOM.EM.HorizontalSep, EOM.HorizontalSep))
- {
- EOM.EM.HorizontalSep = Mathf.Clamp(EOM.EM.HorizontalSep, (-1f * HorizRoadMax), HorizRoadMax);
- }
-
-
- EditorGUILayout.BeginHorizontal();
- EOM.EM.HorizontalSep = EditorGUILayout.Slider("Horiz offset magnitude:", EOM.EM.HorizontalSep, (-1f * HorizRoadMax), HorizRoadMax);
- if (GUILayout.Button(btnDefaultText, GSDImageButton, GUILayout.Width(16f)))
- {
- EOM.EM.HorizontalSep = 0f;
- }
- if (!GSDRootUtil.IsApproximately(EOM.EM.HorizontalSep, EOM.HorizontalSep))
- {
- EOM.EM.HorizontalSep = Mathf.Clamp(EOM.EM.HorizontalSep, (-1f * HorizRoadMax), HorizRoadMax);
- }
- EditorGUILayout.EndHorizontal();
- if (EOM.HorizontalCurve == null || EOM.HorizontalCurve.keys.Length < 2) { EnforceCurve(ref EOM.HorizontalCurve); }
- EditorGUILayout.BeginHorizontal();
- EOM.EM.HorizontalCurve = EditorGUILayout.CurveField("Curve: ", EOM.HorizontalCurve);
- if (GUILayout.Button(btnDefaultText, GSDImageButton, GUILayout.Width(16f)))
- {
- ResetCurve(ref EOM.EM.HorizontalCurve);
- }
- EditorGUILayout.EndHorizontal();
- EditorGUILayout.EndVertical();
-
- EditorGUILayout.LabelField("Rotation/scale options:");
- EditorGUILayout.BeginVertical("box");
- if (EOM.HorizontalSep < 0f)
- {
- EOM.EM.bOncomingRotation = EditorGUILayout.Toggle("Auto rotate oncoming objects: ", EOM.bOncomingRotation);
- }
-
- EditorGUILayout.BeginHorizontal();
- EditorGUILayout.LabelField("Custom rotation: ");
- if (GUILayout.Button(btnDefaultText, GSDImageButton, GUILayout.Width(16f)))
- {
- EOM.EM.CustomRotation = new Vector3(0f, 0f, 0f);
- }
- EditorGUILayout.EndHorizontal();
-
- EOM.EM.CustomRotation.x = EditorGUILayout.Slider("x-axis: ", EOM.CustomRotation.x, -360f, 360f);
- EOM.EM.CustomRotation.y = EditorGUILayout.Slider("y-axis: ", EOM.CustomRotation.y, -360f, 360f);
- EOM.EM.CustomRotation.z = EditorGUILayout.Slider("z-axis: ", EOM.CustomRotation.z, -360f, 360f);
- EditorGUILayout.EndVertical();
- EditorGUILayout.BeginVertical("box"); /* scale */
- EditorGUILayout.BeginHorizontal();
- float scale = EditorGUILayout.Slider("Custom scale: ", EOM.CustomScale.x, 1f, 10f);
- EOM.EM.CustomScale = new Vector3(scale, scale, scale);
- if (GUILayout.Button(btnDefaultText, GSDImageButton, GUILayout.Width(16f)))
- {
- EOM.EM.CustomScale = new Vector3(1f, 1f, 1f);
- }
- EditorGUILayout.EndHorizontal();
- EditorGUILayout.EndVertical(); /* scale */
- EditorGUILayout.EndVertical();
- }
- }
-
- public void UpdateEdgeObjects()
- {
- if (!tNode.CanSplinate()) { return; }
- eCount = tNode.EdgeObjects.Count;
- for (int i = 0; i < tNode.EdgeObjects.Count; i++)
- {
- EOM = tNode.EdgeObjects[i];
- if (EOM.EM != null)
- {
- if (!EOM.EM.IsEqual(EOM))
- {
- EOM.EM.LoadTo(EOM);
- EOM.UpdatePositions();
- EOM.Setup();
- // Debug.Log ("Setup EOM");
- }
- }
- }
- }
-
- public void UpdateEdgeObjects_OnUndo()
- {
- if (!tNode.CanSplinate()) { return; }
- eCount = tNode.EdgeObjects.Count;
- for (int i = 0; i < tNode.EdgeObjects.Count; i++)
- {
- EOM = tNode.EdgeObjects[i];
- EOM.Setup();
- }
- }
-
- #region "Quick adds"
- private void BridgeAdd_TopBase(float tHorizSep = 0f, float tVertRaise = -0.01f, string tMat = "", bool bOverridePrefab = false, string OverridePrefab = "")
- {
- if (tMat == "")
- tMat = GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Materials/GSDConcrete2.mat";
- SMM = tNode.AddSplinatedObject();
- string tBridgeTopBaseToAdd = "";
- string tName = "";
- if (tNode.GSDSpline.tRoad.opt_Lanes == 2)
- {
- if (tBridgeTopBaseQuickAdd == BridgeTopBaseDefaultsEnum.Base1MOver)
- {
- tBridgeTopBaseToAdd = GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Mesh/RoadObj/Bridges/BridgeBase-19w-5l-1d.fbx";
- tName = "BridgeTop1M-1M";
- }
- else if (tBridgeTopBaseQuickAdd == BridgeTopBaseDefaultsEnum.Base2MOver)
- {
- tBridgeTopBaseToAdd = GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Mesh/RoadObj/Bridges/BridgeBase-20w-5l-1d.fbx";
- tName = "BridgeTop2M-1M";
- }
- else if (tBridgeTopBaseQuickAdd == BridgeTopBaseDefaultsEnum.Base3MDeep)
- {
- tBridgeTopBaseToAdd = GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Mesh/RoadObj/Bridges/BridgeBase-18w-5l-3d.fbx";
- tName = "BridgeTop0M-3M";
- }
- else
- {
- tBridgeTopBaseToAdd = GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Mesh/RoadObj/Bridges/BridgeBase-18w-5l-1d.fbx";
- tName = "BridgeTop0M-1M";
- }
- }
- else if (tNode.GSDSpline.tRoad.opt_Lanes == 4)
- {
- if (tBridgeTopBaseQuickAdd == BridgeTopBaseDefaultsEnum.Base1MOver)
- {
- tBridgeTopBaseToAdd = GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Mesh/RoadObj/Bridges/BridgeBase-29w-5l-1d.fbx";
- tName = "BridgeTop1M-1M";
- }
- else if (tBridgeTopBaseQuickAdd == BridgeTopBaseDefaultsEnum.Base2MOver)
- {
- tBridgeTopBaseToAdd = GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Mesh/RoadObj/Bridges/BridgeBase-30w-5l-1d.fbx";
- tName = "BridgeTop2M-1M";
- }
- else if (tBridgeTopBaseQuickAdd == BridgeTopBaseDefaultsEnum.Base3MDeep)
- {
- tBridgeTopBaseToAdd = GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Mesh/RoadObj/Bridges/BridgeBase-28w-5l-3d.fbx";
- tName = "BridgeTop0M-3M";
- }
- else
- {
- tBridgeTopBaseToAdd = GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Mesh/RoadObj/Bridges/BridgeBase-28w-5l-1d.fbx";
- tName = "BridgeTop0M-1M";
- }
- }
- else
- {
- if (tBridgeTopBaseQuickAdd == BridgeTopBaseDefaultsEnum.Base1MOver)
- {
- tBridgeTopBaseToAdd = GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Mesh/RoadObj/Bridges/BridgeBase-39w-5l-1d.fbx";
- tName = "BridgeTop1M-1M";
- }
- else if (tBridgeTopBaseQuickAdd == BridgeTopBaseDefaultsEnum.Base2MOver)
- {
- tBridgeTopBaseToAdd = GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Mesh/RoadObj/Bridges/BridgeBase-40w-5l-1d.fbx";
- tName = "BridgeTop2M-1M";
- }
- else if (tBridgeTopBaseQuickAdd == BridgeTopBaseDefaultsEnum.Base3MDeep)
- {
- tBridgeTopBaseToAdd = GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Mesh/RoadObj/Bridges/BridgeBase-38w-5l-3d.fbx";
- tName = "BridgeTop0M-3M";
- }
- else
- {
- tBridgeTopBaseToAdd = GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Mesh/RoadObj/Bridges/BridgeBase-38w-5l-1d.fbx";
- tName = "BridgeTop0M-1M";
- }
- }
-
- if (bOverridePrefab) { tBridgeTopBaseToAdd = OverridePrefab; }
-
- SMM.tName = tName;
- SMM.CurrentSplination = (GameObject)UnityEditor.AssetDatabase.LoadAssetAtPath(tBridgeTopBaseToAdd, typeof(GameObject));
- SMM.HorizontalSep = tHorizSep;
- SMM.VerticalRaise = tVertRaise;
- SMM.bMaterialOverride = true;
- SMM.SplinatedMaterial1 = GSD.Roads.GSDRoadUtilityEditor.GiveMaterial(tMat);
- SMM.Axis = GSD.Roads.Splination.AxisTypeEnum.Z;
-
- tBridgeTopBaseQuickAdd = BridgeTopBaseDefaultsEnum.None;
- if (SMM.StartTime < tNode.MinSplination) { SMM.StartTime = tNode.MinSplination; }
- if (SMM.EndTime > tNode.MaxSplination) { SMM.EndTime = tNode.MaxSplination; }
- }
-
- private void BridgeAdd_BottomBase(float tHorizSep = 0f, float tVertRaise = -1.01f, string tMat = "", bool bOverridePrefab = false, string OverridePrefab = "")
- {
- if (tMat == "")
- tMat = GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Materials/GSDConcrete2.mat";
- SMM = tNode.AddSplinatedObject();
- string tBridgeBottomBaseToAdd = "";
- string tName = "";
- if (tNode.GSDSpline.tRoad.opt_Lanes == 2)
- {
- if (tBridgeBottomBaseQuickAdd == BridgeBottomBaseDefaultsEnum.BridgeBase2)
- {
- tBridgeBottomBaseToAdd = GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Mesh/RoadObj/Bridges/BridgeBase2-18w-5l-3d.fbx";
- tName = "BridgeBase2";
- }
- else if (tBridgeBottomBaseQuickAdd == BridgeBottomBaseDefaultsEnum.BridgeBase3)
- {
- tBridgeBottomBaseToAdd = GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Mesh/RoadObj/Bridges/BridgeBase3-18w-5l-5d.fbx";
- tName = "BridgeBase3";
- }
- else if (tBridgeBottomBaseQuickAdd == BridgeBottomBaseDefaultsEnum.BridgeBase4)
- {
- tBridgeBottomBaseToAdd = GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Mesh/RoadObj/Bridges/BridgeBase4-18w-5l-5d.fbx";
- tName = "BridgeBase4";
- }
- else if (tBridgeBottomBaseQuickAdd == BridgeBottomBaseDefaultsEnum.BridgeBase5)
- {
- tBridgeBottomBaseToAdd = GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Mesh/RoadObj/Bridges/BridgeBase5-18w-5l-5d.fbx";
- tName = "BridgeBase5";
- }
- else if (tBridgeBottomBaseQuickAdd == BridgeBottomBaseDefaultsEnum.BridgeBase6)
- {
- tBridgeBottomBaseToAdd = GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Mesh/RoadObj/Bridges/BridgeBase6-2L.fbx";
- tName = "BridgeArchBeam80";
- }
- else if (tBridgeBottomBaseQuickAdd == BridgeBottomBaseDefaultsEnum.BridgeBase7)
- {
- tBridgeBottomBaseToAdd = GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Mesh/RoadObj/Bridges/BridgeBase7-2L.fbx";
- tName = "BridgeArchSolid80";
- }
- else if (tBridgeBottomBaseQuickAdd == BridgeBottomBaseDefaultsEnum.BridgeBase8)
- {
- tBridgeBottomBaseToAdd = GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Mesh/RoadObj/Bridges/BridgeBase8-2L.fbx";
- tName = "BridgeArchSolid180";
- }
- else if (tBridgeBottomBaseQuickAdd == BridgeBottomBaseDefaultsEnum.BridgeBaseGrid)
- {
- tBridgeBottomBaseToAdd = GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Mesh/RoadObj/Bridges/BridgeBaseGrid-18w-5l-5d.fbx";
- tName = "BridgeGrid";
- }
- else if (tBridgeBottomBaseQuickAdd == BridgeBottomBaseDefaultsEnum.BridgeSteel)
- {
- tBridgeBottomBaseToAdd = GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Mesh/RoadObj/Bridges/BridgeBaseSteelBeam-18w-20l-3d.fbx";
- tName = "BridgeSteelBeams";
- }
- }
- else if (tNode.GSDSpline.tRoad.opt_Lanes == 4)
- {
- if (tBridgeBottomBaseQuickAdd == BridgeBottomBaseDefaultsEnum.BridgeBase2)
- {
- tBridgeBottomBaseToAdd = GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Mesh/RoadObj/Bridges/BridgeBase2-28w-5l-3d.fbx";
- tName = "BridgeBase2";
- }
- else if (tBridgeBottomBaseQuickAdd == BridgeBottomBaseDefaultsEnum.BridgeBase3)
- {
- tBridgeBottomBaseToAdd = GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Mesh/RoadObj/Bridges/BridgeBase3-28w-5l-5d.fbx";
- tName = "BridgeBase3";
- }
- else if (tBridgeBottomBaseQuickAdd == BridgeBottomBaseDefaultsEnum.BridgeBase4)
- {
- tBridgeBottomBaseToAdd = GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Mesh/RoadObj/Bridges/BridgeBase4-28w-5l-5d.fbx";
- tName = "BridgeBase4";
- }
- else if (tBridgeBottomBaseQuickAdd == BridgeBottomBaseDefaultsEnum.BridgeBase5)
- {
- tBridgeBottomBaseToAdd = GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Mesh/RoadObj/Bridges/BridgeBase5-28w-5l-5d.fbx";
- tName = "BridgeBase5";
- }
- else if (tBridgeBottomBaseQuickAdd == BridgeBottomBaseDefaultsEnum.BridgeBase6)
- {
- tBridgeBottomBaseToAdd = GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Mesh/RoadObj/Bridges/BridgeBase6-4L.fbx";
- tName = "BridgeArchBeam80";
- }
- else if (tBridgeBottomBaseQuickAdd == BridgeBottomBaseDefaultsEnum.BridgeBase7)
- {
- tBridgeBottomBaseToAdd = GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Mesh/RoadObj/Bridges/BridgeBase7-4L.fbx";
- tName = "BridgeArchSolid80";
- }
- else if (tBridgeBottomBaseQuickAdd == BridgeBottomBaseDefaultsEnum.BridgeBase8)
- {
- tBridgeBottomBaseToAdd = GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Mesh/RoadObj/Bridges/BridgeBase8-4L.fbx";
- tName = "BridgeArchSolid180";
- }
- else if (tBridgeBottomBaseQuickAdd == BridgeBottomBaseDefaultsEnum.BridgeBaseGrid)
- {
- tBridgeBottomBaseToAdd = GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Mesh/RoadObj/Bridges/BridgeBaseGrid-28w-5l-5d.fbx";
- tName = "BridgeGrid";
- }
- else if (tBridgeBottomBaseQuickAdd == BridgeBottomBaseDefaultsEnum.BridgeSteel)
- {
- tBridgeBottomBaseToAdd = GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Mesh/RoadObj/Bridges/BridgeBaseSteelBeam-28w-20l-3d.fbx";
- tName = "BridgeSteelBeams";
- }
- }
- else
- {
- if (tBridgeBottomBaseQuickAdd == BridgeBottomBaseDefaultsEnum.BridgeBase2)
- {
- tBridgeBottomBaseToAdd = GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Mesh/RoadObj/Bridges/BridgeBase2-38w-5l-3d.fbx";
- tName = "BridgeBase2";
- }
- else if (tBridgeBottomBaseQuickAdd == BridgeBottomBaseDefaultsEnum.BridgeBase3)
- {
- tBridgeBottomBaseToAdd = GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Mesh/RoadObj/Bridges/BridgeBase3-38w-5l-5d.fbx";
- tName = "BridgeBase3";
- }
- else if (tBridgeBottomBaseQuickAdd == BridgeBottomBaseDefaultsEnum.BridgeBase4)
- {
- tBridgeBottomBaseToAdd = GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Mesh/RoadObj/Bridges/BridgeBase4-38w-5l-5d.fbx";
- tName = "BridgeBase4";
- }
- else if (tBridgeBottomBaseQuickAdd == BridgeBottomBaseDefaultsEnum.BridgeBase5)
- {
- tBridgeBottomBaseToAdd = GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Mesh/RoadObj/Bridges/BridgeBase5-38w-5l-5d.fbx";
- tName = "BridgeBase5";
- }
- else if (tBridgeBottomBaseQuickAdd == BridgeBottomBaseDefaultsEnum.BridgeBase6)
- {
- tBridgeBottomBaseToAdd = GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Mesh/RoadObj/Bridges/BridgeBase6-6L.fbx";
- tName = "BridgeArchBeam80";
- }
- else if (tBridgeBottomBaseQuickAdd == BridgeBottomBaseDefaultsEnum.BridgeBase7)
- {
- tBridgeBottomBaseToAdd = GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Mesh/RoadObj/Bridges/BridgeBase7-6L.fbx";
- tName = "BridgeArchSolid80";
- }
- else if (tBridgeBottomBaseQuickAdd == BridgeBottomBaseDefaultsEnum.BridgeBase8)
- {
- tBridgeBottomBaseToAdd = GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Mesh/RoadObj/Bridges/BridgeBase8-6L.fbx";
- tName = "BridgeArchSolid180";
- }
- else if (tBridgeBottomBaseQuickAdd == BridgeBottomBaseDefaultsEnum.BridgeBaseGrid)
- {
- tBridgeBottomBaseToAdd = GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Mesh/RoadObj/Bridges/BridgeBaseGrid-38w-5l-5d.fbx";
- tName = "BridgeGrid";
- }
- else if (tBridgeBottomBaseQuickAdd == BridgeBottomBaseDefaultsEnum.BridgeSteel)
- {
- tBridgeBottomBaseToAdd = GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Mesh/RoadObj/Bridges/BridgeBaseSteelBeam-38w-20l-3d.fbx";
- tName = "BridgeBeams";
- }
- }
-
- if (bOverridePrefab) { tBridgeBottomBaseToAdd = OverridePrefab; }
-
- SMM.CurrentSplination = (GameObject)UnityEditor.AssetDatabase.LoadAssetAtPath(tBridgeBottomBaseToAdd, typeof(GameObject));
- SMM.HorizontalSep = tHorizSep;
- SMM.VerticalRaise = tVertRaise;
- SMM.bMaterialOverride = true;
- SMM.tName = tName;
-
- if (tBridgeBottomBaseQuickAdd == BridgeBottomBaseDefaultsEnum.BridgeBase2)
- {
- SMM.SplinatedMaterial1 = GSD.Roads.GSDRoadUtilityEditor.GiveMaterial(tMat);
- }
- else if (tBridgeBottomBaseQuickAdd == BridgeBottomBaseDefaultsEnum.BridgeBase3)
- {
- SMM.SplinatedMaterial1 = GSD.Roads.GSDRoadUtilityEditor.GiveMaterial(tMat);
- }
- else if (tBridgeBottomBaseQuickAdd == BridgeBottomBaseDefaultsEnum.BridgeBase4)
- {
- SMM.SplinatedMaterial1 = GSD.Roads.GSDRoadUtilityEditor.GiveMaterial(tMat);
- }
- else if (tBridgeBottomBaseQuickAdd == BridgeBottomBaseDefaultsEnum.BridgeBase5)
- {
- SMM.SplinatedMaterial1 = GSD.Roads.GSDRoadUtilityEditor.GiveMaterial(tMat);
- }
- else if (tBridgeBottomBaseQuickAdd == BridgeBottomBaseDefaultsEnum.BridgeBase6)
- {
- SMM.SplinatedMaterial1 = GSD.Roads.GSDRoadUtilityEditor.GiveMaterial(tMat);
- }
- else if (tBridgeBottomBaseQuickAdd == BridgeBottomBaseDefaultsEnum.BridgeBase7)
- {
- SMM.SplinatedMaterial1 = GSD.Roads.GSDRoadUtilityEditor.GiveMaterial(tMat);
- }
- else if (tBridgeBottomBaseQuickAdd == BridgeBottomBaseDefaultsEnum.BridgeBase8)
- {
- SMM.SplinatedMaterial1 = GSD.Roads.GSDRoadUtilityEditor.GiveMaterial(tMat);
- }
- else if (tBridgeBottomBaseQuickAdd == BridgeBottomBaseDefaultsEnum.BridgeBaseGrid)
- {
- SMM.SplinatedMaterial1 = GSD.Roads.GSDRoadUtilityEditor.GiveMaterial(GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Materials/GSDSteel7.mat");
- }
- else if (tBridgeBottomBaseQuickAdd == BridgeBottomBaseDefaultsEnum.BridgeSteel)
- {
- SMM.SplinatedMaterial1 = GSD.Roads.GSDRoadUtilityEditor.GiveMaterial(GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Materials/GSDSteel7.mat");
- }
-
- SMM.Axis = GSD.Roads.Splination.AxisTypeEnum.Z;
-
- tBridgeTopBaseQuickAdd = BridgeTopBaseDefaultsEnum.None;
- if (SMM.StartTime < tNode.MinSplination) { SMM.StartTime = tNode.MinSplination; }
- if (SMM.EndTime > tNode.MaxSplination) { SMM.EndTime = tNode.MaxSplination; }
- }
-
- private void ExtrusionQuickAdd(bool bHorizOverride = false, float tHorizSep = 0f, bool bVertOverride = false, float tVertRaise = 0f)
- {
- try
- {
- ExtrusionQuickAdd_Do();
- }
- catch (System.Exception e)
- {
- tSMMQuickAdd = SMMDefaultsEnum.None;
- throw e;
- }
- }
-
- private void ExtrusionQuickAdd_Do()
- {
- if (tSMMQuickAdd == SMMDefaultsEnum.KRail)
- {
- tNode.SplinatedObjectQuickAdd("KRail");
- }
- }
-
- private void ExtrudeHelper(string tPath, string tName, float DefaultHoriz, GSD.Roads.Splination.AxisTypeEnum tAxis = GSD.Roads.Splination.AxisTypeEnum.Z, bool bHorizOverride = false, float tHorizSep = 0f, bool bVertOverride = false, float tVertRaise = 0f, bool bFlipRot = false)
- {
- SMM = tNode.AddSplinatedObject();
- SMM.CurrentSplination = (GameObject)UnityEditor.AssetDatabase.LoadAssetAtPath(tPath, typeof(GameObject));
-
- if (bHorizOverride)
- {
- SMM.HorizontalSep = tHorizSep;
- }
- else
- {
- SMM.HorizontalSep = ((tNode.GSDSpline.tRoad.RoadWidth() / 2) + tNode.GSDSpline.tRoad.opt_ShoulderWidth) * -1f;
- }
-
- if (bVertOverride)
- {
- SMM.VerticalRaise = tVertRaise;
- }
- else
- {
- if (tNode.bIsBridgeStart) { SMM.VerticalRaise = -0.01f; }
- }
-
- SMM.bFlipRotation = bFlipRot;
- SMM.Axis = tAxis;
- if (SMM.StartTime < tNode.MinSplination) { SMM.StartTime = tNode.MinSplination; }
- if (SMM.EndTime > tNode.MaxSplination) { SMM.EndTime = tNode.MaxSplination; }
- SMM.tName = tName;
- }
- #endregion
-
- public void OnSceneGUI()
- {
- Event current = Event.current;
- int controlID = GUIUtility.GetControlID(GetHashCode(), FocusType.Passive);
- bool bUsed = false;
-
- if (!bSceneRectSet)
- {
- try
- {
- tSceneRect = EditorWindow.GetWindow().position;
- }
- catch
- {
- tSceneRect = EditorWindow.GetWindow().position;
- }
- bSceneRectSet = true;
- }
-
- if (!tNode.bEditorSelected)
- {
- tNode.bEditorSelected = true;
- }
-
- if (current.type == EventType.ValidateCommand)
- {
- switch (current.commandName)
- {
- case "UndoRedoPerformed":
- UpdateSplineObjects_OnUndo();
- break;
- }
- }
-
- if (controlID != tNode.GetHashCode()) { tNode.bEditorSelected = false; }
-
- //Drag with left click:
- if (Event.current.type == EventType.MouseDrag && Event.current.button == 0)
- {
- bMouseDragHasProcessed = false;
- tNode.bGizmoDrawIntersectionHighlight = true;
- }
- //Drag with left click release:
- if (Event.current.type == EventType.MouseUp && Event.current.button == 0)
- {
- Object[] xNodeObjects = GameObject.FindObjectsOfType(typeof(GSDSplineN));
- Object[] connectorObjects = GameObject.FindObjectsOfType(typeof(GSDRoadConnector));
- foreach (GSDSplineN xNode in xNodeObjects)
- {
- if (Vector3.Distance(xNode.transform.position, tNode.transform.position) < 2f)
- {
- if (xNode == tNode) { continue; }
- if (tNode.bSpecialEndNode || xNode.bSpecialEndNode) { continue; }
- if (xNode.bIsEndPoint && tNode.bIsEndPoint)
- {
- //End point connection.
- tNode.transform.position = xNode.transform.position;
- //Activate special end node for tnode
- TriggerRoadConnection(tNode, xNode);
- bUsed = true;
- break;
- }
- if (xNode.bIsIntersection) { continue; }
- if (xNode.bNeverIntersect) { continue; }
- if (tNode.bIsEndPoint && xNode.bIsEndPoint) { continue; }
- if (xNode.GSDSpline == tNode.GSDSpline)
- { //Don't let intersection be created on consecutive nodes:
- if ((tNode.idOnSpline + 1) == xNode.idOnSpline || (tNode.idOnSpline - 1) == xNode.idOnSpline)
- {
- continue;
- }
- }
- tNode.transform.position = xNode.transform.position;
- TriggerIntersection(tNode, xNode);
- bUsed = true;
- break;
- }
- else
- {
- continue;
- }
- }
- foreach (GSDRoadConnector connector in connectorObjects)
- {
- if (Vector3.Distance(connector.transform.position, tNode.transform.position) < 2f)
- {
- if (connector.connectedNode != null) continue;
- connector.ConnectToNode(tNode);
- break;
- }
- }
-
- if (!bMouseDragHasProcessed)
- {
- //Enforce maximum road grade:
- if (tNode.IsLegitimate() && tNode.GSDSpline.tRoad.opt_bMaxGradeEnabled)
- {
- tNode.EnsureGradeValidity();
- }
- TriggerRoadUpdate();
- bUsed = true;
- }
- bMouseDragHasProcessed = true;
- tNode.bGizmoDrawIntersectionHighlight = false;
- bUsed = true;
- }
-
- //Enforce maximum road grade:
- if (bMouseDragHasProcessed)
- {
-
- Vector3 vChangeChecker = tNode.transform.position;
- if (VectorDiff(vChangeChecker, tNode.pos))
- {
- tNode.pos = vChangeChecker;
- if (tNode.IsLegitimate() && tNode.GSDSpline.tRoad.opt_bMaxGradeEnabled)
- {
- tNode.EnsureGradeValidity();
- }
- TriggerRoadUpdate();
- }
- bUsed = true;
- }
-
- if (Selection.activeGameObject == tNode.transform.gameObject)
- {
- if (current.keyCode == KeyCode.F5)
- {
- TriggerRoadUpdate();
- }
- }
-
- if (bUsed)
- {
- // switch(current.type){
- // case EventType.layout:
- // HandleUtility.AddDefaultControl(controlID);
- // break;
- // }
- }
-
- if (GUI.changed)
- {
- EditorUtility.SetDirty(tNode);
- }
- }
-
- private bool VectorDiff(Vector3 tVect1, Vector3 tVect2)
- {
- if (!GSDRootUtil.IsApproximately(tVect1.x, tVect2.x, 0.0001f))
- {
- return true;
- }
- if (!GSDRootUtil.IsApproximately(tVect1.y, tVect2.y, 0.0001f))
- {
- return true;
- }
- if (!GSDRootUtil.IsApproximately(tVect1.z, tVect2.z, 0.0001f))
- {
- return true;
- }
- return false;
- }
-
- private void TriggerRoadConnection(GSDSplineN tNode1, GSDSplineN tNode2)
- {
- tNode.GSDSpline.ActivateEndNodeConnection(tNode1, tNode2);
- }
-
- private void TriggerIntersection(GSDSplineN tNode1, GSDSplineN tNode2)
- {
- bCreateIntersection = true;
- iNode1 = tNode1;
- iNode2 = tNode2;
- Selection.activeGameObject = GSD.Roads.GSDIntersections.CreateIntersection(tNode1, tNode2);
- }
-
- private void TriggerRoadUpdate()
- {
- if (tNode != null)
- {
- tNode.GSDSpline.tRoad.EditorUpdateMe = true;
- }
- }
-
- void Line()
- {
- GUILayout.Space(4f);
- GUILayout.Box("", GUILayout.ExpandWidth(true), GUILayout.Height(1f)); //Horizontal bar
- GUILayout.Space(4f);
- }
-
- void LineSmall()
- {
- GUILayout.Space(2f);
- GUILayout.Box("", GUILayout.ExpandWidth(true), GUILayout.Height(1f)); //Horizontal bar
- GUILayout.Space(2f);
- }
-
- void BigLine()
- {
- GUILayout.Space(4f);
- GUILayout.Box("", GUILayout.ExpandWidth(true), GUILayout.Height(4f)); //Horizontal bar
- GUILayout.Space(4f);
- }
-
- void ResetCurve(ref AnimationCurve tCurve)
- {
- tCurve = null;
- tCurve = new AnimationCurve();
- EnforceCurve(ref tCurve);
- }
-
- bool V3Equal(ref Vector3 V1, ref Vector3 V2)
- {
- if (!GSDRootUtil.IsApproximately(V1.x, V2.x, 0.001f))
- {
- return false;
- }
- if (!GSDRootUtil.IsApproximately(V1.y, V2.y, 0.001f))
- {
- return false;
- }
- if (!GSDRootUtil.IsApproximately(V1.z, V2.z, 0.001f))
- {
- return false;
- }
- return true;
- }
-
- void EnforceCurve(ref AnimationCurve tCurve)
- {
- if (tCurve == null)
- return;
- if (tCurve.keys.Length == 0)
- {
- tCurve.AddKey(0f, 1f);
- tCurve.AddKey(1f, 1f);
- }
- else if (tCurve.keys.Length == 1)
- {
- tCurve.keys[0].time = 0f;
- tCurve.AddKey(1f, 1f);
- }
- }
-
- GameObject GetEndObjectQuickAdd()
- {
- string tPath = "";
- if (tEndObjectAdd == EndObjectsDefaultsEnum.WarningSign1_Static)
- {
- tPath = GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Mesh/RoadObj/Interactive/GSDWarningSign_Static.prefab";
- }
- else if (tEndObjectAdd == EndObjectsDefaultsEnum.WarningSign2_Static)
- {
- tPath = GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Mesh/RoadObj/Interactive/GSDWarningSign2_Static.prefab";
- }
- else if (tEndObjectAdd == EndObjectsDefaultsEnum.Atten_Static)
- {
- tPath = GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Mesh/RoadObj/Interactive/GSDAtten_Static.prefab";
- }
- else if (tEndObjectAdd == EndObjectsDefaultsEnum.Barrel1_Static)
- {
- tPath = GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Mesh/RoadObj/Interactive/GSDRoadBarrel_Static.prefab";
- }
- else if (tEndObjectAdd == EndObjectsDefaultsEnum.Barrel1_Rigid)
- {
- tPath = GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Mesh/RoadObj/Interactive/GSDRoadBarrel_Rigid.prefab";
- }
- else if (tEndObjectAdd == EndObjectsDefaultsEnum.Barrel3_Static)
- {
- tPath = GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Mesh/RoadObj/Interactive/GSDRoadBarrel3_Static.prefab";
- }
- else if (tEndObjectAdd == EndObjectsDefaultsEnum.Barrel3_Rigid)
- {
- tPath = GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Mesh/RoadObj/Interactive/GSDRoadBarrel3_Rigid.prefab";
- }
- else if (tEndObjectAdd == EndObjectsDefaultsEnum.Barrel7_Static)
- {
- tPath = GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Mesh/RoadObj/Interactive/GSDRoadBarrel7_Static.prefab";
- }
- else if (tEndObjectAdd == EndObjectsDefaultsEnum.Barrel7_Rigid)
- {
- tPath = GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Mesh/RoadObj/Interactive/GSDRoadBarrel7_Rigid.prefab";
- }
- else
- {
- return null;
- }
-
- return (GameObject)UnityEditor.AssetDatabase.LoadAssetAtPath(tPath, typeof(GameObject)) as GameObject;
- }
-}
+#region "Imports"
+using UnityEngine;
+using UnityEditor;
+using System.Collections;
+using System.Collections.Generic;
+using GSD;
+#endregion
+
+
+//=====================================================
+//== NOTE THAT CUSTOM SERIALIZATION IS USED HERE ==
+//== SOLELY TO COMPLY WITH UNDO REQUIREMENTS ==
+//=====================================================
+
+[CustomEditor(typeof(GSDSplineN))]
+public class GSDSplineNEditor : Editor
+{
+ #region "Vars"
+ protected GSDSplineN tNode { get { return (GSDSplineN) target; } }
+ const string tOnlineHelpDesc = "Visit the online manual for the most effective help.";
+ bool bMouseDragHasProcessed = true;
+ int eCount = -1;
+ int currentCount = 0;
+ public bool bSplinatedObjectHelp = false;
+ public bool bEdgeObjectHelp = false;
+ bool bRemoveAll = false;
+ float HorizRoadMax = 0;
+
+
+ #region Button icons:
+ Texture btnDeleteText = null;
+ Texture btnCopyText = null;
+ Texture btnSaveText = null;
+ Texture btnLoadText = null;
+ Texture btnExtrudeText = null;
+ Texture btnEdgeText = null;
+ Texture btnHelpText = null;
+ Texture btnRefreshText = null;
+ Texture btnDefaultText = null;
+ Texture2D LoadBtnBG = null;
+ Texture2D GSDTextAreaBG = null;
+ Texture2D LoadBtnBGGlow = null;
+ Texture2D ManualBG = null;
+ #endregion
+
+
+ public bool bLoadingEOS = false;
+ public int LoadingEOSIndex = 0;
+ public List LoadingEOSNames = null;
+ public List LoadingEOSPaths = null;
+
+ public bool bLoadingEOM = false;
+ public int LoadingEOMIndex = 0;
+ public List LoadingEOMNames = null;
+ public List LoadingEOMPaths = null;
+
+ //Checkers:
+ // float ChangeChecker = -1f;
+ // bool bChangeChecker = false;
+ // Vector3 vChangeChecker = default(Vector3);
+ // GameObject tObj = null;
+ // Material tMat = null;
+ GSD.Roads.Splination.SplinatedMeshMaker SMM = null;
+
+
+ #region "Enums"
+ public enum EndObjectsDefaultsEnum
+ {
+ None,
+ WarningSign1_Static,
+ WarningSign2_Static,
+ Atten_Static,
+ Barrel1_Static,
+ Barrel1_Rigid,
+ Barrel3_Static,
+ Barrel3_Rigid,
+ Barrel7_Static,
+ Barrel7_Rigid
+ };
+
+
+ EndObjectsDefaultsEnum tEndObjectAdd = EndObjectsDefaultsEnum.None;
+
+
+ private static string[] EndObjectsDefaultsEnumDesc = new string[]{
+ "Quick add",
+ "WarningSign1",
+ "WarningSign2",
+ "Attenuator",
+ "1 Sand barrel Static",
+ "1 Sand barrel Rigid",
+ "3 Sand barrels Static",
+ "3 Sand barrels Rigid",
+ "7 Sand barrels Static",
+ "7 Sand barrels Rigid"
+ };
+
+
+ public enum SMMDefaultsEnum
+ {
+ None, Custom,
+ KRail,
+ WBeamR,
+ WBeamL,
+ Railing1,
+ Railing2,
+ Railing3,
+ Railing4,
+ RailingBase05m,
+ RailingBase1m
+ };
+
+
+ SMMDefaultsEnum tSMMQuickAdd = SMMDefaultsEnum.None;
+
+
+ public enum BridgeTopBaseDefaultsEnum
+ {
+ None,
+ BaseExact,
+ Base1MOver,
+ Base2MOver,
+ Base3MDeep,
+ };
+
+
+ BridgeTopBaseDefaultsEnum tBridgeTopBaseQuickAdd = BridgeTopBaseDefaultsEnum.None;
+
+
+ public enum BridgeBottomBaseDefaultsEnum
+ {
+ None,
+ BridgeBase6,
+ BridgeBase7,
+ BridgeBase8,
+ BridgeBaseGrid,
+ BridgeSteel,
+ BridgeBase2,
+ BridgeBase3,
+ BridgeBase4,
+ BridgeBase5,
+ };
+
+
+ BridgeBottomBaseDefaultsEnum tBridgeBottomBaseQuickAdd = BridgeBottomBaseDefaultsEnum.None;
+
+
+ public enum BridgeWizardDefaultsEnum
+ {
+ None,
+ ArchBridge12m,
+ ArchBridge24m,
+ ArchBridge48m,
+ SuspensionBridgeSmall,
+ SuspensionBridgeLarge,
+ CausewayBridge1,
+ CausewayBridge2,
+ CausewayBridge3,
+ CausewayBridge4,
+ ArchBridge1,
+ ArchBridge2,
+ ArchBridge3,
+ GridBridge,
+ SteelBeamBridge
+ };
+ // BridgeWizardDefaultsEnum tBridgeWizardQuickAdd = BridgeWizardDefaultsEnum.None;
+
+
+ public enum HorizMatchingDefaultsEnum
+ {
+ None,
+ MatchCenter,
+ MatchRoadLeft,
+ MatchShoulderLeft,
+ MatchRoadRight,
+ MatchShoulderRight
+ };
+
+
+ HorizMatchingDefaultsEnum tHorizMatching = HorizMatchingDefaultsEnum.None;
+
+
+ public enum EOMDefaultsEnum { None, Custom, StreetLightSingle, StreetLightDouble };
+ #endregion
+
+
+ //GSD.Roads.Splination.CollisionTypeEnum tCollisionTypeSpline = GSD.Roads.Splination.CollisionTypeEnum.SimpleMeshTriangle;
+ //GSD.Roads.Splination.RepeatUVTypeEnum tRepeatUVType = GSD.Roads.Splination.RepeatUVTypeEnum.None;
+ GSD.Roads.EdgeObjects.EdgeObjectMaker EOM = null;
+
+
+ private static string[] TheAxisDescriptions_Spline = new string[]{
+ "X axis",
+ "Z axis"
+ };
+
+
+ private static string[] RepeatUVTypeDescriptions_Spline = new string[]{
+ "None",
+ "X axis",
+ "Y axis"
+ };
+
+
+ private static string[] TheCollisionTypeEnumDescSpline = new string[]{
+ "None",
+ "Simple triangle",
+ "Simple trapezoid",
+ "Meshfilter collision mesh",
+ "Straight line box collider"
+ };
+
+
+ private string[] HorizMatchSubTypeDescriptions;
+ #endregion
+
+ GUIStyle GSDImageButton = null;
+ GUIStyle GSDLoadButton = null;
+ GUIStyle GSDManualButton = null;
+ GUIStyle GSDUrl = null;
+
+ bool bSceneRectSet = false;
+ Rect tSceneRect = default(Rect);
+
+ bool bHasInit = false;
+
+ //Buffers:
+ // bool t_opt_GizmosEnabled = false;
+ bool t_opt_GizmosEnabled = false;
+
+ // Bridge
+ bool t_bIsBridgeStart = false;
+ bool t_bIsBridgeEnd = false;
+
+ bool t_bRoadCut = false;
+
+
+ void Init()
+ {
+ bHasInit = true;
+ EditorStyles.label.wordWrap = true;
+ EditorStyles.miniLabel.wordWrap = true;
+
+ if (btnDeleteText == null)
+ {
+ btnDeleteText = (Texture) AssetDatabase.LoadAssetAtPath(GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Editor/Icons/delete.png", typeof(Texture)) as Texture;
+ }
+ if (btnCopyText == null)
+ {
+ btnCopyText = (Texture) AssetDatabase.LoadAssetAtPath(GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Editor/Icons/copy.png", typeof(Texture)) as Texture;
+ }
+ if (btnLoadText == null)
+ {
+ btnLoadText = (Texture) AssetDatabase.LoadAssetAtPath(GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Editor/Icons/load.png", typeof(Texture)) as Texture;
+ }
+ if (btnSaveText == null)
+ {
+ btnSaveText = (Texture) AssetDatabase.LoadAssetAtPath(GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Editor/Icons/save.png", typeof(Texture)) as Texture;
+ }
+ if (btnExtrudeText == null)
+ {
+ btnExtrudeText = (Texture) AssetDatabase.LoadAssetAtPath(GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Editor/Icons/extrude.png", typeof(Texture)) as Texture;
+ }
+ if (btnEdgeText == null)
+ {
+ btnEdgeText = (Texture) AssetDatabase.LoadAssetAtPath(GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Editor/Icons/edge.png", typeof(Texture)) as Texture;
+ }
+ if (btnHelpText == null)
+ {
+ btnHelpText = (Texture) AssetDatabase.LoadAssetAtPath(GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Editor/Icons/help.png", typeof(Texture)) as Texture;
+ }
+ if (GSDTextAreaBG == null)
+ {
+ GSDTextAreaBG = (Texture2D) AssetDatabase.LoadAssetAtPath(GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Editor/Icons/popupbg.png", typeof(Texture2D)) as Texture2D;
+ }
+ if (LoadBtnBG == null)
+ {
+ LoadBtnBG = (Texture2D) AssetDatabase.LoadAssetAtPath(GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Editor/Icons/loadbg.png", typeof(Texture2D)) as Texture2D;
+ }
+ if (LoadBtnBGGlow == null)
+ {
+ LoadBtnBGGlow = (Texture2D) AssetDatabase.LoadAssetAtPath(GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Editor/Icons/loadbgglow.png", typeof(Texture2D)) as Texture2D;
+ }
+ if (ManualBG == null)
+ {
+ ManualBG = (Texture2D) AssetDatabase.LoadAssetAtPath(GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Editor/Icons/manualbg.png", typeof(Texture2D)) as Texture2D;
+ }
+ if (btnRefreshText == null)
+ {
+ btnRefreshText = (Texture) AssetDatabase.LoadAssetAtPath(GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Editor/Icons/refresh.png", typeof(Texture)) as Texture;
+ }
+ if (btnDefaultText == null)
+ {
+ btnDefaultText = (Texture) AssetDatabase.LoadAssetAtPath(GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Editor/Icons/refresh2.png", typeof(Texture)) as Texture;
+ }
+
+ if (GSDImageButton == null)
+ {
+ GSDImageButton = new GUIStyle(GUI.skin.button);
+ GSDImageButton.contentOffset = new Vector2(0f, -2f);
+ GSDImageButton.border = new RectOffset(0, 0, 0, 0);
+ GSDImageButton.fixedHeight = 16f;
+ GSDImageButton.padding = new RectOffset(0, 0, 0, 0);
+ GSDImageButton.normal.background = null;
+ }
+
+ if (GSDLoadButton == null)
+ {
+ GSDLoadButton = new GUIStyle(GUI.skin.button);
+ GSDLoadButton.contentOffset = new Vector2(0f, 1f);
+ GSDLoadButton.normal.textColor = new Color(1f, 1f, 1f, 1f);
+ GSDLoadButton.normal.background = LoadBtnBG;
+ GSDLoadButton.active.background = LoadBtnBGGlow;
+ GSDLoadButton.focused.background = LoadBtnBGGlow;
+ GSDLoadButton.hover.background = LoadBtnBGGlow;
+ GSDLoadButton.fixedHeight = 16f;
+ GSDLoadButton.fixedWidth = 128f;
+ GSDLoadButton.padding = new RectOffset(0, 35, 0, 0);
+ }
+
+ if (GSDManualButton == null)
+ {
+ GSDManualButton = new GUIStyle(GUI.skin.button);
+ GSDManualButton.contentOffset = new Vector2(0f, 1f);
+ GSDManualButton.normal.textColor = new Color(1f, 1f, 1f, 1f);
+ GSDManualButton.normal.background = ManualBG;
+ GSDManualButton.fixedHeight = 16f;
+ GSDManualButton.fixedWidth = 128f;
+ }
+
+ if (GSDUrl == null)
+ {
+ GSDUrl = new GUIStyle(GUI.skin.button);
+ GSDUrl.normal.textColor = new Color(0.5f, 1f, 0.5f, 1f);
+ }
+
+ float tRoadWidthHalf = tNode.GSDSpline.tRoad.RoadWidth() * 0.5f;
+ HorizMatchSubTypeDescriptions = new string[6];
+ HorizMatchSubTypeDescriptions[0] = "Select preset";
+ HorizMatchSubTypeDescriptions[1] = "Match center: 0 meters";
+ HorizMatchSubTypeDescriptions[2] = "Match road left edge: -" + tRoadWidthHalf.ToString("F1") + " meters";
+ HorizMatchSubTypeDescriptions[4] = "Match road right edge: " + tRoadWidthHalf.ToString("F1") + " meters";
+
+ if (tNode.GSDSpline.tRoad.opt_bShouldersEnabled)
+ {
+ HorizMatchSubTypeDescriptions[3] = "Match shoulder left edge: -" + (tRoadWidthHalf + tNode.GSDSpline.tRoad.opt_ShoulderWidth).ToString("F1") + " meters";
+ HorizMatchSubTypeDescriptions[5] = "Match shoulder right edge: " + (tRoadWidthHalf + tNode.GSDSpline.tRoad.opt_ShoulderWidth).ToString("F1") + " meters";
+ }
+ else
+ {
+ HorizMatchSubTypeDescriptions[2] = "Match shoulder left edge: -" + tRoadWidthHalf.ToString("F1") + " meters";
+ HorizMatchSubTypeDescriptions[4] = "Match shoulder right edge: " + tRoadWidthHalf.ToString("F1") + " meters";
+ }
+
+ HorizRoadMax = tNode.GSDSpline.tRoad.RoadWidth() * 20;
+ }
+
+
+ GSDSplineN iNode1 = null;
+ GSDSplineN iNode2 = null;
+ bool bCreateIntersection = false;
+
+
+ public override void OnInspectorGUI()
+ {
+ if (Event.current.type == EventType.ValidateCommand)
+ {
+ switch (Event.current.commandName)
+ {
+ case "UndoRedoPerformed":
+ UpdateSplineObjects_OnUndo();
+ break;
+ }
+ }
+
+ if (Event.current.type != EventType.Layout && bCreateIntersection)
+ {
+ bCreateIntersection = false;
+ Selection.activeGameObject = GSD.Roads.GSDIntersections.CreateIntersection(iNode1, iNode2);
+ return;
+ }
+
+
+ if (Event.current.type != EventType.Layout && tNode.bQuitGUI)
+ {
+ tNode.bQuitGUI = false;
+ return;
+ }
+
+ //Graphic null checks:
+ if (!bHasInit)
+ {
+ Init();
+ }
+
+ Line();
+
+ #region Online Manual on Top of SplineN Scripts
+ EditorGUILayout.BeginHorizontal();
+ EditorGUILayout.LabelField(tNode.EditorDisplayString, EditorStyles.boldLabel);
+
+ if (GUILayout.Button("Online manual", EditorStyles.miniButton, GUILayout.Width(128f)))
+ {
+ Application.OpenURL("http://microgsd.com/Support/RoadArchitectManual.aspx");
+ }
+ EditorGUILayout.EndHorizontal();
+ #endregion
+
+
+ #region Option: Gizmo options, Convoluted due to submission compliance for undo rules:
+ if (tNode.GSDSpline.tRoad.opt_GizmosEnabled != tNode.opt_GizmosEnabled)
+ {
+ tNode.GSDSpline.tRoad.opt_GizmosEnabled = tNode.opt_GizmosEnabled;
+ tNode.GSDSpline.tRoad.UpdateGizmoOptions();
+ tNode.GSDSpline.tRoad.Wireframes_Toggle();
+ }
+ t_opt_GizmosEnabled = EditorGUILayout.Toggle("Gizmos: ", tNode.GSDSpline.tRoad.opt_GizmosEnabled);
+ #endregion
+
+
+ #region Option: Manual road cut:
+ if (tNode.idOnSpline > 0 && tNode.idOnSpline < (tNode.GSDSpline.GetNodeCount() - 1) && !tNode.bIsIntersection && !tNode.bSpecialEndNode)
+ { // && !cNode.bIsBridge_PreNode && !cNode.bIsBridge_PostNode){
+ if (tNode.GSDSpline.tRoad.opt_bDynamicCuts)
+ {
+ Line();
+ t_bRoadCut = EditorGUILayout.Toggle("Cut road at this node: ", tNode.bRoadCut);
+ }
+ Line();
+ }
+ #endregion
+
+
+ //Option: Bridge options
+ bool bDidBridge = false;
+ if (!tNode.bIsEndPoint)
+ {
+ //Bridge start:
+ if (!tNode.bIsBridgeEnd && tNode.CanBridgeStart())
+ {
+ t_bIsBridgeStart = EditorGUILayout.Toggle(" Bridge start", tNode.bIsBridgeStart);
+ bDidBridge = true;
+ }
+ //Bridge end:
+ if (!tNode.bIsBridgeStart && tNode.CanBridgeEnd())
+ {
+ t_bIsBridgeEnd = EditorGUILayout.Toggle(" Bridge end", tNode.bIsBridgeEnd);
+ bDidBridge = true;
+ }
+
+ if (bDidBridge)
+ {
+ Line();
+ }
+ }
+
+
+
+ if ((Selection.objects.Length == 1 && Selection.objects[0] is GSDSplineN) || (tNode.SpecialNodeCounterpart == null && !tNode.bSpecialRoadConnPrimary))
+ {
+ //Do extrusion and edge objects overview:
+ DoExtAndEdgeOverview();
+ }
+ else
+ {
+ EditorGUILayout.BeginHorizontal();
+ if (GUILayout.Button("Road objects"))
+ {
+ Selection.objects = new Object[1] { tNode.SpecialNodeCounterpart };
+ }
+ EditorGUILayout.EndHorizontal();
+ }
+
+ if (tNode.bSpecialRoadConnPrimary)
+ {
+ EditorGUILayout.BeginHorizontal();
+ EditorGUILayout.LabelField("Road connection:", EditorStyles.boldLabel);
+ EditorGUILayout.EndHorizontal();
+ EditorGUILayout.BeginVertical();
+ if (GUILayout.Button("Update road connection"))
+ {
+ GSDSplineN tNode1 = tNode.OriginalConnectionNodes[0];
+ GSDSplineN tNode2 = tNode.OriginalConnectionNodes[1];
+ tNode.SpecialNodeCounterpart.BreakConnection();
+ tNode.GSDSpline.tRoad.UpdateRoad();
+ tNode1.GSDSpline.ActivateEndNodeConnection(tNode1, tNode2);
+ }
+ if (GUILayout.Button("Break road connection"))
+ {
+ tNode.SpecialNodeCounterpart.BreakConnection();
+ }
+ if (GUILayout.Button("Access objects on other node"))
+ {
+ Selection.objects = new Object[] { tNode.SpecialNodeCounterpart };
+ }
+ EditorGUILayout.EndVertical();
+ if (tNode.SpecialNodeCounterpart != null)
+ {
+ EditorGUILayout.LabelField(tNode.SpecialNodeCounterpart.GSDSpline.tRoad.transform.name + " to " + tNode.SpecialNodeCounterpart.SpecialNodeCounterpart.GSDSpline.tRoad.transform.name);
+ }
+ EditorGUILayout.LabelField("To break this road connection, click the \"Break road connection\" button.");
+ Line();
+ }
+
+ //Statistics:
+ DoStats();
+ EditorGUILayout.EndVertical();
+
+ if (GUI.changed)
+ {
+ //Set snapshot for undo:
+
+ Undo.RecordObject(tNode, "Modify node");
+
+ //Option: Gizmo options, Convoluted due to submission compliance for undo rules:
+ if (t_opt_GizmosEnabled != tNode.GSDSpline.tRoad.opt_GizmosEnabled)
+ {
+ tNode.GSDSpline.tRoad.opt_GizmosEnabled = t_opt_GizmosEnabled;
+ tNode.GSDSpline.tRoad.UpdateGizmoOptions();
+ tNode.GSDSpline.tRoad.Wireframes_Toggle();
+ SceneView.RepaintAll();
+ }
+
+ //Option: Manual cut:
+ if (tNode.idOnSpline > 0 && tNode.idOnSpline < (tNode.GSDSpline.GetNodeCount() - 1) && !tNode.bIsIntersection && !tNode.bSpecialEndNode)
+ { // && !cNode.bIsBridge_PreNode && !cNode.bIsBridge_PostNode){
+ if (tNode.GSDSpline.tRoad.opt_bDynamicCuts)
+ {
+ if (t_bRoadCut != tNode.bRoadCut)
+ {
+ tNode.bRoadCut = t_bRoadCut;
+ }
+ }
+ }
+
+ //Option: Bridge options
+ //Bridge start:
+ if (!tNode.bIsEndPoint)
+ {
+ if (!tNode.bIsBridgeEnd && tNode.CanBridgeStart())
+ {
+ if (t_bIsBridgeStart != tNode.bIsBridgeStart)
+ {
+ tNode.bIsBridgeStart = t_bIsBridgeStart;
+ tNode.BridgeToggleStart();
+ }
+ }
+ }
+ //Bridge end:
+ if (!tNode.bIsEndPoint)
+ {
+ if (!tNode.bIsBridgeStart && tNode.CanBridgeEnd())
+ {
+ if (t_bIsBridgeEnd != tNode.bIsBridgeEnd)
+ {
+ tNode.bIsBridgeEnd = t_bIsBridgeEnd;
+ tNode.BridgeToggleEnd();
+ }
+ }
+ }
+
+ UpdateSplineObjects();
+ UpdateEdgeObjects();
+
+ EditorUtility.SetDirty(target);
+ }
+ }
+
+
+ void OnSelectionChanged()
+ {
+ Repaint();
+ }
+
+
+ //GUIStyle SectionBG;
+
+
+ void DoExtAndEdgeOverview()
+ {
+ EditorGUILayout.BeginHorizontal();
+ EditorGUILayout.LabelField("Extrusion & edge objects", EditorStyles.boldLabel);
+ EditorGUILayout.LabelField("");
+ EditorGUILayout.EndHorizontal();
+
+ EditorGUILayout.BeginHorizontal();
+ if (bEdgeObjectHelp)
+ {
+ bEdgeObjectHelp = EditorGUILayout.Foldout(bEdgeObjectHelp, "Hide quick help");
+ }
+ else
+ {
+ bEdgeObjectHelp = EditorGUILayout.Foldout(bEdgeObjectHelp, "Show quick help");
+ }
+ EditorGUILayout.LabelField("");
+
+ if (GUILayout.Button("Save group", EditorStyles.miniButton, GUILayout.Width(108f)) || GUILayout.Button(btnSaveText, GSDImageButton, GUILayout.Width(16f)))
+ {
+ GSDSaveWindow tSave = EditorWindow.GetWindow();
+ if (tNode.bIsBridge)
+ {
+ tSave.Initialize(ref tSceneRect, GSDSaveWindow.WindowTypeEnum.BridgeWizard, tNode);
+ }
+ else
+ {
+ tSave.Initialize(ref tSceneRect, GSDSaveWindow.WindowTypeEnum.BridgeWizard, tNode);
+ }
+ }
+ EditorGUILayout.EndHorizontal();
+ GUILayout.Space(4f);
+
+ EditorGUILayout.BeginHorizontal();
+ EditorGUILayout.LabelField("");
+ if (GUILayout.Button("Open Wizard", GSDLoadButton, GUILayout.Width(128f)))
+ {// || GUILayout.Button(btnLoadText,GSDImageButton,GUILayout.Width(16f))){
+ GSDWizard tWiz = EditorWindow.GetWindow();
+ if (tSceneRect.x < 0)
+ {
+ tSceneRect.x = 0f;
+ }
+ if (tSceneRect.y < 0)
+ {
+ tSceneRect.y = 0f;
+ }
+ tWiz.xRect = tSceneRect;
+ if (tNode.bIsBridgeStart)
+ {
+ tWiz.Initialize(GSDWizard.WindowTypeEnum.BridgeComplete, tNode);
+ }
+ else
+ {
+ tWiz.Initialize(GSDWizard.WindowTypeEnum.Extrusion, tNode);
+ }
+ }
+ EditorGUILayout.EndHorizontal();
+ GUILayout.Space(4f);
+
+ if (bEdgeObjectHelp)
+ {
+ EditorGUILayout.BeginVertical("box");
+ EditorGUILayout.BeginHorizontal();
+ if (GUILayout.Button(btnExtrudeText, GSDImageButton, GUILayout.Width(32f)))
+ { }
+ EditorGUILayout.LabelField("= Extrusion objects", EditorStyles.miniLabel);
+ EditorGUILayout.LabelField("");
+ EditorGUILayout.EndHorizontal();
+ EditorGUILayout.LabelField("Railings, bridge pieces, center dividers and other connected objects.", EditorStyles.miniLabel);
+ EditorGUILayout.EndVertical();
+
+ EditorGUILayout.BeginVertical("box");
+ EditorGUILayout.BeginHorizontal();
+ if (GUILayout.Button(btnEdgeText, GSDImageButton, GUILayout.Width(32f)))
+ { }
+ EditorGUILayout.LabelField("= Edge objects", EditorStyles.miniLabel);
+ EditorGUILayout.LabelField("");
+ EditorGUILayout.EndHorizontal();
+ EditorGUILayout.LabelField("Signs, street lights, bridge pillars and other unconnected road objects.", EditorStyles.miniLabel);
+ EditorGUILayout.EndVertical();
+
+ EditorGUILayout.BeginVertical("box");
+ EditorGUILayout.BeginHorizontal();
+ if (GUILayout.Button(btnSaveText, GSDImageButton, GUILayout.Width(16f)))
+ { }
+ EditorGUILayout.LabelField("= Saves object config to library for use on other nodes.", EditorStyles.miniLabel);
+ EditorGUILayout.EndHorizontal();
+ EditorGUILayout.EndVertical();
+
+ EditorGUILayout.BeginVertical("box");
+ EditorGUILayout.BeginHorizontal();
+ if (GUILayout.Button(btnCopyText, GSDImageButton, GUILayout.Width(16f)))
+ { }
+ EditorGUILayout.LabelField("= Duplicates object onto current node.", EditorStyles.miniLabel);
+ EditorGUILayout.EndHorizontal();
+ EditorGUILayout.EndVertical();
+
+ EditorGUILayout.BeginVertical("box");
+ EditorGUILayout.BeginHorizontal();
+ if (GUILayout.Button(btnDeleteText, GSDImageButton, GUILayout.Width(16f)))
+ { }
+ EditorGUILayout.LabelField("= Deletes object.", EditorStyles.miniLabel);
+ EditorGUILayout.EndHorizontal();
+ EditorGUILayout.EndVertical();
+
+ EditorGUILayout.BeginVertical("box");
+ EditorGUILayout.BeginHorizontal();
+ if (GUILayout.Button(btnRefreshText, GSDImageButton, GUILayout.Width(16f)))
+ { }
+ EditorGUILayout.LabelField("= Refreshes object.", EditorStyles.miniLabel);
+ EditorGUILayout.EndHorizontal();
+ EditorGUILayout.EndVertical();
+
+ EditorGUILayout.BeginVertical("box");
+ EditorGUILayout.BeginHorizontal();
+ if (GUILayout.Button(btnDefaultText, GSDImageButton, GUILayout.Width(16f)))
+ { }
+ EditorGUILayout.LabelField("= Resets setting(s) to default.", EditorStyles.miniLabel);
+ EditorGUILayout.EndHorizontal();
+ EditorGUILayout.EndVertical();
+
+ Line();
+ }
+ currentCount = 0;
+
+ GUILayout.Space(2f);
+
+
+ //Splinated objects:
+ DoSplineObjects();
+
+ //Edge Objects:
+ DoEdgeObjects();
+
+ GUILayout.Space(4f);
+ EditorGUILayout.BeginHorizontal();
+ EditorGUILayout.LabelField("");
+ if (GUILayout.Button("Add custom extrusion object", EditorStyles.miniButton))
+ {
+ tNode.AddSplinatedObject();
+ }
+ EditorGUILayout.EndHorizontal();
+ GUILayout.Space(4f);
+ EditorGUILayout.BeginHorizontal();
+ EditorGUILayout.LabelField("");
+ if (GUILayout.Button("Add custom edge object", EditorStyles.miniButton))
+ {
+ tNode.AddEdgeObject();
+ }
+ EditorGUILayout.EndHorizontal();
+
+ if (tNode.SplinatedObjects.Count > 20 || tNode.EdgeObjects.Count > 20)
+ {
+ EditorGUILayout.BeginHorizontal();
+ EditorGUILayout.LabelField("");
+ bRemoveAll = EditorGUILayout.Toggle(bRemoveAll, GUILayout.Width(20f));
+ if (GUILayout.Button("Remove all", EditorStyles.miniButton, GUILayout.Width(100f)))
+ {
+ if (bRemoveAll)
+ {
+ tNode.RemoveAllSplinatedObjects();
+ tNode.RemoveAllEdgeObjects();
+ bRemoveAll = false;
+ }
+ }
+
+ EditorGUILayout.EndHorizontal();
+ }
+ Line();
+ }
+
+
+ void DoStats()
+ {
+ EditorGUILayout.LabelField("Statistics:");
+ EditorGUILayout.BeginVertical("box");
+ EditorGUILayout.LabelField("Grade to next node: " + tNode.GradeToNext);
+ EditorGUILayout.LabelField("Grade to prev node: " + tNode.GradeToPrev);
+ EditorGUILayout.LabelField("Distance from start: " + tNode.tDist.ToString("F3") + " meters");
+ EditorGUILayout.LabelField("% of spline: " + ((tNode.tDist / tNode.GSDSpline.distance) * 100f).ToString("F2") + "%");
+ EditorGUILayout.LabelField("Parameter: " + tNode.tTime);
+ EditorGUILayout.LabelField("Tangent: " + tNode.tangent);
+ EditorGUILayout.LabelField("POS: " + tNode.pos);
+ EditorGUILayout.LabelField("ID on spline: " + tNode.idOnSpline);
+ EditorGUILayout.LabelField("Is intersection node: " + tNode.bIsIntersection);
+ EditorGUILayout.LabelField("Is end node: " + tNode.bIsEndPoint);
+ EditorGUILayout.LabelField("Is bridge start: " + tNode.bIsBridgeStart);
+ EditorGUILayout.LabelField("Is bridge end: " + tNode.bIsBridgeEnd);
+ EditorGUILayout.LabelField("Road: " + tNode.GSDSpline.tRoad.transform.name);
+ EditorGUILayout.LabelField("System: " + tNode.GSDSpline.tRoad.GSDRS.transform.name);
+ EditorGUILayout.SelectableLabel("UID: " + tNode.UID);
+ }
+
+
+ public void DoSplineObjects()
+ {
+ if (!tNode.CanSplinate())
+ {
+ return;
+ }
+ if (tNode.SplinatedObjects == null)
+ {
+ tNode.SplinatedObjects = new List();
+ }
+ eCount = tNode.SplinatedObjects.Count;
+
+ SMM = null;
+ eCount = tNode.SplinatedObjects.Count;
+ if (eCount == 0)
+ {
+
+ }
+
+ for (int index = 0; index < tNode.SplinatedObjects.Count; index++)
+ {
+ currentCount += 1;
+ SMM = tNode.SplinatedObjects[index];
+ if (SMM.EM == null)
+ {
+ SMM.EM = new GSD.Roads.Splination.SplinatedMeshMaker.SplinatedMeshEditorMaker();
+ }
+ SMM.EM.Setup(SMM);
+
+ //GSD.Roads.Splination.AxisTypeEnum tAxisTypeSpline = GSD.Roads.Splination.AxisTypeEnum.Z;
+
+ EditorGUILayout.BeginVertical("TextArea");
+
+ if (SMM.bNeedsUpdate)
+ {
+ SMM.Setup(true);
+ }
+
+
+ EditorGUILayout.BeginHorizontal();
+
+ SMM.bToggle = EditorGUILayout.Foldout(SMM.bToggle, "#" + currentCount.ToString() + ": " + SMM.tName);
+
+ if (GUILayout.Button(btnExtrudeText, GSDImageButton, GUILayout.Width(32f)))
+ {
+
+ }
+
+ if (GUILayout.Button(btnRefreshText, GSDImageButton, GUILayout.Width(16f)))
+ {
+ SMM.Setup();
+ }
+ if (GUILayout.Button(btnSaveText, GSDImageButton, GUILayout.Width(16f)))
+ {
+ GSDSaveWindow tSave = EditorWindow.GetWindow();
+ tSave.Initialize(ref tSceneRect, GSDSaveWindow.WindowTypeEnum.Extrusion, tNode, SMM);
+ }
+ if (GUILayout.Button(btnCopyText, GSDImageButton, GUILayout.Width(16f)))
+ {
+ Undo.RecordObject(tNode, "Copy");
+ tNode.CopySplinatedObject(ref SMM);
+ EditorUtility.SetDirty(tNode);
+ }
+ if (GUILayout.Button(btnDeleteText, GSDImageButton, GUILayout.Width(16f)))
+ {
+ Undo.RecordObject(tNode, "Delete");
+ tNode.RemoveSplinatedObject(index);
+ EditorUtility.SetDirty(tNode);
+ }
+ EditorGUILayout.EndHorizontal();
+ if (!SMM.bToggle)
+ {
+ EditorGUILayout.EndVertical();
+ continue;
+ }
+
+ GUILayout.Space(8f);
+ EditorGUILayout.BeginHorizontal();
+ EditorGUILayout.LabelField("General options:");
+ if (GUILayout.Button("Online manual", EditorStyles.miniButton, GUILayout.Width(120f)))
+ {
+ Application.OpenURL("http://microgsd.com/Support/RoadArchitectManual.aspx");
+ }
+ EditorGUILayout.EndHorizontal();
+
+ EditorGUILayout.BeginVertical("box");
+
+ //Name:
+ SMM.EM.tName = EditorGUILayout.TextField("Name:", SMM.tName);
+
+ //Game object (prefab):
+ SMM.EM.CurrentSplination = (GameObject) EditorGUILayout.ObjectField("Prefab:", SMM.CurrentSplination, typeof(GameObject), false);
+
+ //Game object (prefab start cap):
+ SMM.EM.CurrentSplinationCap1 = (GameObject) EditorGUILayout.ObjectField("Prefab start cap:", SMM.CurrentSplinationCap1, typeof(GameObject), false);
+ //Prefab start cap height offset:
+ if (SMM.CurrentSplinationCap1 != null)
+ {
+ SMM.EM.CapHeightOffset1 = EditorGUILayout.FloatField(" Height offset:", SMM.CapHeightOffset1);
+ }
+
+ //Game object (prefab end cap):
+ SMM.EM.CurrentSplinationCap2 = (GameObject) EditorGUILayout.ObjectField("Prefab end cap:", SMM.CurrentSplinationCap2, typeof(GameObject), false);
+ //Prefab end cap height offset:
+ if (SMM.CurrentSplinationCap2 != null)
+ {
+ SMM.EM.CapHeightOffset2 = EditorGUILayout.FloatField(" Height offset:", SMM.CapHeightOffset2);
+ }
+
+ //Material overrides:
+ SMM.EM.bMaterialOverride = EditorGUILayout.Toggle("Material override: ", SMM.bMaterialOverride);
+ if (SMM.bMaterialOverride)
+ {
+ SMM.EM.SplinatedMaterial1 = (Material) EditorGUILayout.ObjectField("Override mat #1: ", SMM.SplinatedMaterial1, typeof(Material), false);
+ SMM.EM.SplinatedMaterial2 = (Material) EditorGUILayout.ObjectField("Override mat #2: ", SMM.SplinatedMaterial2, typeof(Material), false);
+ }
+
+ //Axis:
+ SMM.EM.Axis = (GSD.Roads.Splination.AxisTypeEnum) EditorGUILayout.Popup("Extrusion axis: ", (int) SMM.Axis, TheAxisDescriptions_Spline, GUILayout.Width(250f));
+
+ //Start time:
+ if (SMM.StartTime < tNode.MinSplination)
+ {
+ SMM.StartTime = tNode.MinSplination;
+ }
+ if (SMM.EndTime > tNode.MaxSplination)
+ {
+ SMM.EndTime = tNode.MaxSplination;
+ }
+ EditorGUILayout.BeginHorizontal();
+
+ SMM.EM.StartTime = EditorGUILayout.Slider("Start param: ", SMM.StartTime, tNode.MinSplination, tNode.MaxSplination - 0.01f);
+ if (GUILayout.Button("match node", EditorStyles.miniButton, GUILayout.Width(80f)))
+ {
+ SMM.EM.StartTime = tNode.tTime;
+ }
+ if (SMM.EM.StartTime >= SMM.EM.EndTime)
+ {
+ SMM.EM.EndTime = (SMM.EM.StartTime + 0.01f);
+ }
+ EditorGUILayout.EndHorizontal();
+
+
+ //End time:
+ EditorGUILayout.BeginHorizontal();
+ SMM.EM.EndTime = EditorGUILayout.Slider("End param: ", SMM.EndTime, SMM.StartTime, tNode.MaxSplination);
+ if (GUILayout.Button("match next", EditorStyles.miniButton, GUILayout.Width(80f)))
+ {
+ SMM.EM.EndTime = tNode.NextTime;
+ }
+ if (SMM.EM.StartTime >= SMM.EM.EndTime)
+ {
+ SMM.EM.EndTime = (SMM.EM.StartTime + 0.01f);
+ }
+ EditorGUILayout.EndHorizontal();
+
+
+ //Straight line options:
+ if (tNode.IsStraight())
+ {
+ if (!SMM.bIsStretch)
+ {
+ SMM.EM.bIsStretch = EditorGUILayout.Toggle("Straight line stretch:", SMM.bIsStretch);
+ }
+ else
+ {
+ EditorGUILayout.BeginVertical("box");
+ SMM.EM.bIsStretch = EditorGUILayout.Toggle("Straight line stretch:", SMM.bIsStretch);
+
+ //Stretch_UVThreshold:
+ SMM.EM.Stretch_UVThreshold = EditorGUILayout.Slider("UV stretch threshold:", SMM.Stretch_UVThreshold, 0.01f, 0.5f);
+
+ //UV repeats:
+ SMM.EM.RepeatUVType = (GSD.Roads.Splination.RepeatUVTypeEnum) EditorGUILayout.Popup("UV stretch axis: ", (int) SMM.RepeatUVType, RepeatUVTypeDescriptions_Spline, GUILayout.Width(250f));
+ EditorGUILayout.EndVertical();
+ }
+ }
+ else
+ {
+ SMM.EM.bIsStretch = false;
+ }
+
+
+
+ SMM.EM.bTrimStart = EditorGUILayout.Toggle("Trim start:", SMM.bTrimStart);
+ SMM.EM.bTrimEnd = EditorGUILayout.Toggle("Trim end:", SMM.bTrimEnd);
+
+
+
+ //Static option:
+ SMM.EM.bStatic = EditorGUILayout.Toggle("Static: ", SMM.bStatic);
+
+
+ //Splination method
+ // SMM.EM.bMatchRoadIncrements = EditorGUILayout.Toggle("Match road increments: ",SMM.bMatchRoadIncrements);
+ SMM.EM.bMatchTerrain = EditorGUILayout.Toggle("Match ground: ", SMM.bMatchTerrain);
+
+ //Vector min/max threshold:
+ EditorGUILayout.BeginHorizontal();
+ SMM.EM.MinMaxMod = EditorGUILayout.Slider("Vertex min/max threshold: ", SMM.MinMaxMod, 0.01f, 0.2f);
+ if (GUILayout.Button(btnDefaultText, GSDImageButton, GUILayout.Width(16f)))
+ {
+ SMM.EM.MinMaxMod = 0.05f;
+ }
+ EditorGUILayout.EndHorizontal();
+
+ //Vertex matching precision:
+ EditorGUILayout.BeginHorizontal();
+ SMM.EM.VertexMatchingPrecision = EditorGUILayout.Slider("Vertex matching precision: ", SMM.VertexMatchingPrecision, 0f, 0.01f);
+ if (GUILayout.Button(btnDefaultText, GSDImageButton, GUILayout.Width(16f)))
+ {
+ SMM.EM.VertexMatchingPrecision = 0.005f;
+ }
+ EditorGUILayout.EndHorizontal();
+
+ //UV repeats:
+ if (!SMM.bIsStretch)
+ {
+ SMM.EM.RepeatUVType = (GSD.Roads.Splination.RepeatUVTypeEnum) EditorGUILayout.Popup("UV repeat axis: ", (int) SMM.RepeatUVType, RepeatUVTypeDescriptions_Spline, GUILayout.Width(250f));
+ }
+
+ if (SMM.bMatchRoadDefinition)
+ {
+ EditorGUILayout.BeginVertical("TextArea");
+ EditorGUILayout.BeginHorizontal();
+ SMM.EM.bMatchRoadDefinition = EditorGUILayout.Toggle("Match road definition: ", SMM.bMatchRoadDefinition);
+ if (GUILayout.Button(btnDefaultText, GSDImageButton, GUILayout.Width(16f)))
+ {
+ SMM.EM.bMatchRoadDefinition = false;
+ }
+ EditorGUILayout.EndHorizontal();
+ if (SMM.bMatchRoadDefinition)
+ {
+ EditorGUILayout.LabelField(" Only use this option if object length doesn't match the road definition.", EditorStyles.miniLabel);
+ EditorGUILayout.LabelField(" Matching road definition requires a UV repeat type.", EditorStyles.miniLabel);
+ EditorGUILayout.LabelField(" If the material fails to scale properly, try flipping the Y rotation.", EditorStyles.miniLabel);
+ }
+ //Flip rotation option:
+ SMM.EM.bFlipRotation = EditorGUILayout.Toggle(" Flip Y rotation: ", SMM.bFlipRotation);
+ EditorGUILayout.EndVertical();
+ }
+ else
+ {
+ EditorGUILayout.BeginHorizontal();
+ SMM.EM.bMatchRoadDefinition = EditorGUILayout.Toggle("Match road definition: ", SMM.bMatchRoadDefinition);
+ if (GUILayout.Button(btnDefaultText, GSDImageButton, GUILayout.Width(16f)))
+ {
+ SMM.EM.bMatchRoadDefinition = false;
+ }
+ EditorGUILayout.EndHorizontal();
+ }
+ EditorGUILayout.EndVertical();
+
+
+ #region Vertical offset:
+ EditorGUILayout.LabelField("Vertical options:");
+ EditorGUILayout.BeginVertical("box");
+ EditorGUILayout.BeginHorizontal();
+ SMM.EM.VerticalRaise = EditorGUILayout.Slider("Vertical raise magnitude:", SMM.VerticalRaise, -512f, 512f);
+ if (GUILayout.Button(btnDefaultText, GSDImageButton, GUILayout.Width(16f)))
+ {
+ SMM.EM.VerticalRaise = 0f;
+ }
+ EditorGUILayout.EndHorizontal();
+ #endregion
+
+
+ #region Vertical curve:
+ if (SMM.VerticalCurve == null || SMM.VerticalCurve.keys.Length < 2)
+ { EnforceCurve(ref SMM.VerticalCurve); }
+ EditorGUILayout.BeginHorizontal();
+ SMM.EM.VerticalCurve = EditorGUILayout.CurveField("Curve: ", SMM.VerticalCurve);
+ if (GUILayout.Button(btnDefaultText, GSDImageButton, GUILayout.Width(16f)))
+ {
+ ResetCurve(ref SMM.EM.VerticalCurve);
+ }
+ EditorGUILayout.EndHorizontal();
+ #endregion
+ EditorGUILayout.EndVertical();
+
+
+ #region Horizontal offsets:
+ SMM.EM.HorizontalSep = SMM.HorizontalSep;
+ EditorGUILayout.LabelField("Horizontal offset options:");
+ EditorGUILayout.BeginVertical("box");
+ tHorizMatching = HorizMatchingDefaultsEnum.None;
+ tHorizMatching = (HorizMatchingDefaultsEnum) EditorGUILayout.Popup((int) tHorizMatching, HorizMatchSubTypeDescriptions, GUILayout.Width(100f));
+ if (tHorizMatching != HorizMatchingDefaultsEnum.None)
+ {
+ if (tHorizMatching == HorizMatchingDefaultsEnum.MatchCenter)
+ {
+ SMM.EM.HorizontalSep = 0f;
+ }
+ else if (tHorizMatching == HorizMatchingDefaultsEnum.MatchRoadLeft)
+ {
+ SMM.EM.HorizontalSep = (tNode.GSDSpline.tRoad.RoadWidth() / 2) * -1;
+ }
+ else if (tHorizMatching == HorizMatchingDefaultsEnum.MatchShoulderLeft)
+ {
+ SMM.EM.HorizontalSep = ((tNode.GSDSpline.tRoad.RoadWidth() / 2) + tNode.GSDSpline.tRoad.opt_ShoulderWidth) * -1;
+ }
+ else if (tHorizMatching == HorizMatchingDefaultsEnum.MatchRoadRight)
+ {
+ SMM.EM.HorizontalSep = (tNode.GSDSpline.tRoad.RoadWidth() / 2);
+ }
+ else if (tHorizMatching == HorizMatchingDefaultsEnum.MatchShoulderRight)
+ {
+ SMM.EM.HorizontalSep = (tNode.GSDSpline.tRoad.RoadWidth() / 2) + tNode.GSDSpline.tRoad.opt_ShoulderWidth;
+ }
+ tHorizMatching = HorizMatchingDefaultsEnum.None;
+ }
+ EditorGUILayout.BeginHorizontal();
+ SMM.EM.HorizontalSep = EditorGUILayout.Slider("Horiz offset magnitude:", SMM.EM.HorizontalSep, (-1f * HorizRoadMax), HorizRoadMax);
+ if (GUILayout.Button(btnDefaultText, GSDImageButton, GUILayout.Width(16f)))
+ {
+ SMM.EM.HorizontalSep = 0f;
+ }
+ EditorGUILayout.EndHorizontal();
+ #endregion
+
+
+ //Horizontal curve:
+ if (SMM.HorizontalCurve == null || SMM.HorizontalCurve.keys.Length < 2)
+ {
+ EnforceCurve(ref SMM.HorizontalCurve);
+ }
+
+ EditorGUILayout.BeginHorizontal();
+ SMM.EM.HorizontalCurve = EditorGUILayout.CurveField("Curve: ", SMM.HorizontalCurve);
+ if (GUILayout.Button(btnDefaultText, GSDImageButton, GUILayout.Width(16f)))
+ {
+ ResetCurve(ref SMM.EM.HorizontalCurve);
+ }
+ EditorGUILayout.EndHorizontal();
+ EditorGUILayout.EndVertical();
+
+ //Vertical cutoff:
+ EditorGUILayout.LabelField("Vertical cutoff:");
+ EditorGUILayout.BeginVertical("box");
+ SMM.EM.bVerticalCutoff = EditorGUILayout.Toggle("Height cutoff enabled:", SMM.bVerticalCutoff);
+ if (SMM.bVerticalCutoff)
+ {
+ SMM.EM.bVerticalCutoff_MatchZero = EditorGUILayout.Toggle("Match spline height:", SMM.bVerticalCutoff_MatchZero);
+ SMM.EM.bVerticalCutoffDownwards = EditorGUILayout.Toggle("Cut direction toggle:", SMM.bVerticalCutoffDownwards);
+ SMM.EM.VerticalCutoff = EditorGUILayout.Slider("Height cut offset: ", SMM.VerticalCutoff, -50f, 50f);
+ SMM.EM.bVerticalMeshCutoff_OppositeDir = EditorGUILayout.Toggle("Opposite dir mesh cut:", SMM.bVerticalMeshCutoff_OppositeDir);
+ SMM.EM.VerticalMeshCutoffOffset = EditorGUILayout.Slider("Mesh cut offset: ", SMM.VerticalMeshCutoffOffset, -5f, 5f);
+ }
+ EditorGUILayout.EndVertical();
+
+ //End type:
+ EditorGUILayout.LabelField("Extrusion ending options:");
+ EditorGUILayout.BeginVertical("box");
+ SMM.EM.bStartDown = EditorGUILayout.Toggle("Push start down:", SMM.bStartDown);
+ SMM.EM.bEndDown = EditorGUILayout.Toggle("Push end down:", SMM.bEndDown);
+ if (SMM.bStartDown)
+ {
+ SMM.EM.bStartTypeDownOverride = EditorGUILayout.Toggle("Override start down value: ", SMM.bStartTypeDownOverride);
+ if (SMM.bStartTypeDownOverride)
+ {
+ SMM.EM.StartTypeDownOverride = EditorGUILayout.Slider("Downward movement: ", SMM.StartTypeDownOverride, -10f, 10f);
+ }
+ }
+ if (SMM.bEndDown)
+ {
+ SMM.EM.bEndTypeDownOverride = EditorGUILayout.Toggle("Override end down value: ", SMM.bEndTypeDownOverride);
+ if (SMM.bEndTypeDownOverride)
+ {
+ SMM.EM.EndTypeDownOverride = EditorGUILayout.Slider("Downward movement: ", SMM.EndTypeDownOverride, -10f, 10f);
+ }
+ }
+ EditorGUILayout.EndVertical();
+
+ //Start and end objects:
+ EditorGUILayout.LabelField("Start & end objects:");
+ EditorGUILayout.BeginVertical("box");
+ //End cap custom match start:
+ SMM.EM.bEndCapCustomMatchStart = EditorGUILayout.Toggle("Match objects to ends:", SMM.bEndCapCustomMatchStart);
+
+ //End objects match ground:
+ SMM.EM.bEndObjectsMatchGround = EditorGUILayout.Toggle("Force origins to ground:", SMM.bEndObjectsMatchGround);
+
+ //Start cap:
+ EditorGUILayout.BeginVertical("box");
+ EditorGUILayout.BeginHorizontal();
+ EditorGUILayout.LabelField("Start object:");
+ tEndObjectAdd = (EndObjectsDefaultsEnum) EditorGUILayout.Popup((int) tEndObjectAdd, EndObjectsDefaultsEnumDesc);
+ if (tEndObjectAdd != EndObjectsDefaultsEnum.None)
+ {
+ SMM.EM.EndCapStart = GetEndObjectQuickAdd();
+ tEndObjectAdd = EndObjectsDefaultsEnum.None;
+ }
+ EditorGUILayout.EndHorizontal();
+
+
+ SMM.EM.EndCapStart = (GameObject) EditorGUILayout.ObjectField("Prefab:", SMM.EndCapStart, typeof(GameObject), false);
+ if (SMM.EndCapStart != null)
+ {
+ SMM.EM.EndCapCustomOffsetStart = EditorGUILayout.Vector3Field("Position offset:", SMM.EndCapCustomOffsetStart);
+ SMM.EM.EndCapCustomRotOffsetStart = EditorGUILayout.Vector3Field("Rotation offset:", SMM.EndCapCustomRotOffsetStart);
+ }
+ EditorGUILayout.EndVertical();
+
+ //End cap:
+ EditorGUILayout.BeginVertical("box");
+ EditorGUILayout.BeginHorizontal();
+ EditorGUILayout.LabelField("End object:");
+ tEndObjectAdd = (EndObjectsDefaultsEnum) EditorGUILayout.Popup((int) tEndObjectAdd, EndObjectsDefaultsEnumDesc);
+ if (tEndObjectAdd != EndObjectsDefaultsEnum.None)
+ {
+ SMM.EM.EndCapEnd = GetEndObjectQuickAdd();
+ SMM.EM.EndCapCustomRotOffsetEnd = new Vector3(0f, 180f, 0f);
+ tEndObjectAdd = EndObjectsDefaultsEnum.None;
+ }
+ EditorGUILayout.EndHorizontal();
+
+
+ SMM.EM.EndCapEnd = (GameObject) EditorGUILayout.ObjectField("Prefab:", SMM.EndCapEnd, typeof(GameObject), false);
+ if (SMM.EndCapEnd != null)
+ {
+ SMM.EM.EndCapCustomOffsetEnd = EditorGUILayout.Vector3Field("Position offset:", SMM.EndCapCustomOffsetEnd);
+ SMM.EM.EndCapCustomRotOffsetEnd = EditorGUILayout.Vector3Field("Rotation offset:", SMM.EndCapCustomRotOffsetEnd);
+ }
+ EditorGUILayout.EndVertical();
+
+ EditorGUILayout.EndVertical();
+
+ //Collision:
+ EditorGUILayout.LabelField("Collision options:");
+ EditorGUILayout.BeginVertical("box");
+ SMM.EM.CollisionType = (GSD.Roads.Splination.CollisionTypeEnum) EditorGUILayout.Popup("Collision type: ", (int) SMM.CollisionType, TheCollisionTypeEnumDescSpline, GUILayout.Width(320f));
+ //Mesh collison convex option
+ if (SMM.CollisionType != GSD.Roads.Splination.CollisionTypeEnum.None && SMM.CollisionType != GSD.Roads.Splination.CollisionTypeEnum.BoxCollision)
+ {
+ SMM.EM.bCollisionConvex = EditorGUILayout.Toggle(" Convex: ", SMM.bCollisionConvex);
+ SMM.EM.bCollisionTrigger = EditorGUILayout.Toggle(" Trigger: ", SMM.bCollisionTrigger);
+ }
+
+ if (SMM.CollisionType == GSD.Roads.Splination.CollisionTypeEnum.SimpleMeshTriangle || SMM.CollisionType == GSD.Roads.Splination.CollisionTypeEnum.SimpleMeshTrapezoid)
+ {
+ SMM.EM.bSimpleCollisionAutomatic = EditorGUILayout.Toggle(" Automatic simple collision: ", SMM.bSimpleCollisionAutomatic);
+ }
+ //If not automatic simple collisions:
+ if (!SMM.bSimpleCollisionAutomatic)
+ {
+ if (SMM.CollisionType == GSD.Roads.Splination.CollisionTypeEnum.SimpleMeshTriangle)
+ {
+ SMM.EM.CollisionTriBL = SMM.CollisionTriBL;
+ SMM.EM.CollisionTriBR = SMM.CollisionTriBR;
+ SMM.EM.CollisionTriT = SMM.CollisionTriT;
+
+ EditorGUILayout.LabelField("Bottom left:");
+ SMM.EM.CollisionTriBL.x = EditorGUILayout.Slider(" x-axis: ", SMM.CollisionTriBL.x, SMM.mMinX - 5f, SMM.mMaxX + 5f);
+ SMM.EM.CollisionTriBL.y = EditorGUILayout.Slider(" y-axis: ", SMM.CollisionTriBL.y, SMM.mMinY - 5f, SMM.mMaxY + 5f);
+ SMM.EM.CollisionTriBL.z = EditorGUILayout.Slider(" z-axis: ", SMM.CollisionTriBL.z, SMM.mMinZ - 5f, SMM.mMaxZ + 5f);
+
+ EditorGUILayout.LabelField("Bottom right:");
+ SMM.EM.CollisionTriBR.x = EditorGUILayout.Slider(" x-axis: ", SMM.CollisionTriBR.x, SMM.mMinX - 5f, SMM.mMaxX + 5f);
+ SMM.EM.CollisionTriBR.y = EditorGUILayout.Slider(" y-axis: ", SMM.CollisionTriBR.y, SMM.mMinY - 5f, SMM.mMaxY + 5f);
+ SMM.EM.CollisionTriBR.z = EditorGUILayout.Slider(" z-axis: ", SMM.CollisionTriBR.z, SMM.mMinZ - 5f, SMM.mMaxZ + 5f);
+
+ EditorGUILayout.LabelField("Top:");
+ SMM.EM.CollisionTriT.x = EditorGUILayout.Slider(" x-axis: ", SMM.CollisionTriT.x, SMM.mMinX - 5f, SMM.mMaxX + 5f);
+ SMM.EM.CollisionTriT.y = EditorGUILayout.Slider(" y-axis: ", SMM.CollisionTriT.y, SMM.mMinY - 5f, SMM.mMaxY + 5f);
+ SMM.EM.CollisionTriT.z = EditorGUILayout.Slider(" z-axis: ", SMM.CollisionTriT.z, SMM.mMinZ - 5f, SMM.mMaxZ + 5f);
+
+ }
+ else if (SMM.CollisionType == GSD.Roads.Splination.CollisionTypeEnum.SimpleMeshTrapezoid)
+ {
+ SMM.EM.CollisionBoxBL = EditorGUILayout.Vector3Field(" Bottom left:", SMM.CollisionBoxBL);
+ SMM.EM.CollisionBoxBR = EditorGUILayout.Vector3Field(" Bottom right:", SMM.CollisionBoxBR);
+ SMM.EM.CollisionBoxTL = EditorGUILayout.Vector3Field(" Top left:", SMM.CollisionBoxTL);
+ SMM.EM.CollisionBoxTR = EditorGUILayout.Vector3Field(" Top right:", SMM.CollisionBoxTR);
+ }
+ }
+
+ if (SMM.CollisionType == GSD.Roads.Splination.CollisionTypeEnum.BoxCollision)
+ {
+ SMM.EM.StretchBC_LocOffset = EditorGUILayout.Vector3Field("Box collider center offset:", SMM.StretchBC_LocOffset);
+ SMM.EM.bBCFlipX = EditorGUILayout.Toggle("Flip center X:", SMM.bBCFlipX);
+ SMM.EM.bBCFlipZ = EditorGUILayout.Toggle("Flip center Z:", SMM.bBCFlipZ);
+
+
+ SMM.EM.bStretchSize = EditorGUILayout.Toggle("Box collider size edit:", SMM.bStretchSize);
+ if (SMM.bStretchSize)
+ {
+ SMM.EM.StretchBC_Size = EditorGUILayout.Vector3Field("Size:", SMM.StretchBC_Size);
+ }
+ else
+ {
+ EditorGUILayout.LabelField("Size:", SMM.StretchBC_Size.ToString());
+ }
+ }
+ EditorGUILayout.EndVertical();
+
+
+ EditorGUILayout.LabelField("Rotation options:");
+ EditorGUILayout.BeginVertical("box");
+
+ //Custom rotation:
+ SMM.EM.CustomRotation = SMM.CustomRotation;
+ //EOM.CustomRotation = EditorGUILayout.Vector3Field("Custom rotation: ",EOM.CustomRotation);
+ EditorGUILayout.BeginHorizontal();
+ //Flip rotation option:
+ if (SMM.EM.bFlipRotation != SMM.bFlipRotation)
+ {
+ SMM.EM.bFlipRotation = EditorGUILayout.Toggle("Flip Y rotation: ", SMM.EM.bFlipRotation);
+ }
+ else
+ {
+ SMM.EM.bFlipRotation = EditorGUILayout.Toggle("Flip Y rotation: ", SMM.bFlipRotation);
+ }
+
+
+ // if(GUILayout.Button("Reset custom rotation",EditorStyles.miniButton,GUILayout.Width(160f))){
+ // SMM.CustomRotation = new Vector3(0f,0f,0f);
+ // }
+ if (GUILayout.Button(btnDefaultText, GSDImageButton, GUILayout.Width(16f)))
+ {
+ SMM.EM.CustomRotation = new Vector3(0f, 0f, 0f);
+ }
+ EditorGUILayout.EndHorizontal();
+ // SMM.EM.CustomRotation = EditorGUILayout.Vector3Field("",SMM.CustomRotation);
+ // SMM.EM.CustomRotation.x = EditorGUILayout.Slider("x-axis: ",SMM.CustomRotation.x,-360f,360f);
+ // SMM.EM.CustomRotation.y = EditorGUILayout.Slider("y-axis: ",SMM.CustomRotation.y,-360f,360f);
+ // SMM.EM.CustomRotation.z = EditorGUILayout.Slider("z-axis: ",SMM.CustomRotation.z,-360f,360f);
+ EditorGUILayout.EndVertical();
+ EditorGUILayout.EndVertical();
+
+
+ EditorGUILayout.LabelField("Deprecated options:");
+ EditorGUILayout.BeginVertical("box");
+ SMM.EM.bExactSplination = EditorGUILayout.Toggle("Directional extrusion: ", SMM.bExactSplination);
+
+ EditorGUILayout.EndVertical();
+ BigLine();
+ BigLine();
+ }
+ }
+
+
+ public void UpdateSplineObjects()
+ {
+ if (!tNode.CanSplinate())
+ {
+ return;
+ }
+ if (tNode.SplinatedObjects == null)
+ {
+ tNode.SplinatedObjects = new List();
+ }
+ eCount = tNode.SplinatedObjects.Count;
+ for (int index = 0; index < eCount; index++)
+ {
+ SMM = tNode.SplinatedObjects[index];
+ if (SMM.EM != null)
+ {
+ if (!SMM.EM.IsEqualToSMM(SMM))
+ {
+ SMM.EM.LoadToSMM(SMM);
+
+ SMM.UpdatePositions();
+ if (SMM.EM.bIsStretch != SMM.bIsStretch)
+ {
+ if (SMM.bIsStretch)
+ {
+ SMM.CollisionType = GSD.Roads.Splination.CollisionTypeEnum.BoxCollision;
+ SMM.bMatchRoadDefinition = false;
+ SMM.bMatchTerrain = false;
+ SMM.bCollisionConvex = false;
+ SMM.bStartDown = false;
+ SMM.bEndDown = false;
+ SMM.bVerticalCutoff = false;
+ SMM.bExactSplination = false;
+ SMM.bEndTypeDownOverride = false;
+ }
+ }
+
+ SMM.Setup(true);
+ // Debug.Log ("Setup SMM");
+ }
+ }
+ }
+ }
+
+
+ public void UpdateSplineObjects_OnUndo()
+ {
+ if (!tNode.CanSplinate())
+ {
+ return;
+ }
+ if (tNode.SplinatedObjects == null)
+ {
+ tNode.SplinatedObjects = new List();
+ }
+
+ //Destroy all children:
+ for (int index = tNode.transform.childCount - 1; index >= 0; index--)
+ {
+ Object.DestroyImmediate(tNode.transform.GetChild(index).gameObject);
+ }
+
+ //Re-setup the SMM:
+ eCount = tNode.SplinatedObjects.Count;
+ for (int index = 0; index < eCount; index++)
+ {
+ SMM = tNode.SplinatedObjects[index];
+ SMM.UpdatePositions();
+ //if(SMM.bIsStretch != SMM.bIsStretch){
+ if (SMM.bIsStretch)
+ {
+ SMM.CollisionType = GSD.Roads.Splination.CollisionTypeEnum.BoxCollision;
+ SMM.bMatchRoadDefinition = false;
+ SMM.bMatchTerrain = false;
+ SMM.bCollisionConvex = false;
+ SMM.bStartDown = false;
+ SMM.bEndDown = false;
+ SMM.bVerticalCutoff = false;
+ SMM.bExactSplination = false;
+ SMM.bEndTypeDownOverride = false;
+ }
+ //}
+ SMM.Setup(true);
+ }
+
+ UpdateEdgeObjects_OnUndo();
+ }
+
+
+ public void DoEdgeObjects()
+ {
+ if (!tNode.CanSplinate())
+ {
+ return;
+ }
+
+ if (tNode.EdgeObjects == null)
+ {
+ tNode.EdgeObjects = new List();
+ }
+ eCount = tNode.EdgeObjects.Count;
+
+ EOM = null;
+
+ for (int index = 0; index < tNode.EdgeObjects.Count; index++)
+ {
+ EOM = tNode.EdgeObjects[index];
+ if (EOM.EM == null)
+ {
+ EOM.EM = new GSD.Roads.EdgeObjects.EdgeObjectMaker.EdgeObjectEditorMaker();
+ }
+ EOM.EM.Setup(EOM);
+
+ currentCount += 1;
+ EditorGUILayout.BeginVertical("TextArea");
+
+
+ if (EOM.bNeedsUpdate)
+ {
+ EOM.Setup();
+ }
+ EOM.bNeedsUpdate = false;
+
+ EditorGUILayout.BeginHorizontal();
+
+ EOM.bToggle = EditorGUILayout.Foldout(EOM.bToggle, "#" + currentCount.ToString() + ": " + EOM.tName);
+
+ if (GUILayout.Button(btnEdgeText, GSDImageButton, GUILayout.Width(32f)))
+ {
+
+ }
+ if (GUILayout.Button(btnRefreshText, GSDImageButton, GUILayout.Width(16f)))
+ {
+ EOM.Setup();
+ }
+ if (GUILayout.Button(btnSaveText, GSDImageButton, GUILayout.Width(16f)))
+ {
+ GSDSaveWindow tSave = EditorWindow.GetWindow();
+ tSave.Initialize(ref tSceneRect, GSDSaveWindow.WindowTypeEnum.Edge, tNode, null, EOM);
+ }
+
+ if (GUILayout.Button(btnCopyText, GSDImageButton, GUILayout.Width(16f)))
+ {
+ Undo.RecordObject(tNode, "Copy");
+ tNode.CopyEdgeObject(index);
+ EditorUtility.SetDirty(tNode);
+ }
+ if (GUILayout.Button(btnDeleteText, GSDImageButton, GUILayout.Width(16f)))
+ {
+ Undo.RecordObject(tNode, "Delete");
+ tNode.RemoveEdgeObject(index);
+ EditorUtility.SetDirty(tNode);
+ }
+ EditorGUILayout.EndHorizontal();
+
+ if (!EOM.bToggle)
+ {
+ EditorGUILayout.EndVertical();
+ continue;
+ }
+
+ GUILayout.Space(8f);
+ EditorGUILayout.BeginHorizontal();
+ EditorGUILayout.LabelField("General options:");
+ if (GUILayout.Button("Online manual", EditorStyles.miniButton, GUILayout.Width(120f)))
+ {
+ Application.OpenURL("http://microgsd.com/Support/RoadArchitectManual.aspx");
+ }
+ EditorGUILayout.EndHorizontal();
+
+ EditorGUILayout.BeginVertical("box");
+ //Name:
+ EOM.EM.tName = EditorGUILayout.TextField("Name: ", EOM.tName);
+
+ //Edge object:
+ EOM.EM.EdgeObject = (GameObject) EditorGUILayout.ObjectField("Edge object: ", EOM.EdgeObject, typeof(GameObject), false);
+ if (EOM.EM.EdgeObject != EOM.EdgeObject)
+ {
+ EOM.bEdgeSignLabelInit = false;
+ EOM.bEdgeSignLabel = false;
+ }
+
+
+ #region Material override:
+ EOM.EM.bMaterialOverride = EditorGUILayout.Toggle("Material override: ", EOM.bMaterialOverride);
+ if (!EOM.bMaterialOverride)
+ {
+ EOM.EM.EdgeMaterial1 = null;
+ EOM.EM.EdgeMaterial2 = null;
+ }
+
+ if (!EOM.bEdgeSignLabelInit && EOM.EM.EdgeObject != null)
+ {
+ EOM.bEdgeSignLabel = false;
+ if (string.CompareOrdinal(EOM.EM.EdgeObject.name, "GSDSignDiamond") == 0)
+ {
+ EOM.bEdgeSignLabel = true;
+ EOM.EdgeSignLabel = "GSDFedSign-diamond";
+
+ }
+ else if (string.CompareOrdinal(EOM.EM.EdgeObject.name, "GSDSignSquare-Small") == 0)
+ {
+ EOM.bEdgeSignLabel = true;
+ EOM.EdgeSignLabel = "GSDFedSign-Square";
+ }
+ else if (string.CompareOrdinal(EOM.EM.EdgeObject.name, "GSDSignSquare") == 0)
+ {
+ EOM.bEdgeSignLabel = true;
+ EOM.EdgeSignLabel = "GSDFedSign-Square";
+
+ }
+ else if (string.CompareOrdinal(EOM.EM.EdgeObject.name, "GSDSign988-Small") == 0)
+ {
+ EOM.bEdgeSignLabel = true;
+ EOM.EdgeSignLabel = "GSDFedSign-988";
+ }
+ else if (string.CompareOrdinal(EOM.EM.EdgeObject.name, "GSDSign988") == 0)
+ {
+ EOM.bEdgeSignLabel = true;
+ EOM.EdgeSignLabel = "GSDFedSign-988";
+
+ }
+ else if (string.CompareOrdinal(EOM.EM.EdgeObject.name, "GSDSign861-Small") == 0)
+ {
+ EOM.bEdgeSignLabel = true;
+ EOM.EdgeSignLabel = "GSDFedSign-861";
+ }
+ else if (string.CompareOrdinal(EOM.EM.EdgeObject.name, "GSDSign861") == 0)
+ {
+ EOM.bEdgeSignLabel = true;
+ EOM.EdgeSignLabel = "GSDFedSign-861";
+
+ }
+ else if (string.CompareOrdinal(EOM.EM.EdgeObject.name, "GSDSign617-Small") == 0)
+ {
+ EOM.bEdgeSignLabel = true;
+ EOM.EdgeSignLabel = "GSDFedSign-617";
+ }
+ else if (string.CompareOrdinal(EOM.EM.EdgeObject.name, "GSDSign617") == 0)
+ {
+ EOM.bEdgeSignLabel = true;
+ EOM.EdgeSignLabel = "GSDFedSign-617";
+
+ }
+ else if (string.CompareOrdinal(EOM.EM.EdgeObject.name, "GSDSign396") == 0)
+ {
+ EOM.bEdgeSignLabel = true;
+ EOM.EdgeSignLabel = "GSDFedSign-396";
+
+ }
+ else if (string.CompareOrdinal(EOM.EM.EdgeObject.name, "GSDSign330") == 0)
+ {
+ EOM.bEdgeSignLabel = true;
+ EOM.EdgeSignLabel = "GSDFedSign-330";
+ }
+ }
+
+ if (EOM.bMaterialOverride)
+ {
+ if (EOM.bEdgeSignLabel)
+ {
+ EditorGUILayout.TextField("Material search term: ", EOM.EdgeSignLabel);
+ }
+
+ EOM.EM.EdgeMaterial1 = (Material) EditorGUILayout.ObjectField("Override mat #1: ", EOM.EdgeMaterial1, typeof(Material), false);
+ EOM.EM.EdgeMaterial2 = (Material) EditorGUILayout.ObjectField("Override mat #2: ", EOM.EdgeMaterial2, typeof(Material), false);
+ }
+ #endregion
+
+
+ #region Combine Mesh / MeshCollider
+ if (EOM.bSingle)
+ {
+ EOM.EM.bCombineMesh = false;
+ }
+ else
+ {
+ EOM.EM.bCombineMesh = EditorGUILayout.Toggle("Combine meshes: ", EOM.bCombineMesh);
+
+ if (EOM.bCombineMesh)
+ {
+ EOM.EM.bCombineMeshCollider = EditorGUILayout.Toggle("Combined mesh collider: ", EOM.bCombineMeshCollider);
+ }
+ }
+ #endregion
+
+
+ #region SingleObject
+ EOM.EM.bSingle = EditorGUILayout.Toggle("Single object only: ", EOM.bSingle);
+ if (EOM.EM.bSingle != EOM.bSingle)
+ {
+ EOM.EM.EndTime = tNode.NextTime;
+ // EOM.EM.EndPos = tNode.GSDSpline.GetSplineValue(EOM.EM.EndTime,false);
+ EOM.EM.SinglePosition = tNode.tTime + 0.025f;
+ if (EOM.EM.bSingle)
+ {
+ EOM.EM.bCombineMesh = false;
+ }
+ }
+
+ if (EOM.bSingle)
+ {
+ EOM.EM.SinglePosition = EditorGUILayout.Slider("Single location: ", EOM.SinglePosition, tNode.tTime, 1f);
+
+ if (tNode.bIsBridgeStart && tNode.bIsBridgeMatched)
+ {
+ EOM.EM.SingleOnlyBridgePercent = EditorGUILayout.Slider("Bridge %: ", EOM.SingleOnlyBridgePercent, 0f, 1f);
+ if (!GSDRootUtil.IsApproximately(EOM.SingleOnlyBridgePercent, EOM.EM.SingleOnlyBridgePercent, 0.001f))
+ {
+ EOM.EM.SingleOnlyBridgePercent = Mathf.Clamp(EOM.EM.SingleOnlyBridgePercent, 0f, 1f);
+ float tDist = (EOM.EM.SingleOnlyBridgePercent * (tNode.BridgeCounterpartNode.tDist - tNode.tDist) + tNode.tDist);
+ EOM.EM.SinglePosition = tNode.GSDSpline.TranslateDistBasedToParam(tDist);
+ }
+ }
+ }
+ #endregion
+
+
+ EOM.EM.bStatic = EditorGUILayout.Toggle("Static: ", EOM.bStatic);
+
+
+ EOM.EM.bMatchTerrain = EditorGUILayout.Toggle("Match ground height: ", EOM.bMatchTerrain);
+
+ if (!EOM.bSingle)
+ {
+ EOM.EM.MeterSep = EditorGUILayout.Slider("Dist between objects: ", EOM.MeterSep, 1f, 256f);
+ }
+
+
+ #region Match Road
+ EOM.EM.bStartMatchRoadDefinition = EditorGUILayout.Toggle("Match road definition: ", EOM.bStartMatchRoadDefinition);
+ if (EOM.bStartMatchRoadDefinition)
+ {
+ EOM.EM.StartMatchRoadDef = EditorGUILayout.Slider("Position fine tuning: ", EOM.StartMatchRoadDef, 0f, 1f);
+ if (!GSDRootUtil.IsApproximately(EOM.EM.StartMatchRoadDef, EOM.StartMatchRoadDef, 0.001f))
+ {
+ EOM.EM.StartMatchRoadDef = Mathf.Clamp(EOM.EM.StartMatchRoadDef, 0f, 1f);
+ }
+ }
+ #endregion
+
+
+ if (!EOM.bSingle)
+ {
+ if (EOM.EM.StartTime < tNode.MinSplination)
+ {
+ EOM.EM.StartTime = tNode.MinSplination;
+ }
+ if (EOM.EM.EndTime > tNode.MaxSplination)
+ {
+ EOM.EM.EndTime = tNode.MaxSplination;
+ }
+
+
+ #region Start param
+ EditorGUILayout.BeginHorizontal();
+ EOM.EM.StartTime = EditorGUILayout.Slider("Start param: ", EOM.StartTime, tNode.MinSplination, EOM.EndTime); // EndTime = 1f??
+
+ if (EOM.EM.EndTime < EOM.EM.StartTime)
+ {
+ EOM.EM.EndTime = Mathf.Clamp(EOM.StartTime + 0.01f, 0f, 1f);
+ }
+
+
+ if (GUILayout.Button("match node", EditorStyles.miniButton, GUILayout.Width(80f)))
+ {
+ EOM.EM.StartTime = tNode.tTime;
+ }
+ EditorGUILayout.EndHorizontal();
+ #endregion
+
+
+ #region End param
+ EditorGUILayout.BeginHorizontal();
+ EOM.EM.EndTime = EditorGUILayout.Slider("End param: ", EOM.EndTime, EOM.StartTime, tNode.MaxSplination);
+ //Mathf.Clamp(EditorGUILayout.Slider( "End param: ", EOM.EndTime, 0f/*EOM.StartTime*/, 1f/*tNode.MaxSplination*/ ), 0f, 1f);
+ // FH EXPERIMENTAL fix for EdgeObjects???
+
+ /*
+ if(EOM.EndTime != 1f) // Does not fix the problem, anyway a really dirty and shitty bugfix...
+ {
+ EOM.EndTime = 1f;
+ }
+ */
+
+ if (EOM.EM.StartTime > EOM.EM.EndTime)
+ {
+ EOM.EM.StartTime = Mathf.Clamp(EOM.EndTime - 0.01f, 0f, 1f);
+ }
+
+
+
+
+ if (GUILayout.Button("match next", EditorStyles.miniButton, GUILayout.Width(80f)))
+ {
+ EOM.EM.EndTime = tNode.NextTime;
+ }
+ EditorGUILayout.EndHorizontal();
+ #endregion
+ }
+
+
+ EditorGUILayout.EndVertical();
+
+
+ #region Vertical offset:
+ EditorGUILayout.LabelField("Vertical options:");
+ EditorGUILayout.BeginVertical("box");
+
+ EditorGUILayout.BeginHorizontal();
+ EOM.EM.VerticalRaise = EditorGUILayout.Slider("Vertical raise magnitude:", EOM.VerticalRaise, -512f, 512f);
+ if (GUILayout.Button(btnDefaultText, GSDImageButton, GUILayout.Width(16f)))
+ {
+ EOM.EM.VerticalRaise = 0f;
+ }
+ EditorGUILayout.EndHorizontal();
+
+ if (EOM.VerticalCurve == null || EOM.VerticalCurve.keys.Length < 2)
+ {
+ EnforceCurve(ref EOM.VerticalCurve);
+ }
+ EditorGUILayout.BeginHorizontal();
+ EOM.EM.VerticalCurve = EditorGUILayout.CurveField("Curve: ", EOM.VerticalCurve);
+ if (GUILayout.Button(btnDefaultText, GSDImageButton, GUILayout.Width(16f)))
+ {
+ ResetCurve(ref EOM.EM.VerticalCurve);
+ }
+ EditorGUILayout.EndHorizontal();
+ EditorGUILayout.EndVertical();
+ #endregion
+
+
+ #region Horizontal offsets:
+ EditorGUILayout.LabelField("Horizontal offset options:");
+ EditorGUILayout.BeginVertical("box");
+ tHorizMatching = HorizMatchingDefaultsEnum.None;
+ tHorizMatching = (HorizMatchingDefaultsEnum) EditorGUILayout.Popup((int) tHorizMatching, HorizMatchSubTypeDescriptions, GUILayout.Width(100f));
+ if (tHorizMatching != HorizMatchingDefaultsEnum.None)
+ {
+ if (tHorizMatching == HorizMatchingDefaultsEnum.MatchCenter)
+ {
+ EOM.EM.HorizontalSep = 0f;
+ }
+ else if (tHorizMatching == HorizMatchingDefaultsEnum.MatchRoadLeft)
+ {
+ EOM.EM.HorizontalSep = (tNode.GSDSpline.tRoad.RoadWidth() * 0.5f) * -1;
+ }
+ else if (tHorizMatching == HorizMatchingDefaultsEnum.MatchShoulderLeft)
+ {
+ if (tNode.GSDSpline.tRoad.opt_bShouldersEnabled)
+ {
+ EOM.EM.HorizontalSep = ((tNode.GSDSpline.tRoad.RoadWidth() * 0.5f) + tNode.GSDSpline.tRoad.opt_ShoulderWidth) * -1;
+ }
+ else
+ {
+ EOM.EM.HorizontalSep = ((tNode.GSDSpline.tRoad.RoadWidth() * 0.5f)) * -1;
+ }
+ }
+ else if (tHorizMatching == HorizMatchingDefaultsEnum.MatchRoadRight)
+ {
+ EOM.EM.HorizontalSep = (tNode.GSDSpline.tRoad.RoadWidth() * 0.5f);
+ }
+ else if (tHorizMatching == HorizMatchingDefaultsEnum.MatchShoulderRight)
+ {
+ if (tNode.GSDSpline.tRoad.opt_bShouldersEnabled)
+ {
+ EOM.EM.HorizontalSep = (tNode.GSDSpline.tRoad.RoadWidth() * 0.5f) + tNode.GSDSpline.tRoad.opt_ShoulderWidth;
+ }
+ else
+ {
+ EOM.EM.HorizontalSep = (tNode.GSDSpline.tRoad.RoadWidth() * 0.5f);
+ }
+ }
+ tHorizMatching = HorizMatchingDefaultsEnum.None;
+ }
+ if (!GSDRootUtil.IsApproximately(EOM.EM.HorizontalSep, EOM.HorizontalSep))
+ {
+ EOM.EM.HorizontalSep = Mathf.Clamp(EOM.EM.HorizontalSep, (-1f * HorizRoadMax), HorizRoadMax);
+ }
+
+
+ EditorGUILayout.BeginHorizontal();
+ EOM.EM.HorizontalSep = EditorGUILayout.Slider("Horiz offset magnitude:", EOM.EM.HorizontalSep, (-1f * HorizRoadMax), HorizRoadMax);
+ if (GUILayout.Button(btnDefaultText, GSDImageButton, GUILayout.Width(16f)))
+ {
+ EOM.EM.HorizontalSep = 0f;
+ }
+ if (!GSDRootUtil.IsApproximately(EOM.EM.HorizontalSep, EOM.HorizontalSep))
+ {
+ EOM.EM.HorizontalSep = Mathf.Clamp(EOM.EM.HorizontalSep, (-1f * HorizRoadMax), HorizRoadMax);
+ }
+ EditorGUILayout.EndHorizontal();
+ if (EOM.HorizontalCurve == null || EOM.HorizontalCurve.keys.Length < 2)
+ { EnforceCurve(ref EOM.HorizontalCurve); }
+ EditorGUILayout.BeginHorizontal();
+ EOM.EM.HorizontalCurve = EditorGUILayout.CurveField("Curve: ", EOM.HorizontalCurve);
+ if (GUILayout.Button(btnDefaultText, GSDImageButton, GUILayout.Width(16f)))
+ {
+ ResetCurve(ref EOM.EM.HorizontalCurve);
+ }
+ EditorGUILayout.EndHorizontal();
+ EditorGUILayout.EndVertical();
+ #endregion
+
+
+ #region Rotation/scale options
+ EditorGUILayout.LabelField("Rotation/scale options:");
+ EditorGUILayout.BeginVertical("box");
+ if (EOM.HorizontalSep < 0f)
+ {
+ EOM.EM.bOncomingRotation = EditorGUILayout.Toggle("Auto rotate oncoming objects: ", EOM.bOncomingRotation);
+ }
+
+ EditorGUILayout.BeginHorizontal();
+ EditorGUILayout.LabelField("Custom rotation: ");
+ if (GUILayout.Button(btnDefaultText, GSDImageButton, GUILayout.Width(16f)))
+ {
+ EOM.EM.CustomRotation = new Vector3(0f, 0f, 0f);
+ }
+ EditorGUILayout.EndHorizontal();
+
+ EOM.EM.CustomRotation.x = EditorGUILayout.Slider("x-axis: ", EOM.CustomRotation.x, -360f, 360f);
+ EOM.EM.CustomRotation.y = EditorGUILayout.Slider("y-axis: ", EOM.CustomRotation.y, -360f, 360f);
+ EOM.EM.CustomRotation.z = EditorGUILayout.Slider("z-axis: ", EOM.CustomRotation.z, -360f, 360f);
+ EditorGUILayout.EndVertical();
+ EditorGUILayout.BeginVertical("box"); /* scale */
+ EditorGUILayout.BeginHorizontal();
+ float scale = EditorGUILayout.Slider("Custom scale: ", EOM.CustomScale.x, 1f, 10f);
+ EOM.EM.CustomScale = new Vector3(scale, scale, scale);
+ if (GUILayout.Button(btnDefaultText, GSDImageButton, GUILayout.Width(16f)))
+ {
+ EOM.EM.CustomScale = new Vector3(1f, 1f, 1f);
+ }
+ EditorGUILayout.EndHorizontal();
+ EditorGUILayout.EndVertical(); /* scale */
+ EditorGUILayout.EndVertical();
+ #endregion
+ }
+ }
+
+
+ public void UpdateEdgeObjects()
+ {
+ if (!tNode.CanSplinate())
+ {
+ return;
+ }
+ eCount = tNode.EdgeObjects.Count;
+ for (int index = 0; index < tNode.EdgeObjects.Count; index++)
+ {
+ EOM = tNode.EdgeObjects[index];
+ if (EOM.EM != null)
+ {
+ if (!EOM.EM.IsEqual(EOM))
+ {
+ EOM.EM.LoadTo(EOM);
+ EOM.UpdatePositions();
+ EOM.Setup();
+ // Debug.Log ("Setup EOM");
+ }
+ }
+ }
+ }
+
+
+ public void UpdateEdgeObjects_OnUndo()
+ {
+ if (!tNode.CanSplinate())
+ {
+ return;
+ }
+ eCount = tNode.EdgeObjects.Count;
+ for (int index = 0; index < tNode.EdgeObjects.Count; index++)
+ {
+ EOM = tNode.EdgeObjects[index];
+ EOM.Setup();
+ }
+ }
+
+
+ #region "Quick adds"
+ private void BridgeAdd_TopBase(float tHorizSep = 0f, float tVertRaise = -0.01f, string tMat = "", bool bOverridePrefab = false, string OverridePrefab = "")
+ {
+ if (tMat == "")
+ {
+ tMat = GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Materials/GSDConcrete2.mat";
+ }
+ SMM = tNode.AddSplinatedObject();
+ string tBridgeTopBaseToAdd = "";
+ string tName = "";
+ if (tNode.GSDSpline.tRoad.opt_Lanes == 2)
+ {
+ if (tBridgeTopBaseQuickAdd == BridgeTopBaseDefaultsEnum.Base1MOver)
+ {
+ tBridgeTopBaseToAdd = GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Mesh/RoadObj/Bridges/BridgeBase-19w-5l-1d.fbx";
+ tName = "BridgeTop1M-1M";
+ }
+ else if (tBridgeTopBaseQuickAdd == BridgeTopBaseDefaultsEnum.Base2MOver)
+ {
+ tBridgeTopBaseToAdd = GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Mesh/RoadObj/Bridges/BridgeBase-20w-5l-1d.fbx";
+ tName = "BridgeTop2M-1M";
+ }
+ else if (tBridgeTopBaseQuickAdd == BridgeTopBaseDefaultsEnum.Base3MDeep)
+ {
+ tBridgeTopBaseToAdd = GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Mesh/RoadObj/Bridges/BridgeBase-18w-5l-3d.fbx";
+ tName = "BridgeTop0M-3M";
+ }
+ else
+ {
+ tBridgeTopBaseToAdd = GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Mesh/RoadObj/Bridges/BridgeBase-18w-5l-1d.fbx";
+ tName = "BridgeTop0M-1M";
+ }
+ }
+ else if (tNode.GSDSpline.tRoad.opt_Lanes == 4)
+ {
+ if (tBridgeTopBaseQuickAdd == BridgeTopBaseDefaultsEnum.Base1MOver)
+ {
+ tBridgeTopBaseToAdd = GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Mesh/RoadObj/Bridges/BridgeBase-29w-5l-1d.fbx";
+ tName = "BridgeTop1M-1M";
+ }
+ else if (tBridgeTopBaseQuickAdd == BridgeTopBaseDefaultsEnum.Base2MOver)
+ {
+ tBridgeTopBaseToAdd = GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Mesh/RoadObj/Bridges/BridgeBase-30w-5l-1d.fbx";
+ tName = "BridgeTop2M-1M";
+ }
+ else if (tBridgeTopBaseQuickAdd == BridgeTopBaseDefaultsEnum.Base3MDeep)
+ {
+ tBridgeTopBaseToAdd = GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Mesh/RoadObj/Bridges/BridgeBase-28w-5l-3d.fbx";
+ tName = "BridgeTop0M-3M";
+ }
+ else
+ {
+ tBridgeTopBaseToAdd = GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Mesh/RoadObj/Bridges/BridgeBase-28w-5l-1d.fbx";
+ tName = "BridgeTop0M-1M";
+ }
+ }
+ else
+ {
+ if (tBridgeTopBaseQuickAdd == BridgeTopBaseDefaultsEnum.Base1MOver)
+ {
+ tBridgeTopBaseToAdd = GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Mesh/RoadObj/Bridges/BridgeBase-39w-5l-1d.fbx";
+ tName = "BridgeTop1M-1M";
+ }
+ else if (tBridgeTopBaseQuickAdd == BridgeTopBaseDefaultsEnum.Base2MOver)
+ {
+ tBridgeTopBaseToAdd = GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Mesh/RoadObj/Bridges/BridgeBase-40w-5l-1d.fbx";
+ tName = "BridgeTop2M-1M";
+ }
+ else if (tBridgeTopBaseQuickAdd == BridgeTopBaseDefaultsEnum.Base3MDeep)
+ {
+ tBridgeTopBaseToAdd = GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Mesh/RoadObj/Bridges/BridgeBase-38w-5l-3d.fbx";
+ tName = "BridgeTop0M-3M";
+ }
+ else
+ {
+ tBridgeTopBaseToAdd = GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Mesh/RoadObj/Bridges/BridgeBase-38w-5l-1d.fbx";
+ tName = "BridgeTop0M-1M";
+ }
+ }
+
+ if (bOverridePrefab)
+ {
+ tBridgeTopBaseToAdd = OverridePrefab;
+ }
+
+ SMM.tName = tName;
+ SMM.CurrentSplination = (GameObject) UnityEditor.AssetDatabase.LoadAssetAtPath(tBridgeTopBaseToAdd, typeof(GameObject));
+ SMM.HorizontalSep = tHorizSep;
+ SMM.VerticalRaise = tVertRaise;
+ SMM.bMaterialOverride = true;
+ SMM.SplinatedMaterial1 = GSD.Roads.GSDRoadUtilityEditor.GiveMaterial(tMat);
+ SMM.Axis = GSD.Roads.Splination.AxisTypeEnum.Z;
+
+ tBridgeTopBaseQuickAdd = BridgeTopBaseDefaultsEnum.None;
+ if (SMM.StartTime < tNode.MinSplination)
+ {
+ SMM.StartTime = tNode.MinSplination;
+ }
+ if (SMM.EndTime > tNode.MaxSplination)
+ {
+ SMM.EndTime = tNode.MaxSplination;
+ }
+ }
+
+
+ private void BridgeAdd_BottomBase(float tHorizSep = 0f, float tVertRaise = -1.01f, string tMat = "", bool bOverridePrefab = false, string OverridePrefab = "")
+ {
+ if (tMat == "")
+ {
+ tMat = GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Materials/GSDConcrete2.mat";
+ }
+ SMM = tNode.AddSplinatedObject();
+ string tBridgeBottomBaseToAdd = "";
+ string tName = "";
+ if (tNode.GSDSpline.tRoad.opt_Lanes == 2)
+ {
+ if (tBridgeBottomBaseQuickAdd == BridgeBottomBaseDefaultsEnum.BridgeBase2)
+ {
+ tBridgeBottomBaseToAdd = GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Mesh/RoadObj/Bridges/BridgeBase2-18w-5l-3d.fbx";
+ tName = "BridgeBase2";
+ }
+ else if (tBridgeBottomBaseQuickAdd == BridgeBottomBaseDefaultsEnum.BridgeBase3)
+ {
+ tBridgeBottomBaseToAdd = GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Mesh/RoadObj/Bridges/BridgeBase3-18w-5l-5d.fbx";
+ tName = "BridgeBase3";
+ }
+ else if (tBridgeBottomBaseQuickAdd == BridgeBottomBaseDefaultsEnum.BridgeBase4)
+ {
+ tBridgeBottomBaseToAdd = GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Mesh/RoadObj/Bridges/BridgeBase4-18w-5l-5d.fbx";
+ tName = "BridgeBase4";
+ }
+ else if (tBridgeBottomBaseQuickAdd == BridgeBottomBaseDefaultsEnum.BridgeBase5)
+ {
+ tBridgeBottomBaseToAdd = GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Mesh/RoadObj/Bridges/BridgeBase5-18w-5l-5d.fbx";
+ tName = "BridgeBase5";
+ }
+ else if (tBridgeBottomBaseQuickAdd == BridgeBottomBaseDefaultsEnum.BridgeBase6)
+ {
+ tBridgeBottomBaseToAdd = GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Mesh/RoadObj/Bridges/BridgeBase6-2L.fbx";
+ tName = "BridgeArchBeam80";
+ }
+ else if (tBridgeBottomBaseQuickAdd == BridgeBottomBaseDefaultsEnum.BridgeBase7)
+ {
+ tBridgeBottomBaseToAdd = GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Mesh/RoadObj/Bridges/BridgeBase7-2L.fbx";
+ tName = "BridgeArchSolid80";
+ }
+ else if (tBridgeBottomBaseQuickAdd == BridgeBottomBaseDefaultsEnum.BridgeBase8)
+ {
+ tBridgeBottomBaseToAdd = GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Mesh/RoadObj/Bridges/BridgeBase8-2L.fbx";
+ tName = "BridgeArchSolid180";
+ }
+ else if (tBridgeBottomBaseQuickAdd == BridgeBottomBaseDefaultsEnum.BridgeBaseGrid)
+ {
+ tBridgeBottomBaseToAdd = GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Mesh/RoadObj/Bridges/BridgeBaseGrid-18w-5l-5d.fbx";
+ tName = "BridgeGrid";
+ }
+ else if (tBridgeBottomBaseQuickAdd == BridgeBottomBaseDefaultsEnum.BridgeSteel)
+ {
+ tBridgeBottomBaseToAdd = GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Mesh/RoadObj/Bridges/BridgeBaseSteelBeam-18w-20l-3d.fbx";
+ tName = "BridgeSteelBeams";
+ }
+ }
+ else if (tNode.GSDSpline.tRoad.opt_Lanes == 4)
+ {
+ if (tBridgeBottomBaseQuickAdd == BridgeBottomBaseDefaultsEnum.BridgeBase2)
+ {
+ tBridgeBottomBaseToAdd = GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Mesh/RoadObj/Bridges/BridgeBase2-28w-5l-3d.fbx";
+ tName = "BridgeBase2";
+ }
+ else if (tBridgeBottomBaseQuickAdd == BridgeBottomBaseDefaultsEnum.BridgeBase3)
+ {
+ tBridgeBottomBaseToAdd = GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Mesh/RoadObj/Bridges/BridgeBase3-28w-5l-5d.fbx";
+ tName = "BridgeBase3";
+ }
+ else if (tBridgeBottomBaseQuickAdd == BridgeBottomBaseDefaultsEnum.BridgeBase4)
+ {
+ tBridgeBottomBaseToAdd = GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Mesh/RoadObj/Bridges/BridgeBase4-28w-5l-5d.fbx";
+ tName = "BridgeBase4";
+ }
+ else if (tBridgeBottomBaseQuickAdd == BridgeBottomBaseDefaultsEnum.BridgeBase5)
+ {
+ tBridgeBottomBaseToAdd = GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Mesh/RoadObj/Bridges/BridgeBase5-28w-5l-5d.fbx";
+ tName = "BridgeBase5";
+ }
+ else if (tBridgeBottomBaseQuickAdd == BridgeBottomBaseDefaultsEnum.BridgeBase6)
+ {
+ tBridgeBottomBaseToAdd = GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Mesh/RoadObj/Bridges/BridgeBase6-4L.fbx";
+ tName = "BridgeArchBeam80";
+ }
+ else if (tBridgeBottomBaseQuickAdd == BridgeBottomBaseDefaultsEnum.BridgeBase7)
+ {
+ tBridgeBottomBaseToAdd = GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Mesh/RoadObj/Bridges/BridgeBase7-4L.fbx";
+ tName = "BridgeArchSolid80";
+ }
+ else if (tBridgeBottomBaseQuickAdd == BridgeBottomBaseDefaultsEnum.BridgeBase8)
+ {
+ tBridgeBottomBaseToAdd = GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Mesh/RoadObj/Bridges/BridgeBase8-4L.fbx";
+ tName = "BridgeArchSolid180";
+ }
+ else if (tBridgeBottomBaseQuickAdd == BridgeBottomBaseDefaultsEnum.BridgeBaseGrid)
+ {
+ tBridgeBottomBaseToAdd = GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Mesh/RoadObj/Bridges/BridgeBaseGrid-28w-5l-5d.fbx";
+ tName = "BridgeGrid";
+ }
+ else if (tBridgeBottomBaseQuickAdd == BridgeBottomBaseDefaultsEnum.BridgeSteel)
+ {
+ tBridgeBottomBaseToAdd = GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Mesh/RoadObj/Bridges/BridgeBaseSteelBeam-28w-20l-3d.fbx";
+ tName = "BridgeSteelBeams";
+ }
+ }
+ else
+ {
+ if (tBridgeBottomBaseQuickAdd == BridgeBottomBaseDefaultsEnum.BridgeBase2)
+ {
+ tBridgeBottomBaseToAdd = GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Mesh/RoadObj/Bridges/BridgeBase2-38w-5l-3d.fbx";
+ tName = "BridgeBase2";
+ }
+ else if (tBridgeBottomBaseQuickAdd == BridgeBottomBaseDefaultsEnum.BridgeBase3)
+ {
+ tBridgeBottomBaseToAdd = GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Mesh/RoadObj/Bridges/BridgeBase3-38w-5l-5d.fbx";
+ tName = "BridgeBase3";
+ }
+ else if (tBridgeBottomBaseQuickAdd == BridgeBottomBaseDefaultsEnum.BridgeBase4)
+ {
+ tBridgeBottomBaseToAdd = GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Mesh/RoadObj/Bridges/BridgeBase4-38w-5l-5d.fbx";
+ tName = "BridgeBase4";
+ }
+ else if (tBridgeBottomBaseQuickAdd == BridgeBottomBaseDefaultsEnum.BridgeBase5)
+ {
+ tBridgeBottomBaseToAdd = GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Mesh/RoadObj/Bridges/BridgeBase5-38w-5l-5d.fbx";
+ tName = "BridgeBase5";
+ }
+ else if (tBridgeBottomBaseQuickAdd == BridgeBottomBaseDefaultsEnum.BridgeBase6)
+ {
+ tBridgeBottomBaseToAdd = GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Mesh/RoadObj/Bridges/BridgeBase6-6L.fbx";
+ tName = "BridgeArchBeam80";
+ }
+ else if (tBridgeBottomBaseQuickAdd == BridgeBottomBaseDefaultsEnum.BridgeBase7)
+ {
+ tBridgeBottomBaseToAdd = GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Mesh/RoadObj/Bridges/BridgeBase7-6L.fbx";
+ tName = "BridgeArchSolid80";
+ }
+ else if (tBridgeBottomBaseQuickAdd == BridgeBottomBaseDefaultsEnum.BridgeBase8)
+ {
+ tBridgeBottomBaseToAdd = GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Mesh/RoadObj/Bridges/BridgeBase8-6L.fbx";
+ tName = "BridgeArchSolid180";
+ }
+ else if (tBridgeBottomBaseQuickAdd == BridgeBottomBaseDefaultsEnum.BridgeBaseGrid)
+ {
+ tBridgeBottomBaseToAdd = GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Mesh/RoadObj/Bridges/BridgeBaseGrid-38w-5l-5d.fbx";
+ tName = "BridgeGrid";
+ }
+ else if (tBridgeBottomBaseQuickAdd == BridgeBottomBaseDefaultsEnum.BridgeSteel)
+ {
+ tBridgeBottomBaseToAdd = GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Mesh/RoadObj/Bridges/BridgeBaseSteelBeam-38w-20l-3d.fbx";
+ tName = "BridgeBeams";
+ }
+ }
+
+ if (bOverridePrefab)
+ {
+ tBridgeBottomBaseToAdd = OverridePrefab;
+ }
+
+ SMM.CurrentSplination = (GameObject) UnityEditor.AssetDatabase.LoadAssetAtPath(tBridgeBottomBaseToAdd, typeof(GameObject));
+ SMM.HorizontalSep = tHorizSep;
+ SMM.VerticalRaise = tVertRaise;
+ SMM.bMaterialOverride = true;
+ SMM.tName = tName;
+
+ if (tBridgeBottomBaseQuickAdd == BridgeBottomBaseDefaultsEnum.BridgeBase2)
+ {
+ SMM.SplinatedMaterial1 = GSD.Roads.GSDRoadUtilityEditor.GiveMaterial(tMat);
+ }
+ else if (tBridgeBottomBaseQuickAdd == BridgeBottomBaseDefaultsEnum.BridgeBase3)
+ {
+ SMM.SplinatedMaterial1 = GSD.Roads.GSDRoadUtilityEditor.GiveMaterial(tMat);
+ }
+ else if (tBridgeBottomBaseQuickAdd == BridgeBottomBaseDefaultsEnum.BridgeBase4)
+ {
+ SMM.SplinatedMaterial1 = GSD.Roads.GSDRoadUtilityEditor.GiveMaterial(tMat);
+ }
+ else if (tBridgeBottomBaseQuickAdd == BridgeBottomBaseDefaultsEnum.BridgeBase5)
+ {
+ SMM.SplinatedMaterial1 = GSD.Roads.GSDRoadUtilityEditor.GiveMaterial(tMat);
+ }
+ else if (tBridgeBottomBaseQuickAdd == BridgeBottomBaseDefaultsEnum.BridgeBase6)
+ {
+ SMM.SplinatedMaterial1 = GSD.Roads.GSDRoadUtilityEditor.GiveMaterial(tMat);
+ }
+ else if (tBridgeBottomBaseQuickAdd == BridgeBottomBaseDefaultsEnum.BridgeBase7)
+ {
+ SMM.SplinatedMaterial1 = GSD.Roads.GSDRoadUtilityEditor.GiveMaterial(tMat);
+ }
+ else if (tBridgeBottomBaseQuickAdd == BridgeBottomBaseDefaultsEnum.BridgeBase8)
+ {
+ SMM.SplinatedMaterial1 = GSD.Roads.GSDRoadUtilityEditor.GiveMaterial(tMat);
+ }
+ else if (tBridgeBottomBaseQuickAdd == BridgeBottomBaseDefaultsEnum.BridgeBaseGrid)
+ {
+ SMM.SplinatedMaterial1 = GSD.Roads.GSDRoadUtilityEditor.GiveMaterial(GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Materials/GSDSteel7.mat");
+ }
+ else if (tBridgeBottomBaseQuickAdd == BridgeBottomBaseDefaultsEnum.BridgeSteel)
+ {
+ SMM.SplinatedMaterial1 = GSD.Roads.GSDRoadUtilityEditor.GiveMaterial(GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Materials/GSDSteel7.mat");
+ }
+
+ SMM.Axis = GSD.Roads.Splination.AxisTypeEnum.Z;
+
+ tBridgeTopBaseQuickAdd = BridgeTopBaseDefaultsEnum.None;
+ if (SMM.StartTime < tNode.MinSplination)
+ {
+ SMM.StartTime = tNode.MinSplination;
+ }
+ if (SMM.EndTime > tNode.MaxSplination)
+ {
+ SMM.EndTime = tNode.MaxSplination;
+ }
+ }
+
+
+ private void ExtrusionQuickAdd(bool bHorizOverride = false, float tHorizSep = 0f, bool bVertOverride = false, float tVertRaise = 0f)
+ {
+ try
+ {
+ ExtrusionQuickAdd_Do();
+ }
+ catch (System.Exception exception)
+ {
+ tSMMQuickAdd = SMMDefaultsEnum.None;
+ throw exception;
+ }
+ }
+
+
+ private void ExtrusionQuickAdd_Do()
+ {
+ if (tSMMQuickAdd == SMMDefaultsEnum.KRail)
+ {
+ tNode.SplinatedObjectQuickAdd("KRail");
+ }
+ }
+
+
+ private void ExtrudeHelper(string tPath, string tName, float DefaultHoriz, GSD.Roads.Splination.AxisTypeEnum tAxis = GSD.Roads.Splination.AxisTypeEnum.Z, bool bHorizOverride = false, float tHorizSep = 0f, bool bVertOverride = false, float tVertRaise = 0f, bool bFlipRot = false)
+ {
+ SMM = tNode.AddSplinatedObject();
+ SMM.CurrentSplination = (GameObject) UnityEditor.AssetDatabase.LoadAssetAtPath(tPath, typeof(GameObject));
+
+ if (bHorizOverride)
+ {
+ SMM.HorizontalSep = tHorizSep;
+ }
+ else
+ {
+ SMM.HorizontalSep = ((tNode.GSDSpline.tRoad.RoadWidth() / 2) + tNode.GSDSpline.tRoad.opt_ShoulderWidth) * -1f;
+ }
+
+ if (bVertOverride)
+ {
+ SMM.VerticalRaise = tVertRaise;
+ }
+ else
+ {
+ if (tNode.bIsBridgeStart)
+ {
+ SMM.VerticalRaise = -0.01f;
+ }
+ }
+
+ SMM.bFlipRotation = bFlipRot;
+ SMM.Axis = tAxis;
+ if (SMM.StartTime < tNode.MinSplination)
+ {
+ SMM.StartTime = tNode.MinSplination;
+ }
+ if (SMM.EndTime > tNode.MaxSplination)
+ {
+ SMM.EndTime = tNode.MaxSplination;
+ }
+ SMM.tName = tName;
+ }
+ #endregion
+
+
+ public void OnSceneGUI()
+ {
+ Event current = Event.current;
+ int controlID = GUIUtility.GetControlID(GetHashCode(), FocusType.Passive);
+ bool bUsed = false;
+
+ if (!bSceneRectSet)
+ {
+ try
+ {
+ tSceneRect = EditorWindow.GetWindow().position;
+ }
+ catch
+ {
+ tSceneRect = EditorWindow.GetWindow().position;
+ }
+ bSceneRectSet = true;
+ }
+
+ if (!tNode.bEditorSelected)
+ {
+ tNode.bEditorSelected = true;
+ }
+
+ if (current.type == EventType.ValidateCommand)
+ {
+ switch (current.commandName)
+ {
+ case "UndoRedoPerformed":
+ UpdateSplineObjects_OnUndo();
+ break;
+ }
+ }
+
+ if (controlID != tNode.GetHashCode())
+ {
+ tNode.bEditorSelected = false;
+ }
+
+ //Drag with left click:
+ if (Event.current.type == EventType.MouseDrag && Event.current.button == 0)
+ {
+ bMouseDragHasProcessed = false;
+ tNode.bGizmoDrawIntersectionHighlight = true;
+ }
+ //Drag with left click release:
+ if (Event.current.type == EventType.MouseUp && Event.current.button == 0)
+ {
+ Object[] xNodeObjects = GameObject.FindObjectsOfType(typeof(GSDSplineN));
+ Object[] connectorObjects = GameObject.FindObjectsOfType(typeof(GSDRoadConnector));
+ foreach (GSDSplineN xNode in xNodeObjects)
+ {
+ if (Vector3.Distance(xNode.transform.position, tNode.transform.position) < 2f)
+ {
+ if (xNode == tNode)
+ {
+ continue;
+ }
+ if (tNode.bSpecialEndNode || xNode.bSpecialEndNode)
+ {
+ continue;
+ }
+ if (xNode.bIsEndPoint && tNode.bIsEndPoint)
+ {
+ //End point connection.
+ tNode.transform.position = xNode.transform.position;
+ //Activate special end node for tnode
+ TriggerRoadConnection(tNode, xNode);
+ bUsed = true;
+ break;
+ }
+ if (xNode.bIsIntersection)
+ {
+ continue;
+ }
+ if (xNode.bNeverIntersect)
+ {
+ continue;
+ }
+ if (tNode.bIsEndPoint && xNode.bIsEndPoint)
+ {
+ continue;
+ }
+ if (xNode.GSDSpline == tNode.GSDSpline)
+ { //Don't let intersection be created on consecutive nodes:
+ if ((tNode.idOnSpline + 1) == xNode.idOnSpline || (tNode.idOnSpline - 1) == xNode.idOnSpline)
+ {
+ continue;
+ }
+ }
+ tNode.transform.position = xNode.transform.position;
+ TriggerIntersection(tNode, xNode);
+ bUsed = true;
+ break;
+ }
+ else
+ {
+ continue;
+ }
+ }
+ foreach (GSDRoadConnector connector in connectorObjects)
+ {
+ if (Vector3.Distance(connector.transform.position, tNode.transform.position) < 2f)
+ {
+ if (connector.connectedNode != null)
+ {
+ continue;
+ }
+ connector.ConnectToNode(tNode);
+ break;
+ }
+ }
+
+ if (!bMouseDragHasProcessed)
+ {
+ //Enforce maximum road grade:
+ if (tNode.IsLegitimate() && tNode.GSDSpline.tRoad.opt_bMaxGradeEnabled)
+ {
+ tNode.EnsureGradeValidity();
+ }
+ TriggerRoadUpdate();
+ bUsed = true;
+ }
+ bMouseDragHasProcessed = true;
+ tNode.bGizmoDrawIntersectionHighlight = false;
+ bUsed = true;
+ }
+
+ //Enforce maximum road grade:
+ if (bMouseDragHasProcessed)
+ {
+
+ Vector3 vChangeChecker = tNode.transform.position;
+ if (VectorDiff(vChangeChecker, tNode.pos))
+ {
+ tNode.pos = vChangeChecker;
+ if (tNode.IsLegitimate() && tNode.GSDSpline.tRoad.opt_bMaxGradeEnabled)
+ {
+ tNode.EnsureGradeValidity();
+ }
+ TriggerRoadUpdate();
+ }
+ bUsed = true;
+ }
+
+ if (Selection.activeGameObject == tNode.transform.gameObject)
+ {
+ if (current.keyCode == KeyCode.F5)
+ {
+ TriggerRoadUpdate();
+ }
+ }
+
+ if (bUsed)
+ {
+ // switch(current.type){
+ // case EventType.layout:
+ // HandleUtility.AddDefaultControl(controlID);
+ // break;
+ // }
+ }
+
+ if (GUI.changed)
+ {
+ EditorUtility.SetDirty(tNode);
+ }
+ }
+
+
+ private bool VectorDiff(Vector3 tVect1, Vector3 tVect2)
+ {
+ if (!GSDRootUtil.IsApproximately(tVect1.x, tVect2.x, 0.0001f))
+ {
+ return true;
+ }
+ if (!GSDRootUtil.IsApproximately(tVect1.y, tVect2.y, 0.0001f))
+ {
+ return true;
+ }
+ if (!GSDRootUtil.IsApproximately(tVect1.z, tVect2.z, 0.0001f))
+ {
+ return true;
+ }
+ return false;
+ }
+
+
+ #region Triggers Interesctions; Connections; Update
+ private void TriggerRoadConnection(GSDSplineN tNode1, GSDSplineN tNode2)
+ {
+ tNode.GSDSpline.ActivateEndNodeConnection(tNode1, tNode2);
+ }
+
+
+ private void TriggerIntersection(GSDSplineN tNode1, GSDSplineN tNode2)
+ {
+ bCreateIntersection = true;
+ iNode1 = tNode1;
+ iNode2 = tNode2;
+ Selection.activeGameObject = GSD.Roads.GSDIntersections.CreateIntersection(tNode1, tNode2);
+ }
+
+
+ private void TriggerRoadUpdate()
+ {
+ if (tNode != null)
+ {
+ tNode.GSDSpline.tRoad.EditorUpdateMe = true;
+ }
+ }
+ #endregion
+
+
+ #region Optimizable // LineGUILayout
+ void Line()
+ {
+ GUILayout.Space(4f);
+ GUILayout.Box("", GUILayout.ExpandWidth(true), GUILayout.Height(1f)); //Horizontal bar
+ GUILayout.Space(4f);
+ }
+
+
+ void LineSmall()
+ {
+ GUILayout.Space(2f);
+ GUILayout.Box("", GUILayout.ExpandWidth(true), GUILayout.Height(1f)); //Horizontal bar
+ GUILayout.Space(2f);
+ }
+
+
+ void BigLine()
+ {
+ GUILayout.Space(4f);
+ GUILayout.Box("", GUILayout.ExpandWidth(true), GUILayout.Height(4f)); //Horizontal bar
+ GUILayout.Space(4f);
+ }
+ #endregion
+
+
+ void ResetCurve(ref AnimationCurve tCurve)
+ {
+ tCurve = null;
+ tCurve = new AnimationCurve();
+ EnforceCurve(ref tCurve);
+ }
+
+
+ bool V3Equal(ref Vector3 V1, ref Vector3 V2)
+ {
+ if (!GSDRootUtil.IsApproximately(V1.x, V2.x, 0.001f))
+ {
+ return false;
+ }
+ if (!GSDRootUtil.IsApproximately(V1.y, V2.y, 0.001f))
+ {
+ return false;
+ }
+ if (!GSDRootUtil.IsApproximately(V1.z, V2.z, 0.001f))
+ {
+ return false;
+ }
+ return true;
+ }
+
+
+ void EnforceCurve(ref AnimationCurve tCurve)
+ {
+ if (tCurve == null)
+ {
+ return;
+ }
+ if (tCurve.keys.Length == 0)
+ {
+ tCurve.AddKey(0f, 1f);
+ tCurve.AddKey(1f, 1f);
+ }
+ else if (tCurve.keys.Length == 1)
+ {
+ tCurve.keys[0].time = 0f;
+ tCurve.AddKey(1f, 1f);
+ }
+ }
+
+
+ GameObject GetEndObjectQuickAdd()
+ {
+ string tPath = "";
+ if (tEndObjectAdd == EndObjectsDefaultsEnum.WarningSign1_Static)
+ {
+ tPath = GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Mesh/RoadObj/Interactive/GSDWarningSign_Static.prefab";
+ }
+ else if (tEndObjectAdd == EndObjectsDefaultsEnum.WarningSign2_Static)
+ {
+ tPath = GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Mesh/RoadObj/Interactive/GSDWarningSign2_Static.prefab";
+ }
+ else if (tEndObjectAdd == EndObjectsDefaultsEnum.Atten_Static)
+ {
+ tPath = GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Mesh/RoadObj/Interactive/GSDAtten_Static.prefab";
+ }
+ else if (tEndObjectAdd == EndObjectsDefaultsEnum.Barrel1_Static)
+ {
+ tPath = GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Mesh/RoadObj/Interactive/GSDRoadBarrel_Static.prefab";
+ }
+ else if (tEndObjectAdd == EndObjectsDefaultsEnum.Barrel1_Rigid)
+ {
+ tPath = GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Mesh/RoadObj/Interactive/GSDRoadBarrel_Rigid.prefab";
+ }
+ else if (tEndObjectAdd == EndObjectsDefaultsEnum.Barrel3_Static)
+ {
+ tPath = GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Mesh/RoadObj/Interactive/GSDRoadBarrel3_Static.prefab";
+ }
+ else if (tEndObjectAdd == EndObjectsDefaultsEnum.Barrel3_Rigid)
+ {
+ tPath = GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Mesh/RoadObj/Interactive/GSDRoadBarrel3_Rigid.prefab";
+ }
+ else if (tEndObjectAdd == EndObjectsDefaultsEnum.Barrel7_Static)
+ {
+ tPath = GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Mesh/RoadObj/Interactive/GSDRoadBarrel7_Static.prefab";
+ }
+ else if (tEndObjectAdd == EndObjectsDefaultsEnum.Barrel7_Rigid)
+ {
+ tPath = GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Mesh/RoadObj/Interactive/GSDRoadBarrel7_Rigid.prefab";
+ }
+ else
+ {
+ return null;
+ }
+
+ return (GameObject) UnityEditor.AssetDatabase.LoadAssetAtPath(tPath, typeof(GameObject)) as GameObject;
+ }
+}
\ No newline at end of file
diff --git a/Editor/GSDTerrainEditor.cs b/Editor/GSDTerrainEditor.cs
index f4f27317..79a91f16 100755
--- a/Editor/GSDTerrainEditor.cs
+++ b/Editor/GSDTerrainEditor.cs
@@ -1,291 +1,301 @@
-using UnityEngine;
-using UnityEditor;
-using GSD;
-[CustomEditor(typeof(GSDTerrain))]
-public class GSDTerrainEditor : Editor
-{
- protected GSDTerrain GSDT { get { return (GSDTerrain)target; } }
-
- //Serialized properties:
- SerializedProperty tSplatImageWidth;
- SerializedProperty tSplatImageHeight;
- SerializedProperty tSplatBackgroundColor;
- SerializedProperty tSplatForegroundColor;
- SerializedProperty tSplatWidth;
- SerializedProperty tSkipBridges;
- SerializedProperty tSkipTunnels;
- SerializedProperty tSplatSingleRoad;
- SerializedProperty tSplatSingleChoiceIndex;
- SerializedProperty tRoadSingleChoiceUID;
-
- public enum SplatImageResoMatchingEnum
- {
- None,
- Match512x512,
- Match1024x1024,
- Match2048x2048,
- Match4096x4096,
- MatchHeightmapResolution,
- MatchDetailResolution,
- MatchTerrainSize
- };
- SplatImageResoMatchingEnum tSplatReso = SplatImageResoMatchingEnum.None;
-
- private static string[] TheSplatResoOptions = new string[]{
- "Select option to match resolution",
- "512 x 512",
- "1024 x 1024",
- "2048 x 2048",
- "4096 x 4096",
- "Match heightmap resolution",
- "Match detail resolution",
- "Match terrain size"
- };
-
- //Editor only variables:
- string[] tRoads = null;
- string[] tRoadsString = null;
- Texture btnRefreshText = null;
- GUIStyle GSDImageButton = null;
- Texture2D LoadBtnBG = null;
- Texture2D LoadBtnBGGlow = null;
- GUIStyle GSDLoadButton = null;
-
- private void OnEnable()
- {
- tSplatImageWidth = serializedObject.FindProperty("SplatResoWidth");
- tSplatImageHeight = serializedObject.FindProperty("SplatResoHeight");
- tSplatBackgroundColor = serializedObject.FindProperty("SplatBackground");
- tSplatForegroundColor = serializedObject.FindProperty("SplatForeground");
- tSplatWidth = serializedObject.FindProperty("SplatWidth");
- tSkipBridges = serializedObject.FindProperty("SplatSkipBridges");
- tSkipTunnels = serializedObject.FindProperty("SplatSkipTunnels");
- tSplatSingleRoad = serializedObject.FindProperty("SplatSingleRoad");
- tSplatSingleChoiceIndex = serializedObject.FindProperty("SplatSingleChoiceIndex");
- tRoadSingleChoiceUID = serializedObject.FindProperty("RoadSingleChoiceUID");
- }
-
- public override void OnInspectorGUI()
- {
- serializedObject.Update();
- InitNullChecks();
-
- Line();
- EditorGUILayout.BeginHorizontal();
- //Main label:
- EditorGUILayout.LabelField("Splat map generation:", EditorStyles.boldLabel);
- //Online manual button:
- if (GUILayout.Button("Online manual", EditorStyles.miniButton, GUILayout.Width(120f)))
- {
- Application.OpenURL("http://microgsd.com/Support/RoadArchitectManual.aspx");
- }
- EditorGUILayout.EndHorizontal();
- GUILayout.Space(6f);
-
- //Splat Resolution input:
- tSplatImageWidth.intValue = GSDT.SplatResoWidth;
- tSplatImageHeight.intValue = GSDT.SplatResoHeight;
- EditorGUILayout.BeginHorizontal();
- tSplatReso = (SplatImageResoMatchingEnum)EditorGUILayout.Popup("Match resolutions:", (int)tSplatReso, TheSplatResoOptions);
- if (GUILayout.Button(btnRefreshText, GSDImageButton, GUILayout.Width(16f)))
- {
- tSplatImageWidth.intValue = 1024;
- tSplatImageHeight.intValue = 1024;
- }
- EditorGUILayout.EndHorizontal();
-
- if (tSplatReso != SplatImageResoMatchingEnum.None)
- {
- if (tSplatReso == SplatImageResoMatchingEnum.MatchHeightmapResolution)
- {
- tSplatImageWidth.intValue = GSDT.tTerrain.terrainData.heightmapResolution;
- tSplatImageHeight.intValue = GSDT.tTerrain.terrainData.heightmapResolution;
- }
- else if (tSplatReso == SplatImageResoMatchingEnum.MatchDetailResolution)
- {
- tSplatImageWidth.intValue = GSDT.tTerrain.terrainData.detailResolution;
- tSplatImageHeight.intValue = GSDT.tTerrain.terrainData.detailResolution;
- }
- else if (tSplatReso == SplatImageResoMatchingEnum.MatchTerrainSize)
- {
- tSplatImageWidth.intValue = (int)GSDT.tTerrain.terrainData.size.x;
- tSplatImageHeight.intValue = (int)GSDT.tTerrain.terrainData.size.z;
- }
- else if (tSplatReso == SplatImageResoMatchingEnum.Match512x512)
- {
- tSplatImageWidth.intValue = 512;
- tSplatImageHeight.intValue = 512;
- }
- else if (tSplatReso == SplatImageResoMatchingEnum.Match1024x1024)
- {
- tSplatImageWidth.intValue = 1024;
- tSplatImageHeight.intValue = 1024;
- }
- else if (tSplatReso == SplatImageResoMatchingEnum.Match2048x2048)
- {
- tSplatImageWidth.intValue = 2048;
- tSplatImageHeight.intValue = 2048;
- }
- else if (tSplatReso == SplatImageResoMatchingEnum.Match4096x4096)
- {
- tSplatImageWidth.intValue = 4096;
- tSplatImageHeight.intValue = 4096;
- }
- tSplatReso = SplatImageResoMatchingEnum.None;
- }
-
- //Splat image width input:
- tSplatImageWidth.intValue = EditorGUILayout.IntField("Splat image width:", tSplatImageWidth.intValue);
- //Splat image height input:
- tSplatImageHeight.intValue = EditorGUILayout.IntField("Splat image height:", tSplatImageHeight.intValue);
-
-
- //Splat background color input:
- EditorGUILayout.BeginHorizontal();
- tSplatBackgroundColor.colorValue = EditorGUILayout.ColorField("Splat background:", GSDT.SplatBackground);
- //Default button:
- if (GUILayout.Button(btnRefreshText, GSDImageButton, GUILayout.Width(16f)))
- {
- tSplatBackgroundColor.colorValue = new Color(0f, 0f, 0f, 1f);
- }
- EditorGUILayout.EndHorizontal();
-
- //Splat foreground color input:
- EditorGUILayout.BeginHorizontal();
- tSplatForegroundColor.colorValue = EditorGUILayout.ColorField("Splat foreground:", GSDT.SplatForeground);
- //Default button:
- if (GUILayout.Button(btnRefreshText, GSDImageButton, GUILayout.Width(16f)))
- {
- tSplatForegroundColor.colorValue = new Color(1f, 1f, 1f, 1f);
- }
- EditorGUILayout.EndHorizontal();
-
- //Splat width (meters) input:
- EditorGUILayout.BeginHorizontal();
- tSplatWidth.floatValue = EditorGUILayout.Slider("Splat width (meters):", GSDT.SplatWidth, 0.02f, 256f);
- //Default button:
- if (GUILayout.Button(btnRefreshText, GSDImageButton, GUILayout.Width(16f)))
- {
- tSplatWidth.floatValue = 30f;
- }
- EditorGUILayout.EndHorizontal();
-
- //Skip bridges:
- tSkipBridges.boolValue = EditorGUILayout.Toggle("Skip bridges: ", GSDT.SplatSkipBridges);
-
- //Skip tunnels:
- tSkipTunnels.boolValue = EditorGUILayout.Toggle("Skip tunnels: ", GSDT.SplatSkipTunnels);
-
- //Splat single road bool input:
- EditorGUILayout.BeginHorizontal();
- tSplatSingleRoad.boolValue = EditorGUILayout.Toggle("Splat a single road: ", GSDT.SplatSingleRoad);
-
- //Splat single road , road input:
- if (GSDT.SplatSingleRoad)
- {
- LoadSplatSingleChoice();
- tSplatSingleChoiceIndex.intValue = EditorGUILayout.Popup(GSDT.SplatSingleChoiceIndex, tRoadsString, GUILayout.Width(150f));
- tRoadSingleChoiceUID.stringValue = tRoads[tSplatSingleChoiceIndex.intValue];
- }
-
- EditorGUILayout.EndHorizontal();
-
- //Generate splatmap button:
- GUILayout.Space(8f);
- if (GUILayout.Button("Generate splatmap for this terrain"))
- {
- GenerateSplatMap();
- }
- GUILayout.Space(10f);
-
- if (GUI.changed)
- {
- serializedObject.ApplyModifiedProperties();
- // EditorUtility.SetDirty(target); //Necessary?
- }
- }
-
- void InitNullChecks()
- {
- if (btnRefreshText == null)
- {
- btnRefreshText = (Texture)AssetDatabase.LoadAssetAtPath(GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Editor/Icons/refresh2.png", typeof(Texture)) as Texture;
- }
- if (GSDImageButton == null)
- {
- GSDImageButton = new GUIStyle(GUI.skin.button);
- GSDImageButton.contentOffset = new Vector2(0f, 0f);
- GSDImageButton.border = new RectOffset(0, 0, 0, 0);
- GSDImageButton.fixedHeight = 16f;
- GSDImageButton.padding = new RectOffset(0, 0, 0, 0);
- GSDImageButton.normal.background = null;
- }
- if (LoadBtnBG == null)
- {
- LoadBtnBG = (Texture2D)AssetDatabase.LoadAssetAtPath(GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Editor/Icons/FlexBG.png", typeof(Texture2D)) as Texture2D;
- }
- if (LoadBtnBGGlow == null)
- {
- LoadBtnBGGlow = (Texture2D)AssetDatabase.LoadAssetAtPath(GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Editor/Icons/FlexBG.png", typeof(Texture2D)) as Texture2D;
- }
- if (GSDLoadButton == null)
- {
- GSDLoadButton = new GUIStyle(GUI.skin.button);
- GSDLoadButton.contentOffset = new Vector2(0f, 1f);
- GSDLoadButton.normal.textColor = new Color(1f, 1f, 1f, 1f);
- GSDLoadButton.normal.background = LoadBtnBG;
- GSDLoadButton.active.background = LoadBtnBGGlow;
- GSDLoadButton.focused.background = LoadBtnBGGlow;
- GSDLoadButton.hover.background = LoadBtnBGGlow;
- GSDLoadButton.fixedHeight = 16f;
- GSDLoadButton.padding = new RectOffset(0, 0, 0, 0);
- }
- }
-
- private void LoadSplatSingleChoice()
- {
- tRoads = null;
- tRoadsString = null;
- Object[] xRoads = GameObject.FindObjectsOfType(typeof(GSDRoad));
- int xRoadsCount = xRoads.Length;
- tRoads = new string[xRoadsCount];
- tRoadsString = new string[xRoadsCount];
- int xCounter = 0;
- foreach (GSDRoad tRoad in xRoads)
- {
- tRoads[xCounter] = tRoad.UID;
- tRoadsString[xCounter] = tRoad.transform.name;
- xCounter += 1;
- }
- }
-
- private void GenerateSplatMap()
- {
- byte[] tBytes = null;
- if (GSDT.SplatSingleRoad && GSDT.RoadSingleChoiceUID != "")
- {
- tBytes = GSD.Roads.GSDRoadUtil.MakeSplatMap(GSDT.tTerrain, GSDT.SplatBackground, GSDT.SplatForeground, GSDT.SplatResoWidth, GSDT.SplatResoHeight, GSDT.SplatWidth, GSDT.SplatSkipBridges, GSDT.SplatSkipTunnels, GSDT.RoadSingleChoiceUID);
- }
- else
- {
- tBytes = GSD.Roads.GSDRoadUtil.MakeSplatMap(GSDT.tTerrain, GSDT.SplatBackground, GSDT.SplatForeground, GSDT.SplatResoWidth, GSDT.SplatResoHeight, GSDT.SplatWidth, GSDT.SplatSkipBridges, GSDT.SplatSkipTunnels);
- }
-
- if (tBytes != null && tBytes.Length > 3)
- {
- string tPath = UnityEditor.EditorUtility.SaveFilePanel("Save splat map", Application.dataPath, "Splat", "png");
- if (tPath != null && tPath.Length > 3)
- {
- System.IO.File.WriteAllBytes(tPath, tBytes);
- }
- tBytes = null;
- }
- }
-
- void Line()
- {
- GUILayout.Space(4f);
- GUILayout.Box("", GUILayout.ExpandWidth(true), GUILayout.Height(1)); //Horizontal bar
- GUILayout.Space(4f);
- }
+#region "Imports"
+using UnityEngine;
+using UnityEditor;
+using GSD;
+#endregion
+
+
+[CustomEditor(typeof(GSDTerrain))]
+public class GSDTerrainEditor : Editor
+{
+ protected GSDTerrain GSDT { get { return (GSDTerrain) target; } }
+
+ //Serialized properties:
+ SerializedProperty tSplatImageWidth;
+ SerializedProperty tSplatImageHeight;
+ SerializedProperty tSplatBackgroundColor;
+ SerializedProperty tSplatForegroundColor;
+ SerializedProperty tSplatWidth;
+ SerializedProperty tSkipBridges;
+ SerializedProperty tSkipTunnels;
+ SerializedProperty tSplatSingleRoad;
+ SerializedProperty tSplatSingleChoiceIndex;
+ SerializedProperty tRoadSingleChoiceUID;
+
+ public enum SplatImageResoMatchingEnum
+ {
+ None,
+ Match512x512,
+ Match1024x1024,
+ Match2048x2048,
+ Match4096x4096,
+ MatchHeightmapResolution,
+ MatchDetailResolution,
+ MatchTerrainSize
+ };
+ SplatImageResoMatchingEnum tSplatReso = SplatImageResoMatchingEnum.None;
+
+ private static string[] TheSplatResoOptions = new string[]{
+ "Select option to match resolution",
+ "512 x 512",
+ "1024 x 1024",
+ "2048 x 2048",
+ "4096 x 4096",
+ "Match heightmap resolution",
+ "Match detail resolution",
+ "Match terrain size"
+ };
+
+ //Editor only variables:
+ string[] tRoads = null;
+ string[] tRoadsString = null;
+ Texture btnRefreshText = null;
+ GUIStyle GSDImageButton = null;
+ Texture2D LoadBtnBG = null;
+ Texture2D LoadBtnBGGlow = null;
+ GUIStyle GSDLoadButton = null;
+
+
+ private void OnEnable()
+ {
+ tSplatImageWidth = serializedObject.FindProperty("SplatResoWidth");
+ tSplatImageHeight = serializedObject.FindProperty("SplatResoHeight");
+ tSplatBackgroundColor = serializedObject.FindProperty("SplatBackground");
+ tSplatForegroundColor = serializedObject.FindProperty("SplatForeground");
+ tSplatWidth = serializedObject.FindProperty("SplatWidth");
+ tSkipBridges = serializedObject.FindProperty("SplatSkipBridges");
+ tSkipTunnels = serializedObject.FindProperty("SplatSkipTunnels");
+ tSplatSingleRoad = serializedObject.FindProperty("SplatSingleRoad");
+ tSplatSingleChoiceIndex = serializedObject.FindProperty("SplatSingleChoiceIndex");
+ tRoadSingleChoiceUID = serializedObject.FindProperty("RoadSingleChoiceUID");
+ }
+
+
+ public override void OnInspectorGUI()
+ {
+ serializedObject.Update();
+ InitNullChecks();
+
+ Line();
+ EditorGUILayout.BeginHorizontal();
+ //Main label:
+ EditorGUILayout.LabelField("Splat map generation:", EditorStyles.boldLabel);
+ //Online manual button:
+ if (GUILayout.Button("Online manual", EditorStyles.miniButton, GUILayout.Width(120f)))
+ {
+ Application.OpenURL("http://microgsd.com/Support/RoadArchitectManual.aspx");
+ }
+ EditorGUILayout.EndHorizontal();
+ GUILayout.Space(6f);
+
+ //Splat Resolution input:
+ tSplatImageWidth.intValue = GSDT.SplatResoWidth;
+ tSplatImageHeight.intValue = GSDT.SplatResoHeight;
+ EditorGUILayout.BeginHorizontal();
+ tSplatReso = (SplatImageResoMatchingEnum) EditorGUILayout.Popup("Match resolutions:", (int) tSplatReso, TheSplatResoOptions);
+ if (GUILayout.Button(btnRefreshText, GSDImageButton, GUILayout.Width(16f)))
+ {
+ tSplatImageWidth.intValue = 1024;
+ tSplatImageHeight.intValue = 1024;
+ }
+ EditorGUILayout.EndHorizontal();
+
+ if (tSplatReso != SplatImageResoMatchingEnum.None)
+ {
+ if (tSplatReso == SplatImageResoMatchingEnum.MatchHeightmapResolution)
+ {
+ tSplatImageWidth.intValue = GSDT.tTerrain.terrainData.heightmapResolution;
+ tSplatImageHeight.intValue = GSDT.tTerrain.terrainData.heightmapResolution;
+ }
+ else if (tSplatReso == SplatImageResoMatchingEnum.MatchDetailResolution)
+ {
+ tSplatImageWidth.intValue = GSDT.tTerrain.terrainData.detailResolution;
+ tSplatImageHeight.intValue = GSDT.tTerrain.terrainData.detailResolution;
+ }
+ else if (tSplatReso == SplatImageResoMatchingEnum.MatchTerrainSize)
+ {
+ tSplatImageWidth.intValue = (int) GSDT.tTerrain.terrainData.size.x;
+ tSplatImageHeight.intValue = (int) GSDT.tTerrain.terrainData.size.z;
+ }
+ else if (tSplatReso == SplatImageResoMatchingEnum.Match512x512)
+ {
+ tSplatImageWidth.intValue = 512;
+ tSplatImageHeight.intValue = 512;
+ }
+ else if (tSplatReso == SplatImageResoMatchingEnum.Match1024x1024)
+ {
+ tSplatImageWidth.intValue = 1024;
+ tSplatImageHeight.intValue = 1024;
+ }
+ else if (tSplatReso == SplatImageResoMatchingEnum.Match2048x2048)
+ {
+ tSplatImageWidth.intValue = 2048;
+ tSplatImageHeight.intValue = 2048;
+ }
+ else if (tSplatReso == SplatImageResoMatchingEnum.Match4096x4096)
+ {
+ tSplatImageWidth.intValue = 4096;
+ tSplatImageHeight.intValue = 4096;
+ }
+ tSplatReso = SplatImageResoMatchingEnum.None;
+ }
+
+ //Splat image width input:
+ tSplatImageWidth.intValue = EditorGUILayout.IntField("Splat image width:", tSplatImageWidth.intValue);
+ //Splat image height input:
+ tSplatImageHeight.intValue = EditorGUILayout.IntField("Splat image height:", tSplatImageHeight.intValue);
+
+
+ //Splat background color input:
+ EditorGUILayout.BeginHorizontal();
+ tSplatBackgroundColor.colorValue = EditorGUILayout.ColorField("Splat background:", GSDT.SplatBackground);
+ //Default button:
+ if (GUILayout.Button(btnRefreshText, GSDImageButton, GUILayout.Width(16f)))
+ {
+ tSplatBackgroundColor.colorValue = new Color(0f, 0f, 0f, 1f);
+ }
+ EditorGUILayout.EndHorizontal();
+
+ //Splat foreground color input:
+ EditorGUILayout.BeginHorizontal();
+ tSplatForegroundColor.colorValue = EditorGUILayout.ColorField("Splat foreground:", GSDT.SplatForeground);
+ //Default button:
+ if (GUILayout.Button(btnRefreshText, GSDImageButton, GUILayout.Width(16f)))
+ {
+ tSplatForegroundColor.colorValue = new Color(1f, 1f, 1f, 1f);
+ }
+ EditorGUILayout.EndHorizontal();
+
+ //Splat width (meters) input:
+ EditorGUILayout.BeginHorizontal();
+ tSplatWidth.floatValue = EditorGUILayout.Slider("Splat width (meters):", GSDT.SplatWidth, 0.02f, 256f);
+ //Default button:
+ if (GUILayout.Button(btnRefreshText, GSDImageButton, GUILayout.Width(16f)))
+ {
+ tSplatWidth.floatValue = 30f;
+ }
+ EditorGUILayout.EndHorizontal();
+
+ //Skip bridges:
+ tSkipBridges.boolValue = EditorGUILayout.Toggle("Skip bridges: ", GSDT.SplatSkipBridges);
+
+ //Skip tunnels:
+ tSkipTunnels.boolValue = EditorGUILayout.Toggle("Skip tunnels: ", GSDT.SplatSkipTunnels);
+
+ //Splat single road bool input:
+ EditorGUILayout.BeginHorizontal();
+ tSplatSingleRoad.boolValue = EditorGUILayout.Toggle("Splat a single road: ", GSDT.SplatSingleRoad);
+
+ //Splat single road , road input:
+ if (GSDT.SplatSingleRoad)
+ {
+ LoadSplatSingleChoice();
+ tSplatSingleChoiceIndex.intValue = EditorGUILayout.Popup(GSDT.SplatSingleChoiceIndex, tRoadsString, GUILayout.Width(150f));
+ tRoadSingleChoiceUID.stringValue = tRoads[tSplatSingleChoiceIndex.intValue];
+ }
+
+ EditorGUILayout.EndHorizontal();
+
+ //Generate splatmap button:
+ GUILayout.Space(8f);
+ if (GUILayout.Button("Generate splatmap for this terrain"))
+ {
+ GenerateSplatMap();
+ }
+ GUILayout.Space(10f);
+
+ if (GUI.changed)
+ {
+ serializedObject.ApplyModifiedProperties();
+ // EditorUtility.SetDirty(target); //Necessary?
+ }
+ }
+
+
+ void InitNullChecks()
+ {
+ if (btnRefreshText == null)
+ {
+ btnRefreshText = (Texture) AssetDatabase.LoadAssetAtPath(GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Editor/Icons/refresh2.png", typeof(Texture)) as Texture;
+ }
+ if (GSDImageButton == null)
+ {
+ GSDImageButton = new GUIStyle(GUI.skin.button);
+ GSDImageButton.contentOffset = new Vector2(0f, 0f);
+ GSDImageButton.border = new RectOffset(0, 0, 0, 0);
+ GSDImageButton.fixedHeight = 16f;
+ GSDImageButton.padding = new RectOffset(0, 0, 0, 0);
+ GSDImageButton.normal.background = null;
+ }
+ if (LoadBtnBG == null)
+ {
+ LoadBtnBG = (Texture2D) AssetDatabase.LoadAssetAtPath(GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Editor/Icons/FlexBG.png", typeof(Texture2D)) as Texture2D;
+ }
+ if (LoadBtnBGGlow == null)
+ {
+ LoadBtnBGGlow = (Texture2D) AssetDatabase.LoadAssetAtPath(GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Editor/Icons/FlexBG.png", typeof(Texture2D)) as Texture2D;
+ }
+ if (GSDLoadButton == null)
+ {
+ GSDLoadButton = new GUIStyle(GUI.skin.button);
+ GSDLoadButton.contentOffset = new Vector2(0f, 1f);
+ GSDLoadButton.normal.textColor = new Color(1f, 1f, 1f, 1f);
+ GSDLoadButton.normal.background = LoadBtnBG;
+ GSDLoadButton.active.background = LoadBtnBGGlow;
+ GSDLoadButton.focused.background = LoadBtnBGGlow;
+ GSDLoadButton.hover.background = LoadBtnBGGlow;
+ GSDLoadButton.fixedHeight = 16f;
+ GSDLoadButton.padding = new RectOffset(0, 0, 0, 0);
+ }
+ }
+
+
+ private void LoadSplatSingleChoice()
+ {
+ tRoads = null;
+ tRoadsString = null;
+ Object[] xRoads = GameObject.FindObjectsOfType(typeof(GSDRoad));
+ int xRoadsCount = xRoads.Length;
+ tRoads = new string[xRoadsCount];
+ tRoadsString = new string[xRoadsCount];
+ int xCounter = 0;
+ foreach (GSDRoad tRoad in xRoads)
+ {
+ tRoads[xCounter] = tRoad.UID;
+ tRoadsString[xCounter] = tRoad.transform.name;
+ xCounter += 1;
+ }
+ }
+
+
+ private void GenerateSplatMap()
+ {
+ byte[] tBytes = null;
+ if (GSDT.SplatSingleRoad && GSDT.RoadSingleChoiceUID != "")
+ {
+ tBytes = GSD.Roads.GSDRoadUtil.MakeSplatMap(GSDT.tTerrain, GSDT.SplatBackground, GSDT.SplatForeground, GSDT.SplatResoWidth, GSDT.SplatResoHeight, GSDT.SplatWidth, GSDT.SplatSkipBridges, GSDT.SplatSkipTunnels, GSDT.RoadSingleChoiceUID);
+ }
+ else
+ {
+ tBytes = GSD.Roads.GSDRoadUtil.MakeSplatMap(GSDT.tTerrain, GSDT.SplatBackground, GSDT.SplatForeground, GSDT.SplatResoWidth, GSDT.SplatResoHeight, GSDT.SplatWidth, GSDT.SplatSkipBridges, GSDT.SplatSkipTunnels);
+ }
+
+ if (tBytes != null && tBytes.Length > 3)
+ {
+ string tPath = UnityEditor.EditorUtility.SaveFilePanel("Save splat map", Application.dataPath, "Splat", "png");
+ if (tPath != null && tPath.Length > 3)
+ {
+ System.IO.File.WriteAllBytes(tPath, tBytes);
+ }
+ tBytes = null;
+ }
+ }
+
+
+ void Line()
+ {
+ GUILayout.Space(4f);
+ GUILayout.Box("", GUILayout.ExpandWidth(true), GUILayout.Height(1)); //Horizontal bar
+ GUILayout.Space(4f);
+ }
}
\ No newline at end of file
diff --git a/Editor/GSDWizard.cs b/Editor/GSDWizard.cs
index 0f60d5c9..b2699e86 100755
--- a/Editor/GSDWizard.cs
+++ b/Editor/GSDWizard.cs
@@ -1,956 +1,1013 @@
-#region "Imports"
-using UnityEngine;
-using UnityEditor;
-using System.Collections;
-using System.Collections.Generic;
-using GSD.Roads.Splination;
-using GSD.Roads.EdgeObjects;
-using GSD;
-using System.IO;
-using GSD.Roads;
-#endregion
-public class GSDWizard : EditorWindow
-{
- public enum WindowTypeEnum
- {
- Extrusion,
- Edge,
- BridgeComplete,
- Groups
- };
- public enum WindowTypeEnumShort
- {
- Extrusion,
- Edge,
- Groups
- };
- private static string[] WindowTypeDescBridge = new string[]{
- "Extrusion items",
- "Edge objects",
- "Complete bridges",
- "Other groups"
- };
- private static string[] WindowTypeDesc = new string[]{
- "Extrusion items",
- "Edge objects",
- "Other groups"
- };
- WindowTypeEnum tWindowType = WindowTypeEnum.Extrusion;
- WindowTypeEnum xWindowType = WindowTypeEnum.Extrusion;
- WindowTypeEnumShort StWindowType = WindowTypeEnumShort.Extrusion;
- WindowTypeEnumShort SxWindowType = WindowTypeEnumShort.Extrusion;
- static string xPath = "";
-
- GUIStyle ThumbStyle;
- Vector2 scrollPos = new Vector2(0f, 25f);
- GSDSplineN tNode = null;
- List oList = null;
- bool bNoGUI = false;
-
- void OnGUI()
- {
- DoGUI();
- }
-
- private void DoGUI()
- {
- if (bNoGUI) { return; }
- if (oList == null) { Close(); return; }
-
- GUILayout.Space(4f);
- EditorGUILayout.BeginHorizontal();
-
- if (tNode.bIsBridgeStart)
- {
- xWindowType = (WindowTypeEnum)EditorGUILayout.Popup("Category: ", (int)tWindowType, WindowTypeDescBridge, GUILayout.Width(312f));
- }
- else
- {
-
- if (xWindowType == WindowTypeEnum.Edge)
- {
- SxWindowType = WindowTypeEnumShort.Edge;
- }
- else if (xWindowType == WindowTypeEnum.Extrusion)
- {
- SxWindowType = WindowTypeEnumShort.Extrusion;
- }
- else
- {
- SxWindowType = WindowTypeEnumShort.Groups;
- }
-
- SxWindowType = (WindowTypeEnumShort)EditorGUILayout.Popup("Category: ", (int)StWindowType, WindowTypeDesc, GUILayout.Width(312f));
-
- if (SxWindowType == WindowTypeEnumShort.Extrusion)
- {
- xWindowType = WindowTypeEnum.Extrusion;
- }
- else if (SxWindowType == WindowTypeEnumShort.Edge)
- {
- xWindowType = WindowTypeEnum.Edge;
- }
- else
- {
- xWindowType = WindowTypeEnum.Groups;
- }
- StWindowType = SxWindowType;
- }
-
- if (xWindowType != tWindowType)
- {
- Initialize(xWindowType, tNode);
- EditorGUILayout.EndHorizontal();
- return;
- }
-
-
-
- EditorGUILayout.LabelField("");
- EditorGUILayout.LabelField("Single-click items to load", EditorStyles.boldLabel, GUILayout.Width(200f));
-
-
-
- EditorGUILayout.EndHorizontal();
- if (oList.Count == 0) { return; }
- int oCount = oList.Count;
-
- int WidthSpacing = 160;
- int HeightSpacing = 200;
- int HeightOffset = 30;
- int ScrollHeightOffset = 25;
-
- int xCount = 0;
- int yCount = 0;
- int yMod = Mathf.FloorToInt((float)position.width / 142f) - 1;
-
- int yMax = 0;
- if (yMod == 0)
- {
- yMax = 1;
- }
- else
- {
- yMax = Mathf.CeilToInt((float)oCount / (float)yMod);
- }
-
- bool bScrolling = false;
- if ((((yMax) * HeightSpacing) + 25) > position.height)
- {
- scrollPos = GUI.BeginScrollView(new Rect(0, 25, position.width - 10, position.height - 30), scrollPos, new Rect(0, 0, (yMod * WidthSpacing) + 25, (((yMax) * HeightSpacing) + 50)));
- bScrolling = true;
- HeightOffset = ScrollHeightOffset;
- }
-
- EditorGUILayout.BeginHorizontal();
-
- bool bClicked = false;
- for (int i = 0; i < oCount; i++)
- {
- if (i > 0)
- {
- if (yMod == 0)
- {
- EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); yCount += 1; xCount = 0;
- }
- else
- {
- if (i % yMod == 0) { EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); yCount += 1; xCount = 0; }
- }
- }
-
- if (xCount == 0)
- {
- bClicked = DoItem((xCount * WidthSpacing) + 5, (yCount * HeightSpacing) + HeightOffset, i);
- }
- else
- {
- bClicked = DoItem(xCount * WidthSpacing, (yCount * HeightSpacing) + HeightOffset, i);
- }
-
- if (bClicked)
- {
- if (tWindowType == WindowTypeEnum.Extrusion)
- {
- GSD.Roads.Splination.SplinatedMeshMaker SMM = tNode.AddSplinatedObject();
- SMM.SetDefaultTimes(tNode.bIsEndPoint, tNode.tTime, tNode.NextTime, tNode.idOnSpline, tNode.GSDSpline.distance);
- SMM.LoadFromLibrary(oList[i].FileName, oList[i].bIsDefault);
- SMM.bIsGSD = oList[i].bIsDefault;
- SMM.Setup(true);
- }
- else if (tWindowType == WindowTypeEnum.Edge)
- {
- GSD.Roads.EdgeObjects.EdgeObjectMaker EOM = tNode.AddEdgeObject();
- EOM.SetDefaultTimes(tNode.bIsEndPoint, tNode.tTime, tNode.NextTime, tNode.idOnSpline, tNode.GSDSpline.distance);
- EOM.LoadFromLibrary(oList[i].FileName, oList[i].bIsDefault);
- EOM.bIsGSD = oList[i].bIsDefault;
- EOM.Setup();
- }
- else if (tWindowType == WindowTypeEnum.Groups)
- {
- tNode.LoadWizardObjectsFromLibrary(oList[i].FileName, oList[i].bIsDefault, oList[i].bIsBridge);
- }
- else if (tWindowType == WindowTypeEnum.BridgeComplete)
- {
- tNode.LoadWizardObjectsFromLibrary(oList[i].FileName, oList[i].bIsDefault, oList[i].bIsBridge);
- }
- tNode.bQuitGUI = true;
- oList.Clear(); oList = null;
- EditorGUILayout.EndHorizontal();
- if (bScrolling)
- {
- GUI.EndScrollView();
- }
- bNoGUI = true;
- Close();
- return;
- }
- xCount += 1;
-
- }
- EditorGUILayout.EndHorizontal();
-
- if (bScrolling)
- {
- GUI.EndScrollView();
- }
- }
-
- bool DoItem(int x1, int y1, int i)
- {
- if (oList[i].Thumb != null)
- {
- if (GUI.Button(new Rect(x1, y1, 132f, 132f), oList[i].Thumb))
- {
- return true;
- }
- }
- else
- {
- if (GUI.Button(new Rect(x1, y1, 132f, 132f), "No image"))
- {
- return true;
- }
- }
-
- GUI.Label(new Rect(x1, y1 + 132f, 148f, 20f), oList[i].DisplayName, EditorStyles.boldLabel);
- GUI.Label(new Rect(x1, y1 + 148f, 148f, 52f), oList[i].Desc, EditorStyles.miniLabel);
-
- return false;
- }
-
- #region "Init"
- public Rect xRect;
- public void Initialize(WindowTypeEnum _tWindowType, GSDSplineN _tNode)
- {
- if (xRect.width < 1f && xRect.height < 1f)
- {
- xRect.x = 275f;
- xRect.y = 200f;
- xRect.width = 860f;
- xRect.height = 500f;
- }
-
- position = xRect;
- tWindowType = _tWindowType;
- tNode = _tNode;
- InitWindow();
- Show();
- }
-
- private void InitWindow()
- {
- if (oList != null) { oList.Clear(); oList = null; }
- oList = new List();
- if (tWindowType == WindowTypeEnum.Extrusion)
- {
- titleContent.text = "Extrusion";
- InitObjs();
- }
- else if (tWindowType == WindowTypeEnum.Edge)
- {
- titleContent.text = "Edge objects";
- InitObjs();
- }
- else if (tWindowType == WindowTypeEnum.BridgeComplete)
- {
- titleContent.text = "Bridges";
- InitGroups(true);
- }
- else if (tWindowType == WindowTypeEnum.Groups)
- {
- titleContent.text = "Groups";
- InitGroups(false);
- }
-
- ThumbStyle = new GUIStyle(GUI.skin.button);
- ThumbStyle.contentOffset = new Vector2(0f, 0f);
- ThumbStyle.border = new RectOffset(0, 0, 0, 0);
- ThumbStyle.fixedHeight = 128f;
- ThumbStyle.fixedWidth = 128f;
- ThumbStyle.padding = new RectOffset(0, 0, 0, 0);
- ThumbStyle.normal.background = null;
- ThumbStyle.hover.background = null;
- ThumbStyle.active.background = null;
-
- EditorStyles.label.wordWrap = true;
- EditorStyles.miniLabel.wordWrap = true;
- GUI.skin.label.wordWrap = true;
- }
-
- #region "Init complete bridges"
- private void InitGroups(bool bIsBridge)
- {
- string[] tNames = null;
- string[] tPaths = null;
- //Load user custom ones first:
- GetGroupListing(out tNames, out tPaths, tNode.GSDSpline.tRoad.opt_Lanes, false);
- LoadGroupObjs(ref tNames, ref tPaths, bIsBridge);
- //Load GSD ones last:
- GetGroupListing(out tNames, out tPaths, tNode.GSDSpline.tRoad.opt_Lanes, true);
- LoadGroupObjs(ref tNames, ref tPaths, bIsBridge);
- }
-
- private void LoadGroupObjs(ref string[] tNames, ref string[] tPaths, bool bIsBridge)
- {
- int tCount = tNames.Length;
- string tPath = "";
- // string tStringPath = "";
- // string tDesc = "";
- // string tDisplayName = "";
- // string ThumbString = "";
- for (int i = 0; i < tCount; i++)
- {
- GSDRoadUtil.WizardObject tO = GSDRoadUtil.WizardObject.LoadFromLibrary(tPaths[i]);
- if (tO == null) { continue; }
- if (tO.bIsBridge != bIsBridge) { continue; }
- try
- {
- tO.Thumb = (Texture2D)AssetDatabase.LoadAssetAtPath(tO.ThumbString, typeof(Texture2D)) as Texture2D;
- }
- catch
- {
- tO.Thumb = null;
- }
- tO.FileName = tNames[i];
- tO.FullPath = tPath;
-
- if (tO.bIsDefault && bIsBridge)
- {
- if (tO.DisplayName.Contains("SuspL") || tO.DisplayName.Contains("Large Suspension"))
- {
- tO.DisplayName = "Large Suspension";
- tO.Desc = "Designed after the Golden Gate bridge. For lengths over 850m. Best results over 1300m.";
- tO.sortID = 11;
- }
- else if (tO.DisplayName.Contains("SuspS") || tO.DisplayName.Contains("Small Suspension"))
- {
- tO.DisplayName = "Small Suspension";
- tO.Desc = "Similar style as the large with smaller pillars. For lengths under 725m.";
- tO.sortID = 10;
- }
- else if (tO.DisplayName.Contains("SemiArch1"))
- {
- tO.DisplayName = "SemiArch 80 Degree";
- tO.Desc = "80 Degree arch. For lengths under 300m and small heights.";
- tO.sortID = 40;
- }
- else if (tO.DisplayName.Contains("SemiArch2"))
- {
- tO.DisplayName = "SemiArch 80 Girder";
- tO.Desc = "80 Degree arch with girder style. For lengths under 300m and small heights.";
- tO.sortID = 41;
- }
- else if (tO.DisplayName.Contains("SemiArch3"))
- {
- tO.DisplayName = "SemiArch 180 Degree";
- tO.Desc = "180 Degree arch. For lengths under 300m and small heights.";
- tO.sortID = 42;
- }
- else if (tO.DisplayName.Contains("Arch12m"))
- {
- tO.DisplayName = "Arch 12m Beams";
- tO.Desc = "Full deck arch bridge with 12m beams. Good for any length.";
- tO.sortID = 0;
- }
- else if (tO.DisplayName.Contains("Arch24m"))
- {
- tO.DisplayName = "Arch 24m Beams";
- tO.Desc = "Full deck arch bridge with 24m beams. Good for any length and non-small width roads.";
- tO.sortID = 1;
- }
- else if (tO.DisplayName.Contains("Arch48m"))
- {
- tO.DisplayName = "Arch 48m Beams";
- tO.Desc = "Full deck arch bridge with 48m beams. Good for any length and large width roads.";
- tO.sortID = 3;
- }
- else if (tO.DisplayName.Contains("Grid"))
- {
- tO.DisplayName = "Grid Steel";
- tO.Desc = "Grid based steel bridge. Good for any length depending on triangle counts.";
- tO.sortID = 30;
- }
- else if (tO.DisplayName.Contains("Steel"))
- {
- tO.DisplayName = "Steel Beam";
- tO.Desc = "Standard steel beam bridge. Good for any length depending on triangle counts.";
- tO.sortID = 4;
- }
- else if (tO.DisplayName.Contains("Causeway1"))
- {
- tO.DisplayName = "Causeway Federal";
- tO.Desc = "Standard federal highway bridge style. Good for any length depending on triangle counts.";
- tO.sortID = 5;
- }
- else if (tO.DisplayName.Contains("Causeway2"))
- {
- tO.DisplayName = "Causeway Overpass";
- tO.Desc = "Overpass style. Good for any length depending on triangle counts.";
- tO.sortID = 8;
- }
- else if (tO.DisplayName.Contains("Causeway3"))
- {
- tO.DisplayName = "Causeway Classic";
- tO.Desc = "Classic causeway style. Good for any length depending on triangle counts.";
- tO.sortID = 7;
- }
- else if (tO.DisplayName.Contains("Causeway4"))
- {
- tO.DisplayName = "Causeway Highway";
- tO.Desc = "State highway style. Good for any length depending on triangle counts.";
- tO.sortID = 6;
- }
- }
-
- if (tO.bIsDefault && !bIsBridge)
- {
- if (tO.DisplayName.Contains("GSDTunnel"))
- {
- tO.DisplayName = "Tunnel";
- tO.Desc = "Designed after the Eisenhower tunnel.";
- }
- else if (tO.DisplayName.Contains("GSDGroup-WBeamLeftTurn"))
- {
- tO.DisplayName = "Left turn wbeams";
- tO.Desc = "Contains wbeam and signs on right side of road for left turn.";
- }
- else if (tO.DisplayName.Contains("GSDGroup-KRailLights"))
- {
- tO.DisplayName = "K-rail with lights";
- tO.Desc = "Center divider k-rail with double sided lights. Best used on mostly straight highway type roads.";
- }
- else if (tO.DisplayName.Contains("GSDGroup-Rumblestrips"))
- {
- tO.DisplayName = "Rumblestrips x2";
- tO.Desc = "Rumble strips on both sides of the road.";
- }
- else if (tO.DisplayName.Contains("GSDGroup-Fancy1"))
- {
- tO.DisplayName = "Fancy railing x2";
- tO.Desc = "Luxurious railing with lighting on both sides of the road.";
- }
- }
-
- oList.Add(tO);
- }
- oListSort();
- }
-
- public static void GetGroupListing(out string[] tNames, out string[] tPaths, int Lanes, bool bIsDefault = false)
- {
-
- xPath = GSDRootUtil.Dir_GetLibrary();
- Debug.Log(xPath);
-
- string LaneText = "-2L";
- if (Lanes == 4)
- {
- LaneText = "-4L";
- }
- else if (Lanes == 6)
- {
- LaneText = "-6L";
- }
-
- tNames = null;
- tPaths = null;
- DirectoryInfo info;
- if (bIsDefault)
- {
- info = new DirectoryInfo(xPath + "B/W/");
- }
- else
- {
- info = new DirectoryInfo(xPath + "B/");
- }
-
- FileInfo[] fileInfo = info.GetFiles();
- int tCount = 0;
- foreach (FileInfo tInfo in fileInfo)
- {
- if (tInfo.Extension.ToLower().Contains("gsd"))
- {
- if (!bIsDefault)
- {
- tCount += 1;
- }
- else
- {
- if (tInfo.Name.Contains(LaneText))
- {
- tCount += 1;
- }
- }
- }
- }
-
- tNames = new string[tCount];
- tPaths = new string[tCount];
- tCount = 0;
- foreach (FileInfo tInfo in fileInfo)
- {
- if (tInfo.Extension.ToLower().Contains("gsd"))
- {
- if (!bIsDefault)
- {
- tNames[tCount] = tInfo.Name.Replace(".gsd", "");
- tPaths[tCount] = tInfo.FullName;
- tCount += 1;
- }
- else
- {
- if (tInfo.Name.Contains(LaneText))
- {
- tNames[tCount] = tInfo.Name.Replace(".gsd", "");
- tPaths[tCount] = tInfo.FullName;
- tCount += 1;
- }
- }
- }
- }
- }
- #endregion
-
- #region "Init objs"
- private void InitObjs()
- {
- string[] tNames = null;
- string[] tPaths = null;
- //Load user custom ones first:
- if (tWindowType == WindowTypeEnum.Extrusion)
- {
- SplinatedMeshMaker.GetLibraryFiles(out tNames, out tPaths, false);
- }
- else
- {
- EdgeObjectMaker.GetLibraryFiles(out tNames, out tPaths, false);
- }
- LoadObjs(ref tNames, ref tPaths, false);
- //Load GSD ones last:
- if (tWindowType == WindowTypeEnum.Extrusion)
- {
- SplinatedMeshMaker.GetLibraryFiles(out tNames, out tPaths, true);
- }
- else
- {
- EdgeObjectMaker.GetLibraryFiles(out tNames, out tPaths, true);
- }
- LoadObjs(ref tNames, ref tPaths, true);
- }
-
- private void LoadObjs(ref string[] tNames, ref string[] tPaths, bool bIsDefault = false)
- {
- int tCount = tNames.Length;
- string tPath = "";
- string tStringPath = "";
- string tDesc = "";
- string tDisplayName = "";
- string ThumbString = "";
- bool bIsBridge = false;
- for (int i = 0; i < tCount; i++)
- {
- bIsBridge = false;
- tPath = tPaths[i];
-
- if (tWindowType == WindowTypeEnum.Extrusion)
- {
- SplinatedMeshMaker.SplinatedMeshLibraryMaker SLM = (SplinatedMeshMaker.SplinatedMeshLibraryMaker)GSDRootUtil.LoadXML(ref tPath);
- if (SLM == null) { continue; }
- tStringPath = SLM.CurrentSplinationString;
- tDesc = SLM.Desc;
- tDisplayName = SLM.DisplayName;
- ThumbString = SLM.ThumbString;
- bIsBridge = SLM.bIsBridge;
- }
- else if (tWindowType == WindowTypeEnum.Edge)
- {
- EdgeObjectMaker.EdgeObjectLibraryMaker ELM = (EdgeObjectMaker.EdgeObjectLibraryMaker)GSDRootUtil.LoadXML(ref tPath);
- if (ELM == null) { continue; }
- tStringPath = ELM.EdgeObjectString;
- tDesc = ELM.Desc;
- tDisplayName = ELM.DisplayName;
- ThumbString = ELM.ThumbString;
- bIsBridge = ELM.bIsBridge;
- }
-
- //Don't continue if bridge pieces and this is not a bridge piece:
- if (tWindowType == WindowTypeEnum.Extrusion && bIsBridge) { continue; }
-
- GSDRoadUtil.WizardObject tO = new GSDRoadUtil.WizardObject();
- try
- {
- tO.Thumb = (Texture2D)AssetDatabase.LoadAssetAtPath(ThumbString, typeof(Texture2D)) as Texture2D;
- }
- catch
- {
- tO.Thumb = null;
- }
- if (tO.Thumb == null)
- {
- try
- {
- GameObject xObj = (GameObject)UnityEditor.AssetDatabase.LoadAssetAtPath(tStringPath, typeof(GameObject)) as GameObject;
- tO.Thumb = AssetPreview.GetAssetPreview(xObj);
- }
- catch
- {
- tO.Thumb = null;
- }
- }
- tO.DisplayName = tDisplayName;
- tO.FileName = tNames[i];
- tO.FullPath = tPath;
- tO.Desc = tDesc;
- tO.bIsDefault = bIsDefault;
-
- if (bIsDefault && tWindowType == WindowTypeEnum.Edge)
- {
- if (tO.DisplayName.Contains("GSDAtten"))
- {
- tO.DisplayName = "Attenuator";
- tO.Desc = "Standard double WBeam with impact absorption.";
- }
- else if (tO.DisplayName.Contains("GSDGreenBlinder"))
- {
- tO.DisplayName = "KRail Blinder";
- tO.Desc = "Best results when placed on KRail for KRail blinders.";
- tO.sortID = 5;
- }
- else if (tO.DisplayName.Contains("GSDRoadBarrelStatic"))
- {
- tO.DisplayName = "Sand Barrel Static";
- tO.Desc = "One static sand barrel. Best results when placed in front of railings or bridges.";
- }
- else if (tO.DisplayName.Contains("GSDRoadBarrelRigid"))
- {
- tO.DisplayName = "Sand Barrel Rigid";
- tO.Desc = "One rigid sand barrel. Best results when placed in front of railings or bridges.";
- }
- else if (tO.DisplayName.Contains("GSDRoadBarrel3Static"))
- {
- tO.DisplayName = "Sand Barrels Static 3";
- tO.Desc = "Three static sand barrels in a line. Best results when placed in front of railings or bridges.";
- }
- else if (tO.DisplayName.Contains("GSDRoadBarrel3Rigid"))
- {
- tO.DisplayName = "Sand Barrels Rigid 3";
- tO.Desc = "Three rigid sand barrels in a line. Best results when placed in front of railings or bridges.";
- }
- else if (tO.DisplayName.Contains("GSDRoadBarrel7Static"))
- {
- tO.DisplayName = "Sand Barrels Static 7";
- tO.Desc = "Seven static sand barrels in standard formation. Best results when placed in front of railings or bridges.";
- }
- else if (tO.DisplayName.Contains("GSDRoadBarrel7Rigid"))
- {
- tO.DisplayName = "Sand Barrel Rigid 7";
- tO.Desc = "Seven rigid sand barrels in standard formation. Best results when placed in front of railings or bridges.";
- }
- else if (tO.DisplayName.Contains("GSDRoadConBarrelStatic"))
- {
- tO.DisplayName = "Con Barrels Static";
- tO.Desc = "Static road construction barrels.";
- tO.sortID = 3;
- }
- else if (tO.DisplayName.Contains("GSDRoadConBarrelRigid"))
- {
- tO.DisplayName = "Con Barrels Rigid";
- tO.Desc = "Rigid road construction barrels.";
- tO.sortID = 3;
- }
- else if (tO.DisplayName.Contains("GSDTrafficConeStatic"))
- {
- tO.DisplayName = "Traffic cones Static";
- tO.Desc = "Static traffic cones.";
- tO.sortID = 4;
- }
- else if (tO.DisplayName.Contains("GSDTrafficConeRigid"))
- {
- tO.DisplayName = "Traffic cones Rigid";
- tO.Desc = "Rigid traffic cones.";
- tO.sortID = 4;
- }
- else if (tO.DisplayName.Contains("GSDRoadReflector"))
- {
- tO.DisplayName = "Road reflectors";
- tO.Desc = "Placed one center line of road for center line reflection.";
- tO.sortID = 4;
- }
- else if (tO.DisplayName.Contains("GSDStopSign"))
- {
- tO.DisplayName = "Stop sign";
- tO.Desc = "Standard specification non-interstate stop sign.";
- }
- else if (tO.DisplayName.Contains("GSDStreetLightSingle"))
- {
- tO.DisplayName = "Streetlight Singlesided";
- tO.Desc = "Best used on side of roads.";
- }
- else if (tO.DisplayName.Contains("GSDStreetLightDouble"))
- {
- tO.DisplayName = "Streetlight Doublesided";
- tO.Desc = "Best results when embedded in KRail in centerline of road.";
- }
- else if (tO.DisplayName.Contains("GSDWarningSign1"))
- {
- tO.DisplayName = "Warning Sign #1";
- tO.Desc = "Best results when placed in front of railings or bridges.";
- }
- else if (tO.DisplayName.Contains("GSDWarningSign2"))
- {
- tO.DisplayName = "Warning Sign #2";
- tO.Desc = "Best results when placed in front of railings or bridges.";
- }
- else if (tO.DisplayName.Contains("GSDSignRightTurnOnly"))
- {
- tO.DisplayName = "Right turn only";
- tO.Desc = "Best results when placed near intersection right turn lane.";
- tO.sortID = 4;
- }
-
- else if (tO.DisplayName.Contains("GSDSign330"))
- {
- tO.DisplayName = "Signs 330";
- tO.Desc = "Interchangeable materials, use \"GSDFedSign-330\" as the search term.";
- tO.sortID = 21;
- }
- else if (tO.DisplayName.Contains("GSDSign396"))
- {
- tO.DisplayName = "Signs 396";
- tO.Desc = "Interchangeable materials, use \"GSDFedSign-396\" as the search term.";
- tO.sortID = 21;
- }
- else if (tO.DisplayName.Contains("GSDSign617-Small"))
- {
- tO.DisplayName = "Signs 617 small";
- tO.Desc = "Interchangeable materials, use \"GSDFedSign-617\" as the search term.";
- tO.sortID = 21;
- }
- else if (tO.DisplayName.Contains("GSDSign617"))
- {
- tO.DisplayName = "Signs 617";
- tO.Desc = "Interchangeable materials, use \"GSDFedSign-617\" as the search term.";
- tO.sortID = 21;
- }
- else if (tO.DisplayName.Contains("GSDSign861-Small"))
- {
- tO.DisplayName = "Signs 861 small";
- tO.Desc = "Interchangeable materials, use \"GSDFedSign-861\" as the search term.";
- tO.sortID = 21;
- }
- else if (tO.DisplayName.Contains("GSDSign861"))
- {
- tO.DisplayName = "Sign type 861";
- tO.Desc = "Interchangeable materials, use \"GSDFedSign-861\" as the search term.";
- tO.sortID = 21;
- }
- else if (tO.DisplayName.Contains("GSDSign988-Small"))
- {
- tO.DisplayName = "Signs 988 small";
- tO.Desc = "Interchangeable materials, use \"GSDFedSign-988\" as the search term.";
- tO.sortID = 21;
- }
- else if (tO.DisplayName.Contains("GSDSign988"))
- {
- tO.DisplayName = "Signs 988";
- tO.Desc = "Interchangeable materials, use \"GSDFedSign-988\" as the search term.";
- tO.sortID = 21;
- }
- else if (tO.DisplayName.Contains("GSDSignDiamond"))
- {
- tO.DisplayName = "Signs diamond";
- tO.Desc = "Interchangeable materials, use \"GSDFedSign-diamond\" as the search term.";
- tO.sortID = 21;
- }
- else if (tO.DisplayName.Contains("GSDSignSquare-Small"))
- {
- tO.DisplayName = "Signs square small";
- tO.Desc = "Interchangeable materials, use \"GSDFedSign-Square\" as the search term.";
- tO.sortID = 21;
- }
- else if (tO.DisplayName.Contains("GSDSignSquare"))
- {
- tO.DisplayName = "Signs square";
- tO.Desc = "Interchangeable materials, use \"GSDFedSign-Square\" as the search term.";
- tO.sortID = 21;
- }
- }
-
- if (bIsDefault && tWindowType == WindowTypeEnum.Extrusion)
- {
- if (tO.DisplayName.Contains("GSDKRail"))
- {
- tO.DisplayName = "KRail";
- tO.Desc = "Federal spec cement KRailing (also known as Jersey Barriers). Variant with down ends.";
- }
- else if (tO.DisplayName.Contains("GSDKRailCurvedR"))
- {
- tO.DisplayName = "KRail Curved Right";
- tO.Desc = "Federal spec cement KRailing (also known as Jersey Barriers). Variant with curved ends for right shoulder.";
- }
- else if (tO.DisplayName.Contains("GSDKRailCurvedL"))
- {
- tO.DisplayName = "KRail Curved Left";
- tO.Desc = "Federal spec cement KRailing (also known as Jersey Barriers). Variant with curved ends for left shoulder.";
- }
- else if (tO.DisplayName.Contains("GSDWBeam1R"))
- {
- tO.DisplayName = "WBeam Wood Right";
- tO.Desc = "Federal spec wooden pole WBeam railing. Best used as outer shoulder railing. Right shoulder.";
- }
- else if (tO.DisplayName.Contains("GSDWBeam1L"))
- {
- tO.DisplayName = "WBeam Wood Left";
- tO.Desc = "Federal spec wooden pole WBeam railing. Best used as outer shoulder railing. Left shoulder.";
- }
- else if (tO.DisplayName.Contains("GSDWBeam2R"))
- {
- tO.DisplayName = "WBeam Metal Right";
- tO.Desc = "Federal spec metal pole WBeam railing. Best used as outer shoulder railing. Right shoulder.";
- }
- else if (tO.DisplayName.Contains("GSDWBeam2L"))
- {
- tO.DisplayName = "WBeam Metal Left";
- tO.Desc = "Federal spec metal pole WBeam railing. Best used as outer shoulder railing. Left shoulder.";
- }
- else if (tO.DisplayName.Contains("GSDRailing1"))
- {
- tO.DisplayName = "Railing #1";
- tO.Desc = "Standard double square pole railing.";
- }
- else if (tO.DisplayName.Contains("GSDRailing2"))
- {
- tO.DisplayName = "Railing #2";
- tO.Desc = "Standard concrete big block railing.";
- }
- else if (tO.DisplayName.Contains("GSDRailing3"))
- {
- tO.DisplayName = "Railing #3";
- tO.Desc = "Standard four-strand metal railing.";
- }
- else if (tO.DisplayName.Contains("GSDRailing5"))
- {
- tO.DisplayName = "Railing #5";
- tO.Desc = "Basic concrete railing with pylons.";
- }
- else if (tO.DisplayName.Contains("GSDRailing6"))
- {
- tO.DisplayName = "Railing #6";
- tO.Desc = "Standard two-strand metal pole railing.";
- }
- else if (tO.DisplayName.Contains("GSDRailing7"))
- {
- tO.DisplayName = "Railing #7";
- tO.Desc = "Rock-decorated concrete railing with pylons and double strand rusted look metal railing.";
- }
- else if (tO.DisplayName.Contains("GSDRailing8"))
- {
- tO.DisplayName = "Railing #8";
- tO.Desc = "Rock-decorated concrete railing with standard single pole metal railing.";
- }
- else if (tO.DisplayName.Contains("GSDRailing9"))
- {
- tO.DisplayName = "Railing #9";
- tO.Desc = "Very low poly railing used for mobile.";
- }
- else if (tO.DisplayName.Contains("GSDSidewalk"))
- {
- tO.DisplayName = "Sidewalk";
- tO.Desc = "Sidewalk.";
- }
- else if (tO.DisplayName.Contains("GSDRumbleStrip"))
- {
- tO.DisplayName = "Rumblestrip";
- tO.Desc = "State spec rumblestrip. For best results place several cm from road edge into shoulder.";
- }
- else if (tO.DisplayName.Contains("GSDRailing4R"))
- {
- tO.DisplayName = "Railing #4 Right";
- tO.Desc = "Three bar angled pole railing. Right side of road.";
- }
- else if (tO.DisplayName.Contains("GSDRailing4L"))
- {
- tO.DisplayName = "Railing #4 Left";
- tO.Desc = "Three bar angled pole railing. Left side of road.";
- }
- else if (tO.DisplayName.Contains("GSDRailing4-LightR"))
- {
- tO.DisplayName = "Railing #4 Light Right";
- tO.Desc = "Three bar angled pole railing. Right side of road. Light version with fewer triangle count.";
- }
- else if (tO.DisplayName.Contains("GSDRailing4-LightL"))
- {
- tO.DisplayName = "Railing #4 Light Left";
- tO.Desc = "Three bar angled pole railing. Left side of road. Light version with fewer triangle count.";
- }
- else if (tO.DisplayName.Contains("GSDRailingBase1"))
- {
- tO.DisplayName = "Railing base #1";
- tO.Desc = "Use as a base on other railings to create more detail.";
- }
- else if (tO.DisplayName.Contains("GSDRailingBase2"))
- {
- tO.DisplayName = "Railing base #2";
- tO.Desc = "Use as a base on other railings to create more detail.";
- }
- else if (tO.DisplayName.Contains("GSDCableBarrier-Light"))
- {
- tO.DisplayName = "Cable barrier 10m";
- tO.Desc = "Cable barrier 10m light triangle version. Best used as center divider or as railing barriers.";
- tO.sortID = 20;
- }
- else if (tO.DisplayName.Contains("GSDCableBarrier"))
- {
- tO.DisplayName = "Cable barrier 5m";
- tO.Desc = "Cable barrier 5m. Best used as center divider or as railing barriers.";
- tO.sortID = 20;
- }
- }
-
- oList.Add(tO);
- }
- oListSort();
- }
-
- void oListSort()
- {
- oList.Sort((GSDRoadUtil.WizardObject t1, GSDRoadUtil.WizardObject t2) =>
- {
- if (t1.bIsDefault != t2.bIsDefault)
- {
- return t1.bIsDefault.CompareTo(t2.bIsDefault);
- }
- else if (t1.sortID != t2.sortID)
- {
- return t1.sortID.CompareTo(t2.sortID);
- }
- else
- {
- return t1.DisplayName.CompareTo(t2.DisplayName);
- }
- });
- }
- #endregion
- #endregion
+#region "Imports"
+using UnityEngine;
+using UnityEditor;
+using System.Collections;
+using System.Collections.Generic;
+using GSD.Roads.Splination;
+using GSD.Roads.EdgeObjects;
+using GSD;
+using System.IO;
+using GSD.Roads;
+#endregion
+
+
+public class GSDWizard : EditorWindow
+{
+ public enum WindowTypeEnum
+ {
+ Extrusion,
+ Edge,
+ BridgeComplete,
+ Groups
+ };
+
+
+ public enum WindowTypeEnumShort
+ {
+ Extrusion,
+ Edge,
+ Groups
+ };
+
+
+ private static string[] WindowTypeDescBridge = new string[]{
+ "Extrusion items",
+ "Edge objects",
+ "Complete bridges",
+ "Other groups"
+ };
+
+
+ private static string[] WindowTypeDesc = new string[]{
+ "Extrusion items",
+ "Edge objects",
+ "Other groups"
+ };
+
+
+ WindowTypeEnum tWindowType = WindowTypeEnum.Extrusion;
+ WindowTypeEnum xWindowType = WindowTypeEnum.Extrusion;
+ WindowTypeEnumShort StWindowType = WindowTypeEnumShort.Extrusion;
+ WindowTypeEnumShort SxWindowType = WindowTypeEnumShort.Extrusion;
+ static string xPath = "";
+
+ GUIStyle ThumbStyle;
+ Vector2 scrollPos = new Vector2(0f, 25f);
+ GSDSplineN tNode = null;
+ List oList = null;
+ bool bNoGUI = false;
+
+
+ void OnGUI()
+ {
+ DoGUI();
+ }
+
+
+ private void DoGUI()
+ {
+ if (bNoGUI)
+ {
+ return;
+ }
+ if (oList == null)
+ {
+ Close();
+ return;
+ }
+
+ GUILayout.Space(4f);
+ EditorGUILayout.BeginHorizontal();
+
+ if (tNode.bIsBridgeStart)
+ {
+ xWindowType = (WindowTypeEnum) EditorGUILayout.Popup("Category: ", (int) tWindowType, WindowTypeDescBridge, GUILayout.Width(312f));
+ }
+ else
+ {
+
+ if (xWindowType == WindowTypeEnum.Edge)
+ {
+ SxWindowType = WindowTypeEnumShort.Edge;
+ }
+ else if (xWindowType == WindowTypeEnum.Extrusion)
+ {
+ SxWindowType = WindowTypeEnumShort.Extrusion;
+ }
+ else
+ {
+ SxWindowType = WindowTypeEnumShort.Groups;
+ }
+
+ SxWindowType = (WindowTypeEnumShort) EditorGUILayout.Popup("Category: ", (int) StWindowType, WindowTypeDesc, GUILayout.Width(312f));
+
+ if (SxWindowType == WindowTypeEnumShort.Extrusion)
+ {
+ xWindowType = WindowTypeEnum.Extrusion;
+ }
+ else if (SxWindowType == WindowTypeEnumShort.Edge)
+ {
+ xWindowType = WindowTypeEnum.Edge;
+ }
+ else
+ {
+ xWindowType = WindowTypeEnum.Groups;
+ }
+ StWindowType = SxWindowType;
+ }
+
+ if (xWindowType != tWindowType)
+ {
+ Initialize(xWindowType, tNode);
+ EditorGUILayout.EndHorizontal();
+ return;
+ }
+
+
+
+ EditorGUILayout.LabelField("");
+ EditorGUILayout.LabelField("Single-click items to load", EditorStyles.boldLabel, GUILayout.Width(200f));
+
+
+
+ EditorGUILayout.EndHorizontal();
+ if (oList.Count == 0)
+ {
+ return;
+ }
+ int oCount = oList.Count;
+
+ int WidthSpacing = 160;
+ int HeightSpacing = 200;
+ int HeightOffset = 30;
+ int ScrollHeightOffset = 25;
+
+ int xCount = 0;
+ int yCount = 0;
+ int yMod = Mathf.FloorToInt((float) position.width / 142f) - 1;
+
+ int yMax = 0;
+ if (yMod == 0)
+ {
+ yMax = 1;
+ }
+ else
+ {
+ yMax = Mathf.CeilToInt((float) oCount / (float) yMod);
+ }
+
+ bool bScrolling = false;
+ if ((((yMax) * HeightSpacing) + 25) > position.height)
+ {
+ scrollPos = GUI.BeginScrollView(new Rect(0, 25, position.width - 10, position.height - 30), scrollPos, new Rect(0, 0, (yMod * WidthSpacing) + 25, (((yMax) * HeightSpacing) + 50)));
+ bScrolling = true;
+ HeightOffset = ScrollHeightOffset;
+ }
+
+ EditorGUILayout.BeginHorizontal();
+
+ bool bClicked = false;
+ for (int i = 0; i < oCount; i++)
+ {
+ if (i > 0)
+ {
+ if (yMod == 0)
+ {
+ EditorGUILayout.EndHorizontal();
+ EditorGUILayout.BeginHorizontal();
+ yCount += 1;
+ xCount = 0;
+ }
+ else
+ {
+ if (i % yMod == 0)
+ { EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); yCount += 1; xCount = 0; }
+ }
+ }
+
+ if (xCount == 0)
+ {
+ bClicked = DoItem((xCount * WidthSpacing) + 5, (yCount * HeightSpacing) + HeightOffset, i);
+ }
+ else
+ {
+ bClicked = DoItem(xCount * WidthSpacing, (yCount * HeightSpacing) + HeightOffset, i);
+ }
+
+ if (bClicked)
+ {
+ if (tWindowType == WindowTypeEnum.Extrusion)
+ {
+ GSD.Roads.Splination.SplinatedMeshMaker SMM = tNode.AddSplinatedObject();
+ SMM.SetDefaultTimes(tNode.bIsEndPoint, tNode.tTime, tNode.NextTime, tNode.idOnSpline, tNode.GSDSpline.distance);
+ SMM.LoadFromLibrary(oList[i].FileName, oList[i].bIsDefault);
+ SMM.bIsGSD = oList[i].bIsDefault;
+ SMM.Setup(true);
+ }
+ else if (tWindowType == WindowTypeEnum.Edge)
+ {
+ GSD.Roads.EdgeObjects.EdgeObjectMaker EOM = tNode.AddEdgeObject();
+ EOM.SetDefaultTimes(tNode.bIsEndPoint, tNode.tTime, tNode.NextTime, tNode.idOnSpline, tNode.GSDSpline.distance);
+ EOM.LoadFromLibrary(oList[i].FileName, oList[i].bIsDefault);
+ EOM.bIsGSD = oList[i].bIsDefault;
+ EOM.Setup();
+ }
+ else if (tWindowType == WindowTypeEnum.Groups)
+ {
+ tNode.LoadWizardObjectsFromLibrary(oList[i].FileName, oList[i].bIsDefault, oList[i].bIsBridge);
+ }
+ else if (tWindowType == WindowTypeEnum.BridgeComplete)
+ {
+ tNode.LoadWizardObjectsFromLibrary(oList[i].FileName, oList[i].bIsDefault, oList[i].bIsBridge);
+ }
+ tNode.bQuitGUI = true;
+ oList.Clear();
+ oList = null;
+ EditorGUILayout.EndHorizontal();
+ if (bScrolling)
+ {
+ GUI.EndScrollView();
+ }
+ bNoGUI = true;
+ Close();
+ return;
+ }
+ xCount += 1;
+
+ }
+ EditorGUILayout.EndHorizontal();
+
+ if (bScrolling)
+ {
+ GUI.EndScrollView();
+ }
+ }
+
+
+ bool DoItem(int x1, int y1, int i)
+ {
+ if (oList[i].Thumb != null)
+ {
+ if (GUI.Button(new Rect(x1, y1, 132f, 132f), oList[i].Thumb))
+ {
+ return true;
+ }
+ }
+ else
+ {
+ if (GUI.Button(new Rect(x1, y1, 132f, 132f), "No image"))
+ {
+ return true;
+ }
+ }
+
+ GUI.Label(new Rect(x1, y1 + 132f, 148f, 20f), oList[i].DisplayName, EditorStyles.boldLabel);
+ GUI.Label(new Rect(x1, y1 + 148f, 148f, 52f), oList[i].Desc, EditorStyles.miniLabel);
+
+ return false;
+ }
+
+
+ #region "Init"
+ public Rect xRect;
+
+
+ public void Initialize(WindowTypeEnum _tWindowType, GSDSplineN _tNode)
+ {
+ if (xRect.width < 1f && xRect.height < 1f)
+ {
+ xRect.x = 275f;
+ xRect.y = 200f;
+ xRect.width = 860f;
+ xRect.height = 500f;
+ }
+
+ position = xRect;
+ tWindowType = _tWindowType;
+ tNode = _tNode;
+ InitWindow();
+ Show();
+ }
+
+
+ private void InitWindow()
+ {
+ if (oList != null)
+ {
+ oList.Clear();
+ oList = null;
+ }
+ oList = new List();
+ if (tWindowType == WindowTypeEnum.Extrusion)
+ {
+ titleContent.text = "Extrusion";
+ InitObjs();
+ }
+ else if (tWindowType == WindowTypeEnum.Edge)
+ {
+ titleContent.text = "Edge objects";
+ InitObjs();
+ }
+ else if (tWindowType == WindowTypeEnum.BridgeComplete)
+ {
+ titleContent.text = "Bridges";
+ InitGroups(true);
+ }
+ else if (tWindowType == WindowTypeEnum.Groups)
+ {
+ titleContent.text = "Groups";
+ InitGroups(false);
+ }
+
+ ThumbStyle = new GUIStyle(GUI.skin.button);
+ ThumbStyle.contentOffset = new Vector2(0f, 0f);
+ ThumbStyle.border = new RectOffset(0, 0, 0, 0);
+ ThumbStyle.fixedHeight = 128f;
+ ThumbStyle.fixedWidth = 128f;
+ ThumbStyle.padding = new RectOffset(0, 0, 0, 0);
+ ThumbStyle.normal.background = null;
+ ThumbStyle.hover.background = null;
+ ThumbStyle.active.background = null;
+
+ EditorStyles.label.wordWrap = true;
+ EditorStyles.miniLabel.wordWrap = true;
+ GUI.skin.label.wordWrap = true;
+ }
+
+
+ #region "Init complete bridges"
+ private void InitGroups(bool bIsBridge)
+ {
+ string[] tNames = null;
+ string[] tPaths = null;
+ //Load user custom ones first:
+ GetGroupListing(out tNames, out tPaths, tNode.GSDSpline.tRoad.opt_Lanes, false);
+ LoadGroupObjs(ref tNames, ref tPaths, bIsBridge);
+ //Load GSD ones last:
+ GetGroupListing(out tNames, out tPaths, tNode.GSDSpline.tRoad.opt_Lanes, true);
+ LoadGroupObjs(ref tNames, ref tPaths, bIsBridge);
+ }
+
+
+ private void LoadGroupObjs(ref string[] tNames, ref string[] tPaths, bool bIsBridge)
+ {
+ int tCount = tNames.Length;
+ string tPath = "";
+ // string tStringPath = "";
+ // string tDesc = "";
+ // string tDisplayName = "";
+ // string ThumbString = "";
+ for (int index = 0; index < tCount; index++)
+ {
+ GSDRoadUtil.WizardObject tO = GSDRoadUtil.WizardObject.LoadFromLibrary(tPaths[index]);
+ if (tO == null)
+ {
+ continue;
+ }
+ if (tO.bIsBridge != bIsBridge)
+ {
+ continue;
+ }
+ try
+ {
+ tO.Thumb = (Texture2D) AssetDatabase.LoadAssetAtPath(tO.ThumbString, typeof(Texture2D)) as Texture2D;
+ }
+ catch
+ {
+ tO.Thumb = null;
+ }
+ tO.FileName = tNames[index];
+ tO.FullPath = tPath;
+
+ if (tO.bIsDefault && bIsBridge)
+ {
+ if (tO.DisplayName.Contains("SuspL") || tO.DisplayName.Contains("Large Suspension"))
+ {
+ tO.DisplayName = "Large Suspension";
+ tO.Desc = "Designed after the Golden Gate bridge. For lengths over 850m. Best results over 1300m.";
+ tO.sortID = 11;
+ }
+ else if (tO.DisplayName.Contains("SuspS") || tO.DisplayName.Contains("Small Suspension"))
+ {
+ tO.DisplayName = "Small Suspension";
+ tO.Desc = "Similar style as the large with smaller pillars. For lengths under 725m.";
+ tO.sortID = 10;
+ }
+ else if (tO.DisplayName.Contains("SemiArch1"))
+ {
+ tO.DisplayName = "SemiArch 80 Degree";
+ tO.Desc = "80 Degree arch. For lengths under 300m and small heights.";
+ tO.sortID = 40;
+ }
+ else if (tO.DisplayName.Contains("SemiArch2"))
+ {
+ tO.DisplayName = "SemiArch 80 Girder";
+ tO.Desc = "80 Degree arch with girder style. For lengths under 300m and small heights.";
+ tO.sortID = 41;
+ }
+ else if (tO.DisplayName.Contains("SemiArch3"))
+ {
+ tO.DisplayName = "SemiArch 180 Degree";
+ tO.Desc = "180 Degree arch. For lengths under 300m and small heights.";
+ tO.sortID = 42;
+ }
+ else if (tO.DisplayName.Contains("Arch12m"))
+ {
+ tO.DisplayName = "Arch 12m Beams";
+ tO.Desc = "Full deck arch bridge with 12m beams. Good for any length.";
+ tO.sortID = 0;
+ }
+ else if (tO.DisplayName.Contains("Arch24m"))
+ {
+ tO.DisplayName = "Arch 24m Beams";
+ tO.Desc = "Full deck arch bridge with 24m beams. Good for any length and non-small width roads.";
+ tO.sortID = 1;
+ }
+ else if (tO.DisplayName.Contains("Arch48m"))
+ {
+ tO.DisplayName = "Arch 48m Beams";
+ tO.Desc = "Full deck arch bridge with 48m beams. Good for any length and large width roads.";
+ tO.sortID = 3;
+ }
+ else if (tO.DisplayName.Contains("Grid"))
+ {
+ tO.DisplayName = "Grid Steel";
+ tO.Desc = "Grid based steel bridge. Good for any length depending on triangle counts.";
+ tO.sortID = 30;
+ }
+ else if (tO.DisplayName.Contains("Steel"))
+ {
+ tO.DisplayName = "Steel Beam";
+ tO.Desc = "Standard steel beam bridge. Good for any length depending on triangle counts.";
+ tO.sortID = 4;
+ }
+ else if (tO.DisplayName.Contains("Causeway1"))
+ {
+ tO.DisplayName = "Causeway Federal";
+ tO.Desc = "Standard federal highway bridge style. Good for any length depending on triangle counts.";
+ tO.sortID = 5;
+ }
+ else if (tO.DisplayName.Contains("Causeway2"))
+ {
+ tO.DisplayName = "Causeway Overpass";
+ tO.Desc = "Overpass style. Good for any length depending on triangle counts.";
+ tO.sortID = 8;
+ }
+ else if (tO.DisplayName.Contains("Causeway3"))
+ {
+ tO.DisplayName = "Causeway Classic";
+ tO.Desc = "Classic causeway style. Good for any length depending on triangle counts.";
+ tO.sortID = 7;
+ }
+ else if (tO.DisplayName.Contains("Causeway4"))
+ {
+ tO.DisplayName = "Causeway Highway";
+ tO.Desc = "State highway style. Good for any length depending on triangle counts.";
+ tO.sortID = 6;
+ }
+ }
+
+ if (tO.bIsDefault && !bIsBridge)
+ {
+ if (tO.DisplayName.Contains("GSDTunnel"))
+ {
+ tO.DisplayName = "Tunnel";
+ tO.Desc = "Designed after the Eisenhower tunnel.";
+ }
+ else if (tO.DisplayName.Contains("GSDGroup-WBeamLeftTurn"))
+ {
+ tO.DisplayName = "Left turn wbeams";
+ tO.Desc = "Contains wbeam and signs on right side of road for left turn.";
+ }
+ else if (tO.DisplayName.Contains("GSDGroup-KRailLights"))
+ {
+ tO.DisplayName = "K-rail with lights";
+ tO.Desc = "Center divider k-rail with double sided lights. Best used on mostly straight highway type roads.";
+ }
+ else if (tO.DisplayName.Contains("GSDGroup-Rumblestrips"))
+ {
+ tO.DisplayName = "Rumblestrips x2";
+ tO.Desc = "Rumble strips on both sides of the road.";
+ }
+ else if (tO.DisplayName.Contains("GSDGroup-Fancy1"))
+ {
+ tO.DisplayName = "Fancy railing x2";
+ tO.Desc = "Luxurious railing with lighting on both sides of the road.";
+ }
+ }
+
+ oList.Add(tO);
+ }
+ oListSort();
+ }
+
+
+ public static void GetGroupListing(out string[] tNames, out string[] tPaths, int Lanes, bool bIsDefault = false)
+ {
+
+ xPath = GSDRootUtil.Dir_GetLibrary();
+ Debug.Log(xPath);
+
+ string LaneText = "-2L";
+ if (Lanes == 4)
+ {
+ LaneText = "-4L";
+ }
+ else if (Lanes == 6)
+ {
+ LaneText = "-6L";
+ }
+
+ tNames = null;
+ tPaths = null;
+ DirectoryInfo info;
+ if (bIsDefault)
+ {
+ info = new DirectoryInfo(xPath + "B/W/");
+ }
+ else
+ {
+ info = new DirectoryInfo(xPath + "B/");
+ }
+
+ FileInfo[] fileInfo = info.GetFiles();
+ int tCount = 0;
+ foreach (FileInfo tInfo in fileInfo)
+ {
+ if (tInfo.Extension.ToLower().Contains("gsd"))
+ {
+ if (!bIsDefault)
+ {
+ tCount += 1;
+ }
+ else
+ {
+ if (tInfo.Name.Contains(LaneText))
+ {
+ tCount += 1;
+ }
+ }
+ }
+ }
+
+ tNames = new string[tCount];
+ tPaths = new string[tCount];
+ tCount = 0;
+ foreach (FileInfo tInfo in fileInfo)
+ {
+ if (tInfo.Extension.ToLower().Contains("gsd"))
+ {
+ if (!bIsDefault)
+ {
+ tNames[tCount] = tInfo.Name.Replace(".gsd", "");
+ tPaths[tCount] = tInfo.FullName;
+ tCount += 1;
+ }
+ else
+ {
+ if (tInfo.Name.Contains(LaneText))
+ {
+ tNames[tCount] = tInfo.Name.Replace(".gsd", "");
+ tPaths[tCount] = tInfo.FullName;
+ tCount += 1;
+ }
+ }
+ }
+ }
+ }
+ #endregion
+
+
+ #region "Init objs"
+ private void InitObjs()
+ {
+ string[] tNames = null;
+ string[] tPaths = null;
+ //Load user custom ones first:
+ if (tWindowType == WindowTypeEnum.Extrusion)
+ {
+ SplinatedMeshMaker.GetLibraryFiles(out tNames, out tPaths, false);
+ }
+ else
+ {
+ EdgeObjectMaker.GetLibraryFiles(out tNames, out tPaths, false);
+ }
+ LoadObjs(ref tNames, ref tPaths, false);
+ //Load GSD ones last:
+ if (tWindowType == WindowTypeEnum.Extrusion)
+ {
+ SplinatedMeshMaker.GetLibraryFiles(out tNames, out tPaths, true);
+ }
+ else
+ {
+ EdgeObjectMaker.GetLibraryFiles(out tNames, out tPaths, true);
+ }
+ LoadObjs(ref tNames, ref tPaths, true);
+ }
+
+
+ private void LoadObjs(ref string[] tNames, ref string[] tPaths, bool bIsDefault = false)
+ {
+ int tCount = tNames.Length;
+ string tPath = "";
+ string tStringPath = "";
+ string tDesc = "";
+ string tDisplayName = "";
+ string ThumbString = "";
+ bool bIsBridge = false;
+ for (int i = 0; i < tCount; i++)
+ {
+ bIsBridge = false;
+ tPath = tPaths[i];
+
+ if (tWindowType == WindowTypeEnum.Extrusion)
+ {
+ SplinatedMeshMaker.SplinatedMeshLibraryMaker SLM = (SplinatedMeshMaker.SplinatedMeshLibraryMaker) GSDRootUtil.LoadXML(ref tPath);
+ if (SLM == null)
+ {
+ continue;
+ }
+ tStringPath = SLM.CurrentSplinationString;
+ tDesc = SLM.Desc;
+ tDisplayName = SLM.DisplayName;
+ ThumbString = SLM.ThumbString;
+ bIsBridge = SLM.bIsBridge;
+ }
+ else if (tWindowType == WindowTypeEnum.Edge)
+ {
+ EdgeObjectMaker.EdgeObjectLibraryMaker ELM = (EdgeObjectMaker.EdgeObjectLibraryMaker) GSDRootUtil.LoadXML(ref tPath);
+ if (ELM == null)
+ {
+ continue;
+ }
+ tStringPath = ELM.EdgeObjectString;
+ tDesc = ELM.Desc;
+ tDisplayName = ELM.DisplayName;
+ ThumbString = ELM.ThumbString;
+ bIsBridge = ELM.bIsBridge;
+ }
+
+ //Don't continue if bridge pieces and this is not a bridge piece:
+ if (tWindowType == WindowTypeEnum.Extrusion && bIsBridge)
+ {
+ continue;
+ }
+
+ GSDRoadUtil.WizardObject tO = new GSDRoadUtil.WizardObject();
+ try
+ {
+ tO.Thumb = (Texture2D) AssetDatabase.LoadAssetAtPath(ThumbString, typeof(Texture2D)) as Texture2D;
+ }
+ catch
+ {
+ tO.Thumb = null;
+ }
+ if (tO.Thumb == null)
+ {
+ try
+ {
+ GameObject xObj = (GameObject) UnityEditor.AssetDatabase.LoadAssetAtPath(tStringPath, typeof(GameObject)) as GameObject;
+ tO.Thumb = AssetPreview.GetAssetPreview(xObj);
+ }
+ catch
+ {
+ tO.Thumb = null;
+ }
+ }
+ tO.DisplayName = tDisplayName;
+ tO.FileName = tNames[i];
+ tO.FullPath = tPath;
+ tO.Desc = tDesc;
+ tO.bIsDefault = bIsDefault;
+
+ if (bIsDefault && tWindowType == WindowTypeEnum.Edge)
+ {
+ if (tO.DisplayName.Contains("GSDAtten"))
+ {
+ tO.DisplayName = "Attenuator";
+ tO.Desc = "Standard double WBeam with impact absorption.";
+ }
+ else if (tO.DisplayName.Contains("GSDGreenBlinder"))
+ {
+ tO.DisplayName = "KRail Blinder";
+ tO.Desc = "Best results when placed on KRail for KRail blinders.";
+ tO.sortID = 5;
+ }
+ else if (tO.DisplayName.Contains("GSDRoadBarrelStatic"))
+ {
+ tO.DisplayName = "Sand Barrel Static";
+ tO.Desc = "One static sand barrel. Best results when placed in front of railings or bridges.";
+ }
+ else if (tO.DisplayName.Contains("GSDRoadBarrelRigid"))
+ {
+ tO.DisplayName = "Sand Barrel Rigid";
+ tO.Desc = "One rigid sand barrel. Best results when placed in front of railings or bridges.";
+ }
+ else if (tO.DisplayName.Contains("GSDRoadBarrel3Static"))
+ {
+ tO.DisplayName = "Sand Barrels Static 3";
+ tO.Desc = "Three static sand barrels in a line. Best results when placed in front of railings or bridges.";
+ }
+ else if (tO.DisplayName.Contains("GSDRoadBarrel3Rigid"))
+ {
+ tO.DisplayName = "Sand Barrels Rigid 3";
+ tO.Desc = "Three rigid sand barrels in a line. Best results when placed in front of railings or bridges.";
+ }
+ else if (tO.DisplayName.Contains("GSDRoadBarrel7Static"))
+ {
+ tO.DisplayName = "Sand Barrels Static 7";
+ tO.Desc = "Seven static sand barrels in standard formation. Best results when placed in front of railings or bridges.";
+ }
+ else if (tO.DisplayName.Contains("GSDRoadBarrel7Rigid"))
+ {
+ tO.DisplayName = "Sand Barrel Rigid 7";
+ tO.Desc = "Seven rigid sand barrels in standard formation. Best results when placed in front of railings or bridges.";
+ }
+ else if (tO.DisplayName.Contains("GSDRoadConBarrelStatic"))
+ {
+ tO.DisplayName = "Con Barrels Static";
+ tO.Desc = "Static road construction barrels.";
+ tO.sortID = 3;
+ }
+ else if (tO.DisplayName.Contains("GSDRoadConBarrelRigid"))
+ {
+ tO.DisplayName = "Con Barrels Rigid";
+ tO.Desc = "Rigid road construction barrels.";
+ tO.sortID = 3;
+ }
+ else if (tO.DisplayName.Contains("GSDTrafficConeStatic"))
+ {
+ tO.DisplayName = "Traffic cones Static";
+ tO.Desc = "Static traffic cones.";
+ tO.sortID = 4;
+ }
+ else if (tO.DisplayName.Contains("GSDTrafficConeRigid"))
+ {
+ tO.DisplayName = "Traffic cones Rigid";
+ tO.Desc = "Rigid traffic cones.";
+ tO.sortID = 4;
+ }
+ else if (tO.DisplayName.Contains("GSDRoadReflector"))
+ {
+ tO.DisplayName = "Road reflectors";
+ tO.Desc = "Placed one center line of road for center line reflection.";
+ tO.sortID = 4;
+ }
+ else if (tO.DisplayName.Contains("GSDStopSign"))
+ {
+ tO.DisplayName = "Stop sign";
+ tO.Desc = "Standard specification non-interstate stop sign.";
+ }
+ else if (tO.DisplayName.Contains("GSDStreetLightSingle"))
+ {
+ tO.DisplayName = "Streetlight Singlesided";
+ tO.Desc = "Best used on side of roads.";
+ }
+ else if (tO.DisplayName.Contains("GSDStreetLightDouble"))
+ {
+ tO.DisplayName = "Streetlight Doublesided";
+ tO.Desc = "Best results when embedded in KRail in centerline of road.";
+ }
+ else if (tO.DisplayName.Contains("GSDWarningSign1"))
+ {
+ tO.DisplayName = "Warning Sign #1";
+ tO.Desc = "Best results when placed in front of railings or bridges.";
+ }
+ else if (tO.DisplayName.Contains("GSDWarningSign2"))
+ {
+ tO.DisplayName = "Warning Sign #2";
+ tO.Desc = "Best results when placed in front of railings or bridges.";
+ }
+ else if (tO.DisplayName.Contains("GSDSignRightTurnOnly"))
+ {
+ tO.DisplayName = "Right turn only";
+ tO.Desc = "Best results when placed near intersection right turn lane.";
+ tO.sortID = 4;
+ }
+
+ else if (tO.DisplayName.Contains("GSDSign330"))
+ {
+ tO.DisplayName = "Signs 330";
+ tO.Desc = "Interchangeable materials, use \"GSDFedSign-330\" as the search term.";
+ tO.sortID = 21;
+ }
+ else if (tO.DisplayName.Contains("GSDSign396"))
+ {
+ tO.DisplayName = "Signs 396";
+ tO.Desc = "Interchangeable materials, use \"GSDFedSign-396\" as the search term.";
+ tO.sortID = 21;
+ }
+ else if (tO.DisplayName.Contains("GSDSign617-Small"))
+ {
+ tO.DisplayName = "Signs 617 small";
+ tO.Desc = "Interchangeable materials, use \"GSDFedSign-617\" as the search term.";
+ tO.sortID = 21;
+ }
+ else if (tO.DisplayName.Contains("GSDSign617"))
+ {
+ tO.DisplayName = "Signs 617";
+ tO.Desc = "Interchangeable materials, use \"GSDFedSign-617\" as the search term.";
+ tO.sortID = 21;
+ }
+ else if (tO.DisplayName.Contains("GSDSign861-Small"))
+ {
+ tO.DisplayName = "Signs 861 small";
+ tO.Desc = "Interchangeable materials, use \"GSDFedSign-861\" as the search term.";
+ tO.sortID = 21;
+ }
+ else if (tO.DisplayName.Contains("GSDSign861"))
+ {
+ tO.DisplayName = "Sign type 861";
+ tO.Desc = "Interchangeable materials, use \"GSDFedSign-861\" as the search term.";
+ tO.sortID = 21;
+ }
+ else if (tO.DisplayName.Contains("GSDSign988-Small"))
+ {
+ tO.DisplayName = "Signs 988 small";
+ tO.Desc = "Interchangeable materials, use \"GSDFedSign-988\" as the search term.";
+ tO.sortID = 21;
+ }
+ else if (tO.DisplayName.Contains("GSDSign988"))
+ {
+ tO.DisplayName = "Signs 988";
+ tO.Desc = "Interchangeable materials, use \"GSDFedSign-988\" as the search term.";
+ tO.sortID = 21;
+ }
+ else if (tO.DisplayName.Contains("GSDSignDiamond"))
+ {
+ tO.DisplayName = "Signs diamond";
+ tO.Desc = "Interchangeable materials, use \"GSDFedSign-diamond\" as the search term.";
+ tO.sortID = 21;
+ }
+ else if (tO.DisplayName.Contains("GSDSignSquare-Small"))
+ {
+ tO.DisplayName = "Signs square small";
+ tO.Desc = "Interchangeable materials, use \"GSDFedSign-Square\" as the search term.";
+ tO.sortID = 21;
+ }
+ else if (tO.DisplayName.Contains("GSDSignSquare"))
+ {
+ tO.DisplayName = "Signs square";
+ tO.Desc = "Interchangeable materials, use \"GSDFedSign-Square\" as the search term.";
+ tO.sortID = 21;
+ }
+ }
+
+ if (bIsDefault && tWindowType == WindowTypeEnum.Extrusion)
+ {
+ if (tO.DisplayName.Contains("GSDKRail"))
+ {
+ tO.DisplayName = "KRail";
+ tO.Desc = "Federal spec cement KRailing (also known as Jersey Barriers). Variant with down ends.";
+ }
+ else if (tO.DisplayName.Contains("GSDKRailCurvedR"))
+ {
+ tO.DisplayName = "KRail Curved Right";
+ tO.Desc = "Federal spec cement KRailing (also known as Jersey Barriers). Variant with curved ends for right shoulder.";
+ }
+ else if (tO.DisplayName.Contains("GSDKRailCurvedL"))
+ {
+ tO.DisplayName = "KRail Curved Left";
+ tO.Desc = "Federal spec cement KRailing (also known as Jersey Barriers). Variant with curved ends for left shoulder.";
+ }
+ else if (tO.DisplayName.Contains("GSDWBeam1R"))
+ {
+ tO.DisplayName = "WBeam Wood Right";
+ tO.Desc = "Federal spec wooden pole WBeam railing. Best used as outer shoulder railing. Right shoulder.";
+ }
+ else if (tO.DisplayName.Contains("GSDWBeam1L"))
+ {
+ tO.DisplayName = "WBeam Wood Left";
+ tO.Desc = "Federal spec wooden pole WBeam railing. Best used as outer shoulder railing. Left shoulder.";
+ }
+ else if (tO.DisplayName.Contains("GSDWBeam2R"))
+ {
+ tO.DisplayName = "WBeam Metal Right";
+ tO.Desc = "Federal spec metal pole WBeam railing. Best used as outer shoulder railing. Right shoulder.";
+ }
+ else if (tO.DisplayName.Contains("GSDWBeam2L"))
+ {
+ tO.DisplayName = "WBeam Metal Left";
+ tO.Desc = "Federal spec metal pole WBeam railing. Best used as outer shoulder railing. Left shoulder.";
+ }
+ else if (tO.DisplayName.Contains("GSDRailing1"))
+ {
+ tO.DisplayName = "Railing #1";
+ tO.Desc = "Standard double square pole railing.";
+ }
+ else if (tO.DisplayName.Contains("GSDRailing2"))
+ {
+ tO.DisplayName = "Railing #2";
+ tO.Desc = "Standard concrete big block railing.";
+ }
+ else if (tO.DisplayName.Contains("GSDRailing3"))
+ {
+ tO.DisplayName = "Railing #3";
+ tO.Desc = "Standard four-strand metal railing.";
+ }
+ else if (tO.DisplayName.Contains("GSDRailing5"))
+ {
+ tO.DisplayName = "Railing #5";
+ tO.Desc = "Basic concrete railing with pylons.";
+ }
+ else if (tO.DisplayName.Contains("GSDRailing6"))
+ {
+ tO.DisplayName = "Railing #6";
+ tO.Desc = "Standard two-strand metal pole railing.";
+ }
+ else if (tO.DisplayName.Contains("GSDRailing7"))
+ {
+ tO.DisplayName = "Railing #7";
+ tO.Desc = "Rock-decorated concrete railing with pylons and double strand rusted look metal railing.";
+ }
+ else if (tO.DisplayName.Contains("GSDRailing8"))
+ {
+ tO.DisplayName = "Railing #8";
+ tO.Desc = "Rock-decorated concrete railing with standard single pole metal railing.";
+ }
+ else if (tO.DisplayName.Contains("GSDRailing9"))
+ {
+ tO.DisplayName = "Railing #9";
+ tO.Desc = "Very low poly railing used for mobile.";
+ }
+ else if (tO.DisplayName.Contains("GSDSidewalk"))
+ {
+ tO.DisplayName = "Sidewalk";
+ tO.Desc = "Sidewalk.";
+ }
+ else if (tO.DisplayName.Contains("GSDRumbleStrip"))
+ {
+ tO.DisplayName = "Rumblestrip";
+ tO.Desc = "State spec rumblestrip. For best results place several cm from road edge into shoulder.";
+ }
+ else if (tO.DisplayName.Contains("GSDRailing4R"))
+ {
+ tO.DisplayName = "Railing #4 Right";
+ tO.Desc = "Three bar angled pole railing. Right side of road.";
+ }
+ else if (tO.DisplayName.Contains("GSDRailing4L"))
+ {
+ tO.DisplayName = "Railing #4 Left";
+ tO.Desc = "Three bar angled pole railing. Left side of road.";
+ }
+ else if (tO.DisplayName.Contains("GSDRailing4-LightR"))
+ {
+ tO.DisplayName = "Railing #4 Light Right";
+ tO.Desc = "Three bar angled pole railing. Right side of road. Light version with fewer triangle count.";
+ }
+ else if (tO.DisplayName.Contains("GSDRailing4-LightL"))
+ {
+ tO.DisplayName = "Railing #4 Light Left";
+ tO.Desc = "Three bar angled pole railing. Left side of road. Light version with fewer triangle count.";
+ }
+ else if (tO.DisplayName.Contains("GSDRailingBase1"))
+ {
+ tO.DisplayName = "Railing base #1";
+ tO.Desc = "Use as a base on other railings to create more detail.";
+ }
+ else if (tO.DisplayName.Contains("GSDRailingBase2"))
+ {
+ tO.DisplayName = "Railing base #2";
+ tO.Desc = "Use as a base on other railings to create more detail.";
+ }
+ else if (tO.DisplayName.Contains("GSDCableBarrier-Light"))
+ {
+ tO.DisplayName = "Cable barrier 10m";
+ tO.Desc = "Cable barrier 10m light triangle version. Best used as center divider or as railing barriers.";
+ tO.sortID = 20;
+ }
+ else if (tO.DisplayName.Contains("GSDCableBarrier"))
+ {
+ tO.DisplayName = "Cable barrier 5m";
+ tO.Desc = "Cable barrier 5m. Best used as center divider or as railing barriers.";
+ tO.sortID = 20;
+ }
+ }
+
+ oList.Add(tO);
+ }
+ oListSort();
+ }
+
+
+ void oListSort()
+ {
+ oList.Sort((GSDRoadUtil.WizardObject t1, GSDRoadUtil.WizardObject t2) =>
+ {
+ if (t1.bIsDefault != t2.bIsDefault)
+ {
+ return t1.bIsDefault.CompareTo(t2.bIsDefault);
+ }
+ else if (t1.sortID != t2.sortID)
+ {
+ return t1.sortID.CompareTo(t2.sortID);
+ }
+ else
+ {
+ return t1.DisplayName.CompareTo(t2.DisplayName);
+ }
+ });
+ }
+ #endregion
+ #endregion
}
\ No newline at end of file
diff --git a/Editor/Library.meta b/Editor/Library.meta
index c1c7c731..ed243992 100755
--- a/Editor/Library.meta
+++ b/Editor/Library.meta
@@ -1,8 +1,8 @@
-fileFormatVersion: 2
-guid: 0c2a5b8a5881fbf4891420e63e1769ad
-folderAsset: yes
-DefaultImporter:
- externalObjects: {}
- userData:
- assetBundleName:
- assetBundleVariant:
+fileFormatVersion: 2
+guid: 58e33fe3598ca124a80db310156eda99
+folderAsset: yes
+DefaultImporter:
+ externalObjects: {}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/GSDOffRoadObject.cs b/GSDOffRoadObject.cs
index 76815fdf..5a43713b 100644
--- a/GSDOffRoadObject.cs
+++ b/GSDOffRoadObject.cs
@@ -1,20 +1,17 @@
-using System.Collections;
-using System.Collections.Generic;
-using UnityEngine;
-
-public class GSDOffRoadObject : MonoBehaviour
-{
- public static readonly Color Color_NodeOffRoadColor = new Color(1f, 0f, 0.5f, 0.75f);
- public static readonly Color Color_NodeOffRoadSelectedColor = new Color(1f, 0f, 0.8f, 1f);
- // Start is called before the first frame update
- void Start()
- {
-
- }
-
- // Update is called once per frame
- void Update()
- {
-
- }
-}
+using System.Collections;
+using System.Collections.Generic;
+using UnityEngine;
+
+
+public class GSDOffRoadObject : MonoBehaviour
+{
+ public static readonly Color Color_NodeOffRoadColor = new Color(1f, 0f, 0.5f, 0.75f);
+ public static readonly Color Color_NodeOffRoadSelectedColor = new Color(1f, 0f, 0.8f, 1f);
+
+
+ // Update is called once per frame
+ void Update()
+ {
+
+ }
+}
\ No newline at end of file
diff --git a/GSDRigidBody.cs b/GSDRigidBody.cs
index 4766f02e..da54bbbd 100755
--- a/GSDRigidBody.cs
+++ b/GSDRigidBody.cs
@@ -1,53 +1,77 @@
-using UnityEngine;
-
-public class GSDRigidBody : MonoBehaviour
-{
- public float MinCollVelocity = 2f;
- // bool bIsForcedSleeping = false;
- Rigidbody RB;
- // bool bIgnoreRB = false;
-
- void Awake()
- {
- RB = transform.GetComponent();
- if (RB != null)
- {
- DestroyImmediate(RB);
- }
- }
-
- // void OnCollisionEnter(Collision collision) {
- // if(bIgnoreRB || !bIsForcedSleeping){ return; }
- // Debug.Log (collision.relativeVelocity.magnitude);
- // if(RB != null){
- // if(collision.relativeVelocity.magnitude <= MinCollVelocity){
- // RB.Sleep();
- // }else{
- // //RB.isKinematic = false;
- // bIsForcedSleeping = false;
- // //RB.AddForce(collision.relativeVelocity*collision.relativeVelocity.magnitude*(RB.mass*0.3f));
- // }
- // }
- // }
- //
- // void OnCollisionExit(Collision collisionInfo) {
- // if(bIgnoreRB || !bIsForcedSleeping){ return; }
- // if(bIsForcedSleeping && RB != null){
- // RB.Sleep();
- // }
- // }
- //
- // float TimerMax = 0.1f;
- // float TimerNow = 0f;
- // void Update(){
- // if(bIsForcedSleeping){
- // TimerNow += Time.deltaTime;
- // if(TimerNow > TimerMax){
- // if(RB != null && !RB.IsSleeping()){
- // RB.Sleep();
- // }
- // TimerNow = 0f;
- // }
- // }
- // }
+using UnityEngine;
+
+
+public class GSDRigidBody : MonoBehaviour
+{
+ public float MinCollVelocity = 2f;
+ // bool bIsForcedSleeping = false;
+ Rigidbody rigidBody; // Formerly RB // FH 29.01.19
+ // bool bIgnoreRB = false;
+
+
+ void Awake()
+ {
+ rigidBody = transform.GetComponent();
+ if (rigidBody != null)
+ {
+ DestroyImmediate(rigidBody);
+ }
+ }
+
+
+ /*
+ void OnCollisionEnter(Collision collision)
+ {
+ if ( bIgnoreRB || !bIsForcedSleeping )
+ {
+ return;
+ }
+ Debug.Log( collision.relativeVelocity.magnitude );
+ if ( rigidbody != null )
+ {
+ if ( collision.relativeVelocity.magnitude <= MinCollVelocity )
+ {
+ rigidbody.Sleep();
+ }
+ else
+ {
+ //RB.isKinematic = false;
+ bIsForcedSleeping = false;
+ //RB.AddForce(collision.relativeVelocity*collision.relativeVelocity.magnitude*(RB.mass*0.3f));
+ }
+ }
+ }
+
+
+ void OnCollisionExit(Collision collisionInfo)
+ {
+ if ( bIgnoreRB || !bIsForcedSleeping )
+ { return; }
+ if ( bIsForcedSleeping && rigidbody != null )
+ {
+ rigidbody.Sleep();
+ }
+ }
+
+
+ float TimerMax = 0.1f;
+ float TimerNow = 0f;
+
+
+ void Update()
+ {
+ if ( bIsForcedSleeping )
+ {
+ TimerNow += Time.deltaTime;
+ if ( TimerNow > TimerMax )
+ {
+ if ( rigidbody != null && !rigidbody.IsSleeping() )
+ {
+ rigidbody.Sleep();
+ }
+ TimerNow = 0f;
+ }
+ }
+ }
+ */
}
\ No newline at end of file
diff --git a/GSDRoad.cs b/GSDRoad.cs
index dad832fc..446884a4 100755
--- a/GSDRoad.cs
+++ b/GSDRoad.cs
@@ -1,1808 +1,1938 @@
-using UnityEngine;
-using System.Collections;
-using System.Collections.Generic;
-using GSD.Roads;
-using GSD;
-#if UNITY_EDITOR
-using UnityEditor;
-#endif
-[ExecuteInEditMode]
-public class GSDRoad : MonoBehaviour
-{
-
-
- public GameObject MainMeshes;
- public GameObject MeshRoad;
- public GameObject MeshShoR;
- public GameObject MeshShoL;
- public GameObject MeshiLanes;
- public GameObject MeshiLanes0;
- public GameObject MeshiLanes1;
- public GameObject MeshiLanes2;
- public GameObject MeshiLanes3;
- public GameObject MeshiMainPlates;
- public GameObject MeshiMarkerPlates;
- [System.NonSerialized]
- public string EditorTitleString = "";
-
- public GSDSplineC GSDSpline;
-
- public int MostRecentNodeCount = -1;
- // private bool bMostRecentCheck = false;
- public GameObject GSDSplineObj;
- public GSDRoadSystem GSDRS;
- public GSDSplineC[] PiggyBacks = null;
- public bool bEditorProgressBar = false;
- public string UID; //Unique ID
-#if UNITY_EDITOR
- [SerializeField]
- public List TerrainHistory;
- public string TerrainHistoryByteSize = "";
-#endif
- [System.NonSerialized]
- public bool bUpdateSpline = false;
-
- //Road editor options:
- public float opt_LaneWidth = 5f; //Done.
- public bool opt_bShouldersEnabled = true; //Disabled for now. Comprimises integrity of roads.
- public float opt_ShoulderWidth = 3f; //Done.
- public int opt_Lanes = 2; //Done.
- public float opt_RoadDefinition = 5f; //Done.
- public bool opt_RoadCornerDefinition = false; //Disable for now. No point.
- public bool opt_bRoadCuts = true;
- public bool opt_bShoulderCuts = true;
- public bool opt_bDynamicCuts = false;
- public bool opt_bMaxGradeEnabled = true;
- public float opt_MaxGrade = 0.08f;
- public bool opt_UseDefaultMaterials = true;
- public bool opt_AutoUpdateInEditor = true;
-
- public float opt_TerrainSubtract_Match = 0.1f;
- public bool opt_bGSDRoadRaise = false;
-
- public float opt_MatchHeightsDistance = 50f;
- public float opt_ClearDetailsDistance = 30f;
- public float opt_ClearDetailsDistanceHeight = 5f;
- public float opt_ClearTreesDistance = 30f;
- public float opt_ClearTreesDistanceHeight = 50f;
-
- public bool opt_HeightModEnabled = true;
- public bool opt_DetailModEnabled = true;
- public bool opt_TreeModEnabled = true;
-
- public bool opt_SaveTerrainHistoryOnDisk = true;
- public float opt_MagnitudeThreshold = 300f;
- public bool opt_GizmosEnabled = true;
- public bool opt_bMultithreading = true;
- public bool opt_bSaveMeshes = false;
- public bool opt_bUseMeshColliders = true;
- public bool opt_bIsStatic = false;
- public bool opt_bIsLightmapped = false;
-
- public enum RoadMaterialDropdownEnum
- {
- Asphalt,
- Dirt,
- Brick,
- Cobblestone
- };
- public RoadMaterialDropdownEnum opt_tRoadMaterialDropdown = RoadMaterialDropdownEnum.Asphalt;
- public RoadMaterialDropdownEnum tRoadMaterialDropdownOLD = RoadMaterialDropdownEnum.Asphalt;
-
-
- public Material RoadMaterial1;
- public Material RoadMaterial2;
- public Material RoadMaterial3;
- public Material RoadMaterial4;
- public Material RoadMaterialMarker1;
- public Material RoadMaterialMarker2;
- public Material RoadMaterialMarker3;
- public Material RoadMaterialMarker4;
- public Material ShoulderMaterial1;
- public Material ShoulderMaterial2;
- public Material ShoulderMaterial3;
- public Material ShoulderMaterial4;
- public Material ShoulderMaterialMarker1;
- public Material ShoulderMaterialMarker2;
- public Material ShoulderMaterialMarker3;
- public Material ShoulderMaterialMarker4;
-
- public PhysicMaterial RoadPhysicMaterial;
- public PhysicMaterial ShoulderPhysicMaterial;
-#if UNITY_EDITOR
- #region "Road Construction"
- [System.NonSerialized]
- public GSD.Threaded.TerrainCalcs TerrainCalcsJob;
- [System.NonSerialized]
- public GSD.Threaded.RoadCalcs1 RoadCalcsJob1;
- [System.NonSerialized]
- public GSD.Threaded.RoadCalcs2 RoadCalcsJob2;
- [System.NonSerialized]
- public RoadConstructorBufferMaker RCS;
-
- public string tName = "";
- public bool bProfiling = false;
- public bool bSkipStore = true;
- [System.NonSerialized]
- public float EditorConstructionStartTime = 0f;
-
- void CleanRunTime()
- {
- //Make sure unused items are not using memory space in runtime:
- TerrainHistory = null;
- RCS = null;
- }
-
- public bool bEditorError = false;
- public System.Exception tError = null;
- void OnEnable()
- {
- if (!Application.isEditor) { return; }
- // if(Application.isEditor && !UnityEditor.EditorApplication.isPlaying){
- Editor_bIsConstructing = false;
- UnityEditor.EditorApplication.update += delegate { EditorUpdate(); };
-#if UNITY_2018_1_OR_NEWER
- UnityEditor.EditorApplication.hierarchyChanged += delegate { hWindowChanged(); };
-#else
- UnityEditor.EditorApplication.hierarchyWindowChanged += delegate { hWindowChanged(); };
-#endif
- // }
- if (GSDSpline == null || GSDSpline.mNodes == null)
- {
- MostRecentNodeCount = 0;
- }
- else
- {
- MostRecentNodeCount = GSDSpline.GetNodeCount();
- }
- tRoadMaterialDropdownOLD = opt_tRoadMaterialDropdown;
- CheckMats();
- }
-
- public void Awake()
- {
- if (GSDSpline == null || GSDSpline.mNodes == null)
- {
- MostRecentNodeCount = 0;
- }
- else
- {
- MostRecentNodeCount = GSDSpline.GetNodeCount();
- }
- }
-
- int EditorTimer = 0;
- int EditorTimerMax = 0;
- int EditorTimerSpline = 0;
- const int EditorTimerSplineMax = 2;
- [System.NonSerialized]
- public int EditorProgress = 0;
- const int GizmoNodeTimerMax = 2;
- public bool EditorUpdateMe = false;
- public bool bTriggerGC = false;
- bool bTriggerGC_Happening;
- float TriggerGC_End = 0f;
- private void EditorUpdate()
- {
- if (!Application.isEditor)
- {
- UnityEditor.EditorApplication.update -= delegate { EditorUpdate(); };
- }
-
- if (this == null)
- {
- UnityEditor.EditorApplication.update -= delegate { EditorUpdate(); };
- Editor_bIsConstructing = false;
- EditorUtility.ClearProgressBar();
- return;
- }
-
- //Custom garbage collection demands for editor:
- if (bTriggerGC)
- {
- bTriggerGC = false;
- TriggerGC_End = Time.realtimeSinceStartup + 1f;
- bTriggerGC_Happening = true;
- }
- if (bTriggerGC_Happening)
- {
- if (Time.realtimeSinceStartup > TriggerGC_End)
- {
- bTriggerGC_Happening = false;
- GSDRootUtil.ForceCollection();
- TriggerGC_End = 200000f;
- }
- }
-
- if (Editor_bIsConstructing)
- { // && !Application.isPlaying && !UnityEditor.EditorApplication.isPlaying){
- if (GSDRS != null)
- {
- if (GSDRS.opt_bMultithreading)
- {
- EditorTimer += 1;
- if (EditorTimer > EditorTimerMax)
- {
- if ((Time.realtimeSinceStartup - EditorConstructionStartTime) > 180f)
- {
- Editor_bIsConstructing = false;
- EditorUtility.ClearProgressBar();
- Debug.Log("Update shouldn't take longer than 180 seconds. Aborting update.");
- }
-
- EditorTimer = 0;
- if (bEditorError)
- {
- Editor_bIsConstructing = false;
- EditorUtility.ClearProgressBar();
- bEditorError = false;
- if (tError != null)
- {
- Debug.LogError(tError.StackTrace);
- throw tError;
- }
- }
-
- if (TerrainCalcsJob != null && TerrainCalcsJob.Update())
- {
- ConstructRoad2();
- }
- else if (RoadCalcsJob1 != null && RoadCalcsJob1.Update())
- {
- ConstructRoad3();
- }
- else if (RoadCalcsJob2 != null && RoadCalcsJob2.Update())
- {
- ConstructRoad4();
- }
- }
- }
- }
- }
- else
- {
- if (EditorUpdateMe && !Editor_bIsConstructing)
- {
- EditorUpdateMe = false;
- GSDSpline.Setup_Trigger();
- }
- }
-
- if (Editor_bIsConstructing)
- {
- RoadUpdateProgressBar();
- }
- else if (bEditorProgressBar)
- {
- RoadUpdateProgressBar();
- }
-
- if (!Application.isPlaying && bUpdateSpline && !UnityEditor.EditorApplication.isPlaying)
- {
- EditorTimerSpline += 1;
- if (EditorTimerSpline > EditorTimerSplineMax)
- {
- EditorTimerSpline = 0;
- bUpdateSpline = false;
- GSDSpline.Setup_Trigger();
- MostRecentNodeCount = GSDSpline.mNodes.Count;
- }
- }
-
- if (bEditorCameraMoving && EditorCameraNextMove < EditorApplication.timeSinceStartup)
- {
- EditorCameraNextMove = (float)EditorApplication.timeSinceStartup + EditorCameraTimeUpdateInterval;
- DoEditorCameraLoop();
- }
- }
-
- [System.NonSerialized]
- public bool bEditorCameraMoving = false;
- [System.NonSerialized]
- public float EditorCameraPos = 0f;
- // float EditorCameraPos_Full = 0f;
- const float EditorCameraTimeUpdateInterval = 0.015f;
- float EditorCameraNextMove = 0f;
- bool bEditorCameraSetup = false;
- float EditorCameraStartPos = 0f;
- float EditorCameraEndPos = 1f;
- float EditorCameraIncrementDistance = 0f;
- float EditorCameraIncrementDistance_Full = 0f;
- public float EditorCameraMetersPerSecond = 60f;
- public bool bEditorCameraRotate = false;
- Vector3 EditorCameraV1 = default(Vector3);
- Vector3 EditorCameraV2 = default(Vector3);
- [System.NonSerialized]
- public Vector3 EditorCameraOffset = new Vector3(0f, 5f, 0f);
- [System.NonSerialized]
- public Camera EditorPlayCamera = null;
- Vector3 EditorCameraBadVec = default(Vector3);
-
- public void DoEditorCameraLoop()
- {
- if (!bEditorCameraSetup)
- {
- bEditorCameraSetup = true;
- if (GSDSpline.bSpecialEndControlNode)
- { //If control node, start after the control node:
- EditorCameraEndPos = GSDSpline.mNodes[GSDSpline.GetNodeCount() - 2].tTime;
- }
- if (GSDSpline.bSpecialStartControlNode)
- { //If ends in control node, end construction before the control node:
- EditorCameraStartPos = GSDSpline.mNodes[1].tTime;
- }
- // EditorCameraPos_Full = 0f;
- ChangeEditorCameraMetersPerSec();
- }
-
- if (!Selection.Contains(this.transform.gameObject))
- {
- QuitEditorCamera();
- return;
- }
-
- // EditorCameraPos_Full+=EditorCameraIncrementDistance_Full;
- // if(EditorCameraPos_Full > GSDSpline.distance){ EditorCameraPos = EditorCameraStartPos; bEditorCameraMoving = false; bEditorCameraSetup = false; EditorCameraPos_Full = 0f; return; }
- // EditorCameraPos = GSDSpline.TranslateDistBasedToParam(EditorCameraPos_Full);
-
- EditorCameraPos += EditorCameraIncrementDistance;
- if (EditorCameraPos > EditorCameraEndPos)
- {
- QuitEditorCamera();
- return;
- }
- if (EditorCameraPos < EditorCameraStartPos)
- {
- EditorCameraPos = EditorCameraStartPos;
- }
-
- GSDSpline.GetSplineValue_Both(EditorCameraPos, out EditorCameraV1, out EditorCameraV2);
-
- if (EditorApplication.isPlaying)
- {
- if (EditorPlayCamera != null)
- {
- EditorPlayCamera.transform.position = EditorCameraV1;
- if (bEditorCameraRotate)
- {
- EditorPlayCamera.transform.position += EditorCameraOffset;
- if (EditorCameraV2 != EditorCameraBadVec)
- {
- EditorPlayCamera.transform.rotation = Quaternion.LookRotation(EditorCameraV2);
- }
- }
- }
- }
- else
- {
- SceneView.lastActiveSceneView.pivot = EditorCameraV1;
- if (bEditorCameraRotate)
- {
- SceneView.lastActiveSceneView.pivot += EditorCameraOffset;
- if (EditorCameraV2 != EditorCameraBadVec)
- {
- SceneView.lastActiveSceneView.rotation = Quaternion.LookRotation(EditorCameraV2);
- }
- }
- SceneView.lastActiveSceneView.Repaint();
- }
- }
- public void EditorCameraSetSingle()
- {
- if (EditorPlayCamera == null)
- {
- Camera[] EditorCams = (Camera[])GameObject.FindObjectsOfType(typeof(Camera));
- if (EditorCams != null && EditorCams.Length == 1)
- {
- EditorPlayCamera = EditorCams[0];
- }
- }
- }
- public void QuitEditorCamera()
- {
- EditorCameraPos = EditorCameraStartPos;
- bEditorCameraMoving = false;
- bEditorCameraSetup = false;
- // EditorCameraPos_Full = 0f;
- }
- public void ChangeEditorCameraMetersPerSec()
- {
- EditorCameraIncrementDistance_Full = (EditorCameraMetersPerSecond / 60);
- EditorCameraIncrementDistance = (EditorCameraIncrementDistance_Full / GSDSpline.distance);
- }
-
- private void hWindowChanged()
- {
- if (!Application.isEditor)
- {
-#if UNITY_2018_1_OR_NEWER
- UnityEditor.EditorApplication.hierarchyChanged -= delegate { hWindowChanged(); };
-#else
- UnityEditor.EditorApplication.hierarchyWindowChanged -= delegate { hWindowChanged(); };
-#endif
- }
- if (Application.isPlaying || !Application.isEditor) { return; }
- if (Application.isEditor && UnityEditor.EditorApplication.isPlaying) { return; }
- if (Application.isEditor && UnityEditor.EditorApplication.isPlayingOrWillChangePlaymode) { return; }
-
- int tCount = 0;
- if (GSDSpline != null && GSDSpline.mNodes != null)
- {
- tCount = GSDSpline.GetNodeCountNonNull();
- }
- if (tCount != MostRecentNodeCount)
- {
- bUpdateSpline = true;
- }
- }
-
- void RoadUpdateProgressBar()
- {
- if (Editor_bIsConstructing)
- {
- EditorUtility.DisplayProgressBar(
- "GSD Road Update",
- EditorTitleString,
- ((float)EditorProgress / 100f));
- }
- else if (bEditorProgressBar)
- {
- bEditorProgressBar = false;
- EditorUtility.ClearProgressBar();
- }
- }
-
- public void UpdateRoad(RoadUpdateTypeEnum tUpdateType = RoadUpdateTypeEnum.Full)
- {
- if (!GSDRS.opt_bAllowRoadUpdates)
- {
- GSDSpline.Setup();
- Editor_bIsConstructing = false;
- return;
- }
-
- if (Editor_bIsConstructing)
- {
- return;
- }
-
- SetupUniqueIdentifier();
-
-
-
- if (bProfiling) { UnityEngine.Profiling.Profiler.BeginSample("UpdateRoadPrelim"); }
- opt_RoadDefinition = Mathf.Clamp(opt_RoadDefinition, 1f, 50f);
- opt_LaneWidth = Mathf.Clamp(opt_LaneWidth, 0.2f, 500f);
- EditorConstructionStartTime = Time.realtimeSinceStartup;
- EditorTitleString = "Updating " + transform.name + "...";
- System.GC.Collect();
-
- if (opt_SaveTerrainHistoryOnDisk)
- {
- ConstructRoad_LoadTerrainHistory();
- }
-
- CheckMats();
-
- EditorUtility.ClearProgressBar();
-
- bProfiling = true;
- if (GSDRS.opt_bMultithreading) { bProfiling = false; }
-
- //Set all terrains to height 0:
- GSD.Roads.GSDTerraforming.CheckAllTerrainsHeight0();
-
- EditorProgress = 20;
- bEditorProgressBar = true;
- if (Editor_bIsConstructing)
- {
- if (TerrainCalcsJob != null) { TerrainCalcsJob.Abort(); TerrainCalcsJob = null; }
- if (RoadCalcsJob1 != null) { RoadCalcsJob1.Abort(); RoadCalcsJob1 = null; }
- if (RoadCalcsJob2 != null) { RoadCalcsJob2.Abort(); RoadCalcsJob2 = null; }
- Editor_bIsConstructing = false;
- }
-
- // if(Application.isPlaying || !Application.isEditor){ return; }
- // if(Application.isEditor && UnityEditor.EditorApplication.isPlaying){ return; }
- // if(Application.isEditor && UnityEditor.EditorApplication.isPlayingOrWillChangePlaymode){ return; }
-
- //In here for intersection patching purposes:
- int mCount = GSDSpline.GetNodeCount();
- GSDSplineN tNode = null;
- GSDSplineN tNode1 = null;
- GSDSplineN tNode2 = null;
- if (GSDSpline.CheckInvalidNodeCount())
- {
- GSDSpline.Setup();
- mCount = GSDSpline.GetNodeCount();
- }
- if (mCount > 1)
- {
- for (int i = 0; i < mCount; i++)
- {
- // try{
- tNode = GSDSpline.mNodes[i];
- // }catch{
- // Editor_bIsConstructing = false;
- // EditorUpdateMe = true;
- // return;
- // }
-
- //If node is intersection with an invalid GSDRI, mark it at non-intersection. Just-in-case.
- if (tNode.bIsIntersection && tNode.GSDRI == null)
- {
- tNode.bIsIntersection = false;
- tNode.id_intersection_othernode = -1;
- tNode.Intersection_OtherNode = null;
- }
- //If node is intersection, re-setup:
- if (tNode.bIsIntersection && tNode.GSDRI != null)
- {
- tNode1 = tNode.GSDRI.Node1;
- tNode2 = tNode.GSDRI.Node2;
- tNode.GSDRI.Setup(tNode1, tNode2);
- tNode.GSDRI.DeleteRelevantChildren(tNode, tNode.GSDSpline.tRoad.transform.name);
- //If primary node on intersection, do more re-setup:
- if (tNode.GSDRI.Node1 == tNode)
- {
- tNode.GSDRI.Lanes = opt_Lanes;
- tNode.GSDRI.name = tNode.GSDRI.transform.name;
- }
- //Setup construction objects:
- tNode.GSDRI.Node1.iConstruction = new GSD.Roads.GSDIntersections.iConstructionMaker();
- tNode.GSDRI.Node2.iConstruction = new GSD.Roads.GSDIntersections.iConstructionMaker();
- }
-
- //Store materials and physical materials for road and or shoulder cuts on each node, if necessary:
- tNode.StoreCuts();
- }
- }
- name = transform.name;
-
-
-
- GSDSpline.RoadWidth = RoadWidth();
- // if(bProfiling){ UnityEngine.Profiling.Profiler.BeginSample("SplineSetup"); }
- GSDSpline.Setup();
- // if(bProfiling){ UnityEngine.Profiling.Profiler.EndSample(); }
- mCount = GSDSpline.GetNodeCount();
-
- if (GSDSpline == null || GSDSpline.mNodes == null)
- {
- MostRecentNodeCount = 0;
- }
- else
- {
- MostRecentNodeCount = GSDSpline.GetNodeCount();
- }
-
- if (opt_UseDefaultMaterials)
- {
- SetDefaultMats();
- }
-
- if (opt_UseDefaultMaterials)
- {
- if (DetectInvalidDefaultMatsForUndo())
- {
- SetAllCutsToCurrentMaterials();
- }
- }
-
- //Hiding in hierarchy:
- for (int i = 0; i < mCount; i++)
- {
- tNode = GSDSpline.mNodes[i];
- if (tNode != null)
- {
- if (tNode.bIsIntersection || tNode.bSpecialEndNode)
- {
- tNode.ToggleHideFlags(true);
- }
- else
- {
- tNode.ToggleHideFlags(false);
- }
- }
- }
-
- int cCount = transform.childCount;
- GameObject tMainMeshes = null;
- List tObjs = new List();
- for (int i = 0; i < cCount; i++)
- {
- if (transform.GetChild(i).transform.name.ToLower().Contains("mainmeshes"))
- {
- tMainMeshes = transform.GetChild(i).transform.gameObject;
- tObjs.Add(tMainMeshes);
- }
- }
- for (int i = (tObjs.Count - 1); i >= 0; i--)
- {
- tMainMeshes = tObjs[i];
- Object.DestroyImmediate(tMainMeshes);
- }
-
- if (mCount < 2)
- {
- //Delete old objs and return:
- if (MainMeshes != null) { Object.DestroyImmediate(MainMeshes); }
- if (MeshRoad != null) { Object.DestroyImmediate(MeshRoad); }
- if (MeshShoR != null) { Object.DestroyImmediate(MeshShoR); }
- if (MeshShoL != null) { Object.DestroyImmediate(MeshShoL); }
- if (MeshiLanes != null) { Object.DestroyImmediate(MeshiLanes); }
- if (MeshiLanes0 != null) { Object.DestroyImmediate(MeshiLanes0); }
- if (MeshiLanes1 != null) { Object.DestroyImmediate(MeshiLanes1); }
- if (MeshiLanes2 != null) { Object.DestroyImmediate(MeshiLanes2); }
- if (MeshiLanes3 != null) { Object.DestroyImmediate(MeshiLanes3); }
- if (MeshiMainPlates != null) { Object.DestroyImmediate(MeshiMainPlates); }
- if (MeshiMarkerPlates != null) { Object.DestroyImmediate(MeshiMarkerPlates); }
- if (bProfiling) { UnityEngine.Profiling.Profiler.EndSample(); }
- return;
- }
-
- GSDSpline.HeightHistory = new List>();
- if (GSDRS == null) { GSDRS = transform.parent.GetComponent(); } //Compatibility update.
-
- if (GSDRS.opt_bMultithreading)
- {
- Editor_bIsConstructing = true;
- }
- else
- {
- Editor_bIsConstructing = false;
- }
- Editor_bConstructionID = 0;
-
-
-
- //Check if road takes place on only 1 terrain:
- Terrain tTerrain = GSD.Roads.GSDRoadUtil.GetTerrain(GSDSpline.mNodes[0].pos);
- bool bSameTerrain = true;
- for (int i = 1; i < mCount; i++)
- {
- if (tTerrain != GSD.Roads.GSDRoadUtil.GetTerrain(GSDSpline.mNodes[0].pos))
- {
- bSameTerrain = false;
- break;
- }
- }
-
- RCS = new RoadConstructorBufferMaker(this, tUpdateType);
-
- if (bSameTerrain)
- {
- RCS.tTerrain = tTerrain;
- }
- else
- {
- RCS.tTerrain = null;
- }
- tTerrain = null;
-
- if (bProfiling) { UnityEngine.Profiling.Profiler.EndSample(); }
-
- if (GSDRS.opt_bMultithreading)
- {
- if (RCS.bTerrainOn || TerrainHistory == null)
- {
- GSDTerraforming.ProcessRoad_Terrain_Hook1(GSDSpline, this);
- }
- else
- {
- ConstructRoad2();
- }
- }
- else
- {
- UpdateRoad_NoMultiThreading();
- }
- }
-
- #region "Terrain history"
- public void ConstructRoad_StoreTerrainHistory(bool bDiskOnly = false)
- {
- if (!bDiskOnly)
- {
- GSDRoad tRoad = this;
- GSDRoadUtil.ConstructRoad_StoreTerrainHistory(ref tRoad);
- }
-
- if (opt_SaveTerrainHistoryOnDisk && TerrainHistory != null && TerrainHistory.Count > 0)
- {
- if (bProfiling) { UnityEngine.Profiling.Profiler.BeginSample("TerrainHistory_Save"); }
- GSDGeneralEditor.TerrainHistory_Save(TerrainHistory, this);
- if (bProfiling) { UnityEngine.Profiling.Profiler.EndSample(); }
- TerrainHistory.Clear();
- TerrainHistory = null;
- }
- else
- {
- if (TerrainHistory != null && TerrainHistory.Count > 0)
- {
- int tSize = 0;
- for (int i = 0; i < TerrainHistory.Count; i++)
- {
- tSize += TerrainHistory[i].GetSize();
- }
- TerrainHistoryByteSize = (tSize * 0.001f).ToString("n0") + " kb";
- }
- else
- {
- TerrainHistoryByteSize = "0 bytes";
- }
- }
- }
- public void ConstructRoad_ResetTerrainHistory()
- {
- GSDRoad tRoad = this;
- if (opt_SaveTerrainHistoryOnDisk && TerrainHistory != null)
- {
- GSDGeneralEditor.TerrainHistory_Delete(this);
- }
- else
- {
- GSDRoadUtil.ConstructRoad_ResetTerrainHistory(ref tRoad);
- }
- }
- public void ConstructRoad_LoadTerrainHistory(bool bForce = false)
- {
- if (opt_SaveTerrainHistoryOnDisk || bForce)
- {
- if (TerrainHistory != null)
- {
- TerrainHistory.Clear();
- TerrainHistory = null;
- }
- TerrainHistory = GSDGeneralEditor.TerrainHistory_Load(this);
- }
- if (bForce)
- {
- GSDGeneralEditor.TerrainHistory_Delete(this);
- }
- }
- #endregion
-
- #region "Construction process"
- #region "No multithread"
- private void UpdateRoad_NoMultiThreading()
- {
- if (opt_HeightModEnabled || opt_DetailModEnabled || opt_TreeModEnabled)
- {
- if (bProfiling) { UnityEngine.Profiling.Profiler.BeginSample("RoadCon_Terrain"); }
- if (RCS.bTerrainOn || TerrainHistory == null)
- {
- GSDTerraforming.ProcessRoad_Terrain_Hook1(GSDSpline, this, false);
- GSDTerraforming.ProcessRoad_Terrain_Hook2(GSDSpline, ref EditorTTDList);
- ConstructRoad_StoreTerrainHistory();//Store history.
- int EditorTTDListCount = EditorTTDList.Count;
- for (int i = 0; i < EditorTTDListCount; i++)
- {
- EditorTTDList[i] = null;
- }
- EditorTTDList = null;
- System.GC.Collect();
- }
- if (bProfiling)
- {
- UnityEngine.Profiling.Profiler.EndSample();
- }
- }
-
- EditorProgress = 50;
- GSDRoad tRoad = this;
- if (bProfiling)
- {
- UnityEngine.Profiling.Profiler.BeginSample("RoadCon_RoadPrelim");
- }
-
- EditorProgress = 80;
- GSD.Threaded.GSDRoadCreationT.RoadJob_Prelim(ref tRoad);
- if (bProfiling)
- {
- UnityEngine.Profiling.Profiler.EndSample();
- UnityEngine.Profiling.Profiler.BeginSample("RoadCon_Road1");
- }
- EditorProgress = 90;
- GSD.Threaded.RoadCalcs1_static.RunMe(ref RCS);
- if (bProfiling) { UnityEngine.Profiling.Profiler.EndSample(); }
- if (bProfiling) { UnityEngine.Profiling.Profiler.BeginSample("MeshSetup1"); }
- EditorProgress = 92;
- RCS.MeshSetup1();
- if (bProfiling)
- {
- UnityEngine.Profiling.Profiler.EndSample();
- UnityEngine.Profiling.Profiler.BeginSample("RoadCon_Road2");
- }
- EditorProgress = 94;
- GSD.Threaded.RoadCalcs2_static.RunMe(ref RCS);
- if (bProfiling) { UnityEngine.Profiling.Profiler.EndSample(); }
- if (bProfiling) { UnityEngine.Profiling.Profiler.BeginSample("MeshSetup2"); }
- EditorProgress = 96;
- RCS.MeshSetup2();
- if (bProfiling) { UnityEngine.Profiling.Profiler.EndSample(); }
- Construction_Cleanup();
- }
- #endregion
-
- private void ConstructRoad2()
- {
- EditorProgress = 40;
- if (RCS.bTerrainOn)
- {
- //Store history:
- GSDTerraforming.ProcessRoad_Terrain_Hook2(GSDSpline, ref EditorTTDList);
- ConstructRoad_StoreTerrainHistory();
- int EditorTTDListCount = EditorTTDList.Count;
- for (int i = 0; i < EditorTTDListCount; i++)
- {
- EditorTTDList[i] = null;
- }
- EditorTTDList = null;
- System.GC.Collect();
- }
- EditorProgress = 60;
-
- if (TerrainCalcsJob != null) { TerrainCalcsJob.Abort(); TerrainCalcsJob = null; }
- GSDRoad tRoad = this;
- EditorProgress = 72;
- RoadCalcsJob1 = new GSD.Threaded.RoadCalcs1();
- RoadCalcsJob1.Setup(ref RCS, ref tRoad);
- RoadCalcsJob1.Start();
- }
-
- private void ConstructRoad3()
- {
- EditorProgress = 84;
- RCS.MeshSetup1();
- EditorProgress = 96;
- if (RoadCalcsJob1 != null) { RoadCalcsJob1.Abort(); RoadCalcsJob1 = null; }
- RoadCalcsJob2 = new GSD.Threaded.RoadCalcs2();
- RoadCalcsJob2.Setup(ref RCS);
- RoadCalcsJob2.Start();
- EditorProgress = 98;
- }
-
- private void ConstructRoad4()
- {
- RCS.MeshSetup2();
- Construction_Cleanup();
- }
- #endregion
-
- private void Construction_Cleanup()
- {
- FixZ();
-
- if (TerrainCalcsJob != null) { TerrainCalcsJob.Abort(); TerrainCalcsJob = null; }
- if (RoadCalcsJob1 != null) { RoadCalcsJob1.Abort(); RoadCalcsJob1 = null; }
- if (RoadCalcsJob2 != null) { RoadCalcsJob2.Abort(); RoadCalcsJob2 = null; }
- Editor_bIsConstructing = false;
- int mCount = GSDSpline.GetNodeCount();
- GSDSplineN tNode;
- for (int i = 0; i < mCount; i++)
- {
- tNode = GSDSpline.mNodes[i];
- if (tNode.bIsIntersection)
- {
- if (tNode.iConstruction != null)
- {
- tNode.iConstruction.Nullify();
- tNode.iConstruction = null;
- }
- }
- tNode.SetupSplinationLimits();
- tNode.SetupEdgeObjects(false);
- tNode.SetupSplinatedMeshes(false);
- }
- if (GSDSpline.HeightHistory != null) { GSDSpline.HeightHistory.Clear(); GSDSpline.HeightHistory = null; }
- if (RCS != null)
- {
- RCS.Nullify();
- RCS = null;
- }
-
- if (GSDRS.opt_bSaveMeshes)
- {
- UnityEditor.AssetDatabase.SaveAssets();
- }
- bEditorProgressBar = false;
- EditorUtility.ClearProgressBar();
- //Make sure terrain history out of memory if necessary (redudant but keep):
- if (opt_SaveTerrainHistoryOnDisk && TerrainHistory != null)
- {
- TerrainHistory.Clear();
- TerrainHistory = null;
- }
-
- //Collect:
- bTriggerGC = true;
-
- if (tRoadMaterialDropdownOLD != opt_tRoadMaterialDropdown)
- {
- tRoadMaterialDropdownOLD = opt_tRoadMaterialDropdown;
- SetAllCutsToCurrentMaterials();
- }
-
- if (PiggyBacks != null && PiggyBacks.Length > 0)
- {
- for (int i = 0; i < PiggyBacks.Length; i++)
- {
- if (PiggyBacks[i] == null)
- {
- PiggyBacks = null;
- break;
- }
- }
-
- if (PiggyBacks != null)
- {
- GSDSplineC tPiggy = PiggyBacks[0];
- GSDSplineC[] NewPiggys = null;
-
- PiggyBacks[0] = null;
- if (PiggyBacks.Length > 1)
- {
- NewPiggys = new GSDSplineC[PiggyBacks.Length - 1];
- for (int i = 1; i < PiggyBacks.Length; i++)
- {
- NewPiggys[i - 1] = PiggyBacks[i];
- }
- }
-
- if (NewPiggys != null)
- {
- tPiggy.tRoad.PiggyBacks = NewPiggys;
- }
- NewPiggys = null;
- tPiggy.Setup_Trigger();
- }
- }
- }
-
- public List EditorTTDList;
- public void EditorTerrainCalcs(ref List tList)
- {
- EditorTTDList = tList;
- }
- #endregion
-
- #region "Gizmos"
- public bool Editor_bIsConstructing = false;
- public int Editor_bConstructionID = 0;
- public bool Editor_bSelected = false;
- public bool Editor_MouseTerrainHit = false;
- public Vector3 Editor_MousePos = new Vector3(0f, 0f, 0f);
- public readonly Color Color_NodeDefaultColor = new Color(0f, 1f, 1f, 0.75f);
- public readonly Color Color_NodeConnColor = new Color(0f, 1f, 0f, 0.75f);
- public readonly Color Color_NodeInter = new Color(0f, 1f, 0f, 0.75f);
-
- void OnDrawGizmosSelected()
- {
- if (Editor_MouseTerrainHit)
- {
- Gizmos.color = Color.red;
- Gizmos.DrawCube(Editor_MousePos, new Vector3(10f, 4f, 10f));
- }
- }
- #endregion
-#endif
- public float RoadWidth()
- {
- return (opt_LaneWidth * (float)opt_Lanes);
- }
-#if UNITY_EDITOR
- public float EditorCameraTimer = 0f;
- float EditorTestTimer = 0f;
- bool bEditorTestTimer = true;
- void Update()
- {
- if (Application.isEditor && bEditorCameraMoving)
- {
- EditorCameraTimer += Time.deltaTime;
- if (EditorCameraTimer > EditorCameraTimeUpdateInterval)
- {
- EditorCameraTimer = 0f;
- DoEditorCameraLoop();
- }
- }
-
- if (bEditorTestTimer)
- {
- if (transform.name == "Road1")
- {
- EditorTestTimer += Time.deltaTime;
- if (EditorTestTimer > 2f)
- {
- // UpdateRoad(RoadUpdateTypeEnum.Full);
- // akjsdfkajlgffdghfsdghsdf();
- bEditorTestTimer = false;
- }
- }
- else
- {
- bEditorTestTimer = false;
- }
- }
- }
-
-
-
-
- static void akjsdfkajlgffdghfsdghsdf()
- {
- int LoopMax = 1000;
- DoShort(LoopMax);
- DoInt(LoopMax);
- DoLong(LoopMax);
- }
-
-
- static void DoShort(int LoopMax)
- {
- ushort[] tSubject = new ushort[25000];
- // int tInt = 0;
- for (int i = 0; i < LoopMax; i++)
- {
- for (int j = 0; j < 25000; j++)
- {
- tSubject[j] = (ushort)(j + 1);
- // int xTemp = (int)tSubject[j];
- }
- }
- }
-
- static void DoInt(int LoopMax)
- {
- int[] tSubject = new int[25000];
- // int tInt = 0;
- for (int i = 0; i < LoopMax; i++)
- {
- for (int j = 0; j < 25000; j++)
- {
- tSubject[j] = j + 1;
- // int xTemp = tSubject[j];
- }
- }
- }
-
- static void DoLong(int LoopMax)
- {
- long[] tSubject = new long[25000];
- // int tInt = 0;
- for (int i = 0; i < LoopMax; i++)
- {
- for (int j = 0; j < 25000; j++)
- {
- tSubject[j] = (long)(j + 1);
- // int xTemp = (int)tSubject[j];
- }
- }
- }
-
- #region "Default materials retrieval"
- public bool DetectInvalidDefaultMatsForUndo()
- {
- string tNameLower = "";
- int tCounter = 0;
- if (!MeshRoad) { return false; }
-
- MeshRenderer[] MRs = MeshRoad.GetComponentsInChildren();
- Material tMat2 = GSD.Roads.GSDRoadUtilityEditor.GiveMaterial(GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Materials/Markers/GSDWhiteYellowDouble.mat");
- Material tMat4 = GSD.Roads.GSDRoadUtilityEditor.GiveMaterial(GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Materials/Markers/GSDWhiteYellowDouble-4L.mat");
- Material tMat6 = GSD.Roads.GSDRoadUtilityEditor.GiveMaterial(GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Materials/Markers/GSDWhiteYellowDouble-6L.mat");
- foreach (MeshRenderer MR in MRs)
- {
- tNameLower = MR.transform.name.ToLower();
- if (tNameLower.Contains("marker"))
- {
- if (opt_Lanes == 2)
- {
- if (MR.sharedMaterials[0] == tMat4)
- {
- tCounter += 1;
- }
- else if (MR.sharedMaterials[0] == tMat6)
- {
- tCounter += 1;
- }
- }
- else if (opt_Lanes == 4)
- {
- if (MR.sharedMaterials[0] == tMat2)
- {
- tCounter += 1;
- }
- else if (MR.sharedMaterials[0] == tMat6)
- {
- tCounter += 1;
- }
- }
- else if (opt_Lanes == 6)
- {
- if (MR.sharedMaterials[0] == tMat2)
- {
- tCounter += 1;
- }
- else if (MR.sharedMaterials[0] == tMat4)
- {
- tCounter += 1;
- }
- }
- }
- if (tCounter > 1)
- {
- return true;
- }
- }
- return false;
- }
-
- public void SetAllCutsToCurrentMaterials()
- {
- string tNameLower = "";
- if (!MeshRoad) { return; }
-
- MeshRenderer[] MRs = MeshRoad.GetComponentsInChildren();
- Material[] tMats_World = GetMaterials_RoadWorld();
- Material[] tMats_Marker = GetMaterials_RoadMarker();
- foreach (MeshRenderer MR in MRs)
- {
- tNameLower = MR.transform.name.ToLower();
- if (tNameLower.Contains("marker"))
- {
- if (tMats_Marker != null)
- {
- MR.sharedMaterials = tMats_Marker;
- }
- }
- else if (tNameLower.Contains("cut"))
- {
- if (tMats_World != null)
- {
- MR.sharedMaterials = tMats_World;
- }
- }
- }
-
- if (opt_bShouldersEnabled && MeshShoL != null)
- {
- MRs = MeshShoL.GetComponentsInChildren();
- tMats_World = GetMaterials_ShoulderWorld();
- tMats_Marker = GetMaterials_ShoulderMarker();
- foreach (MeshRenderer MR in MRs)
- {
- tNameLower = MR.transform.name.ToLower();
- if (tNameLower.Contains("marker"))
- {
- if (tMats_Marker != null)
- {
- MR.sharedMaterials = tMats_Marker;
- }
- }
- else if (tNameLower.Contains("cut"))
- {
- if (tMats_World != null)
- {
- MR.sharedMaterials = tMats_World;
- }
- }
- }
- }
-
- if (opt_bShouldersEnabled && MeshShoR != null)
- {
- MRs = MeshShoR.GetComponentsInChildren();
- foreach (MeshRenderer MR in MRs)
- {
- tNameLower = MR.transform.name.ToLower();
- if (tNameLower.Contains("marker"))
- {
- if (tMats_Marker != null)
- {
- MR.sharedMaterials = tMats_Marker;
- }
- }
- else if (tNameLower.Contains("cut"))
- {
- if (tMats_World != null)
- {
- MR.sharedMaterials = tMats_World;
- }
- }
- }
- }
- }
-
- public Material[] GetMaterials_RoadWorld()
- {
- int mCounter = 0;
- if (RoadMaterial1 != null)
- {
- mCounter += 1;
- if (RoadMaterial2 != null)
- {
- mCounter += 1;
- if (RoadMaterial3 != null)
- {
- mCounter += 1;
- if (RoadMaterial4 != null)
- {
- mCounter += 1;
- }
- }
- }
- }
- if (mCounter > 0)
- {
- Material[] tMats = new Material[mCounter];
- if (RoadMaterial1 != null)
- {
- tMats[0] = RoadMaterial1;
- if (RoadMaterial2 != null)
- {
- tMats[1] = RoadMaterial2;
- if (RoadMaterial3 != null)
- {
- tMats[2] = RoadMaterial3;
- if (RoadMaterial4 != null)
- {
- tMats[3] = RoadMaterial4;
- }
- }
- }
- }
- return tMats;
- }
- else
- {
- return null;
- }
- }
-
- public Material[] GetMaterials_RoadMarker()
- {
- int mCounter = 0;
- if (RoadMaterialMarker1 != null)
- {
- mCounter += 1;
- if (RoadMaterialMarker2 != null)
- {
- mCounter += 1;
- if (RoadMaterialMarker3 != null)
- {
- mCounter += 1;
- if (RoadMaterialMarker4 != null)
- {
- mCounter += 1;
- }
- }
- }
- }
- if (mCounter > 0)
- {
- Material[] tMats = new Material[mCounter];
- if (RoadMaterialMarker1 != null)
- {
- tMats[0] = RoadMaterialMarker1;
- if (RoadMaterialMarker2 != null)
- {
- tMats[1] = RoadMaterialMarker2;
- if (RoadMaterialMarker3 != null)
- {
- tMats[2] = RoadMaterialMarker3;
- if (RoadMaterialMarker4 != null)
- {
- tMats[3] = RoadMaterialMarker4;
- }
- }
- }
- }
- return tMats;
- }
- else
- {
- return null;
- }
- }
-
- public Material[] GetMaterials_ShoulderWorld()
- {
- if (!opt_bShouldersEnabled)
- {
- return null;
- }
-
- int mCounter = 0;
- if (ShoulderMaterial1 != null)
- {
- mCounter += 1;
- if (ShoulderMaterial2 != null)
- {
- mCounter += 1;
- if (ShoulderMaterial3 != null)
- {
- mCounter += 1;
- if (ShoulderMaterial4 != null)
- {
- mCounter += 1;
- }
- }
- }
- }
- if (mCounter > 0)
- {
- Material[] tMats = new Material[mCounter];
- if (ShoulderMaterial1 != null)
- {
- tMats[0] = ShoulderMaterial1;
- if (ShoulderMaterial2 != null)
- {
- tMats[1] = ShoulderMaterial2;
- if (ShoulderMaterial3 != null)
- {
- tMats[2] = ShoulderMaterial3;
- if (ShoulderMaterial4 != null)
- {
- tMats[3] = ShoulderMaterial4;
- }
- }
- }
- }
- return tMats;
- }
- else
- {
- return null;
- }
- }
-
- public Material[] GetMaterials_ShoulderMarker()
- {
- if (!opt_bShouldersEnabled)
- {
- return null;
- }
-
- int mCounter = 0;
- if (ShoulderMaterialMarker1 != null)
- {
- mCounter += 1;
- if (ShoulderMaterialMarker2 != null)
- {
- mCounter += 1;
- if (ShoulderMaterialMarker3 != null)
- {
- mCounter += 1;
- if (ShoulderMaterialMarker4 != null)
- {
- mCounter += 1;
- }
- }
- }
- }
- if (mCounter > 0)
- {
- Material[] tMats = new Material[mCounter];
- if (ShoulderMaterialMarker1 != null)
- {
- tMats[0] = ShoulderMaterialMarker1;
- if (ShoulderMaterialMarker2 != null)
- {
- tMats[1] = ShoulderMaterialMarker2;
- if (ShoulderMaterialMarker3 != null)
- {
- tMats[2] = ShoulderMaterialMarker3;
- if (ShoulderMaterialMarker4 != null)
- {
- tMats[3] = ShoulderMaterialMarker4;
- }
- }
- }
- }
- return tMats;
- }
- else
- {
- return null;
- }
- }
- #endregion
-
- #region "Materials"
- void CheckMats()
- {
- if (!opt_UseDefaultMaterials)
- {
- return;
- }
-
- if (!RoadMaterial1)
- {
- RoadMaterial1 = GSD.Roads.GSDRoadUtilityEditor.GiveMaterial(GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Materials/GSDRoad1.mat");
- RoadMaterial2 = GSD.Roads.GSDRoadUtilityEditor.GiveMaterial(GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Materials/Markers/GSDRoadDetailOverlay1.mat");
- }
- if (!RoadMaterialMarker1)
- {
- if (opt_Lanes == 2)
- {
- RoadMaterialMarker1 = GSD.Roads.GSDRoadUtilityEditor.GiveMaterial(GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Materials/Markers/GSDWhiteYellowDouble.mat");
- }
- else if (opt_Lanes == 4)
- {
- RoadMaterialMarker1 = GSD.Roads.GSDRoadUtilityEditor.GiveMaterial(GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Materials/Markers/GSDWhiteYellowDouble-4L.mat");
- }
- else if (opt_Lanes == 6)
- {
- RoadMaterialMarker1 = GSD.Roads.GSDRoadUtilityEditor.GiveMaterial(GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Materials/Markers/GSDWhiteYellowDouble-6L.mat");
- }
- else
- {
- RoadMaterialMarker1 = GSD.Roads.GSDRoadUtilityEditor.GiveMaterial(GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Materials/Markers/GSDWhiteYellowDouble.mat");
- }
-
- if (opt_Lanes == 2)
- {
- RoadMaterialMarker2 = GSD.Roads.GSDRoadUtilityEditor.GiveMaterial(GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Materials/Markers/GSDTireMarks.mat");
- }
- else if (opt_Lanes == 4)
- {
- RoadMaterialMarker2 = GSD.Roads.GSDRoadUtilityEditor.GiveMaterial(GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Materials/Markers/GSDTireMarks-4L.mat");
- }
- else if (opt_Lanes == 6)
- {
- RoadMaterialMarker2 = GSD.Roads.GSDRoadUtilityEditor.GiveMaterial(GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Materials/Markers/GSDTireMarks-6L.mat");
- }
- else
- {
- RoadMaterialMarker2 = GSD.Roads.GSDRoadUtilityEditor.GiveMaterial(GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Materials/Markers/GSDTireMarks.mat");
- }
- }
- if (opt_bShouldersEnabled && !ShoulderMaterial1)
- {
- ShoulderMaterial1 = GSD.Roads.GSDRoadUtilityEditor.GiveMaterial(GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Materials/GSDShoulder1.mat");
- ShoulderMaterial2 = GSD.Roads.GSDRoadUtilityEditor.GiveMaterial(GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Materials/Markers/GSDRoadDetailOverlay1.mat");
- }
-
- if (opt_bShouldersEnabled && !RoadPhysicMaterial)
- {
- RoadPhysicMaterial = GSD.Roads.GSDRoadUtilityEditor.GivePhysicsMaterial(GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Physics/GSDPavement.physicMaterial");
- }
- if (opt_bShouldersEnabled && !ShoulderPhysicMaterial)
- {
- ShoulderPhysicMaterial = GSD.Roads.GSDRoadUtilityEditor.GivePhysicsMaterial(GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Physics/GSDDirt.physicMaterial");
- }
- }
-
- public void SetDefaultMats()
- {
- if (opt_tRoadMaterialDropdown == RoadMaterialDropdownEnum.Asphalt)
- {
- RoadMaterial1 = GSD.Roads.GSDRoadUtilityEditor.GiveMaterial(GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Materials/GSDRoad1.mat");
- RoadMaterial2 = GSD.Roads.GSDRoadUtilityEditor.GiveMaterial(GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Materials/Markers/GSDRoadDetailOverlay1.mat");
-
- if (opt_Lanes == 2)
- {
- RoadMaterialMarker1 = GSD.Roads.GSDRoadUtilityEditor.GiveMaterial(GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Materials/Markers/GSDWhiteYellowDouble.mat");
- }
- else if (opt_Lanes == 4)
- {
- RoadMaterialMarker1 = GSD.Roads.GSDRoadUtilityEditor.GiveMaterial(GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Materials/Markers/GSDWhiteYellowDouble-4L.mat");
- }
- else if (opt_Lanes == 6)
- {
- RoadMaterialMarker1 = GSD.Roads.GSDRoadUtilityEditor.GiveMaterial(GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Materials/Markers/GSDWhiteYellowDouble-6L.mat");
- }
- else
- {
- RoadMaterialMarker1 = GSD.Roads.GSDRoadUtilityEditor.GiveMaterial(GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Materials/Markers/GSDWhiteYellowDouble.mat");
- }
-
- if (opt_Lanes == 2)
- {
- RoadMaterialMarker2 = GSD.Roads.GSDRoadUtilityEditor.GiveMaterial(GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Materials/Markers/GSDTireMarks.mat");
- }
- else if (opt_Lanes == 4)
- {
- RoadMaterialMarker2 = GSD.Roads.GSDRoadUtilityEditor.GiveMaterial(GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Materials/Markers/GSDTireMarks-4L.mat");
- }
- else if (opt_Lanes == 6)
- {
- RoadMaterialMarker2 = GSD.Roads.GSDRoadUtilityEditor.GiveMaterial(GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Materials/Markers/GSDTireMarks-6L.mat");
- }
- else
- {
- RoadMaterialMarker2 = GSD.Roads.GSDRoadUtilityEditor.GiveMaterial(GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Materials/Markers/GSDTireMarks.mat");
- }
-
- ShoulderMaterial1 = GSD.Roads.GSDRoadUtilityEditor.GiveMaterial(GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Materials/GSDShoulder1.mat");
- ShoulderMaterial2 = GSD.Roads.GSDRoadUtilityEditor.GiveMaterial(GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Materials/Markers/GSDRoadDetailOverlay1.mat");
-
- RoadPhysicMaterial = GSD.Roads.GSDRoadUtilityEditor.GivePhysicsMaterial(GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Physics/GSDPavement.physicMaterial");
- ShoulderPhysicMaterial = GSD.Roads.GSDRoadUtilityEditor.GivePhysicsMaterial(GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Physics/GSDDirt.physicMaterial");
- }
- else if (opt_tRoadMaterialDropdown == RoadMaterialDropdownEnum.Dirt)
- {
- RoadMaterial1 = null;
- RoadMaterial2 = null;
- RoadMaterial3 = null;
- RoadMaterial4 = null;
- RoadMaterialMarker1 = GSD.Roads.GSDRoadUtilityEditor.GiveMaterial(GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Materials/GSDDirtRoad.mat");
- RoadMaterialMarker2 = null;
- RoadMaterialMarker3 = null;
- RoadMaterialMarker4 = null;
- }
- else if (opt_tRoadMaterialDropdown == RoadMaterialDropdownEnum.Brick)
- {
- RoadMaterial1 = null;
- RoadMaterial2 = null;
- RoadMaterial3 = null;
- RoadMaterial4 = null;
- RoadMaterialMarker1 = GSD.Roads.GSDRoadUtilityEditor.GiveMaterial(GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Materials/GSDBrickRoad.mat");
- RoadMaterialMarker2 = null;
- RoadMaterialMarker3 = null;
- RoadMaterialMarker4 = null;
- }
- else if (opt_tRoadMaterialDropdown == RoadMaterialDropdownEnum.Cobblestone)
- {
- RoadMaterial1 = null;
- RoadMaterial2 = null;
- RoadMaterial3 = null;
- RoadMaterial4 = null;
- RoadMaterialMarker1 = GSD.Roads.GSDRoadUtilityEditor.GiveMaterial(GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Materials/GSDCobblestoneRoad.mat");
- RoadMaterialMarker2 = null;
- RoadMaterialMarker3 = null;
- RoadMaterialMarker4 = null;
- }
- if (opt_tRoadMaterialDropdown == RoadMaterialDropdownEnum.Brick
- || opt_tRoadMaterialDropdown == RoadMaterialDropdownEnum.Cobblestone
- || opt_tRoadMaterialDropdown == RoadMaterialDropdownEnum.Dirt)
- {
- if (opt_Lanes > 2)
- {
- RoadMaterialMarker1 = new Material(RoadMaterialMarker1);
- RoadMaterialMarker1.mainTextureScale *= new Vector2(opt_Lanes / 2, 1f);
- }
- }
-
- int mCount = GSDSpline.GetNodeCount();
- for (int i = 0; i < mCount; i++)
- {
- if (GSDSpline.mNodes[i] && GSDSpline.mNodes[i].bIsIntersection && GSDSpline.mNodes[i].GSDRI != null && GSDSpline.mNodes[i].GSDRI.bUseDefaultMaterials)
- {
- GSDSpline.mNodes[i].GSDRI.ResetMaterials_All();
- }
- }
- }
- #endregion
-
- public void Wireframes_Toggle()
- {
- MeshRenderer[] tMRs = transform.GetComponentsInChildren();
- Wireframes_Toggle_Help(ref tMRs);
-
- if (GSDSpline != null)
- {
- tMRs = GSDSpline.transform.GetComponentsInChildren();
- Wireframes_Toggle_Help(ref tMRs);
- }
- }
- void Wireframes_Toggle_Help(ref MeshRenderer[] tMRs)
- {
- int tCount = tMRs.Length;
- for (int i = 0; i < tCount; i++)
- {
- //EditorUtility.SetSelectedWireframeHidden(tMRs[i], !opt_GizmosEnabled);
- EditorUtility.SetSelectedRenderState(tMRs[i], opt_GizmosEnabled ? EditorSelectedRenderState.Wireframe : EditorSelectedRenderState.Hidden);
- }
- }
-
-#endif
-
- void Start()
- {
-#if UNITY_EDITOR
- if (Application.isPlaying)
- {
- CleanRunTime();
- }
-#else
- this.enabled = false;
-#endif
- }
-
-#if UNITY_EDITOR
- //For compliance on submission rules:
- public void UpdateGizmoOptions()
- {
- if (GSDSpline == null) { return; }
- GSDSplineN tNode = null;
-
- int mCount = GSDSpline.GetNodeCount();
- for (int i = 0; i < mCount; i++)
- {
- tNode = GSDSpline.mNodes[i];
- if (tNode != null)
- {
- tNode.opt_GizmosEnabled = opt_GizmosEnabled;
- }
- }
- }
-
- public void SetupUniqueIdentifier()
- {
- if (UID == null || UID.Length < 4)
- {
- UID = System.Guid.NewGuid().ToString();
- }
- }
-
- public void DuplicateRoad()
- {
- GameObject tRoadObj = GSDRS.AddRoad();
- UnityEditor.Undo.RegisterCreatedObjectUndo(tRoadObj, "Duplicate");
-
- GSDRoad xRoad = tRoadObj.GetComponent();
- if (xRoad == null) { return; }
-
- //Road editor options:
- xRoad.opt_LaneWidth = opt_LaneWidth; //Done.
- xRoad.opt_bShouldersEnabled = opt_bShouldersEnabled; //Disabled for now. Comprimises integrity of roads.
- xRoad.opt_ShoulderWidth = opt_ShoulderWidth; //Done.
- xRoad.opt_Lanes = opt_Lanes; //Done.
- xRoad.opt_RoadDefinition = opt_RoadDefinition; //Done.
- xRoad.opt_RoadCornerDefinition = opt_RoadCornerDefinition; //Disable for now. No point.
- xRoad.opt_bRoadCuts = opt_bRoadCuts;
- xRoad.opt_bShoulderCuts = opt_bShoulderCuts;
- xRoad.opt_bDynamicCuts = opt_bDynamicCuts;
- xRoad.opt_bMaxGradeEnabled = opt_bMaxGradeEnabled;
- xRoad.opt_MaxGrade = opt_MaxGrade;
- xRoad.opt_UseDefaultMaterials = opt_UseDefaultMaterials;
- xRoad.opt_AutoUpdateInEditor = opt_AutoUpdateInEditor;
-
- xRoad.opt_TerrainSubtract_Match = opt_TerrainSubtract_Match;
- xRoad.opt_bGSDRoadRaise = opt_bGSDRoadRaise;
-
- xRoad.opt_MatchHeightsDistance = opt_MatchHeightsDistance;
- xRoad.opt_ClearDetailsDistance = opt_ClearDetailsDistance;
- xRoad.opt_ClearDetailsDistanceHeight = opt_ClearDetailsDistanceHeight;
- xRoad.opt_ClearTreesDistance = opt_ClearTreesDistance;
- xRoad.opt_ClearTreesDistanceHeight = opt_ClearTreesDistanceHeight;
-
- xRoad.opt_HeightModEnabled = opt_HeightModEnabled;
- xRoad.opt_DetailModEnabled = opt_DetailModEnabled;
- xRoad.opt_TreeModEnabled = opt_TreeModEnabled;
-
- xRoad.opt_SaveTerrainHistoryOnDisk = opt_SaveTerrainHistoryOnDisk;
- xRoad.opt_MagnitudeThreshold = opt_MagnitudeThreshold;
- xRoad.opt_GizmosEnabled = opt_GizmosEnabled;
- xRoad.opt_bMultithreading = opt_bMultithreading;
- xRoad.opt_bSaveMeshes = opt_bSaveMeshes;
- xRoad.opt_bUseMeshColliders = opt_bUseMeshColliders;
-
- xRoad.opt_tRoadMaterialDropdown = opt_tRoadMaterialDropdown;
- xRoad.tRoadMaterialDropdownOLD = tRoadMaterialDropdownOLD;
-
- xRoad.RoadMaterial1 = RoadMaterial1;
- xRoad.RoadMaterial2 = RoadMaterial2;
- xRoad.RoadMaterial3 = RoadMaterial3;
- xRoad.RoadMaterial4 = RoadMaterial4;
- xRoad.RoadMaterialMarker1 = RoadMaterialMarker1;
- xRoad.RoadMaterialMarker2 = RoadMaterialMarker2;
- xRoad.RoadMaterialMarker3 = RoadMaterialMarker3;
- xRoad.RoadMaterialMarker4 = RoadMaterialMarker4;
- xRoad.ShoulderMaterial1 = ShoulderMaterial1;
- xRoad.ShoulderMaterial2 = ShoulderMaterial2;
- xRoad.ShoulderMaterial3 = ShoulderMaterial3;
- xRoad.ShoulderMaterial4 = ShoulderMaterial4;
- xRoad.ShoulderMaterialMarker1 = ShoulderMaterialMarker1;
- xRoad.ShoulderMaterialMarker2 = ShoulderMaterialMarker2;
- xRoad.ShoulderMaterialMarker3 = ShoulderMaterialMarker3;
- xRoad.ShoulderMaterialMarker4 = ShoulderMaterialMarker4;
-
- xRoad.RoadPhysicMaterial = RoadPhysicMaterial;
- xRoad.ShoulderPhysicMaterial = ShoulderPhysicMaterial;
-
- xRoad.GSDSpline.Setup_Trigger();
-
- Selection.activeGameObject = xRoad.transform.gameObject;
- }
-
- private void FixZ()
- {
- FixZ_Mobile();
- }
-
- private void FixZ_Mobile()
- {
- //This road:
- Object[] tMarkerObjs = transform.GetComponentsInChildren();
- Vector3 tVect = default(Vector3);
- foreach (MeshRenderer MR in tMarkerObjs)
- {
- if (MR.transform.name.Contains("Marker"))
- {
- tVect = new Vector3(0f, 0.02f, 0f);
- MR.transform.localPosition = tVect;
- }
- else if (MR.transform.name.Contains("SCut") || MR.transform.name.Contains("RoadCut")
- || MR.transform.name.Contains("ShoulderR")
- || MR.transform.name.Contains("ShoulderL"))
- {
- tVect = MR.transform.position;
- tVect.y += 0.01f;
- MR.transform.position = tVect;
- }
- else if (MR.transform.name.Contains("RoadMesh"))
- {
- tVect = MR.transform.position;
- tVect.y += 0.02f;
- MR.transform.position = tVect;
- }
- else if (MR.transform.name.Contains("Pavement"))
- {
- tVect = MR.transform.position;
- tVect.y -= 0.01f;
- MR.transform.position = tVect;
- }
- }
-
- //Intersections (all):
- tMarkerObjs = GSDRS.GetComponentsInChildren();
- foreach (MeshRenderer MR in tMarkerObjs)
- {
- if (MR.transform.name.Contains("CenterMarkers"))
- {
- tVect = new Vector3(0f, 0.02f, 0f);
- MR.transform.localPosition = tVect;
- }
- else if (MR.transform.name.Contains("-Inter") && MR.transform.name.Contains("-Lane"))
- {
- tVect = new Vector3(0f, 0.02f, 0f);
- MR.transform.localPosition = tVect;
- }
- else if (MR.transform.name.Contains("-Inter") && MR.transform.name.Contains("-Stretch"))
- {
- tVect = new Vector3(0f, 0.03f, 0f);
- MR.transform.localPosition = tVect;
- }
- else if (MR.transform.name.Contains("-Inter") && MR.transform.name.Contains("-Tiled"))
- {
- tVect = new Vector3(0f, 0.01f, 0f);
- MR.transform.localPosition = tVect;
- }
- }
- }
-
- private void FixZ_Win()
- {
- //This road:
- Object[] tMarkerObjs = transform.GetComponentsInChildren();
- Vector3 tVect = default(Vector3);
- foreach (MeshRenderer MR in tMarkerObjs)
- {
- if (MR.transform.name.Contains("Marker"))
- {
- tVect = new Vector3(0f, 0.01f, 0f);
- MR.transform.localPosition = tVect;
- }
- }
-
- //Intersections (all):
- tMarkerObjs = Object.FindObjectsOfType();
- foreach (MeshRenderer MR in tMarkerObjs)
- {
- if (MR.transform.name.Contains("-Inter") && MR.transform.name.Contains("-Lane"))
- {
- tVect = new Vector3(0f, 0.01f, 0f);
- MR.transform.localPosition = tVect;
- }
- else if (MR.transform.name.Contains("-Inter") && MR.transform.name.Contains("-Stretch"))
- {
- tVect = new Vector3(0f, 0.01f, 0f);
- MR.transform.localPosition = tVect;
- }
- }
- }
-#endif
-}
+#region Imports
+using UnityEngine;
+using System.Collections;
+using System.Collections.Generic;
+using GSD.Roads;
+using GSD;
+#if UNITY_EDITOR
+using UnityEditor;
+#endif
+#endregion
+
+
+[ExecuteInEditMode]
+public class GSDRoad : MonoBehaviour
+{
+
+ public GameObject MainMeshes;
+ public GameObject MeshRoad;
+ public GameObject MeshShoR;
+ public GameObject MeshShoL;
+ public GameObject MeshiLanes;
+ public GameObject MeshiLanes0;
+ public GameObject MeshiLanes1;
+ public GameObject MeshiLanes2;
+ public GameObject MeshiLanes3;
+ public GameObject MeshiMainPlates;
+ public GameObject MeshiMarkerPlates;
+
+ [System.NonSerialized]
+ public string EditorTitleString = "";
+
+ public GSDSplineC GSDSpline;
+
+ public int MostRecentNodeCount = -1;
+ // private bool bMostRecentCheck = false;
+ public GameObject GSDSplineObj;
+ public GSDRoadSystem GSDRS;
+ public GSDSplineC[] PiggyBacks = null;
+ public bool bEditorProgressBar = false;
+ public string UID; //Unique ID
+#if UNITY_EDITOR
+ [SerializeField]
+ public List TerrainHistory;
+ public string TerrainHistoryByteSize = "";
+#endif
+ [System.NonSerialized]
+ public bool bUpdateSpline = false;
+
+ //Road editor options:
+ public float opt_LaneWidth = 5f; //Done.
+ public bool opt_bShouldersEnabled = true; //Disabled for now. Comprimises integrity of roads.
+ public float opt_ShoulderWidth = 3f; //Done.
+ public int opt_Lanes = 2; //Done.
+ public float opt_RoadDefinition = 5f; //Done.
+ public bool opt_RoadCornerDefinition = false; //Disable for now. No point.
+ public bool opt_bRoadCuts = true;
+ public bool opt_bShoulderCuts = true;
+ public bool opt_bDynamicCuts = false;
+ public bool opt_bMaxGradeEnabled = true;
+ public float opt_MaxGrade = 0.08f;
+ public bool opt_UseDefaultMaterials = true;
+ public bool opt_AutoUpdateInEditor = true;
+
+ public float opt_TerrainSubtract_Match = 0.1f;
+ public bool opt_bGSDRoadRaise = false;
+
+ public float opt_MatchHeightsDistance = 50f;
+ public float opt_ClearDetailsDistance = 30f;
+ public float opt_ClearDetailsDistanceHeight = 5f;
+ public float opt_ClearTreesDistance = 30f;
+ public float opt_ClearTreesDistanceHeight = 50f;
+
+ public bool opt_HeightModEnabled = true;
+ public bool opt_DetailModEnabled = true;
+ public bool opt_TreeModEnabled = true;
+
+ public bool opt_SaveTerrainHistoryOnDisk = true;
+ public float opt_MagnitudeThreshold = 300f;
+ public bool opt_GizmosEnabled = true;
+ public bool opt_bMultithreading = true;
+ public bool opt_bSaveMeshes = false;
+ public bool opt_bUseMeshColliders = true;
+ public bool opt_bIsStatic = false;
+ public bool opt_bIsLightmapped = false;
+
+ public enum RoadMaterialDropdownEnum
+ {
+ Asphalt,
+ Dirt,
+ Brick,
+ Cobblestone
+ };
+
+ public RoadMaterialDropdownEnum opt_tRoadMaterialDropdown = RoadMaterialDropdownEnum.Asphalt;
+ public RoadMaterialDropdownEnum tRoadMaterialDropdownOLD = RoadMaterialDropdownEnum.Asphalt;
+
+
+ public Material RoadMaterial1;
+ public Material RoadMaterial2;
+ public Material RoadMaterial3;
+ public Material RoadMaterial4;
+ public Material RoadMaterialMarker1;
+ public Material RoadMaterialMarker2;
+ public Material RoadMaterialMarker3;
+ public Material RoadMaterialMarker4;
+ public Material ShoulderMaterial1;
+ public Material ShoulderMaterial2;
+ public Material ShoulderMaterial3;
+ public Material ShoulderMaterial4;
+ public Material ShoulderMaterialMarker1;
+ public Material ShoulderMaterialMarker2;
+ public Material ShoulderMaterialMarker3;
+ public Material ShoulderMaterialMarker4;
+
+ public PhysicMaterial RoadPhysicMaterial;
+ public PhysicMaterial ShoulderPhysicMaterial;
+#if UNITY_EDITOR
+ #region "Road Construction"
+ [System.NonSerialized]
+ public GSD.Threaded.TerrainCalcs TerrainCalcsJob;
+ [System.NonSerialized]
+ public GSD.Threaded.RoadCalcs1 RoadCalcsJob1;
+ [System.NonSerialized]
+ public GSD.Threaded.RoadCalcs2 RoadCalcsJob2;
+ [System.NonSerialized]
+ public RoadConstructorBufferMaker RCS;
+
+ public string tName = "";
+ public bool bProfiling = false;
+ public bool bSkipStore = true;
+ [System.NonSerialized]
+ public float EditorConstructionStartTime = 0f;
+
+
+ void CleanRunTime()
+ {
+ //Make sure unused items are not using memory space in runtime:
+ TerrainHistory = null;
+ RCS = null;
+ }
+
+
+ public bool bEditorError = false;
+ public System.Exception tError = null;
+
+
+ void OnEnable()
+ {
+ if (!Application.isEditor)
+ {
+ return;
+ }
+ // if(Application.isEditor && !UnityEditor.EditorApplication.isPlaying){
+ Editor_bIsConstructing = false;
+ UnityEditor.EditorApplication.update += delegate
+ { EditorUpdate(); };
+#if UNITY_2018_1_OR_NEWER
+ UnityEditor.EditorApplication.hierarchyChanged += delegate
+ { hWindowChanged(); };
+#else
+ UnityEditor.EditorApplication.hierarchyWindowChanged += delegate { hWindowChanged(); };
+#endif
+ // }
+ if (GSDSpline == null || GSDSpline.mNodes == null)
+ {
+ MostRecentNodeCount = 0;
+ }
+ else
+ {
+ MostRecentNodeCount = GSDSpline.GetNodeCount();
+ }
+ tRoadMaterialDropdownOLD = opt_tRoadMaterialDropdown;
+ CheckMats();
+ }
+
+
+ public void Awake()
+ {
+ if (GSDSpline == null || GSDSpline.mNodes == null)
+ {
+ MostRecentNodeCount = 0;
+ }
+ else
+ {
+ MostRecentNodeCount = GSDSpline.GetNodeCount();
+ }
+ }
+
+
+ int EditorTimer = 0;
+ int EditorTimerMax = 0;
+ int EditorTimerSpline = 0;
+ const int EditorTimerSplineMax = 2;
+ [System.NonSerialized]
+ public int EditorProgress = 0;
+ const int GizmoNodeTimerMax = 2;
+ public bool EditorUpdateMe = false;
+ public bool bTriggerGC = false;
+ bool bTriggerGC_Happening;
+ float TriggerGC_End = 0f;
+
+
+ private void EditorUpdate()
+ {
+ if (!Application.isEditor)
+ {
+ UnityEditor.EditorApplication.update -= delegate
+ { EditorUpdate(); };
+ }
+
+ if (this == null)
+ {
+ UnityEditor.EditorApplication.update -= delegate
+ { EditorUpdate(); };
+ Editor_bIsConstructing = false;
+ EditorUtility.ClearProgressBar();
+ return;
+ }
+
+ //Custom garbage collection demands for editor:
+ if (bTriggerGC)
+ {
+ bTriggerGC = false;
+ TriggerGC_End = Time.realtimeSinceStartup + 1f;
+ bTriggerGC_Happening = true;
+ }
+ if (bTriggerGC_Happening)
+ {
+ if (Time.realtimeSinceStartup > TriggerGC_End)
+ {
+ bTriggerGC_Happening = false;
+ GSDRootUtil.ForceCollection();
+ TriggerGC_End = 200000f;
+ }
+ }
+
+ if (Editor_bIsConstructing)
+ { // && !Application.isPlaying && !UnityEditor.EditorApplication.isPlaying){
+ if (GSDRS != null)
+ {
+ if (GSDRS.opt_bMultithreading)
+ {
+ EditorTimer += 1;
+ if (EditorTimer > EditorTimerMax)
+ {
+ if ((Time.realtimeSinceStartup - EditorConstructionStartTime) > 180f)
+ {
+ Editor_bIsConstructing = false;
+ EditorUtility.ClearProgressBar();
+ Debug.Log("Update shouldn't take longer than 180 seconds. Aborting update.");
+ }
+
+ EditorTimer = 0;
+ if (bEditorError)
+ {
+ Editor_bIsConstructing = false;
+ EditorUtility.ClearProgressBar();
+ bEditorError = false;
+ if (tError != null)
+ {
+ Debug.LogError(tError.StackTrace);
+ throw tError;
+ }
+ }
+
+ if (TerrainCalcsJob != null && TerrainCalcsJob.Update())
+ {
+ ConstructRoad2();
+ }
+ else if (RoadCalcsJob1 != null && RoadCalcsJob1.Update())
+ {
+ ConstructRoad3();
+ }
+ else if (RoadCalcsJob2 != null && RoadCalcsJob2.Update())
+ {
+ ConstructRoad4();
+ }
+ }
+ }
+ }
+ }
+ else
+ {
+ if (EditorUpdateMe && !Editor_bIsConstructing)
+ {
+ EditorUpdateMe = false;
+ GSDSpline.Setup_Trigger();
+ }
+ }
+
+ if (Editor_bIsConstructing)
+ {
+ RoadUpdateProgressBar();
+ }
+ else if (bEditorProgressBar)
+ {
+ RoadUpdateProgressBar();
+ }
+
+ if (!Application.isPlaying && bUpdateSpline && !UnityEditor.EditorApplication.isPlaying)
+ {
+ EditorTimerSpline += 1;
+ if (EditorTimerSpline > EditorTimerSplineMax)
+ {
+ EditorTimerSpline = 0;
+ bUpdateSpline = false;
+ GSDSpline.Setup_Trigger();
+ MostRecentNodeCount = GSDSpline.mNodes.Count;
+ }
+ }
+
+ if (bEditorCameraMoving && EditorCameraNextMove < EditorApplication.timeSinceStartup)
+ {
+ EditorCameraNextMove = (float) EditorApplication.timeSinceStartup + EditorCameraTimeUpdateInterval;
+ DoEditorCameraLoop();
+ }
+ }
+
+
+ [System.NonSerialized]
+ public bool bEditorCameraMoving = false;
+ [System.NonSerialized]
+ public float EditorCameraPos = 0f;
+ // float EditorCameraPos_Full = 0f;
+ const float EditorCameraTimeUpdateInterval = 0.015f;
+ float EditorCameraNextMove = 0f;
+ bool bEditorCameraSetup = false;
+ float EditorCameraStartPos = 0f;
+ float EditorCameraEndPos = 1f;
+ float EditorCameraIncrementDistance = 0f;
+ float EditorCameraIncrementDistance_Full = 0f;
+ public float EditorCameraMetersPerSecond = 60f;
+ public bool bEditorCameraRotate = false;
+ Vector3 EditorCameraV1 = default(Vector3);
+ Vector3 EditorCameraV2 = default(Vector3);
+ [System.NonSerialized]
+ public Vector3 EditorCameraOffset = new Vector3(0f, 5f, 0f);
+ [System.NonSerialized]
+ public Camera EditorPlayCamera = null;
+ Vector3 EditorCameraBadVec = default(Vector3);
+
+
+ public void DoEditorCameraLoop()
+ {
+ if (!bEditorCameraSetup)
+ {
+ bEditorCameraSetup = true;
+ if (GSDSpline.bSpecialEndControlNode)
+ { //If control node, start after the control node:
+ EditorCameraEndPos = GSDSpline.mNodes[GSDSpline.GetNodeCount() - 2].tTime;
+ }
+ if (GSDSpline.bSpecialStartControlNode)
+ { //If ends in control node, end construction before the control node:
+ EditorCameraStartPos = GSDSpline.mNodes[1].tTime;
+ }
+ // EditorCameraPos_Full = 0f;
+ ChangeEditorCameraMetersPerSec();
+ }
+
+ if (!Selection.Contains(this.transform.gameObject))
+ {
+ QuitEditorCamera();
+ return;
+ }
+
+ // EditorCameraPos_Full+=EditorCameraIncrementDistance_Full;
+ // if(EditorCameraPos_Full > GSDSpline.distance){ EditorCameraPos = EditorCameraStartPos; bEditorCameraMoving = false; bEditorCameraSetup = false; EditorCameraPos_Full = 0f; return; }
+ // EditorCameraPos = GSDSpline.TranslateDistBasedToParam(EditorCameraPos_Full);
+
+ EditorCameraPos += EditorCameraIncrementDistance;
+ if (EditorCameraPos > EditorCameraEndPos)
+ {
+ QuitEditorCamera();
+ return;
+ }
+ if (EditorCameraPos < EditorCameraStartPos)
+ {
+ EditorCameraPos = EditorCameraStartPos;
+ }
+
+ GSDSpline.GetSplineValue_Both(EditorCameraPos, out EditorCameraV1, out EditorCameraV2);
+
+ if (EditorApplication.isPlaying)
+ {
+ if (EditorPlayCamera != null)
+ {
+ EditorPlayCamera.transform.position = EditorCameraV1;
+ if (bEditorCameraRotate)
+ {
+ EditorPlayCamera.transform.position += EditorCameraOffset;
+ if (EditorCameraV2 != EditorCameraBadVec)
+ {
+ EditorPlayCamera.transform.rotation = Quaternion.LookRotation(EditorCameraV2);
+ }
+ }
+ }
+ }
+ else
+ {
+ SceneView.lastActiveSceneView.pivot = EditorCameraV1;
+ if (bEditorCameraRotate)
+ {
+ SceneView.lastActiveSceneView.pivot += EditorCameraOffset;
+ if (EditorCameraV2 != EditorCameraBadVec)
+ {
+ SceneView.lastActiveSceneView.rotation = Quaternion.LookRotation(EditorCameraV2);
+ }
+ }
+ SceneView.lastActiveSceneView.Repaint();
+ }
+ }
+
+
+ public void EditorCameraSetSingle()
+ {
+ if (EditorPlayCamera == null)
+ {
+ Camera[] EditorCams = (Camera[]) GameObject.FindObjectsOfType(typeof(Camera));
+ if (EditorCams != null && EditorCams.Length == 1)
+ {
+ EditorPlayCamera = EditorCams[0];
+ }
+ }
+ }
+
+
+ public void QuitEditorCamera()
+ {
+ EditorCameraPos = EditorCameraStartPos;
+ bEditorCameraMoving = false;
+ bEditorCameraSetup = false;
+ // EditorCameraPos_Full = 0f;
+ }
+
+
+ public void ChangeEditorCameraMetersPerSec()
+ {
+ EditorCameraIncrementDistance_Full = (EditorCameraMetersPerSecond / 60);
+ EditorCameraIncrementDistance = (EditorCameraIncrementDistance_Full / GSDSpline.distance);
+ }
+
+
+ private void hWindowChanged()
+ {
+ if (!Application.isEditor)
+ {
+#if UNITY_2018_1_OR_NEWER
+ UnityEditor.EditorApplication.hierarchyChanged -= delegate
+ { hWindowChanged(); };
+#else
+ UnityEditor.EditorApplication.hierarchyWindowChanged -= delegate { hWindowChanged(); };
+#endif
+ }
+ if (Application.isPlaying || !Application.isEditor)
+ {
+ return;
+ }
+ if (Application.isEditor && UnityEditor.EditorApplication.isPlaying)
+ {
+ return;
+ }
+ if (Application.isEditor && UnityEditor.EditorApplication.isPlayingOrWillChangePlaymode)
+ {
+ return;
+ }
+
+ int tCount = 0;
+ if (GSDSpline != null && GSDSpline.mNodes != null)
+ {
+ tCount = GSDSpline.GetNodeCountNonNull();
+ }
+ if (tCount != MostRecentNodeCount)
+ {
+ bUpdateSpline = true;
+ }
+ }
+
+
+ void RoadUpdateProgressBar()
+ {
+ if (Editor_bIsConstructing)
+ {
+ EditorUtility.DisplayProgressBar(
+ "GSD Road Update",
+ EditorTitleString,
+ ((float) EditorProgress / 100f));
+ }
+ else if (bEditorProgressBar)
+ {
+ bEditorProgressBar = false;
+ EditorUtility.ClearProgressBar();
+ }
+ }
+
+
+ public void UpdateRoad(RoadUpdateTypeEnum tUpdateType = RoadUpdateTypeEnum.Full)
+ {
+ if (!GSDRS.opt_bAllowRoadUpdates)
+ {
+ GSDSpline.Setup();
+ Editor_bIsConstructing = false;
+ return;
+ }
+
+ if (Editor_bIsConstructing)
+ {
+ return;
+ }
+
+ SetupUniqueIdentifier();
+
+
+
+ if (bProfiling)
+ { UnityEngine.Profiling.Profiler.BeginSample("UpdateRoadPrelim"); }
+ opt_RoadDefinition = Mathf.Clamp(opt_RoadDefinition, 1f, 50f);
+ opt_LaneWidth = Mathf.Clamp(opt_LaneWidth, 0.2f, 500f);
+ EditorConstructionStartTime = Time.realtimeSinceStartup;
+ EditorTitleString = "Updating " + transform.name + "...";
+ System.GC.Collect();
+
+ if (opt_SaveTerrainHistoryOnDisk)
+ {
+ ConstructRoad_LoadTerrainHistory();
+ }
+
+ CheckMats();
+
+ EditorUtility.ClearProgressBar();
+
+ bProfiling = true;
+ if (GSDRS.opt_bMultithreading)
+ { bProfiling = false; }
+
+ //Set all terrains to height 0:
+ GSD.Roads.GSDTerraforming.CheckAllTerrainsHeight0();
+
+ EditorProgress = 20;
+ bEditorProgressBar = true;
+ if (Editor_bIsConstructing)
+ {
+ if (TerrainCalcsJob != null)
+ { TerrainCalcsJob.Abort(); TerrainCalcsJob = null; }
+ if (RoadCalcsJob1 != null)
+ { RoadCalcsJob1.Abort(); RoadCalcsJob1 = null; }
+ if (RoadCalcsJob2 != null)
+ { RoadCalcsJob2.Abort(); RoadCalcsJob2 = null; }
+ Editor_bIsConstructing = false;
+ }
+
+ // if(Application.isPlaying || !Application.isEditor){ return; }
+ // if(Application.isEditor && UnityEditor.EditorApplication.isPlaying){ return; }
+ // if(Application.isEditor && UnityEditor.EditorApplication.isPlayingOrWillChangePlaymode){ return; }
+
+ //In here for intersection patching purposes:
+ int mCount = GSDSpline.GetNodeCount();
+ GSDSplineN tNode = null;
+ GSDSplineN tNode1 = null;
+ GSDSplineN tNode2 = null;
+ if (GSDSpline.CheckInvalidNodeCount())
+ {
+ GSDSpline.Setup();
+ mCount = GSDSpline.GetNodeCount();
+ }
+ if (mCount > 1)
+ {
+ for (int i = 0; i < mCount; i++)
+ {
+ // try{
+ tNode = GSDSpline.mNodes[i];
+ // }catch{
+ // Editor_bIsConstructing = false;
+ // EditorUpdateMe = true;
+ // return;
+ // }
+
+ //If node is intersection with an invalid GSDRI, mark it at non-intersection. Just-in-case.
+ if (tNode.bIsIntersection && tNode.GSDRI == null)
+ {
+ tNode.bIsIntersection = false;
+ tNode.id_intersection_othernode = -1;
+ tNode.Intersection_OtherNode = null;
+ }
+ //If node is intersection, re-setup:
+ if (tNode.bIsIntersection && tNode.GSDRI != null)
+ {
+ tNode1 = tNode.GSDRI.Node1;
+ tNode2 = tNode.GSDRI.Node2;
+ tNode.GSDRI.Setup(tNode1, tNode2);
+ tNode.GSDRI.DeleteRelevantChildren(tNode, tNode.GSDSpline.tRoad.transform.name);
+ //If primary node on intersection, do more re-setup:
+ if (tNode.GSDRI.Node1 == tNode)
+ {
+ tNode.GSDRI.Lanes = opt_Lanes;
+ tNode.GSDRI.name = tNode.GSDRI.transform.name;
+ }
+ //Setup construction objects:
+ tNode.GSDRI.Node1.iConstruction = new GSD.Roads.GSDIntersections.iConstructionMaker();
+ tNode.GSDRI.Node2.iConstruction = new GSD.Roads.GSDIntersections.iConstructionMaker();
+ }
+
+ //Store materials and physical materials for road and or shoulder cuts on each node, if necessary:
+ tNode.StoreCuts();
+ }
+ }
+ name = transform.name;
+
+
+
+ GSDSpline.RoadWidth = RoadWidth();
+ // if(bProfiling){ UnityEngine.Profiling.Profiler.BeginSample("SplineSetup"); }
+ GSDSpline.Setup();
+ // if(bProfiling){ UnityEngine.Profiling.Profiler.EndSample(); }
+ mCount = GSDSpline.GetNodeCount();
+
+ if (GSDSpline == null || GSDSpline.mNodes == null)
+ {
+ MostRecentNodeCount = 0;
+ }
+ else
+ {
+ MostRecentNodeCount = GSDSpline.GetNodeCount();
+ }
+
+ if (opt_UseDefaultMaterials)
+ {
+ SetDefaultMats();
+ }
+
+ if (opt_UseDefaultMaterials)
+ {
+ if (DetectInvalidDefaultMatsForUndo())
+ {
+ SetAllCutsToCurrentMaterials();
+ }
+ }
+
+ //Hiding in hierarchy:
+ for (int i = 0; i < mCount; i++)
+ {
+ tNode = GSDSpline.mNodes[i];
+ if (tNode != null)
+ {
+ if (tNode.bIsIntersection || tNode.bSpecialEndNode)
+ {
+ tNode.ToggleHideFlags(true);
+ }
+ else
+ {
+ tNode.ToggleHideFlags(false);
+ }
+ }
+ }
+
+ int cCount = transform.childCount;
+ GameObject tMainMeshes = null;
+ List tObjs = new List();
+ for (int i = 0; i < cCount; i++)
+ {
+ if (transform.GetChild(i).transform.name.ToLower().Contains("mainmeshes"))
+ {
+ tMainMeshes = transform.GetChild(i).transform.gameObject;
+ tObjs.Add(tMainMeshes);
+ }
+ }
+ for (int i = (tObjs.Count - 1); i >= 0; i--)
+ {
+ tMainMeshes = tObjs[i];
+ Object.DestroyImmediate(tMainMeshes);
+ }
+
+ if (mCount < 2)
+ {
+ //Delete old objs and return:
+ if (MainMeshes != null)
+ { Object.DestroyImmediate(MainMeshes); }
+ if (MeshRoad != null)
+ { Object.DestroyImmediate(MeshRoad); }
+ if (MeshShoR != null)
+ { Object.DestroyImmediate(MeshShoR); }
+ if (MeshShoL != null)
+ { Object.DestroyImmediate(MeshShoL); }
+ if (MeshiLanes != null)
+ { Object.DestroyImmediate(MeshiLanes); }
+ if (MeshiLanes0 != null)
+ { Object.DestroyImmediate(MeshiLanes0); }
+ if (MeshiLanes1 != null)
+ { Object.DestroyImmediate(MeshiLanes1); }
+ if (MeshiLanes2 != null)
+ { Object.DestroyImmediate(MeshiLanes2); }
+ if (MeshiLanes3 != null)
+ { Object.DestroyImmediate(MeshiLanes3); }
+ if (MeshiMainPlates != null)
+ { Object.DestroyImmediate(MeshiMainPlates); }
+ if (MeshiMarkerPlates != null)
+ { Object.DestroyImmediate(MeshiMarkerPlates); }
+ if (bProfiling)
+ { UnityEngine.Profiling.Profiler.EndSample(); }
+ return;
+ }
+
+ GSDSpline.HeightHistory = new List>();
+ if (GSDRS == null)
+ { GSDRS = transform.parent.GetComponent(); } //Compatibility update.
+
+ if (GSDRS.opt_bMultithreading)
+ {
+ Editor_bIsConstructing = true;
+ }
+ else
+ {
+ Editor_bIsConstructing = false;
+ }
+ Editor_bConstructionID = 0;
+
+
+
+ //Check if road takes place on only 1 terrain:
+ Terrain tTerrain = GSD.Roads.GSDRoadUtil.GetTerrain(GSDSpline.mNodes[0].pos);
+ bool bSameTerrain = true;
+ for (int i = 1; i < mCount; i++)
+ {
+ if (tTerrain != GSD.Roads.GSDRoadUtil.GetTerrain(GSDSpline.mNodes[0].pos))
+ {
+ bSameTerrain = false;
+ break;
+ }
+ }
+
+ RCS = new RoadConstructorBufferMaker(this, tUpdateType);
+
+ if (bSameTerrain)
+ {
+ RCS.tTerrain = tTerrain;
+ }
+ else
+ {
+ RCS.tTerrain = null;
+ }
+ tTerrain = null;
+
+ if (bProfiling)
+ { UnityEngine.Profiling.Profiler.EndSample(); }
+
+ if (GSDRS.opt_bMultithreading)
+ {
+ if (RCS.bTerrainOn || TerrainHistory == null)
+ {
+ GSDTerraforming.ProcessRoad_Terrain_Hook1(GSDSpline, this);
+ }
+ else
+ {
+ ConstructRoad2();
+ }
+ }
+ else
+ {
+ UpdateRoad_NoMultiThreading();
+ }
+ }
+
+
+ #region "Terrain history"
+ public void ConstructRoad_StoreTerrainHistory(bool bDiskOnly = false)
+ {
+ if (!bDiskOnly)
+ {
+ GSDRoad tRoad = this;
+ GSDRoadUtil.ConstructRoad_StoreTerrainHistory(ref tRoad);
+ }
+
+ if (opt_SaveTerrainHistoryOnDisk && TerrainHistory != null && TerrainHistory.Count > 0)
+ {
+ if (bProfiling)
+ { UnityEngine.Profiling.Profiler.BeginSample("TerrainHistory_Save"); }
+ GSDGeneralEditor.TerrainHistory_Save(TerrainHistory, this);
+ if (bProfiling)
+ { UnityEngine.Profiling.Profiler.EndSample(); }
+ TerrainHistory.Clear();
+ TerrainHistory = null;
+ }
+ else
+ {
+ if (TerrainHistory != null && TerrainHistory.Count > 0)
+ {
+ int tSize = 0;
+ for (int i = 0; i < TerrainHistory.Count; i++)
+ {
+ tSize += TerrainHistory[i].GetSize();
+ }
+ TerrainHistoryByteSize = (tSize * 0.001f).ToString("n0") + " kb";
+ }
+ else
+ {
+ TerrainHistoryByteSize = "0 bytes";
+ }
+ }
+ }
+ public void ConstructRoad_ResetTerrainHistory()
+ {
+ GSDRoad tRoad = this;
+ if (opt_SaveTerrainHistoryOnDisk && TerrainHistory != null)
+ {
+ GSDGeneralEditor.TerrainHistory_Delete(this);
+ }
+ else
+ {
+ GSDRoadUtil.ConstructRoad_ResetTerrainHistory(ref tRoad);
+ }
+ }
+ public void ConstructRoad_LoadTerrainHistory(bool bForce = false)
+ {
+ if (opt_SaveTerrainHistoryOnDisk || bForce)
+ {
+ if (TerrainHistory != null)
+ {
+ TerrainHistory.Clear();
+ TerrainHistory = null;
+ }
+ TerrainHistory = GSDGeneralEditor.TerrainHistory_Load(this);
+ }
+ if (bForce)
+ {
+ GSDGeneralEditor.TerrainHistory_Delete(this);
+ }
+ }
+ #endregion
+
+
+ #region "Construction process"
+ #region "No multithread"
+ private void UpdateRoad_NoMultiThreading()
+ {
+ if (opt_HeightModEnabled || opt_DetailModEnabled || opt_TreeModEnabled)
+ {
+ if (bProfiling)
+ { UnityEngine.Profiling.Profiler.BeginSample("RoadCon_Terrain"); }
+ if (RCS.bTerrainOn || TerrainHistory == null)
+ {
+ GSDTerraforming.ProcessRoad_Terrain_Hook1(GSDSpline, this, false);
+ GSDTerraforming.ProcessRoad_Terrain_Hook2(GSDSpline, ref EditorTTDList);
+ ConstructRoad_StoreTerrainHistory();//Store history.
+ int EditorTTDListCount = EditorTTDList.Count;
+ for (int i = 0; i < EditorTTDListCount; i++)
+ {
+ EditorTTDList[i] = null;
+ }
+ EditorTTDList = null;
+ System.GC.Collect();
+ }
+ if (bProfiling)
+ {
+ UnityEngine.Profiling.Profiler.EndSample();
+ }
+ }
+
+ EditorProgress = 50;
+ GSDRoad tRoad = this;
+ if (bProfiling)
+ {
+ UnityEngine.Profiling.Profiler.BeginSample("RoadCon_RoadPrelim");
+ }
+
+ EditorProgress = 80;
+ GSD.Threaded.GSDRoadCreationT.RoadJob_Prelim(ref tRoad);
+ if (bProfiling)
+ {
+ UnityEngine.Profiling.Profiler.EndSample();
+ UnityEngine.Profiling.Profiler.BeginSample("RoadCon_Road1");
+ }
+ EditorProgress = 90;
+ GSD.Threaded.RoadCalcs1_static.RunMe(ref RCS);
+ if (bProfiling)
+ { UnityEngine.Profiling.Profiler.EndSample(); }
+ if (bProfiling)
+ { UnityEngine.Profiling.Profiler.BeginSample("MeshSetup1"); }
+ EditorProgress = 92;
+ RCS.MeshSetup1();
+ if (bProfiling)
+ {
+ UnityEngine.Profiling.Profiler.EndSample();
+ UnityEngine.Profiling.Profiler.BeginSample("RoadCon_Road2");
+ }
+ EditorProgress = 94;
+ GSD.Threaded.RoadCalcs2_static.RunMe(ref RCS);
+ if (bProfiling)
+ { UnityEngine.Profiling.Profiler.EndSample(); }
+ if (bProfiling)
+ { UnityEngine.Profiling.Profiler.BeginSample("MeshSetup2"); }
+ EditorProgress = 96;
+ RCS.MeshSetup2();
+ if (bProfiling)
+ { UnityEngine.Profiling.Profiler.EndSample(); }
+ Construction_Cleanup();
+ }
+ #endregion
+
+ private void ConstructRoad2()
+ {
+ EditorProgress = 40;
+ if (RCS.bTerrainOn)
+ {
+ //Store history:
+ GSDTerraforming.ProcessRoad_Terrain_Hook2(GSDSpline, ref EditorTTDList);
+ ConstructRoad_StoreTerrainHistory();
+ int EditorTTDListCount = EditorTTDList.Count;
+ for (int i = 0; i < EditorTTDListCount; i++)
+ {
+ EditorTTDList[i] = null;
+ }
+ EditorTTDList = null;
+ System.GC.Collect();
+ }
+ EditorProgress = 60;
+
+ if (TerrainCalcsJob != null)
+ { TerrainCalcsJob.Abort(); TerrainCalcsJob = null; }
+ GSDRoad tRoad = this;
+ EditorProgress = 72;
+ RoadCalcsJob1 = new GSD.Threaded.RoadCalcs1();
+ RoadCalcsJob1.Setup(ref RCS, ref tRoad);
+ RoadCalcsJob1.Start();
+ }
+
+ private void ConstructRoad3()
+ {
+ EditorProgress = 84;
+ RCS.MeshSetup1();
+ EditorProgress = 96;
+ if (RoadCalcsJob1 != null)
+ { RoadCalcsJob1.Abort(); RoadCalcsJob1 = null; }
+ RoadCalcsJob2 = new GSD.Threaded.RoadCalcs2();
+ RoadCalcsJob2.Setup(ref RCS);
+ RoadCalcsJob2.Start();
+ EditorProgress = 98;
+ }
+
+ private void ConstructRoad4()
+ {
+ RCS.MeshSetup2();
+ Construction_Cleanup();
+ }
+ #endregion
+
+
+ private void Construction_Cleanup()
+ {
+ FixZ();
+
+ if (TerrainCalcsJob != null)
+ {
+ TerrainCalcsJob.Abort();
+ TerrainCalcsJob = null;
+ }
+ if (RoadCalcsJob1 != null)
+ {
+ RoadCalcsJob1.Abort();
+ RoadCalcsJob1 = null;
+ }
+ if (RoadCalcsJob2 != null)
+ {
+ RoadCalcsJob2.Abort();
+ RoadCalcsJob2 = null;
+ }
+ Editor_bIsConstructing = false;
+ int mCount = GSDSpline.GetNodeCount();
+ GSDSplineN tNode;
+ for (int i = 0; i < mCount; i++)
+ {
+ tNode = GSDSpline.mNodes[i];
+ if (tNode.bIsIntersection)
+ {
+ if (tNode.iConstruction != null)
+ {
+ tNode.iConstruction.Nullify();
+ tNode.iConstruction = null;
+ }
+ }
+ tNode.SetupSplinationLimits();
+ tNode.SetupEdgeObjects(false);
+ tNode.SetupSplinatedMeshes(false);
+ }
+ if (GSDSpline.HeightHistory != null)
+ {
+ GSDSpline.HeightHistory.Clear();
+ GSDSpline.HeightHistory = null;
+ }
+ if (RCS != null)
+ {
+ RCS.Nullify();
+ RCS = null;
+ }
+
+ if (GSDRS.opt_bSaveMeshes)
+ {
+ UnityEditor.AssetDatabase.SaveAssets();
+ }
+ bEditorProgressBar = false;
+ EditorUtility.ClearProgressBar();
+ //Make sure terrain history out of memory if necessary (redudant but keep):
+ if (opt_SaveTerrainHistoryOnDisk && TerrainHistory != null)
+ {
+ TerrainHistory.Clear();
+ TerrainHistory = null;
+ }
+
+ //Collect:
+ bTriggerGC = true;
+
+ if (tRoadMaterialDropdownOLD != opt_tRoadMaterialDropdown)
+ {
+ tRoadMaterialDropdownOLD = opt_tRoadMaterialDropdown;
+ SetAllCutsToCurrentMaterials();
+ }
+
+ if (PiggyBacks != null && PiggyBacks.Length > 0)
+ {
+ for (int i = 0; i < PiggyBacks.Length; i++)
+ {
+ if (PiggyBacks[i] == null)
+ {
+ PiggyBacks = null;
+ break;
+ }
+ }
+
+ if (PiggyBacks != null)
+ {
+ GSDSplineC tPiggy = PiggyBacks[0];
+ GSDSplineC[] NewPiggys = null;
+
+ PiggyBacks[0] = null;
+ if (PiggyBacks.Length > 1)
+ {
+ NewPiggys = new GSDSplineC[PiggyBacks.Length - 1];
+ for (int i = 1; i < PiggyBacks.Length; i++)
+ {
+ NewPiggys[i - 1] = PiggyBacks[i];
+ }
+ }
+
+ if (NewPiggys != null)
+ {
+ tPiggy.tRoad.PiggyBacks = NewPiggys;
+ }
+ NewPiggys = null;
+ tPiggy.Setup_Trigger();
+ }
+ }
+ }
+
+
+ public List EditorTTDList;
+
+
+ public void EditorTerrainCalcs(ref List tList)
+ {
+ EditorTTDList = tList;
+ }
+ #endregion
+
+
+ #region "Gizmos"
+ public bool Editor_bIsConstructing = false;
+ public int Editor_bConstructionID = 0;
+ public bool Editor_bSelected = false;
+ public bool Editor_MouseTerrainHit = false;
+ public Vector3 Editor_MousePos = new Vector3(0f, 0f, 0f);
+ public readonly Color Color_NodeDefaultColor = new Color(0f, 1f, 1f, 0.75f);
+ public readonly Color Color_NodeConnColor = new Color(0f, 1f, 0f, 0.75f);
+ public readonly Color Color_NodeInter = new Color(0f, 1f, 0f, 0.75f);
+
+
+ void OnDrawGizmosSelected()
+ {
+ if (Editor_MouseTerrainHit)
+ {
+ Gizmos.color = Color.red;
+ Gizmos.DrawCube(Editor_MousePos, new Vector3(10f, 4f, 10f));
+ }
+ }
+ #endregion
+#endif
+
+
+ public float RoadWidth()
+ {
+ return (opt_LaneWidth * (float) opt_Lanes);
+ }
+
+
+#if UNITY_EDITOR
+ public float EditorCameraTimer = 0f;
+ float EditorTestTimer = 0f;
+ bool bEditorTestTimer = true;
+
+
+ void Update()
+ {
+ if (Application.isEditor && bEditorCameraMoving)
+ {
+ EditorCameraTimer += Time.deltaTime;
+ if (EditorCameraTimer > EditorCameraTimeUpdateInterval)
+ {
+ EditorCameraTimer = 0f;
+ DoEditorCameraLoop();
+ }
+ }
+
+ if (bEditorTestTimer)
+ {
+ if (transform.name == "Road1")
+ {
+ EditorTestTimer += Time.deltaTime;
+ if (EditorTestTimer > 2f)
+ {
+ // UpdateRoad(RoadUpdateTypeEnum.Full);
+ // akjsdfkajlgffdghfsdghsdf();
+ bEditorTestTimer = false;
+ }
+ }
+ else
+ {
+ bEditorTestTimer = false;
+ }
+ }
+ }
+
+
+
+ // TODO: Needs a proper Name, who did this anyway? // FH 29.01.19
+ static void akjsdfkajlgffdghfsdghsdf()
+ {
+ int LoopMax = 1000;
+ DoShort(LoopMax);
+ DoInt(LoopMax);
+ DoLong(LoopMax);
+ }
+
+
+ static void DoShort(int LoopMax)
+ {
+ ushort[] tSubject = new ushort[25000];
+ // int tInt = 0;
+ for (int i = 0; i < LoopMax; i++)
+ {
+ for (int j = 0; j < 25000; j++)
+ {
+ tSubject[j] = (ushort) (j + 1);
+ // int xTemp = (int)tSubject[j];
+ }
+ }
+ }
+
+
+ static void DoInt(int LoopMax)
+ {
+ int[] tSubject = new int[25000];
+ // int tInt = 0;
+ for (int i = 0; i < LoopMax; i++)
+ {
+ for (int j = 0; j < 25000; j++)
+ {
+ tSubject[j] = j + 1;
+ // int xTemp = tSubject[j];
+ }
+ }
+ }
+
+
+ static void DoLong(int LoopMax)
+ {
+ long[] tSubject = new long[25000];
+ // int tInt = 0;
+ for (int i = 0; i < LoopMax; i++)
+ {
+ for (int j = 0; j < 25000; j++)
+ {
+ tSubject[j] = (long) (j + 1);
+ // int xTemp = (int)tSubject[j];
+ }
+ }
+ }
+
+
+ #region "Default materials retrieval"
+ public bool DetectInvalidDefaultMatsForUndo()
+ {
+ string tNameLower = "";
+ int tCounter = 0;
+ if (!MeshRoad)
+ { return false; }
+
+ MeshRenderer[] MRs = MeshRoad.GetComponentsInChildren();
+ Material tMat2 = GSD.Roads.GSDRoadUtilityEditor.GiveMaterial(GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Materials/Markers/GSDWhiteYellowDouble.mat");
+ Material tMat4 = GSD.Roads.GSDRoadUtilityEditor.GiveMaterial(GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Materials/Markers/GSDWhiteYellowDouble-4L.mat");
+ Material tMat6 = GSD.Roads.GSDRoadUtilityEditor.GiveMaterial(GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Materials/Markers/GSDWhiteYellowDouble-6L.mat");
+ foreach (MeshRenderer MR in MRs)
+ {
+ tNameLower = MR.transform.name.ToLower();
+ if (tNameLower.Contains("marker"))
+ {
+ if (opt_Lanes == 2)
+ {
+ if (MR.sharedMaterials[0] == tMat4)
+ {
+ tCounter += 1;
+ }
+ else if (MR.sharedMaterials[0] == tMat6)
+ {
+ tCounter += 1;
+ }
+ }
+ else if (opt_Lanes == 4)
+ {
+ if (MR.sharedMaterials[0] == tMat2)
+ {
+ tCounter += 1;
+ }
+ else if (MR.sharedMaterials[0] == tMat6)
+ {
+ tCounter += 1;
+ }
+ }
+ else if (opt_Lanes == 6)
+ {
+ if (MR.sharedMaterials[0] == tMat2)
+ {
+ tCounter += 1;
+ }
+ else if (MR.sharedMaterials[0] == tMat4)
+ {
+ tCounter += 1;
+ }
+ }
+ }
+ if (tCounter > 1)
+ {
+ return true;
+ }
+ }
+ return false;
+ }
+
+
+ public void SetAllCutsToCurrentMaterials()
+ {
+ string tNameLower = "";
+ if (!MeshRoad)
+ { return; }
+
+ MeshRenderer[] MRs = MeshRoad.GetComponentsInChildren();
+ Material[] tMats_World = GetMaterials_RoadWorld();
+ Material[] tMats_Marker = GetMaterials_RoadMarker();
+ foreach (MeshRenderer MR in MRs)
+ {
+ tNameLower = MR.transform.name.ToLower();
+ if (tNameLower.Contains("marker"))
+ {
+ if (tMats_Marker != null)
+ {
+ MR.sharedMaterials = tMats_Marker;
+ }
+ }
+ else if (tNameLower.Contains("cut"))
+ {
+ if (tMats_World != null)
+ {
+ MR.sharedMaterials = tMats_World;
+ }
+ }
+ }
+
+ if (opt_bShouldersEnabled && MeshShoL != null)
+ {
+ MRs = MeshShoL.GetComponentsInChildren();
+ tMats_World = GetMaterials_ShoulderWorld();
+ tMats_Marker = GetMaterials_ShoulderMarker();
+ foreach (MeshRenderer MR in MRs)
+ {
+ tNameLower = MR.transform.name.ToLower();
+ if (tNameLower.Contains("marker"))
+ {
+ if (tMats_Marker != null)
+ {
+ MR.sharedMaterials = tMats_Marker;
+ }
+ }
+ else if (tNameLower.Contains("cut"))
+ {
+ if (tMats_World != null)
+ {
+ MR.sharedMaterials = tMats_World;
+ }
+ }
+ }
+ }
+
+ if (opt_bShouldersEnabled && MeshShoR != null)
+ {
+ MRs = MeshShoR.GetComponentsInChildren();
+ foreach (MeshRenderer MR in MRs)
+ {
+ tNameLower = MR.transform.name.ToLower();
+ if (tNameLower.Contains("marker"))
+ {
+ if (tMats_Marker != null)
+ {
+ MR.sharedMaterials = tMats_Marker;
+ }
+ }
+ else if (tNameLower.Contains("cut"))
+ {
+ if (tMats_World != null)
+ {
+ MR.sharedMaterials = tMats_World;
+ }
+ }
+ }
+ }
+ }
+
+
+ public Material[] GetMaterials_RoadWorld()
+ {
+ int mCounter = 0;
+ if (RoadMaterial1 != null)
+ {
+ mCounter += 1;
+ if (RoadMaterial2 != null)
+ {
+ mCounter += 1;
+ if (RoadMaterial3 != null)
+ {
+ mCounter += 1;
+ if (RoadMaterial4 != null)
+ {
+ mCounter += 1;
+ }
+ }
+ }
+ }
+ if (mCounter > 0)
+ {
+ Material[] tMats = new Material[mCounter];
+ if (RoadMaterial1 != null)
+ {
+ tMats[0] = RoadMaterial1;
+ if (RoadMaterial2 != null)
+ {
+ tMats[1] = RoadMaterial2;
+ if (RoadMaterial3 != null)
+ {
+ tMats[2] = RoadMaterial3;
+ if (RoadMaterial4 != null)
+ {
+ tMats[3] = RoadMaterial4;
+ }
+ }
+ }
+ }
+ return tMats;
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+
+ public Material[] GetMaterials_RoadMarker()
+ {
+ int mCounter = 0;
+ if (RoadMaterialMarker1 != null)
+ {
+ mCounter += 1;
+ if (RoadMaterialMarker2 != null)
+ {
+ mCounter += 1;
+ if (RoadMaterialMarker3 != null)
+ {
+ mCounter += 1;
+ if (RoadMaterialMarker4 != null)
+ {
+ mCounter += 1;
+ }
+ }
+ }
+ }
+ if (mCounter > 0)
+ {
+ Material[] tMats = new Material[mCounter];
+ if (RoadMaterialMarker1 != null)
+ {
+ tMats[0] = RoadMaterialMarker1;
+ if (RoadMaterialMarker2 != null)
+ {
+ tMats[1] = RoadMaterialMarker2;
+ if (RoadMaterialMarker3 != null)
+ {
+ tMats[2] = RoadMaterialMarker3;
+ if (RoadMaterialMarker4 != null)
+ {
+ tMats[3] = RoadMaterialMarker4;
+ }
+ }
+ }
+ }
+ return tMats;
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+
+ public Material[] GetMaterials_ShoulderWorld()
+ {
+ if (!opt_bShouldersEnabled)
+ {
+ return null;
+ }
+
+ int mCounter = 0;
+ if (ShoulderMaterial1 != null)
+ {
+ mCounter += 1;
+ if (ShoulderMaterial2 != null)
+ {
+ mCounter += 1;
+ if (ShoulderMaterial3 != null)
+ {
+ mCounter += 1;
+ if (ShoulderMaterial4 != null)
+ {
+ mCounter += 1;
+ }
+ }
+ }
+ }
+ if (mCounter > 0)
+ {
+ Material[] tMats = new Material[mCounter];
+ if (ShoulderMaterial1 != null)
+ {
+ tMats[0] = ShoulderMaterial1;
+ if (ShoulderMaterial2 != null)
+ {
+ tMats[1] = ShoulderMaterial2;
+ if (ShoulderMaterial3 != null)
+ {
+ tMats[2] = ShoulderMaterial3;
+ if (ShoulderMaterial4 != null)
+ {
+ tMats[3] = ShoulderMaterial4;
+ }
+ }
+ }
+ }
+ return tMats;
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+
+ public Material[] GetMaterials_ShoulderMarker()
+ {
+ if (!opt_bShouldersEnabled)
+ {
+ return null;
+ }
+
+ int mCounter = 0;
+ if (ShoulderMaterialMarker1 != null)
+ {
+ mCounter += 1;
+ if (ShoulderMaterialMarker2 != null)
+ {
+ mCounter += 1;
+ if (ShoulderMaterialMarker3 != null)
+ {
+ mCounter += 1;
+ if (ShoulderMaterialMarker4 != null)
+ {
+ mCounter += 1;
+ }
+ }
+ }
+ }
+ if (mCounter > 0)
+ {
+ Material[] tMats = new Material[mCounter];
+ if (ShoulderMaterialMarker1 != null)
+ {
+ tMats[0] = ShoulderMaterialMarker1;
+ if (ShoulderMaterialMarker2 != null)
+ {
+ tMats[1] = ShoulderMaterialMarker2;
+ if (ShoulderMaterialMarker3 != null)
+ {
+ tMats[2] = ShoulderMaterialMarker3;
+ if (ShoulderMaterialMarker4 != null)
+ {
+ tMats[3] = ShoulderMaterialMarker4;
+ }
+ }
+ }
+ }
+ return tMats;
+ }
+ else
+ {
+ return null;
+ }
+ }
+ #endregion
+
+
+ #region "Materials"
+ void CheckMats()
+ {
+ if (!opt_UseDefaultMaterials)
+ {
+ return;
+ }
+
+ if (!RoadMaterial1)
+ {
+ RoadMaterial1 = GSD.Roads.GSDRoadUtilityEditor.GiveMaterial(GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Materials/GSDRoad1.mat");
+ RoadMaterial2 = GSD.Roads.GSDRoadUtilityEditor.GiveMaterial(GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Materials/Markers/GSDRoadDetailOverlay1.mat");
+ }
+ if (!RoadMaterialMarker1)
+ {
+ if (opt_Lanes == 2)
+ {
+ RoadMaterialMarker1 = GSD.Roads.GSDRoadUtilityEditor.GiveMaterial(GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Materials/Markers/GSDWhiteYellowDouble.mat");
+ }
+ else if (opt_Lanes == 4)
+ {
+ RoadMaterialMarker1 = GSD.Roads.GSDRoadUtilityEditor.GiveMaterial(GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Materials/Markers/GSDWhiteYellowDouble-4L.mat");
+ }
+ else if (opt_Lanes == 6)
+ {
+ RoadMaterialMarker1 = GSD.Roads.GSDRoadUtilityEditor.GiveMaterial(GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Materials/Markers/GSDWhiteYellowDouble-6L.mat");
+ }
+ else
+ {
+ RoadMaterialMarker1 = GSD.Roads.GSDRoadUtilityEditor.GiveMaterial(GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Materials/Markers/GSDWhiteYellowDouble.mat");
+ }
+
+ if (opt_Lanes == 2)
+ {
+ RoadMaterialMarker2 = GSD.Roads.GSDRoadUtilityEditor.GiveMaterial(GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Materials/Markers/GSDTireMarks.mat");
+ }
+ else if (opt_Lanes == 4)
+ {
+ RoadMaterialMarker2 = GSD.Roads.GSDRoadUtilityEditor.GiveMaterial(GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Materials/Markers/GSDTireMarks-4L.mat");
+ }
+ else if (opt_Lanes == 6)
+ {
+ RoadMaterialMarker2 = GSD.Roads.GSDRoadUtilityEditor.GiveMaterial(GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Materials/Markers/GSDTireMarks-6L.mat");
+ }
+ else
+ {
+ RoadMaterialMarker2 = GSD.Roads.GSDRoadUtilityEditor.GiveMaterial(GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Materials/Markers/GSDTireMarks.mat");
+ }
+ }
+ if (opt_bShouldersEnabled && !ShoulderMaterial1)
+ {
+ ShoulderMaterial1 = GSD.Roads.GSDRoadUtilityEditor.GiveMaterial(GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Materials/GSDShoulder1.mat");
+ ShoulderMaterial2 = GSD.Roads.GSDRoadUtilityEditor.GiveMaterial(GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Materials/Markers/GSDRoadDetailOverlay1.mat");
+ }
+
+ if (opt_bShouldersEnabled && !RoadPhysicMaterial)
+ {
+ RoadPhysicMaterial = GSD.Roads.GSDRoadUtilityEditor.GivePhysicsMaterial(GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Physics/GSDPavement.physicMaterial");
+ }
+ if (opt_bShouldersEnabled && !ShoulderPhysicMaterial)
+ {
+ ShoulderPhysicMaterial = GSD.Roads.GSDRoadUtilityEditor.GivePhysicsMaterial(GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Physics/GSDDirt.physicMaterial");
+ }
+ }
+
+
+ public void SetDefaultMats()
+ {
+ if (opt_tRoadMaterialDropdown == RoadMaterialDropdownEnum.Asphalt)
+ {
+ RoadMaterial1 = GSD.Roads.GSDRoadUtilityEditor.GiveMaterial(GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Materials/GSDRoad1.mat");
+ RoadMaterial2 = GSD.Roads.GSDRoadUtilityEditor.GiveMaterial(GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Materials/Markers/GSDRoadDetailOverlay1.mat");
+
+ if (opt_Lanes == 2)
+ {
+ RoadMaterialMarker1 = GSD.Roads.GSDRoadUtilityEditor.GiveMaterial(GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Materials/Markers/GSDWhiteYellowDouble.mat");
+ }
+ else if (opt_Lanes == 4)
+ {
+ RoadMaterialMarker1 = GSD.Roads.GSDRoadUtilityEditor.GiveMaterial(GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Materials/Markers/GSDWhiteYellowDouble-4L.mat");
+ }
+ else if (opt_Lanes == 6)
+ {
+ RoadMaterialMarker1 = GSD.Roads.GSDRoadUtilityEditor.GiveMaterial(GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Materials/Markers/GSDWhiteYellowDouble-6L.mat");
+ }
+ else
+ {
+ RoadMaterialMarker1 = GSD.Roads.GSDRoadUtilityEditor.GiveMaterial(GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Materials/Markers/GSDWhiteYellowDouble.mat");
+ }
+
+ if (opt_Lanes == 2)
+ {
+ RoadMaterialMarker2 = GSD.Roads.GSDRoadUtilityEditor.GiveMaterial(GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Materials/Markers/GSDTireMarks.mat");
+ }
+ else if (opt_Lanes == 4)
+ {
+ RoadMaterialMarker2 = GSD.Roads.GSDRoadUtilityEditor.GiveMaterial(GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Materials/Markers/GSDTireMarks-4L.mat");
+ }
+ else if (opt_Lanes == 6)
+ {
+ RoadMaterialMarker2 = GSD.Roads.GSDRoadUtilityEditor.GiveMaterial(GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Materials/Markers/GSDTireMarks-6L.mat");
+ }
+ else
+ {
+ RoadMaterialMarker2 = GSD.Roads.GSDRoadUtilityEditor.GiveMaterial(GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Materials/Markers/GSDTireMarks.mat");
+ }
+
+ ShoulderMaterial1 = GSD.Roads.GSDRoadUtilityEditor.GiveMaterial(GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Materials/GSDShoulder1.mat");
+ ShoulderMaterial2 = GSD.Roads.GSDRoadUtilityEditor.GiveMaterial(GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Materials/Markers/GSDRoadDetailOverlay1.mat");
+
+ RoadPhysicMaterial = GSD.Roads.GSDRoadUtilityEditor.GivePhysicsMaterial(GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Physics/GSDPavement.physicMaterial");
+ ShoulderPhysicMaterial = GSD.Roads.GSDRoadUtilityEditor.GivePhysicsMaterial(GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Physics/GSDDirt.physicMaterial");
+ }
+ else if (opt_tRoadMaterialDropdown == RoadMaterialDropdownEnum.Dirt)
+ {
+ RoadMaterial1 = null;
+ RoadMaterial2 = null;
+ RoadMaterial3 = null;
+ RoadMaterial4 = null;
+ RoadMaterialMarker1 = GSD.Roads.GSDRoadUtilityEditor.GiveMaterial(GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Materials/GSDDirtRoad.mat");
+ RoadMaterialMarker2 = null;
+ RoadMaterialMarker3 = null;
+ RoadMaterialMarker4 = null;
+ }
+ else if (opt_tRoadMaterialDropdown == RoadMaterialDropdownEnum.Brick)
+ {
+ RoadMaterial1 = null;
+ RoadMaterial2 = null;
+ RoadMaterial3 = null;
+ RoadMaterial4 = null;
+ RoadMaterialMarker1 = GSD.Roads.GSDRoadUtilityEditor.GiveMaterial(GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Materials/GSDBrickRoad.mat");
+ RoadMaterialMarker2 = null;
+ RoadMaterialMarker3 = null;
+ RoadMaterialMarker4 = null;
+ }
+ else if (opt_tRoadMaterialDropdown == RoadMaterialDropdownEnum.Cobblestone)
+ {
+ RoadMaterial1 = null;
+ RoadMaterial2 = null;
+ RoadMaterial3 = null;
+ RoadMaterial4 = null;
+ RoadMaterialMarker1 = GSD.Roads.GSDRoadUtilityEditor.GiveMaterial(GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Materials/GSDCobblestoneRoad.mat");
+ RoadMaterialMarker2 = null;
+ RoadMaterialMarker3 = null;
+ RoadMaterialMarker4 = null;
+ }
+ if (opt_tRoadMaterialDropdown == RoadMaterialDropdownEnum.Brick
+ || opt_tRoadMaterialDropdown == RoadMaterialDropdownEnum.Cobblestone
+ || opt_tRoadMaterialDropdown == RoadMaterialDropdownEnum.Dirt)
+ {
+ if (opt_Lanes > 2)
+ {
+ RoadMaterialMarker1 = new Material(RoadMaterialMarker1);
+ RoadMaterialMarker1.mainTextureScale *= new Vector2(opt_Lanes / 2, 1f);
+ }
+ }
+
+ int mCount = GSDSpline.GetNodeCount();
+ for (int i = 0; i < mCount; i++)
+ {
+ if (GSDSpline.mNodes[i] && GSDSpline.mNodes[i].bIsIntersection && GSDSpline.mNodes[i].GSDRI != null && GSDSpline.mNodes[i].GSDRI.bUseDefaultMaterials)
+ {
+ GSDSpline.mNodes[i].GSDRI.ResetMaterials_All();
+ }
+ }
+ }
+ #endregion
+
+
+ public void Wireframes_Toggle()
+ {
+ MeshRenderer[] tMRs = transform.GetComponentsInChildren();
+ Wireframes_Toggle_Help(ref tMRs);
+
+ if (GSDSpline != null)
+ {
+ tMRs = GSDSpline.transform.GetComponentsInChildren();
+ Wireframes_Toggle_Help(ref tMRs);
+ }
+ }
+
+
+ void Wireframes_Toggle_Help(ref MeshRenderer[] tMRs)
+ {
+ int tCount = tMRs.Length;
+ for (int i = 0; i < tCount; i++)
+ {
+ //EditorUtility.SetSelectedWireframeHidden(tMRs[i], !opt_GizmosEnabled);
+ EditorUtility.SetSelectedRenderState(tMRs[i], opt_GizmosEnabled ? EditorSelectedRenderState.Wireframe : EditorSelectedRenderState.Hidden);
+ }
+ }
+
+#endif
+
+
+ void Start()
+ {
+#if UNITY_EDITOR
+ if (Application.isPlaying)
+ {
+ CleanRunTime();
+ }
+#else
+ this.enabled = false;
+#endif
+ }
+
+
+#if UNITY_EDITOR
+ //For compliance on submission rules:
+ public void UpdateGizmoOptions()
+ {
+ if (GSDSpline == null)
+ {
+ return;
+ }
+ GSDSplineN tNode = null;
+
+ int mCount = GSDSpline.GetNodeCount();
+ for (int i = 0; i < mCount; i++)
+ {
+ tNode = GSDSpline.mNodes[i];
+ if (tNode != null)
+ {
+ tNode.opt_GizmosEnabled = opt_GizmosEnabled;
+ }
+ }
+ }
+
+
+ public void SetupUniqueIdentifier()
+ {
+ if (UID == null || UID.Length < 4)
+ {
+ UID = System.Guid.NewGuid().ToString();
+ }
+ }
+
+
+ public void DuplicateRoad()
+ {
+ GameObject tRoadObj = GSDRS.AddRoad();
+ UnityEditor.Undo.RegisterCreatedObjectUndo(tRoadObj, "Duplicate");
+
+ GSDRoad xRoad = tRoadObj.GetComponent();
+ if (xRoad == null)
+ {
+ return;
+ }
+
+ //Road editor options:
+ xRoad.opt_LaneWidth = opt_LaneWidth; //Done.
+ xRoad.opt_bShouldersEnabled = opt_bShouldersEnabled; //Disabled for now. Comprimises integrity of roads.
+ xRoad.opt_ShoulderWidth = opt_ShoulderWidth; //Done.
+ xRoad.opt_Lanes = opt_Lanes; //Done.
+ xRoad.opt_RoadDefinition = opt_RoadDefinition; //Done.
+ xRoad.opt_RoadCornerDefinition = opt_RoadCornerDefinition; //Disable for now. No point.
+ xRoad.opt_bRoadCuts = opt_bRoadCuts;
+ xRoad.opt_bShoulderCuts = opt_bShoulderCuts;
+ xRoad.opt_bDynamicCuts = opt_bDynamicCuts;
+ xRoad.opt_bMaxGradeEnabled = opt_bMaxGradeEnabled;
+ xRoad.opt_MaxGrade = opt_MaxGrade;
+ xRoad.opt_UseDefaultMaterials = opt_UseDefaultMaterials;
+ xRoad.opt_AutoUpdateInEditor = opt_AutoUpdateInEditor;
+
+ xRoad.opt_TerrainSubtract_Match = opt_TerrainSubtract_Match;
+ xRoad.opt_bGSDRoadRaise = opt_bGSDRoadRaise;
+
+ xRoad.opt_MatchHeightsDistance = opt_MatchHeightsDistance;
+ xRoad.opt_ClearDetailsDistance = opt_ClearDetailsDistance;
+ xRoad.opt_ClearDetailsDistanceHeight = opt_ClearDetailsDistanceHeight;
+ xRoad.opt_ClearTreesDistance = opt_ClearTreesDistance;
+ xRoad.opt_ClearTreesDistanceHeight = opt_ClearTreesDistanceHeight;
+
+ xRoad.opt_HeightModEnabled = opt_HeightModEnabled;
+ xRoad.opt_DetailModEnabled = opt_DetailModEnabled;
+ xRoad.opt_TreeModEnabled = opt_TreeModEnabled;
+
+ xRoad.opt_SaveTerrainHistoryOnDisk = opt_SaveTerrainHistoryOnDisk;
+ xRoad.opt_MagnitudeThreshold = opt_MagnitudeThreshold;
+ xRoad.opt_GizmosEnabled = opt_GizmosEnabled;
+ xRoad.opt_bMultithreading = opt_bMultithreading;
+ xRoad.opt_bSaveMeshes = opt_bSaveMeshes;
+ xRoad.opt_bUseMeshColliders = opt_bUseMeshColliders;
+
+ xRoad.opt_tRoadMaterialDropdown = opt_tRoadMaterialDropdown;
+ xRoad.tRoadMaterialDropdownOLD = tRoadMaterialDropdownOLD;
+
+ xRoad.RoadMaterial1 = RoadMaterial1;
+ xRoad.RoadMaterial2 = RoadMaterial2;
+ xRoad.RoadMaterial3 = RoadMaterial3;
+ xRoad.RoadMaterial4 = RoadMaterial4;
+ xRoad.RoadMaterialMarker1 = RoadMaterialMarker1;
+ xRoad.RoadMaterialMarker2 = RoadMaterialMarker2;
+ xRoad.RoadMaterialMarker3 = RoadMaterialMarker3;
+ xRoad.RoadMaterialMarker4 = RoadMaterialMarker4;
+ xRoad.ShoulderMaterial1 = ShoulderMaterial1;
+ xRoad.ShoulderMaterial2 = ShoulderMaterial2;
+ xRoad.ShoulderMaterial3 = ShoulderMaterial3;
+ xRoad.ShoulderMaterial4 = ShoulderMaterial4;
+ xRoad.ShoulderMaterialMarker1 = ShoulderMaterialMarker1;
+ xRoad.ShoulderMaterialMarker2 = ShoulderMaterialMarker2;
+ xRoad.ShoulderMaterialMarker3 = ShoulderMaterialMarker3;
+ xRoad.ShoulderMaterialMarker4 = ShoulderMaterialMarker4;
+
+ xRoad.RoadPhysicMaterial = RoadPhysicMaterial;
+ xRoad.ShoulderPhysicMaterial = ShoulderPhysicMaterial;
+
+ xRoad.GSDSpline.Setup_Trigger();
+
+ Selection.activeGameObject = xRoad.transform.gameObject;
+ }
+
+
+ private void FixZ()
+ {
+ FixZ_Mobile();
+ }
+
+
+ private void FixZ_Mobile()
+ {
+ //This road:
+ Object[] tMarkerObjs = transform.GetComponentsInChildren();
+ Vector3 tVect = default(Vector3);
+ foreach (MeshRenderer MR in tMarkerObjs)
+ {
+ if (MR.transform.name.Contains("Marker"))
+ {
+ tVect = new Vector3(0f, 0.02f, 0f);
+ MR.transform.localPosition = tVect;
+ }
+ else if (MR.transform.name.Contains("SCut") || MR.transform.name.Contains("RoadCut")
+ || MR.transform.name.Contains("ShoulderR")
+ || MR.transform.name.Contains("ShoulderL"))
+ {
+ tVect = MR.transform.position;
+ tVect.y += 0.01f;
+ MR.transform.position = tVect;
+ }
+ else if (MR.transform.name.Contains("RoadMesh"))
+ {
+ tVect = MR.transform.position;
+ tVect.y += 0.02f;
+ MR.transform.position = tVect;
+ }
+ else if (MR.transform.name.Contains("Pavement"))
+ {
+ tVect = MR.transform.position;
+ tVect.y -= 0.01f;
+ MR.transform.position = tVect;
+ }
+ }
+
+
+ //Intersections (all):
+ tMarkerObjs = GSDRS.GetComponentsInChildren();
+ foreach (MeshRenderer MR in tMarkerObjs)
+ {
+ if (MR.transform.name.Contains("CenterMarkers"))
+ {
+ tVect = new Vector3(0f, 0.02f, 0f);
+ MR.transform.localPosition = tVect;
+ }
+ else if (MR.transform.name.Contains("-Inter") && MR.transform.name.Contains("-Lane"))
+ {
+ tVect = new Vector3(0f, 0.02f, 0f);
+ MR.transform.localPosition = tVect;
+ }
+ else if (MR.transform.name.Contains("-Inter") && MR.transform.name.Contains("-Stretch"))
+ {
+ tVect = new Vector3(0f, 0.03f, 0f);
+ MR.transform.localPosition = tVect;
+ }
+ else if (MR.transform.name.Contains("-Inter") && MR.transform.name.Contains("-Tiled"))
+ {
+ tVect = new Vector3(0f, 0.01f, 0f);
+ MR.transform.localPosition = tVect;
+ }
+ }
+ }
+
+
+ private void FixZ_Win()
+ {
+ //This road:
+ Object[] tMarkerObjs = transform.GetComponentsInChildren();
+ Vector3 tVect = default(Vector3);
+ foreach (MeshRenderer MR in tMarkerObjs)
+ {
+ if (MR.transform.name.Contains("Marker"))
+ {
+ tVect = new Vector3(0f, 0.01f, 0f);
+ MR.transform.localPosition = tVect;
+ }
+ }
+
+
+ //Intersections (all):
+ tMarkerObjs = Object.FindObjectsOfType();
+ foreach (MeshRenderer MR in tMarkerObjs)
+ {
+ if (MR.transform.name.Contains("-Inter") && MR.transform.name.Contains("-Lane"))
+ {
+ tVect = new Vector3(0f, 0.01f, 0f);
+ MR.transform.localPosition = tVect;
+ }
+ else if (MR.transform.name.Contains("-Inter") && MR.transform.name.Contains("-Stretch"))
+ {
+ tVect = new Vector3(0f, 0.01f, 0f);
+ MR.transform.localPosition = tVect;
+ }
+ }
+ }
+#endif
+}
\ No newline at end of file
diff --git a/GSDRoadAutomation.cs b/GSDRoadAutomation.cs
index b46f34fe..d474dccd 100755
--- a/GSDRoadAutomation.cs
+++ b/GSDRoadAutomation.cs
@@ -1,351 +1,384 @@
-using UnityEngine;
-#if UNITY_EDITOR
-using System.Collections.Generic;
-using System.Collections;
-using System.IO;
-using System.Text;
-using System.Runtime.Serialization.Formatters.Binary;
-using System.Runtime.Serialization;
-#endif
-namespace GSD.Roads
-{
-#if UNITY_EDITOR
- // Proper automation flow:
- // 1. Make sure opt_bAllowRoadUpdates in the scene's GSDRoadSystem is set to FALSE.
- // 2. Create your roads programmatically via CreateRoad_Programmatically (pass it the road, and then the points in a list)
- // a. Optionally you can do it via CreateNode_Programmatically and InsertNode_Programmatically
- // 3. Call CreateIntersections_ProgrammaticallyForRoad for each road to create intersections automatically at intersection points.
- // 4. Set opt_bAllowRoadUpdates in the scene's GSDRoadSystem is set to TRUE.
- // 5. Call GSDRoadSystem.UpdateAllRoads();
- // 6. Call GSDRoadSystem.UpdateAllRoads(); after step #5 completes.
- //
- // See "GSDUnitTests.cs" for an example on automation (ignore unit test #3).
-
-
- public static class GSDRoadAutomation
- {
- ///
- /// Use this to create nodes via coding while in editor mode. Make sure opt_bAllowRoadUpdates is set to false in RS.GSDRS.opt_bAllowRoadUpdates.
- ///
- /// The road system to create nodes on.
- /// The location of the newly created node.
- ///
- public static GSDRoad CreateRoad_Programmatically(GSDRoadSystem GSDRS, ref List tLocs)
- {
- GameObject tRoadObj = GSDRS.AddRoad(false);
- GSDRoad tRoad = tRoadObj.GetComponent();
-
- int hCount = tLocs.Count;
- for (int i = 0; i < hCount; i++)
- {
- CreateNode_Programmatically(tRoad, tLocs[i]);
- }
-
- return tRoad;
- }
-
-
- ///
- /// Use this to create nodes via coding while in editor mode. Make sure opt_bAllowRoadUpdates is set to false in RS.GSDRS.opt_bAllowRoadUpdates.
- ///
- /// The road system to create nodes on.
- /// The location of the newly created node.
- ///
- public static GSDSplineN CreateNode_Programmatically(GSDRoad tRoad, Vector3 NodeLocation)
- {
- int SplineChildCount = tRoad.GSDSpline.transform.childCount;
- GameObject tNodeObj = new GameObject("Node" + (SplineChildCount + 1).ToString());
- GSDSplineN tNode = tNodeObj.AddComponent(); //Add the node component.
-
- //Set node location:
- if (NodeLocation.y < 0.03f) { NodeLocation.y = 0.03f; } //Make sure it doesn't try to create a node below 0 height.
- tNodeObj.transform.position = NodeLocation;
-
- //Set the node's parent:
- tNodeObj.transform.parent = tRoad.GSDSplineObj.transform;
-
- //Set the idOnSpline:
- tNode.idOnSpline = (SplineChildCount + 1);
- tNode.GSDSpline = tRoad.GSDSpline;
-
- //Make sure opt_bAllowRoadUpdates is set to false in RS.GSDRS.opt_bAllowRoadUpdates
- tRoad.UpdateRoad();
-
- return tNode;
- }
-
- ///
- /// Use this to insert nodes via coding while in editor mode. Make sure opt_bAllowRoadUpdates is set to false in RS.GSDRS.opt_bAllowRoadUpdates.
- ///
- /// The road system to insert nodes in.
- /// The location of the newly inserted node.
- ///
- public static GSDSplineN InsertNode_Programmatically(GSDRoad RS, Vector3 NodeLocation)
- {
- GameObject tNodeObj;
- Object[] tWorldNodeCount = GameObject.FindObjectsOfType(typeof(GSDSplineN));
- tNodeObj = new GameObject("Node" + tWorldNodeCount.Length.ToString());
-
- //Set node location:
- if (NodeLocation.y < 0.03f) { NodeLocation.y = 0.03f; } //Make sure it doesn't try to create a node below 0 height.
- tNodeObj.transform.position = NodeLocation;
-
- //Set the node's parent:
- tNodeObj.transform.parent = RS.GSDSplineObj.transform;
-
- int cCount = RS.GSDSpline.mNodes.Count;
-
- //Get the closet param on spline:
- float tParam = RS.GSDSpline.GetClosestParam(NodeLocation, false, true);
-
- bool bEndInsert = false;
- bool bZeroInsert = false;
- int iStart = 0;
- if (GSDRootUtil.IsApproximately(tParam, 0f, 0.0001f))
- {
- bZeroInsert = true;
- iStart = 0;
- }
- else if (GSDRootUtil.IsApproximately(tParam, 1f, 0.0001f))
- {
- //Inserted at end, switch to create node instead:
- Object.DestroyImmediate(tNodeObj);
- return CreateNode_Programmatically(RS, NodeLocation);
- }
-
- //Figure out where to insert the node:
- for (int i = 0; i < cCount; i++)
- {
- GSDSplineN xNode = RS.GSDSpline.mNodes[i];
- if (!bZeroInsert && !bEndInsert)
- {
- if (tParam > xNode.tTime)
- {
- iStart = xNode.idOnSpline + 1;
- }
- }
- }
- for (int i = iStart; i < cCount; i++)
- {
- RS.GSDSpline.mNodes[i].idOnSpline += 1;
- }
-
- GSDSplineN tNode = tNodeObj.AddComponent();
- tNode.GSDSpline = RS.GSDSpline;
- tNode.idOnSpline = iStart;
- tNode.pos = NodeLocation;
- RS.GSDSpline.mNodes.Insert(iStart, tNode);
-
- //Make sure opt_bAllowRoadUpdates is set to false in RS.GSDRS.opt_bAllowRoadUpdates
- RS.UpdateRoad();
-
- return tNode;
- }
-
-
- ///
- /// Creates intersections where this road intersects with other roads.
- ///
- /// The primary road to create intersections for.
- /// Stop signs, traffic lights #1 (US) or traffic lights #2 (Euro). Defaults to none.
- /// Intersection type: No turn lane, left turn lane or both turn lanes. Defaults to no turn lane.
- public static void CreateIntersections_ProgrammaticallyForRoad(GSDRoad tRoad, GSDRoadIntersection.iStopTypeEnum iStopType = GSDRoadIntersection.iStopTypeEnum.None, GSDRoadIntersection.RoadTypeEnum rType = GSDRoadIntersection.RoadTypeEnum.NoTurnLane)
- {
- /*
- General logic:
- 20m increments to gather collection of which roads intersect
- 2m increments to find actual intersection point
- each 2m, primary road checks all intersecting array for an intersection.
- find intersection point
- if any intersections already within 75m or 100m, dont create intersection here
- check if nodes within 50m, if more than one just grab closest, and move it to intersecting point
- if no node within 50m, add
- create intersection with above two nodes
- */
-
- Object[] GSDRoadObjs = Object.FindObjectsOfType();
-
- //20m increments to gather collection of which roads intersect
- List xRoads = new List();
- foreach (GSDRoad xRoad in GSDRoadObjs)
- {
- if (tRoad != xRoad)
- {
- float EarlyDistanceCheckMeters = 10f;
- float EarlyDistanceCheckThreshold = 50f;
- bool EarlyDistanceFound = false;
- float tRoadMod = EarlyDistanceCheckMeters / tRoad.GSDSpline.distance;
- float xRoadMod = EarlyDistanceCheckMeters / xRoad.GSDSpline.distance;
- Vector3 tVect1 = default(Vector3);
- Vector3 tVect2 = default(Vector3);
- for (float i = 0f; i < 1.0000001f; i += tRoadMod)
- {
- tVect1 = tRoad.GSDSpline.GetSplineValue(i);
- for (float x = 0f; x < 1.000001f; x += xRoadMod)
- {
- tVect2 = xRoad.GSDSpline.GetSplineValue(x);
- if (Vector3.Distance(tVect1, tVect2) < EarlyDistanceCheckThreshold)
- {
- if (!xRoads.Contains(xRoad))
- {
- xRoads.Add(xRoad);
- }
- EarlyDistanceFound = true;
- break;
- }
- }
- if (EarlyDistanceFound) { break; }
- }
- }
- }
-
- //See if any end point nodes are on top of each other already since T might not intersect all the time.:
- List> tKVP = new List>();
- foreach (GSDRoad xRoad in xRoads)
- {
- foreach (GSDSplineN IntersectionNode1 in tRoad.GSDSpline.mNodes)
- {
- if (IntersectionNode1.bIsIntersection || !IntersectionNode1.IsLegitimate()) { continue; }
- foreach (GSDSplineN IntersectionNode2 in xRoad.GSDSpline.mNodes)
- {
- if (IntersectionNode2.bIsIntersection || !IntersectionNode2.IsLegitimate()) { continue; }
- if (IntersectionNode1.transform.position == IntersectionNode2.transform.position)
- {
- //Only do T intersections and let the next algorithm handle the +, since T might not intersect all the time.
- if (IntersectionNode1.bIsEndPoint || IntersectionNode2.bIsEndPoint)
- {
- tKVP.Add(new KeyValuePair(IntersectionNode1, IntersectionNode2));
- }
- }
- }
- }
- }
- foreach (KeyValuePair KVP in tKVP)
- {
- //Now create the fucking intersection:
- GameObject tInter = GSD.Roads.GSDIntersections.CreateIntersection(KVP.Key, KVP.Value);
- GSDRoadIntersection GSDRI_JustCreated = tInter.GetComponent();
- GSDRI_JustCreated.iStopType = iStopType;
- GSDRI_JustCreated.rType = rType;
- }
-
- //Main algorithm: 2m increments to find actual intersection point:
- foreach (GSDRoad xRoad in xRoads)
- {
- if (tRoad != xRoad)
- {
- //Debug.Log("Checking road: " + xRoad.transform.name);
- float DistanceCheckMeters = 2f;
- bool EarlyDistanceFound = false;
- float tRoadMod = DistanceCheckMeters / tRoad.GSDSpline.distance;
- float xRoadMod = DistanceCheckMeters / xRoad.GSDSpline.distance;
- Vector3 tVect = default(Vector3);
- Vector2 iVect1 = default(Vector2);
- Vector2 iVect2 = default(Vector2);
- Vector2 xVect1 = default(Vector2);
- Vector2 xVect2 = default(Vector2);
- Vector2 IntersectPoint2D = default(Vector2);
- float i2 = 0f;
- for (float i = 0f; i < 1.0000001f; i += tRoadMod)
- {
- i2 = (i + tRoadMod);
- if (i2 > 1f) { i2 = 1f; }
- tVect = tRoad.GSDSpline.GetSplineValue(i);
- iVect1 = new Vector2(tVect.x, tVect.z);
- tVect = tRoad.GSDSpline.GetSplineValue(i2);
- iVect2 = new Vector2(tVect.x, tVect.z);
-
- float x2 = 0f;
- for (float x = 0f; x < 1.000001f; x += xRoadMod)
- {
- x2 = (x + xRoadMod);
- if (x2 > 1f) { x2 = 1f; }
- tVect = xRoad.GSDSpline.GetSplineValue(x);
- xVect1 = new Vector2(tVect.x, tVect.z);
- tVect = xRoad.GSDSpline.GetSplineValue(x2);
- xVect2 = new Vector2(tVect.x, tVect.z);
-
- //Now see if these two lines intersect:
- if (GSD.GSDRootUtil.Intersects2D(ref iVect1, ref iVect2, ref xVect1, ref xVect2, out IntersectPoint2D))
- {
- //Get height of intersection on primary road:
- float tHeight = 0f;
- float hParam = tRoad.GSDSpline.GetClosestParam(new Vector3(IntersectPoint2D.x, 0f, IntersectPoint2D.y));
- Vector3 hVect = tRoad.GSDSpline.GetSplineValue(hParam);
- tHeight = hVect.y;
-
- //if any intersections already within 75m or 100m, dont create intersection here
- Object[] AllInterectionObjects = Object.FindObjectsOfType();
- foreach (GSDRoadIntersection GSDRI in AllInterectionObjects)
- {
- if (Vector2.Distance(new Vector2(GSDRI.transform.position.x, GSDRI.transform.position.z), IntersectPoint2D) < 100f)
- {
- goto NoIntersectionCreation;
- }
- }
-
- GSDSplineN IntersectionNode1 = null;
- GSDSplineN IntersectionNode2 = null;
- Vector3 IntersectionPoint3D = new Vector3(IntersectPoint2D.x, tHeight, IntersectPoint2D.y);
- //Debug.Log("Instersect found road: " + xRoad.transform.name + " at point: " + IntersectionPoint3D.ToString());
-
- //Check primary road if any nodes are nearby and usable for intersection
- foreach (GSDSplineN tNode in tRoad.GSDSpline.mNodes)
- {
- if (tNode.IsLegitimate())
- {
- if (Vector2.Distance(new Vector2(tNode.transform.position.x, tNode.transform.position.z), IntersectPoint2D) < 30f)
- {
- IntersectionNode1 = tNode;
- IntersectionNode1.transform.position = IntersectionPoint3D;
- IntersectionNode1.pos = IntersectionPoint3D;
- break;
- }
- }
- }
-
- //Check secondary road if any nodes are nearby and usable for intersection
- foreach (GSDSplineN tNode in xRoad.GSDSpline.mNodes)
- {
- if (tNode.IsLegitimate())
- {
- if (Vector2.Distance(new Vector2(tNode.transform.position.x, tNode.transform.position.z), IntersectPoint2D) < 30f)
- {
- IntersectionNode2 = tNode;
- IntersectionNode2.transform.position = IntersectionPoint3D;
- IntersectionNode2.pos = IntersectionPoint3D;
- break;
- }
- }
- }
-
- //Check if any of the nodes are null. If so, need to insert node. And maybe update it.
- if (IntersectionNode1 == null)
- {
- IntersectionNode1 = InsertNode_Programmatically(tRoad, IntersectionPoint3D);
- }
- if (IntersectionNode2 == null)
- {
- IntersectionNode2 = InsertNode_Programmatically(xRoad, IntersectionPoint3D);
- }
-
- //Now create the fucking intersection:
- GameObject tInter = GSD.Roads.GSDIntersections.CreateIntersection(IntersectionNode1, IntersectionNode2);
- GSDRoadIntersection GSDRI_JustCreated = tInter.GetComponent();
- GSDRI_JustCreated.iStopType = iStopType;
- GSDRI_JustCreated.rType = rType;
- }
-
- NoIntersectionCreation:
- //Gibberish to get rid of warnings:
- int xxx = 1;
- if (xxx == 1) { xxx = 2; }
- }
- if (EarlyDistanceFound) { break; }
- }
- }
- }
- }
- }
-#endif
-}
+#region Imports
+using UnityEngine;
+#if UNITY_EDITOR
+using System.Collections.Generic;
+using System.Collections;
+using System.IO;
+using System.Text;
+using System.Runtime.Serialization.Formatters.Binary;
+using System.Runtime.Serialization;
+#endif
+#endregion
+
+
+namespace GSD.Roads
+{
+#if UNITY_EDITOR
+ /* Proper automation flow:
+ * 1. Make sure opt_bAllowRoadUpdates in the scene's GSDRoadSystem is set to FALSE.
+ * 2. Create your roads programmatically via CreateRoad_Programmatically (pass it the road, and then the points in a list)
+ * a. Optionally you can do it via CreateNode_Programmatically and InsertNode_Programmatically
+ * 3. Call CreateIntersections_ProgrammaticallyForRoad for each road to create intersections automatically at intersection points.
+ * 4. Set opt_bAllowRoadUpdates in the scene's GSDRoadSystem is set to TRUE.
+ * 5. Call GSDRoadSystem.UpdateAllRoads();
+ * 6. Call GSDRoadSystem.UpdateAllRoads(); after step #5 completes.
+ *
+ * See "GSDUnitTests.cs" for an example on automation (ignore unit test #3).
+ */
+
+
+ public static class GSDRoadAutomation
+ {
+ ///
+ /// Use this to create nodes via coding while in editor mode. Make sure opt_bAllowRoadUpdates is set to false in RS.GSDRS.opt_bAllowRoadUpdates.
+ ///
+ /// The road system to create nodes on.
+ /// The location of the newly created node.
+ ///
+ public static GSDRoad CreateRoad_Programmatically(GSDRoadSystem GSDRS, ref List tLocs)
+ {
+ GameObject tRoadObj = GSDRS.AddRoad(false);
+ GSDRoad tRoad = tRoadObj.GetComponent();
+
+ int hCount = tLocs.Count;
+ for (int index = 0; index < hCount; index++)
+ {
+ CreateNode_Programmatically(tRoad, tLocs[index]);
+ }
+
+ return tRoad;
+ }
+
+
+ ///
+ /// Use this to create nodes via coding while in editor mode. Make sure opt_bAllowRoadUpdates is set to false in RS.GSDRS.opt_bAllowRoadUpdates.
+ ///
+ /// The road system to create nodes on.
+ /// The location of the newly created node.
+ ///
+ public static GSDSplineN CreateNode_Programmatically(GSDRoad tRoad, Vector3 NodeLocation)
+ {
+ int SplineChildCount = tRoad.GSDSpline.transform.childCount;
+ GameObject tNodeObj = new GameObject("Node" + (SplineChildCount + 1).ToString());
+ GSDSplineN tNode = tNodeObj.AddComponent(); //Add the node component.
+
+ //Set node location:
+ if (NodeLocation.y < 0.03f)
+ {
+ NodeLocation.y = 0.03f;
+ } //Make sure it doesn't try to create a node below 0 height.
+ tNodeObj.transform.position = NodeLocation;
+
+ //Set the node's parent:
+ tNodeObj.transform.parent = tRoad.GSDSplineObj.transform;
+
+ //Set the idOnSpline:
+ tNode.idOnSpline = (SplineChildCount + 1);
+ tNode.GSDSpline = tRoad.GSDSpline;
+
+ //Make sure opt_bAllowRoadUpdates is set to false in RS.GSDRS.opt_bAllowRoadUpdates
+ tRoad.UpdateRoad();
+
+ return tNode;
+ }
+
+
+ ///
+ /// Use this to insert nodes via coding while in editor mode. Make sure opt_bAllowRoadUpdates is set to false in RS.GSDRS.opt_bAllowRoadUpdates.
+ ///
+ /// The road system to insert nodes in.
+ /// The location of the newly inserted node.
+ ///
+ public static GSDSplineN InsertNode_Programmatically(GSDRoad RS, Vector3 NodeLocation)
+ {
+ GameObject tNodeObj;
+ Object[] tWorldNodeCount = GameObject.FindObjectsOfType(typeof(GSDSplineN));
+ tNodeObj = new GameObject("Node" + tWorldNodeCount.Length.ToString());
+
+ //Set node location:
+ if (NodeLocation.y < 0.03f)
+ {
+ NodeLocation.y = 0.03f; //Make sure it doesn't try to create a node below 0 height.
+ }
+ tNodeObj.transform.position = NodeLocation;
+
+ //Set the node's parent:
+ tNodeObj.transform.parent = RS.GSDSplineObj.transform;
+
+ int cCount = RS.GSDSpline.mNodes.Count;
+
+ //Get the closet param on spline:
+ float tParam = RS.GSDSpline.GetClosestParam(NodeLocation, false, true);
+
+ bool bEndInsert = false;
+ bool bZeroInsert = false;
+ int iStart = 0;
+ if (GSDRootUtil.IsApproximately(tParam, 0f, 0.0001f))
+ {
+ bZeroInsert = true;
+ iStart = 0;
+ }
+ else if (GSDRootUtil.IsApproximately(tParam, 1f, 0.0001f))
+ {
+ //Inserted at end, switch to create node instead:
+ Object.DestroyImmediate(tNodeObj);
+ return CreateNode_Programmatically(RS, NodeLocation);
+ }
+
+ //Figure out where to insert the node:
+ for (int index = 0; index < cCount; index++)
+ {
+ GSDSplineN xNode = RS.GSDSpline.mNodes[index];
+ if (!bZeroInsert && !bEndInsert)
+ {
+ if (tParam > xNode.tTime)
+ {
+ iStart = xNode.idOnSpline + 1;
+ }
+ }
+ }
+ for (int index = iStart; index < cCount; index++)
+ {
+ RS.GSDSpline.mNodes[index].idOnSpline += 1;
+ }
+
+ GSDSplineN tNode = tNodeObj.AddComponent();
+ tNode.GSDSpline = RS.GSDSpline;
+ tNode.idOnSpline = iStart;
+ tNode.pos = NodeLocation;
+ RS.GSDSpline.mNodes.Insert(iStart, tNode);
+
+ //Make sure opt_bAllowRoadUpdates is set to false in RS.GSDRS.opt_bAllowRoadUpdates
+ RS.UpdateRoad();
+
+ return tNode;
+ }
+
+
+ ///
+ /// Creates intersections where this road intersects with other roads.
+ ///
+ /// The primary road to create intersections for.
+ /// Stop signs, traffic lights #1 (US) or traffic lights #2 (Euro). Defaults to none.
+ /// Intersection type: No turn lane, left turn lane or both turn lanes. Defaults to no turn lane.
+ public static void CreateIntersections_ProgrammaticallyForRoad(GSDRoad tRoad, GSDRoadIntersection.iStopTypeEnum iStopType = GSDRoadIntersection.iStopTypeEnum.None, GSDRoadIntersection.RoadTypeEnum rType = GSDRoadIntersection.RoadTypeEnum.NoTurnLane)
+ {
+ /*
+ General logic:
+ 20m increments to gather collection of which roads intersect
+ 2m increments to find actual intersection point
+ each 2m, primary road checks all intersecting array for an intersection.
+ find intersection point
+ if any intersections already within 75m or 100m, dont create intersection here
+ check if nodes within 50m, if more than one just grab closest, and move it to intersecting point
+ if no node within 50m, add
+ create intersection with above two nodes
+ */
+
+ Object[] GSDRoadObjs = Object.FindObjectsOfType();
+
+ //20m increments to gather collection of which roads intersect
+ List xRoads = new List();
+ foreach (GSDRoad xRoad in GSDRoadObjs)
+ {
+ if (tRoad != xRoad)
+ {
+ float EarlyDistanceCheckMeters = 10f;
+ float EarlyDistanceCheckThreshold = 50f;
+ bool EarlyDistanceFound = false;
+ float tRoadMod = EarlyDistanceCheckMeters / tRoad.GSDSpline.distance;
+ float xRoadMod = EarlyDistanceCheckMeters / xRoad.GSDSpline.distance;
+ Vector3 tVect1 = default(Vector3);
+ Vector3 tVect2 = default(Vector3);
+ for (float index = 0f; index < 1.0000001f; index += tRoadMod)
+ {
+ tVect1 = tRoad.GSDSpline.GetSplineValue(index);
+ for (float x = 0f; x < 1.000001f; x += xRoadMod)
+ {
+ tVect2 = xRoad.GSDSpline.GetSplineValue(x);
+ if (Vector3.Distance(tVect1, tVect2) < EarlyDistanceCheckThreshold)
+ {
+ if (!xRoads.Contains(xRoad))
+ {
+ xRoads.Add(xRoad);
+ }
+ EarlyDistanceFound = true;
+ break;
+ }
+ }
+ if (EarlyDistanceFound)
+ {
+ break;
+ }
+ }
+ }
+ }
+
+ //See if any end point nodes are on top of each other already since T might not intersect all the time.:
+ List> tKVP = new List>();
+ foreach (GSDRoad xRoad in xRoads)
+ {
+ foreach (GSDSplineN IntersectionNode1 in tRoad.GSDSpline.mNodes)
+ {
+ if (IntersectionNode1.bIsIntersection || !IntersectionNode1.IsLegitimate())
+ {
+ continue;
+ }
+ foreach (GSDSplineN IntersectionNode2 in xRoad.GSDSpline.mNodes)
+ {
+ if (IntersectionNode2.bIsIntersection || !IntersectionNode2.IsLegitimate())
+ {
+ continue;
+ }
+ if (IntersectionNode1.transform.position == IntersectionNode2.transform.position)
+ {
+ //Only do T intersections and let the next algorithm handle the +, since T might not intersect all the time.
+ if (IntersectionNode1.bIsEndPoint || IntersectionNode2.bIsEndPoint)
+ {
+ tKVP.Add(new KeyValuePair(IntersectionNode1, IntersectionNode2));
+ }
+ }
+ }
+ }
+ }
+ foreach (KeyValuePair KVP in tKVP)
+ {
+ //Now create the fucking intersection:
+ GameObject tInter = GSD.Roads.GSDIntersections.CreateIntersection(KVP.Key, KVP.Value);
+ GSDRoadIntersection GSDRI_JustCreated = tInter.GetComponent();
+ GSDRI_JustCreated.iStopType = iStopType;
+ GSDRI_JustCreated.rType = rType;
+ }
+
+ //Main algorithm: 2m increments to find actual intersection point:
+ foreach (GSDRoad xRoad in xRoads)
+ {
+ if (tRoad != xRoad)
+ {
+ //Debug.Log("Checking road: " + xRoad.transform.name);
+ float DistanceCheckMeters = 2f;
+ bool EarlyDistanceFound = false;
+ float tRoadMod = DistanceCheckMeters / tRoad.GSDSpline.distance;
+ float xRoadMod = DistanceCheckMeters / xRoad.GSDSpline.distance;
+ Vector3 tVect = default(Vector3);
+ Vector2 iVect1 = default(Vector2);
+ Vector2 iVect2 = default(Vector2);
+ Vector2 xVect1 = default(Vector2);
+ Vector2 xVect2 = default(Vector2);
+ Vector2 IntersectPoint2D = default(Vector2);
+ float i2 = 0f;
+ for (float index = 0f; index < 1.0000001f; index += tRoadMod)
+ {
+ i2 = (index + tRoadMod);
+ if (i2 > 1f)
+ {
+ i2 = 1f;
+ }
+ tVect = tRoad.GSDSpline.GetSplineValue(index);
+ iVect1 = new Vector2(tVect.x, tVect.z);
+ tVect = tRoad.GSDSpline.GetSplineValue(i2);
+ iVect2 = new Vector2(tVect.x, tVect.z);
+
+ float x2 = 0f;
+ for (float x = 0f; x < 1.000001f; x += xRoadMod)
+ {
+ x2 = (x + xRoadMod);
+ if (x2 > 1f)
+ {
+ x2 = 1f;
+ }
+ tVect = xRoad.GSDSpline.GetSplineValue(x);
+ xVect1 = new Vector2(tVect.x, tVect.z);
+ tVect = xRoad.GSDSpline.GetSplineValue(x2);
+ xVect2 = new Vector2(tVect.x, tVect.z);
+
+ //Now see if these two lines intersect:
+ if (GSD.GSDRootUtil.Intersects2D(ref iVect1, ref iVect2, ref xVect1, ref xVect2, out IntersectPoint2D))
+ {
+ //Get height of intersection on primary road:
+ float tHeight = 0f;
+ float hParam = tRoad.GSDSpline.GetClosestParam(new Vector3(IntersectPoint2D.x, 0f, IntersectPoint2D.y));
+ Vector3 hVect = tRoad.GSDSpline.GetSplineValue(hParam);
+ tHeight = hVect.y;
+
+ //if any intersections already within 75m or 100m, dont create intersection here
+ Object[] AllInterectionObjects = Object.FindObjectsOfType();
+ foreach (GSDRoadIntersection GSDRI in AllInterectionObjects)
+ {
+ if (Vector2.Distance(new Vector2(GSDRI.transform.position.x, GSDRI.transform.position.z), IntersectPoint2D) < 100f)
+ {
+ goto NoIntersectionCreation;
+ }
+ }
+
+ GSDSplineN IntersectionNode1 = null;
+ GSDSplineN IntersectionNode2 = null;
+ Vector3 IntersectionPoint3D = new Vector3(IntersectPoint2D.x, tHeight, IntersectPoint2D.y);
+ //Debug.Log("Instersect found road: " + xRoad.transform.name + " at point: " + IntersectionPoint3D.ToString());
+
+ //Check primary road if any nodes are nearby and usable for intersection
+ foreach (GSDSplineN tNode in tRoad.GSDSpline.mNodes)
+ {
+ if (tNode.IsLegitimate())
+ {
+ if (Vector2.Distance(new Vector2(tNode.transform.position.x, tNode.transform.position.z), IntersectPoint2D) < 30f)
+ {
+ IntersectionNode1 = tNode;
+ IntersectionNode1.transform.position = IntersectionPoint3D;
+ IntersectionNode1.pos = IntersectionPoint3D;
+ break;
+ }
+ }
+ }
+
+ //Check secondary road if any nodes are nearby and usable for intersection
+ foreach (GSDSplineN tNode in xRoad.GSDSpline.mNodes)
+ {
+ if (tNode.IsLegitimate())
+ {
+ if (Vector2.Distance(new Vector2(tNode.transform.position.x, tNode.transform.position.z), IntersectPoint2D) < 30f)
+ {
+ IntersectionNode2 = tNode;
+ IntersectionNode2.transform.position = IntersectionPoint3D;
+ IntersectionNode2.pos = IntersectionPoint3D;
+ break;
+ }
+ }
+ }
+
+ //Check if any of the nodes are null. If so, need to insert node. And maybe update it.
+ if (IntersectionNode1 == null)
+ {
+ IntersectionNode1 = InsertNode_Programmatically(tRoad, IntersectionPoint3D);
+ }
+ if (IntersectionNode2 == null)
+ {
+ IntersectionNode2 = InsertNode_Programmatically(xRoad, IntersectionPoint3D);
+ }
+
+ //Now create the fucking intersection:
+ GameObject tInter = GSD.Roads.GSDIntersections.CreateIntersection(IntersectionNode1, IntersectionNode2);
+ GSDRoadIntersection GSDRI_JustCreated = tInter.GetComponent();
+ GSDRI_JustCreated.iStopType = iStopType;
+ GSDRI_JustCreated.rType = rType;
+ }
+
+ NoIntersectionCreation:
+ //Gibberish to get rid of warnings:
+ int xxx = 1;
+ if (xxx == 1)
+ {
+ xxx = 2;
+ }
+ }
+ if (EarlyDistanceFound)
+ {
+ break;
+ }
+ }
+ }
+ }
+ }
+ }
+#endif
+}
\ No newline at end of file
diff --git a/GSDRoadConnector.cs b/GSDRoadConnector.cs
index cd6ef715..74ae4e41 100644
--- a/GSDRoadConnector.cs
+++ b/GSDRoadConnector.cs
@@ -1,73 +1,85 @@
-using System.Collections;
-using System.Collections.Generic;
-using UnityEngine;
-#if UNITY_EDITOR
-using UnityEditor;
-#endif
-[ExecuteInEditMode]
-public class GSDRoadConnector : MonoBehaviour
-{
- public GSDSplineN connectedNode;
- [HideInInspector]
- public GSDOffRoadObject obj { get { return transform.parent.GetComponent(); } }
-
-#if UNITY_EDITOR
- void OnDrawGizmos()
- {
- Gizmos.color = GSDOffRoadObject.Color_NodeOffRoadColor;
- Gizmos.DrawCube(transform.position + new Vector3(0f, 6f, 0f), new Vector3(2f, 11f, 2f));
- }
- void OnDrawGizmosSelected()
- {
- Gizmos.color = GSDOffRoadObject.Color_NodeOffRoadSelectedColor;
- Gizmos.DrawCube(transform.position + new Vector3(0f, 6.25f, 0f), new Vector3(3.5f, 12.5f, 3.5f));
- }
-
- public void ConnectToNode(GSDSplineN node)
- {
- Debug.Log("Would connect to " + node);
- connectedNode = node;
- connectedNode.transform.position = transform.position;
- connectedNode.GSDSpline.tRoad.UpdateRoad();
- }
-
- // Update is called once per frame
- void Update()
- {
- if (connectedNode != null)
- {
- if (obj == null)
- {
- Debug.LogError("Parent should have GSDOffRoadObject component attached");
- }
- if (connectedNode.transform.position != transform.position)
- {
- connectedNode.transform.position = transform.position;
- connectedNode.GSDSpline.tRoad.UpdateRoad();
- }
- }
- }
-#endif
-}
-
-#if UNITY_EDITOR
-[CustomEditor(typeof(GSDRoadConnector))]
-public class GSDRoadConnectorEditor : Editor
-{
- public GSDRoadConnector tConnector { get { return (GSDRoadConnector)target; } }
- public override void OnInspectorGUI()
- {
- if (tConnector.connectedNode != null)
- {
- EditorGUILayout.BeginVertical();
- EditorGUILayout.LabelField("Off-road connection:", EditorStyles.boldLabel);
- EditorGUILayout.LabelField(tConnector.connectedNode.GSDSpline.tRoad.name + " to " + tConnector.obj.name);
- if (GUILayout.Button("Break connection"))
- {
- tConnector.connectedNode = null;
- }
- EditorGUILayout.EndVertical();
- }
- }
-}
+#region Imports
+using System.Collections;
+using System.Collections.Generic;
+using UnityEngine;
+#if UNITY_EDITOR
+using UnityEditor;
+#endif
+#endregion
+
+
+[ExecuteInEditMode]
+public class GSDRoadConnector : MonoBehaviour
+{
+ public GSDSplineN connectedNode;
+ [HideInInspector]
+ public GSDOffRoadObject obj { get { return transform.parent.GetComponent(); } }
+
+
+#if UNITY_EDITOR
+ void OnDrawGizmos()
+ {
+ Gizmos.color = GSDOffRoadObject.Color_NodeOffRoadColor;
+ Gizmos.DrawCube(transform.position + new Vector3(0f, 6f, 0f), new Vector3(2f, 11f, 2f));
+ }
+
+
+ void OnDrawGizmosSelected()
+ {
+ Gizmos.color = GSDOffRoadObject.Color_NodeOffRoadSelectedColor;
+ Gizmos.DrawCube(transform.position + new Vector3(0f, 6.25f, 0f), new Vector3(3.5f, 12.5f, 3.5f));
+ }
+
+
+ public void ConnectToNode(GSDSplineN node)
+ {
+ Debug.Log("Would connect to " + node);
+ connectedNode = node;
+ connectedNode.transform.position = transform.position;
+ connectedNode.GSDSpline.tRoad.UpdateRoad();
+ }
+
+
+ // Update is called once per frame
+ void Update()
+ {
+ if (connectedNode != null)
+ {
+ if (obj == null)
+ {
+ Debug.LogError("Parent should have GSDOffRoadObject component attached");
+ }
+ if (connectedNode.transform.position != transform.position)
+ {
+ connectedNode.transform.position = transform.position;
+ connectedNode.GSDSpline.tRoad.UpdateRoad();
+ }
+ }
+ }
+#endif
+}
+
+
+#if UNITY_EDITOR
+[CustomEditor(typeof(GSDRoadConnector))]
+public class GSDRoadConnectorEditor : Editor
+{
+ public GSDRoadConnector tConnector { get { return (GSDRoadConnector) target; } }
+
+
+ public override void OnInspectorGUI()
+ {
+ if (tConnector.connectedNode != null)
+ {
+ EditorGUILayout.BeginVertical();
+ EditorGUILayout.LabelField("Off-road connection:", EditorStyles.boldLabel);
+ EditorGUILayout.LabelField(tConnector.connectedNode.GSDSpline.tRoad.name + " to " + tConnector.obj.name);
+ if (GUILayout.Button("Break connection"))
+ {
+ tConnector.connectedNode = null;
+ }
+ EditorGUILayout.EndVertical();
+ }
+ }
+}
#endif
\ No newline at end of file
diff --git a/GSDRoadEdgeObjects.cs b/GSDRoadEdgeObjects.cs
index 22b09fbc..f5297890 100755
--- a/GSDRoadEdgeObjects.cs
+++ b/GSDRoadEdgeObjects.cs
@@ -7,6 +7,8 @@
using System.IO;
#endif
#endregion
+
+
namespace GSD.Roads.EdgeObjects
{
#if UNITY_EDITOR
@@ -27,11 +29,13 @@ public class EdgeObjectMaker
public string EdgeMaterial2String = null;
public bool bMatchTerrain = true;
+
//Temp editor buffers:
public bool bEdgeSignLabelInit = false;
public bool bEdgeSignLabel = false;
public string EdgeSignLabel = "";
+
public bool bCombineMesh = false;
public bool bCombineMeshCollider = false;
public GameObject MasterObj = null;
@@ -43,7 +47,8 @@ public class EdgeObjectMaker
public bool bToggle = false;
public bool bIsBridge = false;
- //Horizontal offsets:
+
+ #region Horizontal offsets:
public float HorizontalSep = 5f;
public AnimationCurve HorizontalCurve;
public float HorizCurve_tempchecker1 = 0f;
@@ -54,7 +59,10 @@ public class EdgeObjectMaker
public float HorizCurve_tempchecker6 = 0f;
public float HorizCurve_tempchecker7 = 0f;
public float HorizCurve_tempchecker8 = 0f;
- //Vertical offsets:
+ #endregion
+
+
+ #region Vertical offsets:
public float VerticalRaise = 0f;
public AnimationCurve VerticalCurve;
public float VerticalCurve_tempchecker1 = 0f;
@@ -65,24 +73,39 @@ public class EdgeObjectMaker
public float VerticalCurve_tempchecker6 = 0f;
public float VerticalCurve_tempchecker7 = 0f;
public float VerticalCurve_tempchecker8 = 0f;
+ #endregion
+
+ // Custom Rotation
public Vector3 CustomRotation = default(Vector3);
public bool bOncomingRotation = true;
+
+
+ // EdgeObject is static
public bool bStatic = true;
+
+ // The CustomScale of the EdgeObject
public Vector3 CustomScale = new Vector3(1f, 1f, 1f);
+
+ // Start and EndTime
public float StartTime = 0f;
public float EndTime = 1f;
+
+
public float SingleOnlyBridgePercent = 0f;
public Vector3 StartPos = default(Vector3);
public Vector3 EndPos = default(Vector3);
public bool bSingle = false;
+
+ // Should it be only on a single position
public float SinglePosition;
public bool bStartMatchRoadDefinition = false;
public float StartMatchRoadDef = 0f;
+ // EdgeObjectName
public string tName = "EdgeObject";
public string ThumbString = "";
public string Desc = "";
@@ -90,13 +113,14 @@ public class EdgeObjectMaker
public EdgeObjectEditorMaker EM;
+
public EdgeObjectMaker Copy()
{
EdgeObjectMaker EOM = new EdgeObjectMaker();
EOM.EdgeObjectString = EdgeObjectString;
#if UNITY_EDITOR
- EOM.EdgeObject = (GameObject)UnityEditor.AssetDatabase.LoadAssetAtPath(EdgeObjectString, typeof(GameObject));
+ EOM.EdgeObject = (GameObject) UnityEditor.AssetDatabase.LoadAssetAtPath(EdgeObjectString, typeof(GameObject));
#endif
EOM.bIsGSD = bIsGSD;
@@ -136,9 +160,9 @@ public EdgeObjectMaker Copy()
EOM.VerticalCurve = new AnimationCurve();
if (VerticalCurve != null && VerticalCurve.keys.Length > 0)
{
- for (int i = 0; i < VerticalCurve.keys.Length; i++)
+ for (int index = 0; index < VerticalCurve.keys.Length; index++)
{
- EOM.VerticalCurve.AddKey(VerticalCurve.keys[i]);
+ EOM.VerticalCurve.AddKey(VerticalCurve.keys[index]);
}
}
@@ -161,12 +185,15 @@ public EdgeObjectMaker Copy()
return EOM;
}
+
public void UpdatePositions()
{
StartPos = tNode.GSDSpline.GetSplineValue(StartTime);
- EndPos = tNode.GSDSpline.GetSplineValue(EndTime);
+ EndPos = tNode.GSDSpline.GetSplineValue(EndTime); // FH EXPERIMENTAL fix for NodeEdgeObjectPlacement?
+ // This does not affect the 1f = -0.0001f bug
}
+
#region "Library"
public void SetupUniqueIdentifier()
{
@@ -176,6 +203,7 @@ public void SetupUniqueIdentifier()
}
}
+
public void SaveToLibrary(string fName = "", bool bIsDefault = false)
{
EdgeObjectLibraryMaker ELM = new EdgeObjectLibraryMaker();
@@ -197,6 +225,7 @@ public void SaveToLibrary(string fName = "", bool bIsDefault = false)
GSDRootUtil.CreateXML(ref tPath, ELM);
}
+
public void LoadFromLibrary(string xName, bool bIsQuickAdd = false)
{
GSDRootUtil.Dir_GetLibrary_CheckSpecialDirs();
@@ -206,17 +235,18 @@ public void LoadFromLibrary(string xName, bool bIsQuickAdd = false)
{
tPath = xPath + "Q/EOM" + xName + ".gsd";
}
- EdgeObjectLibraryMaker ELM = (EdgeObjectLibraryMaker)GSDRootUtil.LoadXML(ref tPath);
+ EdgeObjectLibraryMaker ELM = (EdgeObjectLibraryMaker) GSDRootUtil.LoadXML(ref tPath);
ELM.LoadTo(this);
bNeedsUpdate = true;
}
+
public void LoadFromLibraryWizard(string xName)
{
GSDRootUtil.Dir_GetLibrary_CheckSpecialDirs();
string xPath = GSDRootUtil.Dir_GetLibrary();
string tPath = xPath + "W/" + xName + ".gsd";
- EdgeObjectLibraryMaker ELM = (EdgeObjectLibraryMaker)GSDRootUtil.LoadXML(ref tPath);
+ EdgeObjectLibraryMaker ELM = (EdgeObjectLibraryMaker) GSDRootUtil.LoadXML(ref tPath);
ELM.LoadTo(this);
bNeedsUpdate = true;
}
@@ -229,16 +259,18 @@ public string ConvertToString()
return GSDRootUtil.GetString(ELM);
}
+
public void LoadFromLibraryBulk(ref EdgeObjectLibraryMaker ELM)
{
ELM.LoadTo(this);
}
+
public static EdgeObjectLibraryMaker ELMFromData(string tData)
{
try
{
- EdgeObjectLibraryMaker ELM = (EdgeObjectLibraryMaker)GSDRootUtil.LoadData(ref tData);
+ EdgeObjectLibraryMaker ELM = (EdgeObjectLibraryMaker) GSDRootUtil.LoadData(ref tData);
return ELM;
}
catch
@@ -247,6 +279,7 @@ public static EdgeObjectLibraryMaker ELMFromData(string tData)
}
}
+
public static void GetLibraryFiles(out string[] tNames, out string[] tPaths, bool bIsDefault = false)
{
#if UNITY_WEBPLAYER
@@ -295,10 +328,14 @@ public static void GetLibraryFiles(out string[] tNames, out string[] tPaths, boo
#endif
}
+
private void SaveMesh(Mesh tMesh, bool bIsCollider)
{
#if UNITY_EDITOR
- if (!tNode.GSDSpline.tRoad.GSDRS.opt_bSaveMeshes) { return; }
+ if (!tNode.GSDSpline.tRoad.GSDRS.opt_bSaveMeshes)
+ {
+ return;
+ }
//string tSceneName = System.IO.Path.GetFileName(UnityEditor.EditorApplication.currentScene).ToLower().Replace(".unity","");
string tSceneName = UnityEditor.SceneManagement.EditorSceneManager.GetActiveScene().name;
@@ -325,6 +362,7 @@ private void SaveMesh(Mesh tMesh, bool bIsCollider)
#endif
}
+
#region "Library object"
[System.Serializable]
public class EdgeObjectLibraryMaker
@@ -370,6 +408,7 @@ public class EdgeObjectLibraryMaker
public string Desc = "";
public string DisplayName = "";
+
public void Setup(EdgeObjectMaker EOM)
{
EdgeObjectString = EOM.EdgeObjectString;
@@ -405,21 +444,22 @@ public void Setup(EdgeObjectMaker EOM)
DisplayName = EOM.DisplayName;
}
+
public void LoadTo(EdgeObjectMaker EOM)
{
EOM.EdgeObjectString = EdgeObjectString;
#if UNITY_EDITOR
- EOM.EdgeObject = (GameObject)UnityEditor.AssetDatabase.LoadAssetAtPath(EdgeObjectString, typeof(GameObject));
+ EOM.EdgeObject = (GameObject) UnityEditor.AssetDatabase.LoadAssetAtPath(EdgeObjectString, typeof(GameObject));
#endif
EOM.bMaterialOverride = bMaterialOverride;
#if UNITY_EDITOR
if (EdgeMaterial1String.Length > 0)
{
- EOM.EdgeMaterial1 = (Material)UnityEditor.AssetDatabase.LoadAssetAtPath(EdgeMaterial1String, typeof(Material));
+ EOM.EdgeMaterial1 = (Material) UnityEditor.AssetDatabase.LoadAssetAtPath(EdgeMaterial1String, typeof(Material));
}
if (EdgeMaterial2String.Length > 0)
{
- EOM.EdgeMaterial2 = (Material)UnityEditor.AssetDatabase.LoadAssetAtPath(EdgeMaterial2String, typeof(Material));
+ EOM.EdgeMaterial2 = (Material) UnityEditor.AssetDatabase.LoadAssetAtPath(EdgeMaterial2String, typeof(Material));
}
#endif
@@ -459,16 +499,32 @@ public void LoadTo(EdgeObjectMaker EOM)
public class EdgeObjectEditorMaker
{
public GameObject EdgeObject = null;
+
+ // Should we combine the Mesh?
public bool bCombineMesh = false;
+
+ // Should it also combine the Colliders
public bool bCombineMeshCollider = false;
+
+ // Seems to be a List with all Locations for the EdgeObjects
public List EdgeObjectLocations;
+ // Seems to be a List with all Rotations for the EdgeObjects
public List EdgeObjectRotations;
public GSD.Roads.SignPlacementSubTypeEnum SubType = GSD.Roads.SignPlacementSubTypeEnum.Right;
+
+ // Sounds like Speration
public float MeterSep = 5f;
+
+ // A Toggle for? for What?
public bool bToggle = false;
+
+ // Is it Bridge? I think?
public bool bIsBridge = false;
+
+ // ??
public bool bIsGSD = false;
+ // Materials of EdgeObject
public bool bMaterialOverride = false;
public Material EdgeMaterial1;
public Material EdgeMaterial2;
@@ -487,8 +543,10 @@ public class EdgeObjectEditorMaker
public Vector3 CustomScale = new Vector3(1f, 1f, 1f);
+ // Start and EndTime
public float StartTime = 0f;
public float EndTime = 1f;
+
public float SingleOnlyBridgePercent = 0f;
public bool bSingle = false;
public float SinglePosition;
@@ -510,27 +568,40 @@ public void Setup(EdgeObjectMaker EOM)
EdgeMaterial1 = EOM.EdgeMaterial1;
EdgeMaterial2 = EOM.EdgeMaterial2;
+ // Horizontal
HorizontalSep = EOM.HorizontalSep;
HorizontalCurve = EOM.HorizontalCurve;
+
+ // Vertical
VerticalRaise = EOM.VerticalRaise;
VerticalCurve = EOM.VerticalCurve;
+
bMatchTerrain = EOM.bMatchTerrain;
+ // Rotation
CustomRotation = EOM.CustomRotation;
bOncomingRotation = EOM.bOncomingRotation;
+
CustomScale = EOM.CustomScale;
bStatic = EOM.bStatic;
+
+ // Is it Single and if yes Position
bSingle = EOM.bSingle;
SinglePosition = EOM.SinglePosition;
+
+ // Name of EdgeObject??
tName = EOM.tName;
+ // Start and EndTime of EdgeObject
StartTime = EOM.StartTime;
EndTime = EOM.EndTime;
+
SingleOnlyBridgePercent = EOM.SingleOnlyBridgePercent;
bStartMatchRoadDefinition = EOM.bStartMatchRoadDefinition;
StartMatchRoadDef = EOM.StartMatchRoadDef;
}
+
public void LoadTo(EdgeObjectMaker EOM)
{
EOM.EdgeObject = EdgeObject;
@@ -555,47 +626,130 @@ public void LoadTo(EdgeObjectMaker EOM)
EOM.bOncomingRotation = bOncomingRotation;
EOM.bStatic = bStatic;
EOM.bSingle = bSingle;
+
+
EOM.StartTime = StartTime;
EOM.EndTime = EndTime;
+
+
EOM.SinglePosition = SinglePosition;
+
+
EOM.tName = tName;
EOM.SingleOnlyBridgePercent = SingleOnlyBridgePercent;
EOM.bStartMatchRoadDefinition = bStartMatchRoadDefinition;
EOM.StartMatchRoadDef = StartMatchRoadDef;
}
+
public bool IsEqual(EdgeObjectMaker EOM)
{
- if (EOM.EdgeObject != EdgeObject) { return false; }
- if (EOM.bMaterialOverride != bMaterialOverride) { return false; }
- if (EOM.EdgeMaterial1 != EdgeMaterial1) { return false; }
- if (EOM.EdgeMaterial2 != EdgeMaterial2) { return false; }
-
- if (EOM.bCombineMesh != bCombineMesh) { return false; }
- if (EOM.bCombineMeshCollider != bCombineMeshCollider) { return false; }
- if (EOM.SubType != SubType) { return false; }
- if (!GSDRootUtil.IsApproximately(EOM.MeterSep, MeterSep, 0.001f)) { return false; }
- // if(EOM.bToggle != bToggle){ return false; }
-
- if (!GSDRootUtil.IsApproximately(EOM.HorizontalSep, HorizontalSep, 0.001f)) { return false; }
- if (EOM.HorizontalCurve != HorizontalCurve) { return false; }
- if (!GSDRootUtil.IsApproximately(EOM.VerticalRaise, VerticalRaise, 0.001f)) { return false; }
- if (EOM.VerticalCurve != VerticalCurve) { return false; }
- if (EOM.bMatchTerrain != bMatchTerrain) { return false; }
-
- if (EOM.CustomRotation != CustomRotation) { return false; }
- if (EOM.CustomScale != CustomScale) { return false; }
- if (EOM.bOncomingRotation != bOncomingRotation) { return false; }
- if (EOM.bStatic != bStatic) { return false; }
- if (EOM.bSingle != bSingle) { return false; }
-
- if (!GSDRootUtil.IsApproximately(EOM.SinglePosition, SinglePosition, 0.001f)) { return false; }
- if (!GSDRootUtil.IsApproximately(EOM.StartTime, StartTime, 0.001f)) { return false; }
- if (!GSDRootUtil.IsApproximately(EOM.EndTime, EndTime, 0.001f)) { return false; }
- if (EOM.tName != tName) { return false; }
- if (!GSDRootUtil.IsApproximately(EOM.SingleOnlyBridgePercent, SingleOnlyBridgePercent, 0.001f)) { return false; }
- if (EOM.bStartMatchRoadDefinition != bStartMatchRoadDefinition) { return false; }
- if (!GSDRootUtil.IsApproximately(EOM.StartMatchRoadDef, StartMatchRoadDef, 0.001f)) { return false; }
+ if (EOM.EdgeObject != EdgeObject)
+ {
+ return false;
+ }
+ if (EOM.bMaterialOverride != bMaterialOverride)
+ {
+ return false;
+ }
+ if (EOM.EdgeMaterial1 != EdgeMaterial1)
+ {
+ return false;
+ }
+ if (EOM.EdgeMaterial2 != EdgeMaterial2)
+ {
+ return false;
+ }
+
+ if (EOM.bCombineMesh != bCombineMesh)
+ {
+ return false;
+ }
+ if (EOM.bCombineMeshCollider != bCombineMeshCollider)
+ {
+ return false;
+ }
+ if (EOM.SubType != SubType)
+ {
+ return false;
+ }
+ if (!GSDRootUtil.IsApproximately(EOM.MeterSep, MeterSep, 0.001f))
+ {
+ return false;
+ }
+ // if(EOM.bToggle != bToggle)
+ // { return false; }
+
+ if (!GSDRootUtil.IsApproximately(EOM.HorizontalSep, HorizontalSep, 0.001f))
+ {
+ return false;
+ }
+ if (EOM.HorizontalCurve != HorizontalCurve)
+ {
+ return false;
+ }
+ if (!GSDRootUtil.IsApproximately(EOM.VerticalRaise, VerticalRaise, 0.001f))
+ {
+ return false;
+ }
+ if (EOM.VerticalCurve != VerticalCurve)
+ {
+ return false;
+ }
+ if (EOM.bMatchTerrain != bMatchTerrain)
+ {
+ return false;
+ }
+
+ if (EOM.CustomRotation != CustomRotation)
+ {
+ return false;
+ }
+ if (EOM.CustomScale != CustomScale)
+ {
+ return false;
+ }
+ if (EOM.bOncomingRotation != bOncomingRotation)
+ {
+ return false;
+ }
+ if (EOM.bStatic != bStatic)
+ {
+ return false;
+ }
+ if (EOM.bSingle != bSingle)
+ {
+ return false;
+ }
+
+ if (!GSDRootUtil.IsApproximately(EOM.SinglePosition, SinglePosition, 0.001f))
+ {
+ return false;
+ }
+ if (!GSDRootUtil.IsApproximately(EOM.StartTime, StartTime, 0.001f))
+ {
+ return false;
+ }
+ if (!GSDRootUtil.IsApproximately(EOM.EndTime, EndTime, 0.001f))
+ {
+ return false;
+ }
+ if (EOM.tName != tName)
+ {
+ return false;
+ }
+ if (!GSDRootUtil.IsApproximately(EOM.SingleOnlyBridgePercent, SingleOnlyBridgePercent, 0.001f))
+ {
+ return false;
+ }
+ if (EOM.bStartMatchRoadDefinition != bStartMatchRoadDefinition)
+ {
+ return false;
+ }
+ if (!GSDRootUtil.IsApproximately(EOM.StartMatchRoadDef, StartMatchRoadDef, 0.001f))
+ {
+ return false;
+ }
return true;
}
@@ -611,27 +765,32 @@ public void Setup(bool bCollect = true)
{
Setup_Do(bCollect, ref tErrorObjs);
}
- catch (System.Exception e)
+ catch (System.Exception exception)
{
if (tErrorObjs != null && tErrorObjs.Count > 0)
{
int tCount = tErrorObjs.Count;
- for (int i = 0; i < tCount; i++)
+ for (int index = 0; index < tCount; index++)
{
- if (tErrorObjs[i] != null)
+ if (tErrorObjs[index] != null)
{
- Object.DestroyImmediate(tErrorObjs[i]);
+ Object.DestroyImmediate(tErrorObjs[index]);
}
}
- throw e;
+ throw exception;
}
}
#endif
}
+
+
private void Setup_Do(bool bCollect, ref List tErrorObjs)
{
#if UNITY_EDITOR
- if (EdgeObjects == null) { EdgeObjects = new List(); }
+ if (EdgeObjects == null)
+ {
+ EdgeObjects = new List();
+ }
if (HorizontalCurve == null)
{
HorizontalCurve = new AnimationCurve();
@@ -648,9 +807,16 @@ private void Setup_Do(bool bCollect, ref List tErrorObjs)
SetupUniqueIdentifier();
SetupLocations();
+
EdgeObjectString = GSDRootUtil.GetPrefabString(EdgeObject);
- if (EdgeMaterial1 != null) { EdgeMaterial1String = UnityEditor.AssetDatabase.GetAssetPath(EdgeMaterial1); }
- if (EdgeMaterial2 != null) { EdgeMaterial2String = UnityEditor.AssetDatabase.GetAssetPath(EdgeMaterial2); }
+ if (EdgeMaterial1 != null)
+ {
+ EdgeMaterial1String = UnityEditor.AssetDatabase.GetAssetPath(EdgeMaterial1);
+ }
+ if (EdgeMaterial2 != null)
+ {
+ EdgeMaterial2String = UnityEditor.AssetDatabase.GetAssetPath(EdgeMaterial2);
+ }
EdgeObjects = new List();
Quaternion xRot = default(Quaternion);
@@ -658,8 +824,10 @@ private void Setup_Do(bool bCollect, ref List tErrorObjs)
xRot.eulerAngles = CustomRotation;
int lCount = EdgeObjectLocations.Count;
// Quaternion OrigRot = Quaternion.identity;
+
Material[] tMats = null;
GameObject tObj = null;
+
if (EdgeObject != null)
{
GameObject mObj = new GameObject(EdgeObject.name);
@@ -673,13 +841,14 @@ private void Setup_Do(bool bCollect, ref List tErrorObjs)
{
if (EdgeObjectRotations[j] == default(Vector3))
{
- tObj = (GameObject)GameObject.Instantiate(EdgeObject);
+ tObj = GameObject.Instantiate(EdgeObject); // (GameObject) removed; FH Experimental 25.01.19
tErrorObjs.Add(tObj);
tObj.transform.position = EdgeObjectLocations[j];
}
else
{
- tObj = (GameObject)GameObject.Instantiate(EdgeObject, EdgeObjectLocations[j], Quaternion.LookRotation(EdgeObjectRotations[j]));
+ tObj = GameObject.Instantiate(EdgeObject, EdgeObjectLocations[j], Quaternion.LookRotation(EdgeObjectRotations[j]));
+ // (GameObject) removed, since Instantiate returns a GameObject anyway; FH Experimental 25.01.19
tErrorObjs.Add(tObj);
}
// OrigRot = tObj.transform.rotation;
@@ -782,27 +951,36 @@ private void Setup_Do(bool bCollect, ref List tErrorObjs)
System.Array.Copy(kUV, hUV[j], OrigMVL);
Vector3 tVect = default(Vector3);
- for (int i = 0; i < OrigMVL; i++)
+ for (int index = 0; index < OrigMVL; index++)
{
- tVect = hVerts[j][i];
- hVerts[j][i] = tTrans.rotation * tVect;
- hVerts[j][i] += tTrans.localPosition;
+ tVect = hVerts[j][index];
+ hVerts[j][index] = tTrans.rotation * tVect;
+ hVerts[j][index] += tTrans.localPosition;
}
}
GameObject xObj = new GameObject(tName);
MeshRenderer MR = xObj.GetComponent();
- if (MR == null) { MR = xObj.AddComponent(); }
+ if (MR == null)
+ {
+ MR = xObj.AddComponent();
+ }
xObj.isStatic = bStatic;
xObj.transform.parent = MasterObj.transform;
tErrorObjs.Add(xObj);
xObj.transform.name = xObj.transform.name + "Combined";
xObj.transform.name = xObj.transform.name.Replace("(Clone)", "");
MeshFilter MF = xObj.GetComponent();
- if (MF == null) { MF = xObj.AddComponent(); }
+ if (MF == null)
+ {
+ MF = xObj.AddComponent();
+ }
MF.sharedMesh = GSDCombineMeshes(ref hVerts, ref hTris, ref hUV, OrigMVL, OrigTriCount);
MeshCollider MC = xObj.GetComponent();
- if (MC == null) { MC = xObj.AddComponent(); }
+ if (MC == null)
+ {
+ MC = xObj.AddComponent();
+ }
xObj.transform.position = tNode.transform.position;
xObj.transform.rotation = Quaternion.identity;
@@ -823,7 +1001,10 @@ private void Setup_Do(bool bCollect, ref List tErrorObjs)
}
BoxCollider BC = xObj.GetComponent();
- if (BC != null) { Object.DestroyImmediate(BC); }
+ if (BC != null)
+ {
+ Object.DestroyImmediate(BC);
+ }
int cCount = xObj.transform.childCount;
int spamc = 0;
while (cCount > 0 && spamc < 10)
@@ -835,7 +1016,10 @@ private void Setup_Do(bool bCollect, ref List tErrorObjs)
if (bCombineMeshCollider)
{
- if (MC == null) { MC = xObj.AddComponent(); }
+ if (MC == null)
+ {
+ MC = xObj.AddComponent();
+ }
MC.sharedMesh = MF.sharedMesh;
}
else
@@ -863,8 +1047,16 @@ private void Setup_Do(bool bCollect, ref List tErrorObjs)
}
//Zero these out, as they are not needed anymore:
- if (EdgeObjectLocations != null) { EdgeObjectLocations.Clear(); EdgeObjectLocations = null; }
- if (EdgeObjectRotations != null) { EdgeObjectRotations.Clear(); EdgeObjectRotations = null; }
+ if (EdgeObjectLocations != null)
+ {
+ EdgeObjectLocations.Clear();
+ EdgeObjectLocations = null;
+ }
+ if (EdgeObjectRotations != null)
+ {
+ EdgeObjectRotations.Clear();
+ EdgeObjectRotations = null;
+ }
if (bCollect)
{
@@ -873,6 +1065,8 @@ private void Setup_Do(bool bCollect, ref List tErrorObjs)
#endif
}
+
+ // FH_Tag Optimizable
private void SetupLocations()
{
float OrigHeight = 0f;
@@ -898,19 +1092,31 @@ private void SetupLocations()
// Vector3 lVect = default(Vector3);
// float fTimeMax = -1f;
int mCount = tNode.GSDSpline.GetNodeCount();
- if (tNode.idOnSpline >= mCount - 1) { return; }
+ if (tNode.idOnSpline >= mCount - 1)
+ {
+ return;
+ }
// fTimeMax = tNode.GSDSpline.mNodes[tNode.idOnSpline+1].tTime;
// float tStep = -1f;
Vector3 tVect = default(Vector3);
Vector3 POS = default(Vector3);
+
// tStep = MeterSep/tNode.GSDSpline.distance;
//Destroy old objects:
ClearEOM();
//Make sure old locs and rots are fresh:
- if (EdgeObjectLocations != null) { EdgeObjectLocations.Clear(); EdgeObjectLocations = null; }
+ if (EdgeObjectLocations != null)
+ {
+ EdgeObjectLocations.Clear();
+ EdgeObjectLocations = null;
+ }
EdgeObjectLocations = new List();
- if (EdgeObjectRotations != null) { EdgeObjectRotations.Clear(); EdgeObjectRotations = null; }
+ if (EdgeObjectRotations != null)
+ {
+ EdgeObjectRotations.Clear();
+ EdgeObjectRotations = null;
+ }
EdgeObjectRotations = new List();
bool bIsCenter = GSDRootUtil.IsApproximately(HorizontalSep, 0f, 0.02f);
@@ -920,8 +1126,11 @@ private void SetupLocations()
Ray tRay = default(Ray);
RaycastHit[] tRayHit = null;
float[] tRayYs = null;
- if (bSingle)
+ if (bSingle)
{
+ // If the Object is a SingleObject // FH 03.02.19
+
+
tNode.GSDSpline.GetSplineValue_Both(SinglePosition, out tVect, out POS);
OrigHeight = tVect.y;
@@ -967,6 +1176,7 @@ private void SetupLocations()
}
else
{
+ // If this Object is not marked as a single Object // FH 03.02.19
//Get the vector series that this mesh is interpolated on:
List tTimes = new List();
@@ -985,15 +1195,22 @@ private void SetupLocations()
fHeight = HorizontalCurve.Evaluate((cTime - FakeStartTime) / pDiffTime);
CurrentH = fHeight * HorizontalSep;
+ // FH 06.02.19
+ // Hoirzontal1:
if (CurrentH < 0f)
{
- CurrentH *= -1f;
- tVect = (tVect + new Vector3(CurrentH * -POS.normalized.z, 0, CurrentH * POS.normalized.x));
+ CurrentH *= -1f; // So we get a positiv Number again
+ tVect = (tVect + new Vector3(CurrentH * (-POS.normalized.x + (POS.normalized.y / 2)), 0, CurrentH * (POS.normalized.z + +(POS.normalized.y / 2))));
+ // I implemented the POS.normalized.y value to make sure we get to a value of 1 overall to ensure 50m distance, is this mathematicly correct?? FH 10.02.19
+ // Original: tVect = (tVect + new Vector3(CurrentH * -POS.normalized.z, 0, CurrentH * POS.normalized.x));
}
else if (CurrentH > 0f)
{
- tVect = (tVect + new Vector3(CurrentH * POS.normalized.z, 0, CurrentH * -POS.normalized.x));
+ tVect = (tVect + new Vector3(CurrentH * (-POS.normalized.x + (POS.normalized.y / 2)), 0, CurrentH * (POS.normalized.z + (POS.normalized.y / 2))));
+ // I implemented the POS.normalized.y value to make sure we get to a value of 1 overall to ensure 50m distance, is this mathematicly correct?? FH 10.02.19
+ //Original: tVect = (tVect + new Vector3(CurrentH * POS.normalized.z, 0, CurrentH * -POS.normalized.x));
}
+ // FH 06.02.19
xVect = (POS.normalized * MeterSep) + tVect;
@@ -1011,22 +1228,27 @@ private void SetupLocations()
float mMin = FakeStartTime;
float mMax = EndTime;
float tPercent = 0;
- for (int i = 0; i < vSeriesCount; i++)
+ for (int index = 0; index < vSeriesCount; index++)
{
- tNode.GSDSpline.GetSplineValue_Both(tTimes[i], out tVect, out POS);
+ tNode.GSDSpline.GetSplineValue_Both(tTimes[index], out tVect, out POS);
- tPercent = ((tTimes[i] - mMin) / (mMax - mMin));
+ tPercent = ((tTimes[index] - mMin) / (mMax - mMin));
//Horiz:
CurrentH = (HorizontalCurve.Evaluate(tPercent) * HorizontalSep);
if (CurrentH < 0f)
{
CurrentH *= -1f;
- tVect = (tVect + new Vector3(CurrentH * -POS.normalized.z, 0, CurrentH * POS.normalized.x));
+ // FH 03.02.19 // Why has this Code a "wrong" logic, it multiplies z to x and x to z.
+ // Original Code: tVect = (tVect + new Vector3(CurrentH * -POS.normalized.z, 0, CurrentH * POS.normalized.x));
+ tVect = (tVect + new Vector3(CurrentH * (-POS.normalized.z + (POS.normalized.y / 2)), 0, CurrentH * (POS.normalized.x + (POS.normalized.y / 2))));
}
else if (CurrentH > 0f)
{
- tVect = (tVect + new Vector3(CurrentH * POS.normalized.z, 0, CurrentH * -POS.normalized.x));
+ // FH 03.02.19
+ // Original Code: tVect = (tVect + new Vector3(CurrentH * POS.normalized.z, 0, CurrentH * -POS.normalized.x));
+ // Look at the Bug embeddedt/RoadArchitect/issues/4
+ tVect = (tVect + new Vector3(CurrentH * (POS.normalized.z + (POS.normalized.y / 2)), 0, CurrentH * (-POS.normalized.x + (POS.normalized.y / 2))));
}
//Vertical:
@@ -1045,16 +1267,19 @@ private void SetupLocations()
}
}
- tVect.y += (VerticalCurve.Evaluate(tPercent) * VerticalRaise);
+ tVect.y += (VerticalCurve.Evaluate(tPercent) * VerticalRaise); // Adds the Height to the Node including the VerticalRaise
+ // Adds the Vector and the POS to the List of the EdgeObjects, so they can be created
EdgeObjectLocations.Add(tVect);
EdgeObjectRotations.Add(POS);
}
StartPos = tNode.GSDSpline.GetSplineValue(StartTime);
EndPos = tNode.GSDSpline.GetSplineValue(EndTime);
}
+ // FH_Tag Optimizable
}
+
//ref hVerts,ref hTris, ref hNormals, ref hUV, ref hTangents
private Mesh GSDCombineMeshes(ref List hVerts, ref List hTris, ref List hUV, int OrigMVL, int OrigTriCount)
{
@@ -1074,9 +1299,9 @@ private Mesh GSDCombineMeshes(ref List hVerts, ref List hTris,
if (j > 0)
{
- for (int i = 0; i < OrigTriCount; i++)
+ for (int index = 0; index < OrigTriCount; index++)
{
- hTris[j][i] += CurrentMVLIndex;
+ hTris[j][index] += CurrentMVLIndex;
}
}
@@ -1096,6 +1321,7 @@ private Mesh GSDCombineMeshes(ref List hVerts, ref List hTris,
return tMesh;
}
+
public void ClearEOM()
{
if (EdgeObjects != null)
@@ -1140,8 +1366,6 @@ public void SetDefaultTimes(bool bIsEndPoint, float tTime, float tTimeNext, int
}
}
-
}
-
#endif
}
\ No newline at end of file
diff --git a/GSDRoadIntersection.cs b/GSDRoadIntersection.cs
index 672744c1..9272b38c 100755
--- a/GSDRoadIntersection.cs
+++ b/GSDRoadIntersection.cs
@@ -1,1211 +1,1304 @@
-#region "Imports"
-using UnityEngine;
-using System.Collections;
-using System.Collections.Generic;
-#endregion
-public class GSDRoadIntersection : MonoBehaviour
-{
-
- public GSDSplineN Node1;
- public GSDSplineN Node2;
-
- public string Node1UID;
- public string Node2UID;
-
- public bool bSameSpline = false;
- public bool bDrawGizmo = true;
- public bool bSelected = false;
- public string tName = "";
-
- //Markers:
-
- public bool bUseDefaultMaterials = true;
- public Material MarkerCenter1 = null;
- public Material MarkerCenter2 = null;
- public Material MarkerCenter3 = null;
- public Material MarkerExt_Stretch1 = null;
- public Material MarkerExt_Stretch2 = null;
- public Material MarkerExt_Stretch3 = null;
- public Material MarkerExt_Tiled1 = null;
- public Material MarkerExt_Tiled2 = null;
- public Material MarkerExt_Tiled3 = null;
-
- public Material Lane0Mat1 = null;
- public Material Lane0Mat2 = null;
- public Material Lane1Mat1 = null;
- public Material Lane1Mat2 = null;
- public Material Lane2Mat1 = null;
- public Material Lane2Mat2 = null;
- public Material Lane3Mat1 = null;
- public Material Lane3Mat2 = null;
-
- public Material Lane1Mat1_Disabled = null;
- public Material Lane1Mat2_Disabled = null;
- public Material Lane1Mat1_DisabledActive = null;
- public Material Lane1Mat2_DisabledActive = null;
- public Material Lane2Mat1_Disabled = null;
- public Material Lane2Mat2_Disabled = null;
- public Material Lane2Mat1_DisabledActive = null;
- public Material Lane2Mat2_DisabledActive = null;
- public Material Lane2Mat1_DisabledActiveR = null;
- public Material Lane2Mat2_DisabledActiveR = null;
- public Material Lane3Mat1_Disabled = null;
- public Material Lane3Mat2_Disabled = null;
-
- public int IntersectionWidth = 10; //Width of the largest of road connected
- public int Lanes;
- public enum IntersectionTypeEnum { ThreeWay, FourWay };
- public IntersectionTypeEnum iType = IntersectionTypeEnum.FourWay;
- public bool bNode2B_LeftTurnLane = true;
- public bool bNode2B_RightTurnLane = true;
- public bool bNode2F_LeftTurnLane = true;
- public bool bNode2F_RightTurnLane = true;
-
- public enum iStopTypeEnum { StopSign_AllWay, TrafficLight1, None, TrafficLight2 };
- public iStopTypeEnum iStopType = iStopTypeEnum.StopSign_AllWay;
- public bool bLightsEnabled = true;
- public bool bFlipped = false;
- public bool bLeftTurnYieldOnGreen = true;
- public RoadTypeEnum rType = RoadTypeEnum.NoTurnLane;
- public enum RoadTypeEnum { NoTurnLane, TurnLane, BothTurnLanes };
- public enum LightTypeEnum { Timed, Sensors };
- public LightTypeEnum lType = LightTypeEnum.Timed;
-
- public bool bRegularPoleAlignment = true;
- public bool bTrafficPoleStreetLight = true;
- public bool bTrafficLightGray = false;
- public float StreetLight_Range = 30f;
- public float StreetLight_Intensity = 1f;
- public Color StreetLight_Color = new Color(1f, 0.7451f, 0.27451f, 1f);
-
- public float GradeMod = 0.375f;
- public float GradeModNegative = 0.75f;
-
- public int IgnoreSide = -1;
- public int IgnoreCorner = -1;
- public bool bFirstSpecial_First = false;
- public bool bFirstSpecial_Last = false;
- public bool bSecondSpecial_First = false;
- public bool bSecondSpecial_Last = false;
-
- public float ScalingSense = 3f;
-
- public class CornerPositionMaker
- {
- public Vector3 position;
- public Quaternion rotation;
- public Vector3 DirectionFromCenter;
- }
- public CornerPositionMaker[] CornerPoints;
-
- protected string UID; //Unique ID
- public void SetupUniqueIdentifier()
- {
- if (UID == null || UID.Length < 4)
- {
- UID = System.Guid.NewGuid().ToString();
- }
- }
-
- public Vector3 CornerRR, CornerRR_Outer, CornerRR_RampOuter;
- public Vector3 CornerRL, CornerRL_Outer, CornerRL_RampOuter;
- public Vector3 CornerLR, CornerLR_Outer, CornerLR_RampOuter;
- public Vector3 CornerLL, CornerLL_Outer, CornerLL_RampOuter;
-
- public Vector2 CornerRR_2D;
- public Vector2 CornerRL_2D;
- public Vector2 CornerLR_2D;
- public Vector2 CornerLL_2D;
-
- public Vector3[] fCornerLR_CornerRR;
- public Vector3[] fCornerLL_CornerRL;
- public Vector3[] fCornerLL_CornerLR;
- public Vector3[] fCornerRL_CornerRR;
-
- public float OddAngle, EvenAngle;
-
-
- public bool CornerRR1 = false;
- public bool CornerRR2 = false;
- public bool CornerRL1 = false;
- public bool CornerRL2 = false;
- public bool CornerLR1 = false;
- public bool CornerLR2 = false;
- public bool CornerLL1 = false;
- public bool CornerLL2 = false;
-
- public float MaxInterDistance = 0f;
- public float MaxInterDistanceSQ = 0f;
- public float Height = 50000f;
- public float SignHeight = -2000f;
-
- //Traffic lights:
- public GSDTrafficLightController LightsRR;
- public GSDTrafficLightController LightsRL;
- public GSDTrafficLightController LightsLL;
- public GSDTrafficLightController LightsLR;
- public float opt_FixedTime_RegularLightLength = 10f;
- public float opt_FixedTime_LeftTurnLightLength = 5f;
- public float opt_FixedTime_AllRedLightLength = 1f;
- public float opt_FixedTime_YellowLightLength = 2f;
- public bool opt_AutoUpdateIntersections = true;
- public List FixedTimeSequenceList;
-
-#if UNITY_EDITOR
- #region "Setup"
- public void Setup(GSDSplineN tNode, GSDSplineN xNode)
- {
- if (tNode.GSDSpline == xNode.GSDSpline)
- {
- bSameSpline = true;
- }
-
- if (bSameSpline)
- {
- if (tNode.idOnSpline < xNode.idOnSpline)
- {
- Node1 = tNode;
- Node2 = xNode;
- }
- else
- {
- Node1 = xNode;
- Node2 = tNode;
- }
- }
- else
- {
- Node1 = tNode;
- Node2 = xNode;
- }
-
- Node1.Intersection_OtherNode = Node2;
- Node2.Intersection_OtherNode = Node1;
-
- Node1.ToggleHideFlags(true);
- Node2.ToggleHideFlags(true);
-
- Node1UID = Node1.UID;
- Node2UID = Node2.UID;
- Node1.bIsIntersection = true;
- Node2.bIsIntersection = true;
- Node1.GSDRI = this;
- Node2.GSDRI = this;
- }
-
- public void DeleteRelevantChildren(GSDSplineN tNode, string tString)
- {
- int cCount = transform.childCount;
- for (int i = cCount - 1; i >= 0; i--)
- {
- if (transform.GetChild(i).name.ToLower().Contains(tString.ToLower()))
- {
- Object.DestroyImmediate(transform.GetChild(i).gameObject);
- }
- else if (tNode == Node1)
- {
- if (transform.GetChild(i).name.ToLower().Contains("centermarkers"))
- {
- Object.DestroyImmediate(transform.GetChild(i).gameObject);
- }
- }
- }
- }
- #endregion
-
- #region "Utility"
- public void UpdateRoads()
- {
-#if UNITY_EDITOR
- if (!bSameSpline)
- {
- GSDSplineC[] tPiggys = new GSDSplineC[1];
- tPiggys[0] = Node2.GSDSpline;
- Node1.GSDSpline.tRoad.PiggyBacks = tPiggys;
- Node1.GSDSpline.Setup_Trigger();
- }
- else
- {
- Node1.GSDSpline.Setup_Trigger();
- }
-#endif
- }
-
- GSD.Roads.GSDRoadUtil.Construction2DRect BoundsRect;
- public void ConstructBoundsRect()
- {
- BoundsRect = null;
- BoundsRect = new GSD.Roads.GSDRoadUtil.Construction2DRect(new Vector2(CornerRR.x, CornerRR.z), new Vector2(CornerRL.x, CornerRL.z), new Vector2(CornerLR.x, CornerLR.z), new Vector2(CornerLL.x, CornerLL.z));
- }
-
- public bool Contains(ref Vector3 tVect)
- {
- Vector2 vVect = new Vector2(tVect.x, tVect.z);
- if (BoundsRect == null) { ConstructBoundsRect(); }
- return BoundsRect.Contains(ref vVect);
- }
-
- private bool ContainsLineOld(Vector3 tVect1, Vector3 tVect2, int LineDef = 30)
- {
- int MaxDef = LineDef;
- float MaxDefF = (float)MaxDef;
-
- Vector3[] tVects = new Vector3[MaxDef];
-
- tVects[0] = tVect1;
- float mMod = 0f;
- float fcounter = 1f;
- for (int i = 1; i < (MaxDef - 1); i++)
- {
- mMod = fcounter / MaxDefF;
- tVects[i] = ((tVect2 - tVect1) * mMod) + tVect1;
- fcounter += 1f;
- }
- tVects[MaxDef - 1] = tVect2;
-
- Vector2 xVect = default(Vector2);
- for (int i = 0; i < MaxDef; i++)
- {
- xVect = new Vector2(tVects[i].x, tVects[i].z);
- if (BoundsRect.Contains(ref xVect))
- {
- return true;
- }
- }
- return false;
- }
-
- public bool ContainsLine(Vector3 tVect1, Vector3 tVect2)
- {
- Vector2 tVectStart = new Vector2(tVect1.x, tVect1.z);
- Vector2 tVectEnd = new Vector2(tVect2.x, tVect2.z);
- bool bIntersects = Intersects2D(ref tVectStart, ref tVectEnd, ref CornerRR_2D, ref CornerRL_2D);
- if (bIntersects) { return true; }
- bIntersects = Intersects2D(ref tVectStart, ref tVectEnd, ref CornerRL_2D, ref CornerLL_2D);
- if (bIntersects) { return true; }
- bIntersects = Intersects2D(ref tVectStart, ref tVectEnd, ref CornerLL_2D, ref CornerLR_2D);
- if (bIntersects) { return true; }
- bIntersects = Intersects2D(ref tVectStart, ref tVectEnd, ref CornerLR_2D, ref CornerRR_2D);
- return bIntersects;
- }
-
- // Returns true if the lines intersect, otherwise false. If the lines
- // intersect, intersectionPoint holds the intersection point.
- private static bool Intersects2D(ref Vector2 Line1S, ref Vector2 Line1E, ref Vector2 Line2S, ref Vector2 Line2E)
- {
- float firstLineSlopeX, firstLineSlopeY, secondLineSlopeX, secondLineSlopeY;
-
- firstLineSlopeX = Line1E.x - Line1S.x;
- firstLineSlopeY = Line1E.y - Line1S.y;
-
- secondLineSlopeX = Line2E.x - Line2S.x;
- secondLineSlopeY = Line2E.y - Line2S.y;
-
- float s, t;
- s = (-firstLineSlopeY * (Line1S.x - Line2S.x) + firstLineSlopeX * (Line1S.y - Line2S.y)) / (-secondLineSlopeX * firstLineSlopeY + firstLineSlopeX * secondLineSlopeY);
- t = (secondLineSlopeX * (Line1S.y - Line2S.y) - secondLineSlopeY * (Line1S.x - Line2S.x)) / (-secondLineSlopeX * firstLineSlopeY + firstLineSlopeX * secondLineSlopeY);
-
- if (s >= 0 && s <= 1 && t >= 0 && t <= 1)
- {
- return true;
- }
- return false; // No collision
- }
-
- #endregion
-
- #region "Gizmos"
- void OnDrawGizmos()
- {
- if (!bDrawGizmo) { return; }
- Gizmos.color = Color.blue;
- Gizmos.DrawCube(transform.position + new Vector3(0f, 5f, 0f), new Vector3(2f, 11f, 2f));
- }
- #endregion
-#endif
-
- #region "Traffic light controlling"
- void Start()
- {
- LightsRR.Setup(bLeftTurnYieldOnGreen);
- LightsRL.Setup(bLeftTurnYieldOnGreen);
- LightsLL.Setup(bLeftTurnYieldOnGreen);
- LightsLR.Setup(bLeftTurnYieldOnGreen);
- if (lType == LightTypeEnum.Timed)
- {
- CreateFixedSequence();
- FixedTime_Increment();
- }
- else
- {
- //Do your custom stuff
- //In GSD Traffic addon, this will include sensor mode.
- }
- }
-
- private void CreateFixedSequence()
- {
- GSDTrafficLightSequence SMaker = null; FixedTimeSequenceList = new List();
- if (rType != RoadTypeEnum.NoTurnLane) { SMaker = new GSDTrafficLightSequence(true, GSDTrafficLightController.iLightControllerEnum.LeftTurn, GSDTrafficLightController.iLightSubStatusEnum.Green, opt_FixedTime_LeftTurnLightLength); FixedTimeSequenceList.Add(SMaker); }
- if (rType != RoadTypeEnum.NoTurnLane) { SMaker = new GSDTrafficLightSequence(true, GSDTrafficLightController.iLightControllerEnum.LeftTurn, GSDTrafficLightController.iLightSubStatusEnum.Yellow, opt_FixedTime_YellowLightLength); FixedTimeSequenceList.Add(SMaker); }
- SMaker = new GSDTrafficLightSequence(true, GSDTrafficLightController.iLightControllerEnum.Red, GSDTrafficLightController.iLightSubStatusEnum.Green, opt_FixedTime_AllRedLightLength); FixedTimeSequenceList.Add(SMaker);
- SMaker = new GSDTrafficLightSequence(true, GSDTrafficLightController.iLightControllerEnum.Regular, GSDTrafficLightController.iLightSubStatusEnum.Green, opt_FixedTime_RegularLightLength); FixedTimeSequenceList.Add(SMaker);
- SMaker = new GSDTrafficLightSequence(true, GSDTrafficLightController.iLightControllerEnum.Regular, GSDTrafficLightController.iLightSubStatusEnum.Yellow, opt_FixedTime_YellowLightLength); FixedTimeSequenceList.Add(SMaker);
- SMaker = new GSDTrafficLightSequence(true, GSDTrafficLightController.iLightControllerEnum.Red, GSDTrafficLightController.iLightSubStatusEnum.Green, opt_FixedTime_AllRedLightLength); FixedTimeSequenceList.Add(SMaker);
-
- if (rType != RoadTypeEnum.NoTurnLane) { SMaker = new GSDTrafficLightSequence(false, GSDTrafficLightController.iLightControllerEnum.LeftTurn, GSDTrafficLightController.iLightSubStatusEnum.Green, opt_FixedTime_LeftTurnLightLength); FixedTimeSequenceList.Add(SMaker); }
- if (rType != RoadTypeEnum.NoTurnLane) { SMaker = new GSDTrafficLightSequence(false, GSDTrafficLightController.iLightControllerEnum.LeftTurn, GSDTrafficLightController.iLightSubStatusEnum.Yellow, opt_FixedTime_YellowLightLength); FixedTimeSequenceList.Add(SMaker); }
- SMaker = new GSDTrafficLightSequence(true, GSDTrafficLightController.iLightControllerEnum.Red, GSDTrafficLightController.iLightSubStatusEnum.Green, opt_FixedTime_AllRedLightLength); FixedTimeSequenceList.Add(SMaker);
- SMaker = new GSDTrafficLightSequence(false, GSDTrafficLightController.iLightControllerEnum.Regular, GSDTrafficLightController.iLightSubStatusEnum.Green, opt_FixedTime_RegularLightLength); FixedTimeSequenceList.Add(SMaker);
- SMaker = new GSDTrafficLightSequence(false, GSDTrafficLightController.iLightControllerEnum.Regular, GSDTrafficLightController.iLightSubStatusEnum.Yellow, opt_FixedTime_YellowLightLength); FixedTimeSequenceList.Add(SMaker);
- SMaker = new GSDTrafficLightSequence(false, GSDTrafficLightController.iLightControllerEnum.Red, GSDTrafficLightController.iLightSubStatusEnum.Green, opt_FixedTime_AllRedLightLength); FixedTimeSequenceList.Add(SMaker);
- }
-
- private IEnumerator TrafficLightFixedUpdate(float tTime)
- {
- yield return new WaitForSeconds(tTime);
- FixedTime_Increment();
- }
-
- int FixedTimeIndex = 0;
- private void FixedTime_Increment()
- {
- GSDTrafficLightSequence SMaker = FixedTimeSequenceList[FixedTimeIndex];
- FixedTimeIndex += 1;
- if (FixedTimeIndex > (FixedTimeSequenceList.Count - 1)) { FixedTimeIndex = 0; }
-
- GSDTrafficLightController Lights1 = null;
- GSDTrafficLightController Lights2 = null;
-
- GSDTrafficLightController Lights_outer1 = null;
- GSDTrafficLightController Lights_outer2 = null;
-
- if (SMaker.bLightMasterPath1)
- {
- Lights1 = LightsRL;
- Lights2 = LightsLR;
-
- if (bFlipped)
- {
- Lights_outer1 = LightsRR;
- Lights_outer2 = LightsLL;
- }
- else
- {
- Lights_outer1 = LightsRR;
- Lights_outer2 = LightsLL;
- }
- }
- else
- {
- if (bFlipped)
- {
- Lights1 = LightsRR;
- Lights2 = LightsLL;
- }
- else
- {
- Lights1 = LightsRR;
- Lights2 = LightsLL;
- }
-
- Lights_outer1 = LightsRL;
- Lights_outer2 = LightsLR;
- }
-
- GSDTrafficLightController.iLightControllerEnum LCE = SMaker.iLightController;
- GSDTrafficLightController.iLightSubStatusEnum LCESub = SMaker.iLightSubcontroller;
-
- if (LCE == GSDTrafficLightController.iLightControllerEnum.Regular)
- {
- Lights1.UpdateLights(GSDTrafficLightController.iLightStatusEnum.Regular, LCESub, bLightsEnabled);
- Lights2.UpdateLights(GSDTrafficLightController.iLightStatusEnum.Regular, LCESub, bLightsEnabled);
- Lights_outer1.UpdateLights(GSDTrafficLightController.iLightStatusEnum.Red, LCESub, bLightsEnabled);
- Lights_outer2.UpdateLights(GSDTrafficLightController.iLightStatusEnum.Red, LCESub, bLightsEnabled);
- }
- else if (LCE == GSDTrafficLightController.iLightControllerEnum.LeftTurn)
- {
- Lights1.UpdateLights(GSDTrafficLightController.iLightStatusEnum.LeftTurn, LCESub, bLightsEnabled);
- Lights2.UpdateLights(GSDTrafficLightController.iLightStatusEnum.LeftTurn, LCESub, bLightsEnabled);
- Lights_outer1.UpdateLights(GSDTrafficLightController.iLightStatusEnum.RightTurn, LCESub, bLightsEnabled);
- Lights_outer2.UpdateLights(GSDTrafficLightController.iLightStatusEnum.RightTurn, LCESub, bLightsEnabled);
- }
- else if (LCE == GSDTrafficLightController.iLightControllerEnum.Red)
- {
- Lights1.UpdateLights(GSDTrafficLightController.iLightStatusEnum.Red, LCESub, bLightsEnabled);
- Lights2.UpdateLights(GSDTrafficLightController.iLightStatusEnum.Red, LCESub, bLightsEnabled);
- Lights_outer1.UpdateLights(GSDTrafficLightController.iLightStatusEnum.Red, LCESub, bLightsEnabled);
- Lights_outer2.UpdateLights(GSDTrafficLightController.iLightStatusEnum.Red, LCESub, bLightsEnabled);
- }
-
- // Debug.Log ("Starting: " + SMaker.ToString());
- StartCoroutine(TrafficLightFixedUpdate(SMaker.tTime));
- }
- #endregion
-
-#if UNITY_EDITOR
- #region "Materials"
- public void ResetMaterials_All()
- {
- ResetMaterials_Center(false);
- ResetMaterials_Ext_Stretched(false);
- ResetMaterials_Ext_Tiled(false);
- ResetMaterials_Lanes(false);
- UpdateMaterials();
- }
-
- public void ResetMaterials_Center(bool bUpdate = true)
- {
- string tLanes = "-2L";
- Lanes = Node1.GSDSpline.tRoad.opt_Lanes;
- if (Lanes == 4)
- {
- tLanes = "-4L";
- }
- else if (Lanes == 6)
- {
- tLanes = "-6L";
- }
- if (iType == IntersectionTypeEnum.ThreeWay)
- {
- tLanes += "-3";
- if (Node1.idOnSpline < 2 || Node2.idOnSpline < 2)
- {
- // if(bFirstSpecial_First || bFirstSpecial_Last){ //Reverse if from node 0
- tLanes += "-crev"; //stands for "Center Reversed"
- // }
- }
- }
-
- if (rType == RoadTypeEnum.BothTurnLanes)
- {
- MarkerCenter1 = GSD.Roads.GSDRoadUtilityEditor.GiveMaterial(GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Materials/Markers/GSDInterCenter-Both" + tLanes + ".mat");
- MarkerCenter2 = null;
- MarkerCenter3 = null;
- }
- else if (rType == RoadTypeEnum.TurnLane)
- {
- MarkerCenter1 = GSD.Roads.GSDRoadUtilityEditor.GiveMaterial(GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Materials/Markers/GSDInterCenter-Left" + tLanes + ".mat");
- MarkerCenter2 = null;
- MarkerCenter3 = null;
- }
- else if (rType == RoadTypeEnum.NoTurnLane)
- {
- MarkerCenter1 = GSD.Roads.GSDRoadUtilityEditor.GiveMaterial(GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Materials/Markers/GSDInterCenter-None" + tLanes + ".mat");
- MarkerCenter2 = null;
- MarkerCenter3 = null;
- }
- if (bUpdate) { UpdateMaterials(); }
- }
- public void ResetMaterials_Ext_Stretched(bool bUpdate = true)
- {
- string tLanes = "-2L";
- Lanes = Node1.GSDSpline.tRoad.opt_Lanes;
- if (Lanes == 4)
- {
- tLanes = "-4L";
- }
- else if (Lanes == 6)
- {
- tLanes = "-6L";
- }
-
- if (rType == RoadTypeEnum.BothTurnLanes)
- {
- MarkerExt_Stretch1 = GSD.Roads.GSDRoadUtilityEditor.GiveMaterial(GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Materials/Markers/GSDInterStretch-Both" + tLanes + ".mat");
- MarkerExt_Stretch2 = null;
- MarkerExt_Stretch3 = null;
- }
- else if (rType == RoadTypeEnum.TurnLane)
- {
- MarkerExt_Stretch1 = GSD.Roads.GSDRoadUtilityEditor.GiveMaterial(GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Materials/Markers/GSDInterStretch-Left" + tLanes + ".mat");
- MarkerExt_Stretch2 = null;
- MarkerExt_Stretch3 = null;
- }
- else if (rType == RoadTypeEnum.NoTurnLane)
- {
- MarkerExt_Stretch1 = GSD.Roads.GSDRoadUtilityEditor.GiveMaterial(GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Materials/Markers/GSDInterStretch-None" + tLanes + ".mat");
- MarkerExt_Stretch2 = null;
- MarkerExt_Stretch3 = null;
- }
- if (bUpdate) { UpdateMaterials(); }
- }
-
- public void ResetMaterials_Ext_Tiled(bool bUpdate = true)
- {
- if (rType == RoadTypeEnum.BothTurnLanes)
- {
- MarkerExt_Tiled1 = GSD.Roads.GSDRoadUtilityEditor.GiveMaterial(GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Materials/GSDRoad1.mat");
- MarkerExt_Tiled2 = GSD.Roads.GSDRoadUtilityEditor.GiveMaterial(GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Materials/Markers/GSDRoadDetailOverlay1.mat");
- MarkerExt_Tiled3 = null;
- }
- else if (rType == RoadTypeEnum.TurnLane)
- {
- MarkerExt_Tiled1 = GSD.Roads.GSDRoadUtilityEditor.GiveMaterial(GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Materials/GSDRoad1.mat");
- MarkerExt_Tiled2 = GSD.Roads.GSDRoadUtilityEditor.GiveMaterial(GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Materials/Markers/GSDRoadDetailOverlay1.mat");
- MarkerExt_Tiled3 = null;
- }
- else if (rType == RoadTypeEnum.NoTurnLane)
- {
- MarkerExt_Tiled1 = GSD.Roads.GSDRoadUtilityEditor.GiveMaterial(GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Materials/GSDRoad1.mat");
- MarkerExt_Tiled2 = GSD.Roads.GSDRoadUtilityEditor.GiveMaterial(GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Materials/Markers/GSDRoadDetailOverlay1.mat");
- MarkerExt_Tiled3 = null;
- }
- if (bUpdate) { UpdateMaterials(); }
- }
-
- public void ResetMaterials_Lanes(bool bUpdate = true)
- {
- string tLanes = "";
- Lanes = Node1.GSDSpline.tRoad.opt_Lanes;
- if (Lanes == 4)
- {
- tLanes = "-4L";
- }
- else if (Lanes == 6)
- {
- tLanes = "-6L";
- }
-
- if (iType == IntersectionTypeEnum.ThreeWay)
- {
- Lane1Mat1_Disabled = GSD.Roads.GSDRoadUtilityEditor.GiveMaterial(GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Materials/Markers/GSDInterLaneDisabled.mat");
- Lane1Mat2_Disabled = null;
- if (rType == RoadTypeEnum.BothTurnLanes)
- {
- Lane1Mat1_DisabledActive = GSD.Roads.GSDRoadUtilityEditor.GiveMaterial(GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Materials/Markers/GSDInterLaneDisabledOuterRR.mat");
- Lane1Mat2_DisabledActive = null;
- Lane2Mat1_Disabled = GSD.Roads.GSDRoadUtilityEditor.GiveMaterial(GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Materials/Markers/GSDInterLaneDisabledR.mat");
- Lane2Mat2_Disabled = null;
- }
- else
- {
- Lane2Mat1_Disabled = null;
- Lane2Mat2_Disabled = null;
- Lane2Mat1_DisabledActive = null;
- Lane2Mat2_DisabledActive = null;
- }
- Lane2Mat1_DisabledActive = GSD.Roads.GSDRoadUtilityEditor.GiveMaterial(GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Materials/Markers/GSDInterLaneDisabledOuter" + tLanes + ".mat");
- Lane2Mat2_DisabledActive = null;
- if (rType == RoadTypeEnum.BothTurnLanes)
- {
- Lane2Mat1_DisabledActiveR = GSD.Roads.GSDRoadUtilityEditor.GiveMaterial(GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Materials/Markers/GSDInterLaneDisabledOuterR.mat");
- Lane2Mat2_DisabledActiveR = null;
- Lane3Mat1_Disabled = GSD.Roads.GSDRoadUtilityEditor.GiveMaterial(GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Materials/Markers/GSDInterLaneDisabledR.mat");
- Lane3Mat2_Disabled = null;
- }
- else
- {
- Lane2Mat1_DisabledActiveR = null;
- Lane2Mat2_DisabledActiveR = null;
- Lane3Mat1_Disabled = null;
- Lane3Mat2_Disabled = null;
- }
- }
- else
- {
- Lane1Mat1_Disabled = null;
- Lane1Mat2_Disabled = null;
- Lane2Mat1_Disabled = null;
- Lane2Mat2_Disabled = null;
- Lane2Mat1_DisabledActive = null;
- Lane2Mat2_DisabledActive = null;
- Lane2Mat1_DisabledActiveR = null;
- Lane2Mat2_DisabledActiveR = null;
- Lane3Mat1_Disabled = null;
- Lane3Mat2_Disabled = null;
- }
-
- if (rType == RoadTypeEnum.BothTurnLanes)
- {
- Lane0Mat1 = GSD.Roads.GSDRoadUtilityEditor.GiveMaterial(GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Materials/Markers/GSDInterWhiteLYellowR" + tLanes + ".mat");
- Lane0Mat2 = null;
- Lane1Mat1 = GSD.Roads.GSDRoadUtilityEditor.GiveMaterial(GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Materials/Markers/GSDInterYellowLWhiteR.mat");
- Lane1Mat2 = null;
- Lane2Mat1 = GSD.Roads.GSDRoadUtilityEditor.GiveMaterial(GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Materials/Markers/GSDInterWhiteR" + tLanes + ".mat");
- Lane2Mat2 = null;
- Lane3Mat1 = GSD.Roads.GSDRoadUtilityEditor.GiveMaterial(GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Materials/Markers/GSDInterWhiteR.mat");
- Lane3Mat2 = null;
- }
- else if (rType == RoadTypeEnum.TurnLane)
- {
- Lane0Mat1 = GSD.Roads.GSDRoadUtilityEditor.GiveMaterial(GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Materials/Markers/GSDInterWhiteLYellowR" + tLanes + ".mat");
- Lane0Mat2 = null;
- Lane1Mat1 = GSD.Roads.GSDRoadUtilityEditor.GiveMaterial(GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Materials/Markers/GSDInterYellowLWhiteR.mat");
- Lane1Mat2 = null;
- Lane2Mat1 = GSD.Roads.GSDRoadUtilityEditor.GiveMaterial(GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Materials/Markers/GSDInterWhiteR" + tLanes + ".mat");
- Lane2Mat2 = null;
- Lane3Mat1 = null;
- Lane3Mat2 = null;
- }
- else if (rType == RoadTypeEnum.NoTurnLane)
- {
- Lane0Mat1 = GSD.Roads.GSDRoadUtilityEditor.GiveMaterial(GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Materials/Markers/GSDInterWhiteLYellowR" + tLanes + ".mat");
- Lane0Mat2 = null;
- Lane1Mat1 = GSD.Roads.GSDRoadUtilityEditor.GiveMaterial(GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Materials/Markers/GSDInterYellowLWhiteR" + tLanes + ".mat");
- Lane1Mat2 = null;
- Lane2Mat1 = null;
- Lane2Mat2 = null;
- Lane3Mat1 = null;
- Lane3Mat2 = null;
- }
-
- if (bUpdate) { UpdateMaterials(); }
- }
-
- public void UpdateMaterials()
- {
- UpdateMaterials_Do();
- }
- private void UpdateMaterials_Do()
- {
- int cCount = transform.childCount;
- List MR_Ext_Stretch = new List();
- List MR_Ext_Tiled = new List();
- MeshRenderer MR_Center = null;
- List MR_Lane0 = new List();
- List MR_Lane1 = new List();
- List MR_Lane2 = new List();
- List MR_Lane3 = new List();
- List MR_LaneD1 = new List();
- List MR_LaneD3 = new List();
- List MR_LaneDA2 = new List();
- List MR_LaneDAR2 = new List();
- List MR_LaneD2 = new List();
- List MR_LaneDA1 = new List();
-
- string tTransName = "";
- for (int i = 0; i < cCount; i++)
- {
- tTransName = transform.GetChild(i).name.ToLower();
- if (tTransName.Contains("-stretchext"))
- {
- MR_Ext_Stretch.Add(transform.GetChild(i).GetComponent()); continue;
- }
- if (tTransName.Contains("-tiledext"))
- {
- MR_Ext_Tiled.Add(transform.GetChild(i).GetComponent()); continue;
- }
- if (tTransName.Contains("centermarkers"))
- {
- MR_Center = transform.GetChild(i).GetComponent(); continue;
- }
- if (tTransName.Contains("lane0"))
- {
- MR_Lane0.Add(transform.GetChild(i).GetComponent()); continue;
- }
- if (tTransName.Contains("lane1"))
- {
- MR_Lane1.Add(transform.GetChild(i).GetComponent()); continue;
- }
- if (tTransName.Contains("lane2"))
- {
- MR_Lane2.Add(transform.GetChild(i).GetComponent()); continue;
- }
- if (tTransName.Contains("lane3"))
- {
- MR_Lane3.Add(transform.GetChild(i).GetComponent()); continue;
- }
- if (iType == IntersectionTypeEnum.ThreeWay)
- {
- if (tTransName.Contains("laned1"))
- {
- MR_LaneD1.Add(transform.GetChild(i).GetComponent()); continue;
- }
- if (tTransName.Contains("laned3"))
- {
- MR_LaneD3.Add(transform.GetChild(i).GetComponent()); continue;
- }
- if (tTransName.Contains("laneda2"))
- {
- MR_LaneDA2.Add(transform.GetChild(i).GetComponent()); continue;
- }
- if (tTransName.Contains("lanedar2"))
- {
- MR_LaneDAR2.Add(transform.GetChild(i).GetComponent()); continue;
- }
- if (tTransName.Contains("laned2"))
- {
- MR_LaneD2.Add(transform.GetChild(i).GetComponent()); continue;
- }
- if (tTransName.Contains("laneda1"))
- {
- MR_LaneDA1.Add(transform.GetChild(i).GetComponent()); continue;
- }
- }
- }
-
- if (MR_Ext_Stretch != null && MR_Ext_Stretch.Count > 0)
- {
- int MarkerExtStretchCounter = 0;
- if (MarkerExt_Stretch1 != null)
- {
- MarkerExtStretchCounter += 1;
- if (MarkerExt_Stretch2 != null)
- {
- MarkerExtStretchCounter += 1;
- if (MarkerExt_Stretch3 != null)
- {
- MarkerExtStretchCounter += 1;
- }
- }
- }
- Material[] MarkerExtStretchMats = new Material[MarkerExtStretchCounter];
- for (int i = 0; i < MarkerExtStretchCounter; i++)
- {
- if (i == 0)
- {
- MarkerExtStretchMats[i] = MarkerExt_Stretch1;
- }
- else if (i == 1)
- {
- MarkerExtStretchMats[i] = MarkerExt_Stretch2;
- }
- else if (i == 2)
- {
- MarkerExtStretchMats[i] = MarkerExt_Stretch3;
- }
- }
- for (int i = 0; i < MR_Ext_Stretch.Count; i++)
- {
- MR_Ext_Stretch[i].materials = MarkerExtStretchMats;
- }
- }
-
- if (MR_Ext_Tiled != null && MR_Ext_Tiled.Count > 0)
- {
- int MarkerExtTiledCounter = 0;
- if (MarkerExt_Tiled1 != null)
- {
- MarkerExtTiledCounter += 1;
- if (MarkerExt_Tiled2 != null)
- {
- MarkerExtTiledCounter += 1;
- if (MarkerExt_Tiled3 != null)
- {
- MarkerExtTiledCounter += 1;
- }
- }
- }
- Material[] MarkerExtTiledMats = new Material[MarkerExtTiledCounter];
- for (int i = 0; i < MarkerExtTiledCounter; i++)
- {
- if (i == 0)
- {
- MarkerExtTiledMats[i] = MarkerExt_Tiled1;
- }
- else if (i == 1)
- {
- MarkerExtTiledMats[i] = MarkerExt_Tiled2;
- }
- else if (i == 2)
- {
- MarkerExtTiledMats[i] = MarkerExt_Tiled3;
- }
- }
- for (int i = 0; i < MR_Ext_Tiled.Count; i++)
- {
- MR_Ext_Tiled[i].materials = MarkerExtTiledMats;
- }
- }
-
- if (MR_Center != null)
- {
- int CenterCounter = 0;
- if (MarkerCenter1 != null)
- {
- CenterCounter += 1;
- if (MarkerCenter2 != null)
- {
- CenterCounter += 1;
- if (MarkerCenter3 != null)
- {
- CenterCounter += 1;
- }
- }
- }
- Material[] CenterMats = new Material[CenterCounter];
- for (int i = 0; i < CenterCounter; i++)
- {
- if (i == 0)
- {
- CenterMats[i] = MarkerCenter1;
- }
- else if (i == 1)
- {
- CenterMats[i] = MarkerCenter2;
- }
- else if (i == 2)
- {
- CenterMats[i] = MarkerCenter3;
- }
- }
- MR_Center.materials = CenterMats;
- }
-
- int LaneCounter = 0;
- if (MR_Lane0 != null && MR_Lane0.Count > 0)
- {
- LaneCounter = 0;
- if (Lane0Mat1 != null)
- {
- LaneCounter += 1;
- if (Lane0Mat2 != null)
- {
- LaneCounter += 1;
- }
- }
- Material[] Lane0Mats = new Material[LaneCounter];
- for (int i = 0; i < LaneCounter; i++)
- {
- if (i == 0)
- {
- Lane0Mats[i] = Lane0Mat1;
- }
- else if (i == 1)
- {
- Lane0Mats[i] = Lane0Mat2;
- }
- }
- for (int i = 0; i < MR_Lane0.Count; i++)
- {
- MR_Lane0[i].materials = Lane0Mats;
- }
- }
-
- if (MR_Lane1 != null && MR_Lane1.Count > 0)
- {
- LaneCounter = 0;
- if (Lane1Mat1 != null)
- {
- LaneCounter += 1;
- if (Lane1Mat2 != null)
- {
- LaneCounter += 1;
- }
- }
- Material[] Lane1Mats = new Material[LaneCounter];
- for (int i = 0; i < LaneCounter; i++)
- {
- if (i == 0)
- {
- Lane1Mats[i] = Lane1Mat1;
- }
- else if (i == 1)
- {
- Lane1Mats[i] = Lane1Mat2;
- }
- }
- for (int i = 0; i < MR_Lane1.Count; i++)
- {
- MR_Lane1[i].materials = Lane1Mats;
- }
- }
-
- if (MR_Lane2 != null && MR_Lane2.Count > 0)
- {
- LaneCounter = 0;
- if (Lane2Mat1 != null)
- {
- LaneCounter += 1;
- if (Lane2Mat2 != null)
- {
- LaneCounter += 1;
- }
- }
- Material[] Lane2Mats = new Material[LaneCounter];
- for (int i = 0; i < LaneCounter; i++)
- {
- if (i == 0)
- {
- Lane2Mats[i] = Lane2Mat1;
- }
- else if (i == 1)
- {
- Lane2Mats[i] = Lane2Mat2;
- }
- }
- for (int i = 0; i < MR_Lane2.Count; i++)
- {
- MR_Lane2[i].materials = Lane2Mats;
- }
- }
-
- if (MR_Lane3 != null && MR_Lane3.Count > 0)
- {
- LaneCounter = 0;
- if (Lane3Mat1 != null)
- {
- LaneCounter += 1;
- if (Lane3Mat2 != null)
- {
- LaneCounter += 1;
- }
- }
- Material[] Lane3Mats = new Material[LaneCounter];
- for (int i = 0; i < LaneCounter; i++)
- {
- if (i == 0)
- {
- Lane3Mats[i] = Lane3Mat1;
- }
- else if (i == 1)
- {
- Lane3Mats[i] = Lane3Mat2;
- }
- }
- for (int i = 0; i < MR_Lane3.Count; i++)
- {
- MR_Lane3[i].materials = Lane3Mats;
- }
- }
-
- if (MR_LaneD1 != null && MR_LaneD1.Count > 0)
- {
- LaneCounter = 0;
- if (Lane1Mat1_Disabled != null)
- {
- LaneCounter += 1;
- if (Lane1Mat2_Disabled != null)
- {
- LaneCounter += 1;
- }
- }
- Material[] Lane1Mats_Disabled = new Material[LaneCounter];
- for (int i = 0; i < LaneCounter; i++)
- {
- if (i == 0)
- {
- Lane1Mats_Disabled[i] = Lane1Mat1_Disabled;
- }
- else if (i == 1)
- {
- Lane1Mats_Disabled[i] = Lane1Mat2_Disabled;
- }
- }
- for (int i = 0; i < MR_LaneD1.Count; i++)
- {
- MR_LaneD1[i].materials = Lane1Mats_Disabled;
- }
- }
-
- if (MR_LaneD3 != null && MR_LaneD3.Count > 0)
- {
- LaneCounter = 0;
- if (Lane3Mat1_Disabled != null)
- {
- LaneCounter += 1;
- if (Lane3Mat2_Disabled != null)
- {
- LaneCounter += 1;
- }
- }
- Material[] Lane3Mats_Disabled = new Material[LaneCounter];
- for (int i = 0; i < LaneCounter; i++)
- {
- if (i == 0)
- {
- Lane3Mats_Disabled[i] = Lane3Mat1_Disabled;
- }
- else if (i == 1)
- {
- Lane3Mats_Disabled[i] = Lane3Mat2_Disabled;
- }
- }
- for (int i = 0; i < MR_LaneD3.Count; i++)
- {
- MR_LaneD3[i].materials = Lane3Mats_Disabled;
- }
- }
-
- if (MR_LaneDA2 != null && MR_LaneDA2.Count > 0)
- {
- LaneCounter = 0;
- if (Lane2Mat1_DisabledActive != null)
- {
- LaneCounter += 1;
- if (Lane2Mat2_DisabledActive != null)
- {
- LaneCounter += 1;
- }
- }
- Material[] Lane2Mats_DisabledActive = new Material[LaneCounter];
- for (int i = 0; i < LaneCounter; i++)
- {
- if (i == 0)
- {
- Lane2Mats_DisabledActive[i] = Lane2Mat1_DisabledActive;
- }
- else if (i == 1)
- {
- Lane2Mats_DisabledActive[i] = Lane2Mat2_DisabledActive;
- }
- }
- for (int i = 0; i < MR_LaneDA2.Count; i++)
- {
- MR_LaneDA2[i].materials = Lane2Mats_DisabledActive;
- }
- }
-
- if (MR_LaneDAR2 != null && MR_LaneDAR2.Count > 0)
- {
- LaneCounter = 0;
- if (Lane2Mat1_DisabledActiveR != null)
- {
- LaneCounter += 1;
- if (Lane2Mat2_DisabledActiveR != null)
- {
- LaneCounter += 1;
- }
- }
- Material[] Lane2Mats_DisabledActiveR = new Material[LaneCounter];
- for (int i = 0; i < LaneCounter; i++)
- {
- if (i == 0)
- {
- Lane2Mats_DisabledActiveR[i] = Lane2Mat1_DisabledActiveR;
- }
- else if (i == 1)
- {
- Lane2Mats_DisabledActiveR[i] = Lane2Mat2_DisabledActiveR;
- }
- }
- for (int i = 0; i < MR_LaneDAR2.Count; i++)
- {
- MR_LaneDAR2[i].materials = Lane2Mats_DisabledActiveR;
- }
- }
-
- if (MR_LaneD2 != null && MR_LaneD2.Count > 0)
- {
- LaneCounter = 0;
- if (Lane2Mat1_Disabled != null)
- {
- LaneCounter += 1;
- if (Lane2Mat2_Disabled != null)
- {
- LaneCounter += 1;
- }
- }
- Material[] Lane2Mats_Disabled = new Material[LaneCounter];
- for (int i = 0; i < LaneCounter; i++)
- {
- if (i == 0)
- {
- Lane2Mats_Disabled[i] = Lane2Mat1_Disabled;
- }
- else if (i == 1)
- {
- Lane2Mats_Disabled[i] = Lane2Mat2_Disabled;
- }
- }
- for (int i = 0; i < MR_LaneD2.Count; i++)
- {
- MR_LaneD2[i].materials = Lane2Mats_Disabled;
- }
- }
-
-
- if (MR_LaneDA1 != null && MR_LaneDA1.Count > 0)
- {
- LaneCounter = 0;
- if (Lane1Mat1_DisabledActive != null)
- {
- LaneCounter += 1;
- if (Lane1Mat2_DisabledActive != null)
- {
- LaneCounter += 1;
- }
- }
- Material[] Lane1Mats_DisabledActive = new Material[LaneCounter];
- for (int i = 0; i < LaneCounter; i++)
- {
- if (i == 0)
- {
- Lane1Mats_DisabledActive[i] = Lane1Mat1_DisabledActive;
- }
- else if (i == 1)
- {
- Lane1Mats_DisabledActive[i] = Lane1Mat2_DisabledActive;
- }
- }
- for (int i = 0; i < MR_LaneDA1.Count; i++)
- {
- MR_LaneDA1[i].materials = Lane1Mats_DisabledActive;
- }
- }
- }
- #endregion
-
- public void ToggleTrafficLightPoleColor()
- {
- Material TrafficLightMaterial = null;
- if (bTrafficLightGray)
- {
- TrafficLightMaterial = GSD.Roads.GSDRoadUtilityEditor.GiveMaterial(GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Materials/Signs/GSDInterTLB2.mat");
- }
- else
- {
- TrafficLightMaterial = GSD.Roads.GSDRoadUtilityEditor.GiveMaterial(GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Materials/Signs/GSDInterTLB1.mat");
- }
- int cCount = transform.childCount;
- string tName = "";
- MeshRenderer MR = null;
- Material[] tMats = new Material[1];
- tMats[0] = TrafficLightMaterial;
- for (int i = 0; i < cCount; i++)
- {
- tName = transform.GetChild(i).name.ToLower();
- if (tName.Contains("trafficlight"))
- {
- MR = transform.GetChild(i).GetComponent();
- MR.materials = tMats;
- }
- }
- }
-
- public void TogglePointLights(bool _bLightsEnabled)
- {
- bLightsEnabled = _bLightsEnabled;
- int cCount = transform.childCount;
- Light[] fLights = null;
- Transform tTrans = null;
- for (int i = 0; i < cCount; i++)
- {
- if (transform.GetChild(i).name.ToLower().Contains("trafficlight"))
- {
- tTrans = transform.GetChild(i);
- int kCount = tTrans.childCount;
- for (int k = 0; k < kCount; k++)
- {
- if (tTrans.GetChild(k).name.ToLower().Contains("streetlight"))
- {
- fLights = tTrans.GetChild(k).GetComponentsInChildren();
- if (fLights != null)
- {
- for (int j = 0; j < fLights.Length; j++)
- {
- fLights[j].enabled = bLightsEnabled;
- fLights[j].range = StreetLight_Range;
- fLights[j].intensity = StreetLight_Intensity;
- fLights[j].color = StreetLight_Color;
- }
- }
- fLights = null;
- break;
- }
- }
- }
- }
- }
-
- public void ResetStreetLightSettings()
- {
- StreetLight_Range = 30f;
- StreetLight_Intensity = 1f;
- StreetLight_Color = new Color(1f, 0.7451f, 0.27451f, 1f);
- TogglePointLights(bLightsEnabled);
- }
-
-#endif
+#region "Imports"
+using UnityEngine;
+using System.Collections;
+using System.Collections.Generic;
+#endregion
+
+
+public class GSDRoadIntersection : MonoBehaviour
+{
+
+ public GSDSplineN Node1;
+ public GSDSplineN Node2;
+
+ public string Node1UID;
+ public string Node2UID;
+
+ public bool bSameSpline = false;
+ public bool bDrawGizmo = true;
+ public bool bSelected = false;
+ public string tName = "";
+
+ //Markers:
+ public bool bUseDefaultMaterials = true;
+ public Material MarkerCenter1 = null;
+ public Material MarkerCenter2 = null;
+ public Material MarkerCenter3 = null;
+ public Material MarkerExt_Stretch1 = null;
+ public Material MarkerExt_Stretch2 = null;
+ public Material MarkerExt_Stretch3 = null;
+ public Material MarkerExt_Tiled1 = null;
+ public Material MarkerExt_Tiled2 = null;
+ public Material MarkerExt_Tiled3 = null;
+
+ public Material Lane0Mat1 = null;
+ public Material Lane0Mat2 = null;
+ public Material Lane1Mat1 = null;
+ public Material Lane1Mat2 = null;
+ public Material Lane2Mat1 = null;
+ public Material Lane2Mat2 = null;
+ public Material Lane3Mat1 = null;
+ public Material Lane3Mat2 = null;
+
+ public Material Lane1Mat1_Disabled = null;
+ public Material Lane1Mat2_Disabled = null;
+ public Material Lane1Mat1_DisabledActive = null;
+ public Material Lane1Mat2_DisabledActive = null;
+ public Material Lane2Mat1_Disabled = null;
+ public Material Lane2Mat2_Disabled = null;
+ public Material Lane2Mat1_DisabledActive = null;
+ public Material Lane2Mat2_DisabledActive = null;
+ public Material Lane2Mat1_DisabledActiveR = null;
+ public Material Lane2Mat2_DisabledActiveR = null;
+ public Material Lane3Mat1_Disabled = null;
+ public Material Lane3Mat2_Disabled = null;
+
+ public int IntersectionWidth = 10; //Width of the largest of road connected
+ public int Lanes;
+ public enum IntersectionTypeEnum { ThreeWay, FourWay };
+ public IntersectionTypeEnum iType = IntersectionTypeEnum.FourWay;
+ public bool bNode2B_LeftTurnLane = true;
+ public bool bNode2B_RightTurnLane = true;
+ public bool bNode2F_LeftTurnLane = true;
+ public bool bNode2F_RightTurnLane = true;
+
+ public enum iStopTypeEnum { StopSign_AllWay, TrafficLight1, None, TrafficLight2 };
+ public iStopTypeEnum iStopType = iStopTypeEnum.StopSign_AllWay;
+ public bool bLightsEnabled = true;
+ public bool bFlipped = false;
+ public bool bLeftTurnYieldOnGreen = true;
+ public RoadTypeEnum rType = RoadTypeEnum.NoTurnLane;
+ public enum RoadTypeEnum { NoTurnLane, TurnLane, BothTurnLanes };
+ public enum LightTypeEnum { Timed, Sensors };
+ public LightTypeEnum lType = LightTypeEnum.Timed;
+
+ public bool bRegularPoleAlignment = true;
+ public bool bTrafficPoleStreetLight = true;
+ public bool bTrafficLightGray = false;
+ public float StreetLight_Range = 30f;
+ public float StreetLight_Intensity = 1f;
+ public Color StreetLight_Color = new Color(1f, 0.7451f, 0.27451f, 1f);
+
+ public float GradeMod = 0.375f;
+ public float GradeModNegative = 0.75f;
+
+ public int IgnoreSide = -1;
+ public int IgnoreCorner = -1;
+ public bool bFirstSpecial_First = false;
+ public bool bFirstSpecial_Last = false;
+ public bool bSecondSpecial_First = false;
+ public bool bSecondSpecial_Last = false;
+
+ public float ScalingSense = 3f;
+
+
+ // A struct may be better and faster // FH 29.01.19
+ public class CornerPositionMaker
+ {
+ public Vector3 position;
+ public Quaternion rotation;
+ public Vector3 DirectionFromCenter;
+ }
+
+ public CornerPositionMaker[] CornerPoints;
+
+ protected string UID; //Unique ID
+
+
+ public void SetupUniqueIdentifier()
+ {
+ if (UID == null || UID.Length < 4)
+ {
+ UID = System.Guid.NewGuid().ToString();
+ }
+ }
+
+
+ public Vector3 CornerRR, CornerRR_Outer, CornerRR_RampOuter;
+ public Vector3 CornerRL, CornerRL_Outer, CornerRL_RampOuter;
+ public Vector3 CornerLR, CornerLR_Outer, CornerLR_RampOuter;
+ public Vector3 CornerLL, CornerLL_Outer, CornerLL_RampOuter;
+
+ public Vector2 CornerRR_2D;
+ public Vector2 CornerRL_2D;
+ public Vector2 CornerLR_2D;
+ public Vector2 CornerLL_2D;
+
+ public Vector3[] fCornerLR_CornerRR;
+ public Vector3[] fCornerLL_CornerRL;
+ public Vector3[] fCornerLL_CornerLR;
+ public Vector3[] fCornerRL_CornerRR;
+
+ public float OddAngle, EvenAngle;
+
+
+ public bool CornerRR1 = false;
+ public bool CornerRR2 = false;
+ public bool CornerRL1 = false;
+ public bool CornerRL2 = false;
+ public bool CornerLR1 = false;
+ public bool CornerLR2 = false;
+ public bool CornerLL1 = false;
+ public bool CornerLL2 = false;
+
+ public float MaxInterDistance = 0f;
+ public float MaxInterDistanceSQ = 0f;
+ public float Height = 50000f;
+ public float SignHeight = -2000f;
+
+ //Traffic lights:
+ public GSDTrafficLightController LightsRR;
+ public GSDTrafficLightController LightsRL;
+ public GSDTrafficLightController LightsLL;
+ public GSDTrafficLightController LightsLR;
+ public float opt_FixedTime_RegularLightLength = 10f;
+ public float opt_FixedTime_LeftTurnLightLength = 5f;
+ public float opt_FixedTime_AllRedLightLength = 1f;
+ public float opt_FixedTime_YellowLightLength = 2f;
+ public bool opt_AutoUpdateIntersections = true;
+ public List FixedTimeSequenceList;
+
+
+#if UNITY_EDITOR
+ #region "Setup"
+ public void Setup(GSDSplineN tNode, GSDSplineN xNode)
+ {
+ if (tNode.GSDSpline == xNode.GSDSpline)
+ {
+ bSameSpline = true;
+ }
+
+ if (bSameSpline)
+ {
+ if (tNode.idOnSpline < xNode.idOnSpline)
+ {
+ Node1 = tNode;
+ Node2 = xNode;
+ }
+ else
+ {
+ Node1 = xNode;
+ Node2 = tNode;
+ }
+ }
+ else
+ {
+ Node1 = tNode;
+ Node2 = xNode;
+ }
+
+ Node1.Intersection_OtherNode = Node2;
+ Node2.Intersection_OtherNode = Node1;
+
+ Node1.ToggleHideFlags(true);
+ Node2.ToggleHideFlags(true);
+
+ Node1UID = Node1.UID;
+ Node2UID = Node2.UID;
+ Node1.bIsIntersection = true;
+ Node2.bIsIntersection = true;
+ Node1.GSDRI = this;
+ Node2.GSDRI = this;
+ }
+
+
+ public void DeleteRelevantChildren(GSDSplineN tNode, string tString)
+ {
+ int cCount = transform.childCount;
+ for (int index = cCount - 1; index >= 0; index--)
+ {
+ if (transform.GetChild(index).name.ToLower().Contains(tString.ToLower()))
+ {
+ Object.DestroyImmediate(transform.GetChild(index).gameObject);
+ }
+ else if (tNode == Node1)
+ {
+ if (transform.GetChild(index).name.ToLower().Contains("centermarkers"))
+ {
+ Object.DestroyImmediate(transform.GetChild(index).gameObject);
+ }
+ }
+ }
+ }
+ #endregion
+
+
+ #region "Utility"
+ public void UpdateRoads()
+ {
+#if UNITY_EDITOR
+ if (!bSameSpline)
+ {
+ GSDSplineC[] tPiggys = new GSDSplineC[1];
+ tPiggys[0] = Node2.GSDSpline;
+ Node1.GSDSpline.tRoad.PiggyBacks = tPiggys;
+ Node1.GSDSpline.Setup_Trigger();
+ }
+ else
+ {
+ Node1.GSDSpline.Setup_Trigger();
+ }
+#endif
+ }
+
+
+ GSD.Roads.GSDRoadUtil.Construction2DRect BoundsRect;
+
+
+ public void ConstructBoundsRect()
+ {
+ BoundsRect = null;
+ BoundsRect = new GSD.Roads.GSDRoadUtil.Construction2DRect(new Vector2(CornerRR.x, CornerRR.z), new Vector2(CornerRL.x, CornerRL.z), new Vector2(CornerLR.x, CornerLR.z), new Vector2(CornerLL.x, CornerLL.z));
+ }
+
+
+ public bool Contains(ref Vector3 tVect)
+ {
+ Vector2 vVect = new Vector2(tVect.x, tVect.z);
+ if (BoundsRect == null)
+ {
+ ConstructBoundsRect();
+ }
+ return BoundsRect.Contains(ref vVect);
+ }
+
+
+ private bool ContainsLineOld(Vector3 tVect1, Vector3 tVect2, int LineDef = 30)
+ {
+ int MaxDef = LineDef;
+ float MaxDefF = (float) MaxDef;
+
+ Vector3[] tVects = new Vector3[MaxDef];
+
+ tVects[0] = tVect1;
+ float mMod = 0f;
+ float fcounter = 1f;
+ for (int index = 1; index < (MaxDef - 1); index++)
+ {
+ mMod = fcounter / MaxDefF;
+ tVects[index] = ((tVect2 - tVect1) * mMod) + tVect1;
+ fcounter += 1f;
+ }
+ tVects[MaxDef - 1] = tVect2;
+
+ Vector2 xVect = default(Vector2);
+ for (int index = 0; index < MaxDef; index++)
+ {
+ xVect = new Vector2(tVects[index].x, tVects[index].z);
+ if (BoundsRect.Contains(ref xVect))
+ {
+ return true;
+ }
+ }
+ return false;
+ }
+
+
+ public bool ContainsLine(Vector3 tVect1, Vector3 tVect2)
+ {
+ Vector2 tVectStart = new Vector2(tVect1.x, tVect1.z);
+ Vector2 tVectEnd = new Vector2(tVect2.x, tVect2.z);
+ bool bIntersects = Intersects2D(ref tVectStart, ref tVectEnd, ref CornerRR_2D, ref CornerRL_2D);
+ if (bIntersects)
+ {
+ return true;
+ }
+ bIntersects = Intersects2D(ref tVectStart, ref tVectEnd, ref CornerRL_2D, ref CornerLL_2D);
+ if (bIntersects)
+ {
+ return true;
+ }
+ bIntersects = Intersects2D(ref tVectStart, ref tVectEnd, ref CornerLL_2D, ref CornerLR_2D);
+ if (bIntersects)
+ {
+ return true;
+ }
+ bIntersects = Intersects2D(ref tVectStart, ref tVectEnd, ref CornerLR_2D, ref CornerRR_2D);
+ return bIntersects;
+ }
+
+
+ // Returns true if the lines intersect, otherwise false. If the lines
+ // intersect, intersectionPoint holds the intersection point.
+ private static bool Intersects2D(ref Vector2 Line1S, ref Vector2 Line1E, ref Vector2 Line2S, ref Vector2 Line2E)
+ {
+ float firstLineSlopeX, firstLineSlopeY, secondLineSlopeX, secondLineSlopeY;
+
+ firstLineSlopeX = Line1E.x - Line1S.x;
+ firstLineSlopeY = Line1E.y - Line1S.y;
+
+ secondLineSlopeX = Line2E.x - Line2S.x;
+ secondLineSlopeY = Line2E.y - Line2S.y;
+
+ float s, t;
+ s = (-firstLineSlopeY * (Line1S.x - Line2S.x) + firstLineSlopeX * (Line1S.y - Line2S.y)) / (-secondLineSlopeX * firstLineSlopeY + firstLineSlopeX * secondLineSlopeY);
+ t = (secondLineSlopeX * (Line1S.y - Line2S.y) - secondLineSlopeY * (Line1S.x - Line2S.x)) / (-secondLineSlopeX * firstLineSlopeY + firstLineSlopeX * secondLineSlopeY);
+
+ if (s >= 0 && s <= 1 && t >= 0 && t <= 1)
+ {
+ return true;
+ }
+ return false; // No collision
+ }
+ #endregion
+
+
+ #region "Gizmos"
+ void OnDrawGizmos()
+ {
+ if (!bDrawGizmo)
+ {
+ return;
+ }
+ Gizmos.color = Color.blue;
+ Gizmos.DrawCube(transform.position + new Vector3(0f, 5f, 0f), new Vector3(2f, 11f, 2f));
+ }
+ #endregion
+#endif
+
+
+ #region "Traffic light controlling"
+ void Start()
+ {
+ LightsRR.Setup(bLeftTurnYieldOnGreen);
+ LightsRL.Setup(bLeftTurnYieldOnGreen);
+ LightsLL.Setup(bLeftTurnYieldOnGreen);
+ LightsLR.Setup(bLeftTurnYieldOnGreen);
+ if (lType == LightTypeEnum.Timed)
+ {
+ CreateFixedSequence();
+ FixedTime_Increment();
+ }
+ else
+ {
+ //Do your custom stuff
+ //In GSD Traffic addon, this will include sensor mode.
+ }
+ }
+
+
+ private void CreateFixedSequence()
+ {
+ GSDTrafficLightSequence SMaker = null;
+ FixedTimeSequenceList = new List();
+ if (rType != RoadTypeEnum.NoTurnLane)
+ {
+ SMaker = new GSDTrafficLightSequence(true, GSDTrafficLightController.iLightControllerEnum.LeftTurn, GSDTrafficLightController.iLightSubStatusEnum.Green, opt_FixedTime_LeftTurnLightLength);
+ FixedTimeSequenceList.Add(SMaker);
+ }
+ if (rType != RoadTypeEnum.NoTurnLane)
+ {
+ SMaker = new GSDTrafficLightSequence(true, GSDTrafficLightController.iLightControllerEnum.LeftTurn, GSDTrafficLightController.iLightSubStatusEnum.Yellow, opt_FixedTime_YellowLightLength);
+ FixedTimeSequenceList.Add(SMaker);
+ }
+ SMaker = new GSDTrafficLightSequence(true, GSDTrafficLightController.iLightControllerEnum.Red, GSDTrafficLightController.iLightSubStatusEnum.Green, opt_FixedTime_AllRedLightLength);
+ FixedTimeSequenceList.Add(SMaker);
+ SMaker = new GSDTrafficLightSequence(true, GSDTrafficLightController.iLightControllerEnum.Regular, GSDTrafficLightController.iLightSubStatusEnum.Green, opt_FixedTime_RegularLightLength);
+ FixedTimeSequenceList.Add(SMaker);
+ SMaker = new GSDTrafficLightSequence(true, GSDTrafficLightController.iLightControllerEnum.Regular, GSDTrafficLightController.iLightSubStatusEnum.Yellow, opt_FixedTime_YellowLightLength);
+ FixedTimeSequenceList.Add(SMaker);
+ SMaker = new GSDTrafficLightSequence(true, GSDTrafficLightController.iLightControllerEnum.Red, GSDTrafficLightController.iLightSubStatusEnum.Green, opt_FixedTime_AllRedLightLength);
+ FixedTimeSequenceList.Add(SMaker);
+
+ if (rType != RoadTypeEnum.NoTurnLane)
+ {
+ SMaker = new GSDTrafficLightSequence(false, GSDTrafficLightController.iLightControllerEnum.LeftTurn, GSDTrafficLightController.iLightSubStatusEnum.Green, opt_FixedTime_LeftTurnLightLength);
+ FixedTimeSequenceList.Add(SMaker);
+ }
+ if (rType != RoadTypeEnum.NoTurnLane)
+ {
+ SMaker = new GSDTrafficLightSequence(false, GSDTrafficLightController.iLightControllerEnum.LeftTurn, GSDTrafficLightController.iLightSubStatusEnum.Yellow, opt_FixedTime_YellowLightLength);
+ FixedTimeSequenceList.Add(SMaker);
+ }
+ SMaker = new GSDTrafficLightSequence(true, GSDTrafficLightController.iLightControllerEnum.Red, GSDTrafficLightController.iLightSubStatusEnum.Green, opt_FixedTime_AllRedLightLength);
+ FixedTimeSequenceList.Add(SMaker);
+ SMaker = new GSDTrafficLightSequence(false, GSDTrafficLightController.iLightControllerEnum.Regular, GSDTrafficLightController.iLightSubStatusEnum.Green, opt_FixedTime_RegularLightLength);
+ FixedTimeSequenceList.Add(SMaker);
+ SMaker = new GSDTrafficLightSequence(false, GSDTrafficLightController.iLightControllerEnum.Regular, GSDTrafficLightController.iLightSubStatusEnum.Yellow, opt_FixedTime_YellowLightLength);
+ FixedTimeSequenceList.Add(SMaker);
+ SMaker = new GSDTrafficLightSequence(false, GSDTrafficLightController.iLightControllerEnum.Red, GSDTrafficLightController.iLightSubStatusEnum.Green, opt_FixedTime_AllRedLightLength);
+ FixedTimeSequenceList.Add(SMaker);
+ }
+
+
+ private IEnumerator TrafficLightFixedUpdate(float tTime)
+ {
+ yield return new WaitForSeconds(tTime);
+ FixedTime_Increment();
+ }
+
+
+ int FixedTimeIndex = 0;
+
+
+ private void FixedTime_Increment()
+ {
+ GSDTrafficLightSequence SMaker = FixedTimeSequenceList[FixedTimeIndex];
+ FixedTimeIndex += 1;
+ if (FixedTimeIndex > (FixedTimeSequenceList.Count - 1))
+ {
+ FixedTimeIndex = 0;
+ }
+
+ GSDTrafficLightController Lights1 = null;
+ GSDTrafficLightController Lights2 = null;
+
+ GSDTrafficLightController Lights_outer1 = null;
+ GSDTrafficLightController Lights_outer2 = null;
+
+ if (SMaker.bLightMasterPath1)
+ {
+ Lights1 = LightsRL;
+ Lights2 = LightsLR;
+
+ if (bFlipped)
+ {
+ Lights_outer1 = LightsRR;
+ Lights_outer2 = LightsLL;
+ }
+ else
+ {
+ Lights_outer1 = LightsRR;
+ Lights_outer2 = LightsLL;
+ }
+ }
+ else
+ {
+ if (bFlipped)
+ {
+ Lights1 = LightsRR;
+ Lights2 = LightsLL;
+ }
+ else
+ {
+ Lights1 = LightsRR;
+ Lights2 = LightsLL;
+ }
+
+ Lights_outer1 = LightsRL;
+ Lights_outer2 = LightsLR;
+ }
+
+ GSDTrafficLightController.iLightControllerEnum LCE = SMaker.iLightController;
+ GSDTrafficLightController.iLightSubStatusEnum LCESub = SMaker.iLightSubcontroller;
+
+ if (LCE == GSDTrafficLightController.iLightControllerEnum.Regular)
+ {
+ Lights1.UpdateLights(GSDTrafficLightController.iLightStatusEnum.Regular, LCESub, bLightsEnabled);
+ Lights2.UpdateLights(GSDTrafficLightController.iLightStatusEnum.Regular, LCESub, bLightsEnabled);
+ Lights_outer1.UpdateLights(GSDTrafficLightController.iLightStatusEnum.Red, LCESub, bLightsEnabled);
+ Lights_outer2.UpdateLights(GSDTrafficLightController.iLightStatusEnum.Red, LCESub, bLightsEnabled);
+ }
+ else if (LCE == GSDTrafficLightController.iLightControllerEnum.LeftTurn)
+ {
+ Lights1.UpdateLights(GSDTrafficLightController.iLightStatusEnum.LeftTurn, LCESub, bLightsEnabled);
+ Lights2.UpdateLights(GSDTrafficLightController.iLightStatusEnum.LeftTurn, LCESub, bLightsEnabled);
+ Lights_outer1.UpdateLights(GSDTrafficLightController.iLightStatusEnum.RightTurn, LCESub, bLightsEnabled);
+ Lights_outer2.UpdateLights(GSDTrafficLightController.iLightStatusEnum.RightTurn, LCESub, bLightsEnabled);
+ }
+ else if (LCE == GSDTrafficLightController.iLightControllerEnum.Red)
+ {
+ Lights1.UpdateLights(GSDTrafficLightController.iLightStatusEnum.Red, LCESub, bLightsEnabled);
+ Lights2.UpdateLights(GSDTrafficLightController.iLightStatusEnum.Red, LCESub, bLightsEnabled);
+ Lights_outer1.UpdateLights(GSDTrafficLightController.iLightStatusEnum.Red, LCESub, bLightsEnabled);
+ Lights_outer2.UpdateLights(GSDTrafficLightController.iLightStatusEnum.Red, LCESub, bLightsEnabled);
+ }
+
+ // Debug.Log ("Starting: " + SMaker.ToString());
+ StartCoroutine(TrafficLightFixedUpdate(SMaker.tTime));
+ }
+ #endregion
+
+
+#if UNITY_EDITOR
+ #region "Materials"
+ public void ResetMaterials_All()
+ {
+ ResetMaterials_Center(false);
+ ResetMaterials_Ext_Stretched(false);
+ ResetMaterials_Ext_Tiled(false);
+ ResetMaterials_Lanes(false);
+ UpdateMaterials();
+ }
+
+ public void ResetMaterials_Center(bool bUpdate = true)
+ {
+ string tLanes = "-2L";
+ Lanes = Node1.GSDSpline.tRoad.opt_Lanes;
+ if (Lanes == 4)
+ {
+ tLanes = "-4L";
+ }
+ else if (Lanes == 6)
+ {
+ tLanes = "-6L";
+ }
+ if (iType == IntersectionTypeEnum.ThreeWay)
+ {
+ tLanes += "-3";
+ if (Node1.idOnSpline < 2 || Node2.idOnSpline < 2)
+ {
+ // if(bFirstSpecial_First || bFirstSpecial_Last){ //Reverse if from node 0
+ tLanes += "-crev"; //stands for "Center Reversed"
+ // }
+ }
+ }
+
+ if (rType == RoadTypeEnum.BothTurnLanes)
+ {
+ MarkerCenter1 = GSD.Roads.GSDRoadUtilityEditor.GiveMaterial(GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Materials/Markers/GSDInterCenter-Both" + tLanes + ".mat");
+ MarkerCenter2 = null;
+ MarkerCenter3 = null;
+ }
+ else if (rType == RoadTypeEnum.TurnLane)
+ {
+ MarkerCenter1 = GSD.Roads.GSDRoadUtilityEditor.GiveMaterial(GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Materials/Markers/GSDInterCenter-Left" + tLanes + ".mat");
+ MarkerCenter2 = null;
+ MarkerCenter3 = null;
+ }
+ else if (rType == RoadTypeEnum.NoTurnLane)
+ {
+ MarkerCenter1 = GSD.Roads.GSDRoadUtilityEditor.GiveMaterial(GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Materials/Markers/GSDInterCenter-None" + tLanes + ".mat");
+ MarkerCenter2 = null;
+ MarkerCenter3 = null;
+ }
+ if (bUpdate)
+ { UpdateMaterials(); }
+ }
+
+
+ public void ResetMaterials_Ext_Stretched(bool bUpdate = true)
+ {
+ string tLanes = "-2L";
+ Lanes = Node1.GSDSpline.tRoad.opt_Lanes;
+ if (Lanes == 4)
+ {
+ tLanes = "-4L";
+ }
+ else if (Lanes == 6)
+ {
+ tLanes = "-6L";
+ }
+
+ if (rType == RoadTypeEnum.BothTurnLanes)
+ {
+ MarkerExt_Stretch1 = GSD.Roads.GSDRoadUtilityEditor.GiveMaterial(GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Materials/Markers/GSDInterStretch-Both" + tLanes + ".mat");
+ MarkerExt_Stretch2 = null;
+ MarkerExt_Stretch3 = null;
+ }
+ else if (rType == RoadTypeEnum.TurnLane)
+ {
+ MarkerExt_Stretch1 = GSD.Roads.GSDRoadUtilityEditor.GiveMaterial(GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Materials/Markers/GSDInterStretch-Left" + tLanes + ".mat");
+ MarkerExt_Stretch2 = null;
+ MarkerExt_Stretch3 = null;
+ }
+ else if (rType == RoadTypeEnum.NoTurnLane)
+ {
+ MarkerExt_Stretch1 = GSD.Roads.GSDRoadUtilityEditor.GiveMaterial(GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Materials/Markers/GSDInterStretch-None" + tLanes + ".mat");
+ MarkerExt_Stretch2 = null;
+ MarkerExt_Stretch3 = null;
+ }
+ if (bUpdate)
+ { UpdateMaterials(); }
+ }
+
+
+ public void ResetMaterials_Ext_Tiled(bool bUpdate = true)
+ {
+ if (rType == RoadTypeEnum.BothTurnLanes)
+ {
+ MarkerExt_Tiled1 = GSD.Roads.GSDRoadUtilityEditor.GiveMaterial(GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Materials/GSDRoad1.mat");
+ MarkerExt_Tiled2 = GSD.Roads.GSDRoadUtilityEditor.GiveMaterial(GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Materials/Markers/GSDRoadDetailOverlay1.mat");
+ MarkerExt_Tiled3 = null;
+ }
+ else if (rType == RoadTypeEnum.TurnLane)
+ {
+ MarkerExt_Tiled1 = GSD.Roads.GSDRoadUtilityEditor.GiveMaterial(GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Materials/GSDRoad1.mat");
+ MarkerExt_Tiled2 = GSD.Roads.GSDRoadUtilityEditor.GiveMaterial(GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Materials/Markers/GSDRoadDetailOverlay1.mat");
+ MarkerExt_Tiled3 = null;
+ }
+ else if (rType == RoadTypeEnum.NoTurnLane)
+ {
+ MarkerExt_Tiled1 = GSD.Roads.GSDRoadUtilityEditor.GiveMaterial(GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Materials/GSDRoad1.mat");
+ MarkerExt_Tiled2 = GSD.Roads.GSDRoadUtilityEditor.GiveMaterial(GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Materials/Markers/GSDRoadDetailOverlay1.mat");
+ MarkerExt_Tiled3 = null;
+ }
+ if (bUpdate)
+ { UpdateMaterials(); }
+ }
+
+
+ public void ResetMaterials_Lanes(bool bUpdate = true)
+ {
+ string tLanes = "";
+ Lanes = Node1.GSDSpline.tRoad.opt_Lanes;
+ if (Lanes == 4)
+ {
+ tLanes = "-4L";
+ }
+ else if (Lanes == 6)
+ {
+ tLanes = "-6L";
+ }
+
+ if (iType == IntersectionTypeEnum.ThreeWay)
+ {
+ Lane1Mat1_Disabled = GSD.Roads.GSDRoadUtilityEditor.GiveMaterial(GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Materials/Markers/GSDInterLaneDisabled.mat");
+ Lane1Mat2_Disabled = null;
+ if (rType == RoadTypeEnum.BothTurnLanes)
+ {
+ Lane1Mat1_DisabledActive = GSD.Roads.GSDRoadUtilityEditor.GiveMaterial(GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Materials/Markers/GSDInterLaneDisabledOuterRR.mat");
+ Lane1Mat2_DisabledActive = null;
+ Lane2Mat1_Disabled = GSD.Roads.GSDRoadUtilityEditor.GiveMaterial(GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Materials/Markers/GSDInterLaneDisabledR.mat");
+ Lane2Mat2_Disabled = null;
+ }
+ else
+ {
+ Lane2Mat1_Disabled = null;
+ Lane2Mat2_Disabled = null;
+ Lane2Mat1_DisabledActive = null;
+ Lane2Mat2_DisabledActive = null;
+ }
+ Lane2Mat1_DisabledActive = GSD.Roads.GSDRoadUtilityEditor.GiveMaterial(GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Materials/Markers/GSDInterLaneDisabledOuter" + tLanes + ".mat");
+ Lane2Mat2_DisabledActive = null;
+ if (rType == RoadTypeEnum.BothTurnLanes)
+ {
+ Lane2Mat1_DisabledActiveR = GSD.Roads.GSDRoadUtilityEditor.GiveMaterial(GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Materials/Markers/GSDInterLaneDisabledOuterR.mat");
+ Lane2Mat2_DisabledActiveR = null;
+ Lane3Mat1_Disabled = GSD.Roads.GSDRoadUtilityEditor.GiveMaterial(GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Materials/Markers/GSDInterLaneDisabledR.mat");
+ Lane3Mat2_Disabled = null;
+ }
+ else
+ {
+ Lane2Mat1_DisabledActiveR = null;
+ Lane2Mat2_DisabledActiveR = null;
+ Lane3Mat1_Disabled = null;
+ Lane3Mat2_Disabled = null;
+ }
+ }
+ else
+ {
+ Lane1Mat1_Disabled = null;
+ Lane1Mat2_Disabled = null;
+ Lane2Mat1_Disabled = null;
+ Lane2Mat2_Disabled = null;
+ Lane2Mat1_DisabledActive = null;
+ Lane2Mat2_DisabledActive = null;
+ Lane2Mat1_DisabledActiveR = null;
+ Lane2Mat2_DisabledActiveR = null;
+ Lane3Mat1_Disabled = null;
+ Lane3Mat2_Disabled = null;
+ }
+
+ if (rType == RoadTypeEnum.BothTurnLanes)
+ {
+ Lane0Mat1 = GSD.Roads.GSDRoadUtilityEditor.GiveMaterial(GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Materials/Markers/GSDInterWhiteLYellowR" + tLanes + ".mat");
+ Lane0Mat2 = null;
+ Lane1Mat1 = GSD.Roads.GSDRoadUtilityEditor.GiveMaterial(GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Materials/Markers/GSDInterYellowLWhiteR.mat");
+ Lane1Mat2 = null;
+ Lane2Mat1 = GSD.Roads.GSDRoadUtilityEditor.GiveMaterial(GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Materials/Markers/GSDInterWhiteR" + tLanes + ".mat");
+ Lane2Mat2 = null;
+ Lane3Mat1 = GSD.Roads.GSDRoadUtilityEditor.GiveMaterial(GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Materials/Markers/GSDInterWhiteR.mat");
+ Lane3Mat2 = null;
+ }
+ else if (rType == RoadTypeEnum.TurnLane)
+ {
+ Lane0Mat1 = GSD.Roads.GSDRoadUtilityEditor.GiveMaterial(GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Materials/Markers/GSDInterWhiteLYellowR" + tLanes + ".mat");
+ Lane0Mat2 = null;
+ Lane1Mat1 = GSD.Roads.GSDRoadUtilityEditor.GiveMaterial(GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Materials/Markers/GSDInterYellowLWhiteR.mat");
+ Lane1Mat2 = null;
+ Lane2Mat1 = GSD.Roads.GSDRoadUtilityEditor.GiveMaterial(GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Materials/Markers/GSDInterWhiteR" + tLanes + ".mat");
+ Lane2Mat2 = null;
+ Lane3Mat1 = null;
+ Lane3Mat2 = null;
+ }
+ else if (rType == RoadTypeEnum.NoTurnLane)
+ {
+ Lane0Mat1 = GSD.Roads.GSDRoadUtilityEditor.GiveMaterial(GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Materials/Markers/GSDInterWhiteLYellowR" + tLanes + ".mat");
+ Lane0Mat2 = null;
+ Lane1Mat1 = GSD.Roads.GSDRoadUtilityEditor.GiveMaterial(GSD.Roads.GSDRoadUtilityEditor.GetBasePath() + "/Materials/Markers/GSDInterYellowLWhiteR" + tLanes + ".mat");
+ Lane1Mat2 = null;
+ Lane2Mat1 = null;
+ Lane2Mat2 = null;
+ Lane3Mat1 = null;
+ Lane3Mat2 = null;
+ }
+
+ if (bUpdate)
+ { UpdateMaterials(); }
+ }
+
+
+ public void UpdateMaterials()
+ {
+ UpdateMaterials_Do();
+ }
+
+
+ private void UpdateMaterials_Do()
+ {
+ int cCount = transform.childCount;
+ List MR_Ext_Stretch = new List();
+ List MR_Ext_Tiled = new List();
+ MeshRenderer MR_Center = null;
+ List MR_Lane0 = new List();
+ List MR_Lane1 = new List();
+ List MR_Lane2 = new List();
+ List MR_Lane3 = new List();
+ List MR_LaneD1 = new List();
+ List MR_LaneD3 = new List();
+ List MR_LaneDA2 = new List();
+ List MR_LaneDAR2 = new List();
+ List MR_LaneD2 = new List();
+ List MR_LaneDA1 = new List();
+
+ string tTransName = "";
+ for (int i = 0; i < cCount; i++)
+ {
+ tTransName = transform.GetChild(i).name.ToLower();
+ if (tTransName.Contains("-stretchext"))
+ {
+ MR_Ext_Stretch.Add(transform.GetChild(i).GetComponent());
+ continue;
+ }
+ if (tTransName.Contains("-tiledext"))
+ {
+ MR_Ext_Tiled.Add(transform.GetChild(i).GetComponent());
+ continue;
+ }
+ if (tTransName.Contains("centermarkers"))
+ {
+ MR_Center = transform.GetChild(i).GetComponent();
+ continue;
+ }
+ if (tTransName.Contains("lane0"))
+ {
+ MR_Lane0.Add(transform.GetChild(i).GetComponent());
+ continue;
+ }
+ if (tTransName.Contains("lane1"))
+ {
+ MR_Lane1.Add(transform.GetChild(i).GetComponent());
+ continue;
+ }
+ if (tTransName.Contains("lane2"))
+ {
+ MR_Lane2.Add(transform.GetChild(i).GetComponent());
+ continue;
+ }
+ if (tTransName.Contains("lane3"))
+ {
+ MR_Lane3.Add(transform.GetChild(i).GetComponent