use WaterFaceInfo script

This commit is contained in:
in0finite 2022-02-27 18:34:29 +01:00
parent 492ae15444
commit 878e89a8a9
6 changed files with 89 additions and 1 deletions

View file

@ -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>();
waterFaceInfo.WaterFace = face;
}
m_collisionObjects.Add(go.transform);
i++;

View file

@ -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);
}
}
}
}

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 488f0b595ac287a46a583aa25adcb1bd
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -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);
}
}
}
}
}

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: dbb12aa46b368a0448dcfa843e6c9923
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -914,6 +914,11 @@ namespace SanAndreasUnity.Utilities
return new Vector3 (vec3.x, yValue, vec3.z);
}
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);