Fixed the issue that positionWS is camear-relative position but world matrix is in absolute world space
This commit is contained in:
@@ -2,13 +2,14 @@ using UnityEngine;
|
||||
|
||||
namespace Misaki.AoVolume
|
||||
{
|
||||
[ExecuteInEditMode]
|
||||
internal class AoVolume : MonoBehaviour
|
||||
{
|
||||
private VolumeEntity _entity = VolumeEntity.InvalidEntity;
|
||||
|
||||
public VolumeData data;
|
||||
|
||||
protected virtual void InitializeEntity()
|
||||
private void InitializeEntity()
|
||||
{
|
||||
if (_entity.IsValid)
|
||||
{
|
||||
@@ -18,23 +19,27 @@ namespace Misaki.AoVolume
|
||||
_entity = VolumeDatabase.Instance.CreateEntity(this);
|
||||
}
|
||||
|
||||
protected virtual void OnEnable()
|
||||
private void OnEnable()
|
||||
{
|
||||
InitializeEntity();
|
||||
}
|
||||
|
||||
protected virtual void OnDisable()
|
||||
private void OnDisable()
|
||||
{
|
||||
if (_entity.IsValid)
|
||||
{
|
||||
VolumeDatabase.Instance.DestroyEntity(_entity);
|
||||
}
|
||||
VolumeDatabase.Instance.DestroyEntity(_entity);
|
||||
}
|
||||
|
||||
protected virtual void Update()
|
||||
private void Update()
|
||||
{
|
||||
data.worldMatrix = transform.localToWorldMatrix;
|
||||
data.inverseWorldMatrix = data.worldMatrix.inverse;
|
||||
}
|
||||
|
||||
private void OnDrawGizmos()
|
||||
{
|
||||
Gizmos.matrix = transform.localToWorldMatrix;
|
||||
Gizmos.color = Color.green;
|
||||
Gizmos.DrawWireCube(Vector3.zero, data.size);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user