Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions com.unity.render-pipelines.core/Editor/Lighting/IESImporter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ namespace UnityEditor.Rendering
/// Common class use to share code between implementation of IES Importeres
/// </summary>
[System.Serializable]
public class IESImporter
[ScriptedImporter(1, "ies")]
public partial class IESImporter : ScriptedImporter
{
/// <summary>
/// IES Engine
Expand All @@ -23,16 +24,18 @@ public class IESImporter

/// <summary>
/// Delegate prototype which will be sent by the pipeline implementation of the IES Importer
/// Must be initialized during the creation of the SRP
/// </summary>
public delegate void SetupRenderPipelinePrefabLight(IESEngine engine, Light light, Texture ies);
public static event System.Action<AssetImportContext, string, bool, string, float, Light, Texture> createRenderPipelinePrefabLight;

/// <summary>
/// Common method performing the import of the asset
/// </summary>
/// <param name="ctx">Asset importer context.</param>
/// <param name="setupRenderPipelinePrefabLight">Delegate needed to perform operation which are "Render Pipeline specific" here setuping the prefab of light</param>
public void CommonOnImportAsset(AssetImportContext ctx, SetupRenderPipelinePrefabLight setupRenderPipelinePrefabLight)
public override void OnImportAsset(AssetImportContext ctx)
{
engine.TextureGenerationType = TextureImporterType.Default;

Texture cookieTextureCube = null;
Texture cookieTexture2D = null;

Expand Down Expand Up @@ -76,7 +79,7 @@ public void CommonOnImportAsset(AssetImportContext ctx, SetupRenderPipelinePrefa

var iesObject = ScriptableObject.CreateInstance<IESObject>();
iesObject.iesMetaData = iesMetaData;
var lightObject = new GameObject(iesFileName);
GameObject lightObject = new GameObject(iesFileName);

lightObject.transform.localEulerAngles = new Vector3(90f, 0f, iesMetaData.LightAimAxisRotation);

Expand All @@ -86,13 +89,10 @@ public void CommonOnImportAsset(AssetImportContext ctx, SetupRenderPipelinePrefa
light.range = 10f; // would need a better range value formula
light.spotAngle = iesMetaData.SpotAngle;

setupRenderPipelinePrefabLight(engine, light, (iesMetaData.PrefabLightType == IESLightType.Point) ? cookieTextureCube : cookieTexture2D);

ctx.AddObjectToAsset("IES", iesObject);
ctx.SetMainObject(iesObject);

// The light object will be automatically converted into a prefab.
ctx.AddObjectToAsset(iesFileName, lightObject);
IESImporter.createRenderPipelinePrefabLight?.Invoke(ctx, iesFileName, iesMetaData.UseIESMaximumIntensity, iesMetaData.IESMaximumIntensityUnit, iesMetaData.IESMaximumIntensity, light, (iesMetaData.PrefabLightType == IESLightType.Point) ? cookieTextureCube : cookieTexture2D);

if (cookieTextureCube != null)
{
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions com.unity.render-pipelines.core/Editor/Lighting/Icons.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace UnityEditor.Rendering.HighDefinition
/// <summary>
/// Class describing the logic for importer an IES file an generating the IESObject associated
/// </summary>
[CustomEditor(typeof(HDIESImporter))]
[CustomEditor(typeof(IESImporter))]
public partial class HDIESImporterEditor : ScriptedImporterEditor
{
/// <summary>
Expand Down Expand Up @@ -73,11 +73,11 @@ public override void OnEnable()
{
base.OnEnable();

PropertyFetcher<HDIESImporter> entryPoint0 = new PropertyFetcher<HDIESImporter>(serializedObject);
SerializedProperty entryPoint1 = entryPoint0.Find<IESImporter>(x => x.commonIESImporter);
SerializedProperty entryPoint = entryPoint1.FindPropertyRelative("iesMetaData");
PropertyFetcher<IESImporter> entryPoint0 = new PropertyFetcher<IESImporter>(serializedObject);
SerializedProperty entryPoint1 = entryPoint0.Find<IESMetaData>(x => x.iesMetaData);
//SerializedProperty entryPoint = entryPoint1.FindPropertyRelative("iesMetaData");

iesImporterEditor.CommonOnEnable(entryPoint);
iesImporterEditor.CommonOnEnable(entryPoint1);
}

/// <summary>
Expand Down Expand Up @@ -142,7 +142,7 @@ public override GUIContent GetPreviewTitle()
/// <param name="background">Style of the background of the preview.</param>
public override void OnPreviewGUI(Rect r, GUIStyle background)
{
iesImporterEditor.CommonOnPreviewGUI(r, background, target as HDIESImporter,
iesImporterEditor.CommonOnPreviewGUI(r, background, target as IESImporter,
delegate (Light light, SerializedProperty useIESMaximumIntensityProp, SerializedProperty iesMaximumIntensityUnitProp, SerializedProperty iesMaximumIntensityProp)
{
SetupRenderPipelinePreviewLightIntensity(light, useIESMaximumIntensityProp, iesMaximumIntensityUnitProp, iesMaximumIntensityProp);
Expand Down
Loading