mirror of
https://github.com/GTA-ASM/SanAndreasUnity
synced 2024-11-10 14:44:17 +00:00
use WaterFaceInfo script
This commit is contained in:
parent
492ae15444
commit
878e89a8a9
6 changed files with 89 additions and 1 deletions
|
@ -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++;
|
||||
|
|
23
Assets/Scripts/Behaviours/World/WaterFaceInfo.cs
Normal file
23
Assets/Scripts/Behaviours/World/WaterFaceInfo.cs
Normal 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
11
Assets/Scripts/Behaviours/World/WaterFaceInfo.cs.meta
Normal file
11
Assets/Scripts/Behaviours/World/WaterFaceInfo.cs.meta
Normal file
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 488f0b595ac287a46a583aa25adcb1bd
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
32
Assets/Scripts/Editor/WaterFaceInfoInspector.cs
Normal file
32
Assets/Scripts/Editor/WaterFaceInfoInspector.cs
Normal 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
11
Assets/Scripts/Editor/WaterFaceInfoInspector.cs.meta
Normal file
11
Assets/Scripts/Editor/WaterFaceInfoInspector.cs.meta
Normal file
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: dbb12aa46b368a0448dcfa843e6c9923
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue