Improved the culling result of HizCulling;
Added custom inspector for VolumeObject; Change the name of AoVolume to VolumeObject;
This commit is contained in:
59
Editor/View/VolumeObjectView.cs
Normal file
59
Editor/View/VolumeObjectView.cs
Normal file
@@ -0,0 +1,59 @@
|
||||
using UnityEditor;
|
||||
using UnityEditor.IMGUI.Controls;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UIElements;
|
||||
|
||||
namespace Misaki.AoVolume.Editor
|
||||
{
|
||||
[CustomEditor(typeof(VolumeObject))]
|
||||
[CanEditMultipleObjects]
|
||||
public class VolumeObjectView : UnityEditor.Editor
|
||||
{
|
||||
[SerializeField]
|
||||
private VisualTreeAsset _viewAsset;
|
||||
|
||||
private readonly BoxBoundsHandle _boundsHandle = new()
|
||||
{
|
||||
wireframeColor = Color.green,
|
||||
handleColor = Color.green
|
||||
};
|
||||
|
||||
public override VisualElement CreateInspectorGUI()
|
||||
{
|
||||
if (_viewAsset == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
var view = _viewAsset.Instantiate();
|
||||
view.dataSource = target;
|
||||
|
||||
view.Q<Button>("force-update-button").clicked += () =>
|
||||
{
|
||||
var volumeObject = target as VolumeObject;
|
||||
volumeObject.ForceDataUpdate();
|
||||
};
|
||||
|
||||
return view;
|
||||
}
|
||||
|
||||
private void OnSceneGUI()
|
||||
{
|
||||
var volume = (VolumeObject)target;
|
||||
|
||||
using (new Handles.DrawingScope(volume.transform.localToWorldMatrix))
|
||||
{
|
||||
_boundsHandle.center = Vector3.zero;
|
||||
_boundsHandle.size = volume.data.size;
|
||||
|
||||
EditorGUI.BeginChangeCheck();
|
||||
_boundsHandle.DrawHandle();
|
||||
if (EditorGUI.EndChangeCheck())
|
||||
{
|
||||
Undo.RecordObject(volume, string.Format("Change {0} Volume Size", target.name));
|
||||
volume.data.size = _boundsHandle.size;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user