浏览代码

Changed emissive mesh update system to support multi-inspector

/main
Antoine Lelievre 6 年前
当前提交
5c245e8f
共有 2 个文件被更改,包括 29 次插入13 次删除
  1. 2
      com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/HDLightEditor.Styles.cs
  2. 40
      com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/HDLightEditor.cs

2
com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/HDLightEditor.Styles.cs


public readonly GUIContent shapeWidthBox = new GUIContent("Size X", "");
public readonly GUIContent shapeHeightBox = new GUIContent("Size Y", "");
public readonly GUIContent applyRangeAttenuation = new GUIContent("Apply Range Attenuation", "Allows disabling range attenuation. This is useful indoor (like a room) to avoid having to setup a large range for a light to get correct inverse square attenuation that may leak out of the indoor");
public readonly GUIContent showEmissiveMesh = new GUIContent("Show Emissive Mesh", "Generate an emissive mesh using the size and intensity of the light");
public readonly GUIContent showEmissiveMesh = new GUIContent("Show Emissive Mesh", "Generate an emissive mesh using the size, color and intensity of the light");
public readonly GUIContent shape = new GUIContent("Type", "Specifies the current type of light. Possible types are Directional, Spot, Point, Rectangle and Line lights.");
public readonly GUIContent[] shapeNames;

40
com.unity.render-pipelines.high-definition/HDRP/Editor/Lighting/HDLightEditor.cs


HDAdditionalLightData[] m_AdditionalLightDatas;
AdditionalShadowData[] m_AdditionalShaodowDatas;
// Used to detect if the scale have been changed via the transform component
Vector3 m_OldLightSize;
bool m_UpdateEmissiveMesh;
protected override void OnEnable()
{
base.OnEnable();

m_SerializedAdditionalShadowData.ApplyModifiedProperties();
m_SerializedAdditionalLightData.ApplyModifiedProperties();
settings.ApplyModifiedProperties();
if (m_UpdateEmissiveMesh)
UpdateEmissiveMesh();
}
void DrawFoldout(SerializedProperty foldoutProperty, string title, Action func)

if (EditorGUI.EndChangeCheck())
{
UpdateLightIntensity();
UpdateEmissiveMesh();
m_UpdateEmissiveMesh = true;
((Light)target).SetLightDirty(); // Should be apply only to parameter that's affect GI, but make the code cleaner
}
}

GameObject lightGameObject = lightData.gameObject;
MeshRenderer emissiveMeshRenderer = lightData.GetComponent<MeshRenderer>();
MeshFilter emissiveMeshFilter = lightData.GetComponent<MeshFilter>();
Light light = lightGameObject.GetComponent<Light>();
bool showEmissiveMesh = IsAreaLightShape(m_LightShape) && m_LightShape != LightShape.Line && m_AdditionalLightData.showEmissiveMesh.boolValue;

}
float areaLightIntensity = 0;
lightGameObject.transform.localScale = new Vector3(m_AdditionalLightData.shapeWidth.floatValue, m_AdditionalLightData.shapeHeight.floatValue, 0);
lightGameObject.transform.localScale = new Vector3(lightData.shapeWidth, lightData.shapeHeight, 0);
settings.intensity.floatValue,
m_AdditionalLightData.shapeWidth.floatValue,
m_AdditionalLightData.shapeHeight.floatValue);
light.intensity,
lightData.shapeWidth,
lightData.shapeHeight);
break;
default:
break;

emissiveMeshRenderer.material = new Material(Shader.Find("HDRenderPipeline/Unlit"));
emissiveMeshRenderer.sharedMaterial.SetColor("_UnlitColor", Color.black);
emissiveMeshRenderer.sharedMaterial.SetColor("_EmissiveColor", settings.color.colorValue * areaLightIntensity);
emissiveMeshRenderer.sharedMaterial.SetColor("_EmissiveColor", light.color * areaLightIntensity);
}
}

// Early exit if the light type is not an area
if (!IsAreaLightShape(m_LightShape) || target == null)
if (!IsAreaLightShape(m_LightShape) || target == null || targets.Length > 1)
if (lightSize == m_OldLightSize)
return ;
switch (m_LightShape)
{
case LightShape.Rectangle:

default:
break;
}
UpdateLightIntensity();
m_UpdateEmissiveMesh = true;
m_OldLightSize = lightSize;
}
// Caution: this function must match the one in HDAdditionalLightData.ConvertPhysicalLightIntensityToLightIntensity - any change need to be replicated

EditorGUI.BeginChangeCheck();
settings.DrawColor();
if (EditorGUI.EndChangeCheck())
UpdateEmissiveMesh();
m_UpdateEmissiveMesh = true;
EditorGUI.BeginChangeCheck();

if (EditorGUI.EndChangeCheck())
{
UpdateLightIntensity();
UpdateEmissiveMesh();
m_UpdateEmissiveMesh = true;
}
settings.DrawBounceIntensity();

if (IsAreaLightShape(m_LightShape))
{
EditorGUI.BeginChangeCheck();
EditorGUILayout.PropertyField(m_AdditionalLightData.showEmissiveMesh);
EditorGUILayout.PropertyField(m_AdditionalLightData.showEmissiveMesh, s_Styles.showEmissiveMesh);
UpdateEmissiveMesh();
m_UpdateEmissiveMesh = true;
}
if (m_AdditionalLightData.showAdditionalSettings.boolValue)

正在加载...
取消
保存