This repository has been archived by the owner on Jun 26, 2021. It is now read-only.
forked from MicroGSD/RoadArchitect
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Fixed warnings * Begin adding off-road connections
- Loading branch information
1 parent
1466145
commit 8a8bb72
Showing
8 changed files
with
154 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
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() | ||
{ | ||
|
||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
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<GSDOffRoadObject>(); } } | ||
// Start is called before the first frame update | ||
void Start() | ||
{ | ||
} | ||
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(); | ||
} | ||
} | ||
} | ||
} | ||
|
||
#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 |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters