Skip to content

Commit b43fcaf

Browse files
authored
IES Code path refactoring to support multiple SRP (#929)
* Refactor * Refacto to support multiple SRPs * Missing doc + Re-enable PreviewGUI in the Inspector * Add Icons for IES Profiles
1 parent 48ac51f commit b43fcaf

File tree

12 files changed

+278
-69
lines changed

12 files changed

+278
-69
lines changed

com.unity.render-pipelines.core/Editor/Lighting/IESImporter.cs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ namespace UnityEditor.Rendering
99
/// Common class use to share code between implementation of IES Importeres
1010
/// </summary>
1111
[System.Serializable]
12-
public class IESImporter
12+
[ScriptedImporter(1, "ies")]
13+
public partial class IESImporter : ScriptedImporter
1314
{
1415
/// <summary>
1516
/// IES Engine
@@ -23,16 +24,18 @@ public class IESImporter
2324

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

2931
/// <summary>
3032
/// Common method performing the import of the asset
3133
/// </summary>
3234
/// <param name="ctx">Asset importer context.</param>
33-
/// <param name="setupRenderPipelinePrefabLight">Delegate needed to perform operation which are "Render Pipeline specific" here setuping the prefab of light</param>
34-
public void CommonOnImportAsset(AssetImportContext ctx, SetupRenderPipelinePrefabLight setupRenderPipelinePrefabLight)
35+
public override void OnImportAsset(AssetImportContext ctx)
3536
{
37+
engine.TextureGenerationType = TextureImporterType.Default;
38+
3639
Texture cookieTextureCube = null;
3740
Texture cookieTexture2D = null;
3841

@@ -76,7 +79,7 @@ public void CommonOnImportAsset(AssetImportContext ctx, SetupRenderPipelinePrefa
7679

7780
var iesObject = ScriptableObject.CreateInstance<IESObject>();
7881
iesObject.iesMetaData = iesMetaData;
79-
var lightObject = new GameObject(iesFileName);
82+
GameObject lightObject = new GameObject(iesFileName);
8083

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

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

89-
setupRenderPipelinePrefabLight(engine, light, (iesMetaData.PrefabLightType == IESLightType.Point) ? cookieTextureCube : cookieTexture2D);
90-
9192
ctx.AddObjectToAsset("IES", iesObject);
9293
ctx.SetMainObject(iesObject);
9394

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

9797
if (cookieTextureCube != null)
9898
{

com.unity.render-pipelines.core/Editor/Lighting/IESObject.cs.meta

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

com.unity.render-pipelines.core/Editor/Lighting/Icons.meta

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 3 additions & 0 deletions
Loading

com.unity.render-pipelines.core/Editor/Lighting/Icons/IES Profile.png.meta

Lines changed: 96 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 3 additions & 0 deletions
Loading

com.unity.render-pipelines.core/Editor/Lighting/Icons/IES Profile2.png.meta

Lines changed: 96 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

com.unity.render-pipelines.high-definition/Editor/AssetProcessors/HDIESImporter.cs

Lines changed: 0 additions & 52 deletions
This file was deleted.

com.unity.render-pipelines.high-definition/Editor/AssetProcessors/HDIESImporterEditor.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ namespace UnityEditor.Rendering.HighDefinition
1010
/// <summary>
1111
/// Class describing the logic for importer an IES file an generating the IESObject associated
1212
/// </summary>
13-
[CustomEditor(typeof(HDIESImporter))]
13+
[CustomEditor(typeof(IESImporter))]
1414
public partial class HDIESImporterEditor : ScriptedImporterEditor
1515
{
1616
/// <summary>
@@ -73,11 +73,11 @@ public override void OnEnable()
7373
{
7474
base.OnEnable();
7575

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

80-
iesImporterEditor.CommonOnEnable(entryPoint);
80+
iesImporterEditor.CommonOnEnable(entryPoint1);
8181
}
8282

8383
/// <summary>
@@ -142,7 +142,7 @@ public override GUIContent GetPreviewTitle()
142142
/// <param name="background">Style of the background of the preview.</param>
143143
public override void OnPreviewGUI(Rect r, GUIStyle background)
144144
{
145-
iesImporterEditor.CommonOnPreviewGUI(r, background, target as HDIESImporter,
145+
iesImporterEditor.CommonOnPreviewGUI(r, background, target as IESImporter,
146146
delegate (Light light, SerializedProperty useIESMaximumIntensityProp, SerializedProperty iesMaximumIntensityUnitProp, SerializedProperty iesMaximumIntensityProp)
147147
{
148148
SetupRenderPipelinePreviewLightIntensity(light, useIESMaximumIntensityProp, iesMaximumIntensityUnitProp, iesMaximumIntensityProp);

0 commit comments

Comments
 (0)