Firstborn/Library/PackageCache/com.unity.render-pipelines..../Editor/UniversalRenderPipelineLigh...
Schaken-Mods 9092858a58 updated to the latest editor
I updated everything to the latest Unity Editor. Also realized I had the wrong shaders on my hairs, those are fixed and the hairs look MUCH better!
2023-05-07 17:43:11 -05:00

93 lines
3.3 KiB
C#

using UnityEngine;
using UnityEngine.Rendering;
using UnityEngine.Rendering.Universal;
namespace UnityEditor.Rendering.Universal
{
[CanEditMultipleObjects]
[CustomEditorForRenderPipeline(typeof(Light), typeof(UniversalRenderPipelineAsset))]
class UniversalRenderPipelineLightEditor : LightEditor
{
UniversalRenderPipelineSerializedLight serializedLight { get; set; }
protected override void OnEnable()
{
serializedLight = new UniversalRenderPipelineSerializedLight(serializedObject, settings);
}
// IsPreset is an internal API - lets reuse the usable part of this function
// 93 is a "magic number" and does not represent a combination of other flags here
internal static bool IsPresetEditor(UnityEditor.Editor editor)
{
return (int)((editor.target as Component).gameObject.hideFlags) == 93;
}
public override void OnInspectorGUI()
{
serializedLight.Update();
if (IsPresetEditor(this))
{
UniversalRenderPipelineLightUI.PresetInspector.Draw(serializedLight, this);
}
else
{
UniversalRenderPipelineLightUI.Inspector.Draw(serializedLight, this);
}
serializedLight.Apply();
}
protected override void OnSceneGUI()
{
if (!(GraphicsSettings.currentRenderPipeline is UniversalRenderPipelineAsset))
return;
if (!(target is Light light) || light == null)
return;
switch (light.type)
{
case LightType.Spot:
using (new Handles.DrawingScope(Matrix4x4.TRS(light.transform.position, light.transform.rotation, Vector3.one)))
{
CoreLightEditorUtilities.DrawSpotLightGizmo(light);
}
break;
case LightType.Point:
using (new Handles.DrawingScope(Matrix4x4.TRS(light.transform.position, Quaternion.identity, Vector3.one)))
{
CoreLightEditorUtilities.DrawPointLightGizmo(light);
}
break;
case LightType.Rectangle:
using (new Handles.DrawingScope(Matrix4x4.TRS(light.transform.position, light.transform.rotation, Vector3.one)))
{
CoreLightEditorUtilities.DrawRectangleLightGizmo(light);
}
break;
case LightType.Disc:
using (new Handles.DrawingScope(Matrix4x4.TRS(light.transform.position, light.transform.rotation, Vector3.one)))
{
CoreLightEditorUtilities.DrawDiscLightGizmo(light);
}
break;
case LightType.Directional:
using (new Handles.DrawingScope(Matrix4x4.TRS(light.transform.position, light.transform.rotation, Vector3.one)))
{
CoreLightEditorUtilities.DrawDirectionalLightGizmo(light);
}
break;
default:
base.OnSceneGUI();
break;
}
}
}
}