diff --git a/Assets/Scripts/Behaviours/World/Water.cs b/Assets/Scripts/Behaviours/World/Water.cs index c120bada..c2ee5f04 100644 --- a/Assets/Scripts/Behaviours/World/Water.cs +++ b/Assets/Scripts/Behaviours/World/Water.cs @@ -214,6 +214,12 @@ namespace SanAndreasUnity.Behaviours.World visualGo.transform.localScale = size; } + if (Application.isEditor) // only do it in Editor, no need to do it in a build + { + var waterFaceInfo = go.GetOrAddComponent(); + waterFaceInfo.WaterFace = face; + } + m_collisionObjects.Add(go.transform); i++; diff --git a/Assets/Scripts/Behaviours/World/WaterFaceInfo.cs b/Assets/Scripts/Behaviours/World/WaterFaceInfo.cs new file mode 100644 index 00000000..ff04daf2 --- /dev/null +++ b/Assets/Scripts/Behaviours/World/WaterFaceInfo.cs @@ -0,0 +1,23 @@ +using SanAndreasUnity.Importing.Items.Placements; +using UnityEngine; + +namespace SanAndreasUnity.Behaviours.World +{ + public class WaterFaceInfo : MonoBehaviour + { + public WaterFace WaterFace { get; set; } + + private void OnDrawGizmosSelected() + { + if (null == this.WaterFace) + return; + + Gizmos.color = Color.green; + + foreach (var vertex in this.WaterFace.Vertices) + { + Gizmos.DrawWireSphere(vertex.Position, 2f); + } + } + } +} diff --git a/Assets/Scripts/Behaviours/World/WaterFaceInfo.cs.meta b/Assets/Scripts/Behaviours/World/WaterFaceInfo.cs.meta new file mode 100644 index 00000000..5a4ff73f --- /dev/null +++ b/Assets/Scripts/Behaviours/World/WaterFaceInfo.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 488f0b595ac287a46a583aa25adcb1bd +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Editor/WaterFaceInfoInspector.cs b/Assets/Scripts/Editor/WaterFaceInfoInspector.cs new file mode 100644 index 00000000..f1ba090a --- /dev/null +++ b/Assets/Scripts/Editor/WaterFaceInfoInspector.cs @@ -0,0 +1,32 @@ +using SanAndreasUnity.Behaviours.World; +using UnityEditor; +using UnityEngine; + +namespace SanAndreasUnity.Editor +{ + [CustomEditor(typeof(WaterFaceInfo))] + public class WaterFaceInfoInspector : UnityEditor.Editor + { + public override void OnInspectorGUI() + { + base.DrawDefaultInspector(); + + GUILayout.Space(10); + GUILayout.Label("Info:"); + GUILayout.Space(10); + + var waterFaceInfo = (WaterFaceInfo)this.target; + + if (waterFaceInfo.WaterFace != null) + { + EditorUtils.DrawFieldsAndPropertiesInInspector(waterFaceInfo.WaterFace, 0); + + foreach (var vertex in waterFaceInfo.WaterFace.Vertices) + { + GUILayout.Space(10); + EditorUtils.DrawFieldsAndPropertiesInInspector(vertex, 0); + } + } + } + } +} diff --git a/Assets/Scripts/Editor/WaterFaceInfoInspector.cs.meta b/Assets/Scripts/Editor/WaterFaceInfoInspector.cs.meta new file mode 100644 index 00000000..b49e575b --- /dev/null +++ b/Assets/Scripts/Editor/WaterFaceInfoInspector.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: dbb12aa46b368a0448dcfa843e6c9923 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Utilities/F.cs b/Assets/Scripts/Utilities/F.cs index 7c205d53..9adeddbe 100644 --- a/Assets/Scripts/Utilities/F.cs +++ b/Assets/Scripts/Utilities/F.cs @@ -914,7 +914,12 @@ namespace SanAndreasUnity.Utilities return new Vector3 (vec3.x, yValue, vec3.z); } - public static Vector3 Inverted (this Vector3 vec3) + public static Vector3 WithAddedY(this Vector3 vec3, float addedYValue) + { + return new Vector3(vec3.x, vec3.y + addedYValue, vec3.z); + } + + public static Vector3 Inverted (this Vector3 vec3) { return new Vector3 (1.0f / vec3.x, 1.0f / vec3.y, 1.0f / vec3.z); }