Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
8426ea9
Initial addition of documentation URL button to Volume editor framework
johnpars Oct 8, 2020
e979134
Integrate the help button icon for volume component documentation.
johnpars Oct 8, 2020
4d4d710
Correct the alignment of documentation icon so it lines up with addit…
johnpars Oct 8, 2020
a65dfbb
Add also a volume component documentation attribute. This adds suppor…
johnpars Oct 8, 2020
6a95dda
Initial addition of documentation URL for custom volume editors
johnpars Oct 8, 2020
9d7e26b
Initial commit of documentation URL for default volume editors (using…
johnpars Oct 8, 2020
fed6d64
Swap the place of documentation icon with additional options icon
johnpars Oct 8, 2020
aa760b0
update changelog
johnpars Oct 8, 2020
cf85dd8
Revert choosing between two different documentations for raytracing. …
johnpars Oct 8, 2020
a4b605d
Merge latest master
johnpars Oct 19, 2020
3d072f9
Remove the VolumeComponentDocumentation attribute. Same thing can be …
johnpars Oct 19, 2020
4d758aa
Use the HelpURL for all volume components, remove the editor override
johnpars Oct 19, 2020
dc2bdc4
Fix typos to broken URL
johnpars Oct 19, 2020
e004fc8
Fix core util function signature to not break other packages or user …
johnpars Oct 20, 2020
c463e03
Preprocess the help URL attributes
johnpars Oct 20, 2020
5d69120
Do the documentation loading in static construction
johnpars Oct 20, 2020
5611cea
Organize placement of static function
johnpars Oct 20, 2020
449c2e2
Merge branch 'master' into HDRP/add-volume-component-blue-book-link
sebastienlagarde Oct 22, 2020
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
48 changes: 34 additions & 14 deletions com.unity.render-pipelines.core/Editor/CoreEditorUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ static Styles()
moreOptionsStyle.active.background = normalColor;
moreOptionsStyle.focused.background = normalColor;
moreOptionsStyle.hover.background = normalColor;

moreOptionsLabelStyle = new GUIStyle(GUI.skin.label);
moreOptionsLabelStyle.padding = new RectOffset(0, 0, 0, -1);
}
Expand Down Expand Up @@ -99,7 +99,7 @@ static public bool DrawMoreOptions(Rect rect, bool active)
evt.Use();
break;
}

return active;
}

Expand Down Expand Up @@ -232,7 +232,7 @@ public static void DrawSplitter(bool isBoxed = false)
// Splitter rect should be full-width
rect.xMin = 0f;
rect.width += 4f;

if (isBoxed)
{
rect.xMin = xMin == 7.0 ? 4.0f : EditorGUIUtility.singleLineHeight;
Expand Down Expand Up @@ -311,7 +311,7 @@ public static bool DrawHeaderFoldout(GUIContent title, bool state, bool isBoxed
foldoutRect.width = 13f;
foldoutRect.height = 13f;
foldoutRect.x = labelRect.xMin + 15 * (EditorGUI.indentLevel - 1); //fix for presset

// More options 1/2
var moreOptionsRect = new Rect();
if (hasMoreOptions != null)
Expand Down Expand Up @@ -361,7 +361,7 @@ public static bool DrawHeaderFoldout(GUIContent title, bool state, bool isBoxed
state = !state;
e.Use();
}

return state;
}

Expand Down Expand Up @@ -439,7 +439,7 @@ public static bool DrawSubHeaderFoldout(GUIContent title, bool state, bool isBox

return state;
}

/// <summary>Draw a header toggle like in Volumes</summary>
/// <param name="title"> The title of the header </param>
/// <param name="group"> The group of the header </param>
Expand All @@ -448,8 +448,8 @@ public static bool DrawSubHeaderFoldout(GUIContent title, bool state, bool isBox
/// <param name="hasMoreOptions">Delegate saying if we have MoreOptions</param>
/// <param name="toggleMoreOptions">Callback called when the MoreOptions is toggled</param>
/// <returns>return the state of the foldout header</returns>
public static bool DrawHeaderToggle(string title, SerializedProperty group, SerializedProperty activeField, Action<Vector2> contextAction = null, Func<bool> hasMoreOptions = null, Action toggleMoreOptions = null)
=> DrawHeaderToggle(EditorGUIUtility.TrTextContent(title), group, activeField, contextAction, hasMoreOptions, toggleMoreOptions);
public static bool DrawHeaderToggle(string title, SerializedProperty group, SerializedProperty activeField, Action<Vector2> contextAction = null, Func<bool> hasMoreOptions = null, Action toggleMoreOptions = null, string documentationURL = null)
=> DrawHeaderToggle(EditorGUIUtility.TrTextContent(title), group, activeField, contextAction, hasMoreOptions, toggleMoreOptions, documentationURL);

/// <summary>Draw a header toggle like in Volumes</summary>
/// <param name="title"> The title of the header </param>
Expand All @@ -459,7 +459,7 @@ public static bool DrawHeaderToggle(string title, SerializedProperty group, Seri
/// <param name="hasMoreOptions">Delegate saying if we have MoreOptions</param>
/// <param name="toggleMoreOptions">Callback called when the MoreOptions is toggled</param>
/// <returns>return the state of the foldout header</returns>
public static bool DrawHeaderToggle(GUIContent title, SerializedProperty group, SerializedProperty activeField, Action<Vector2> contextAction = null, Func<bool> hasMoreOptions = null, Action toggleMoreOptions = null)
public static bool DrawHeaderToggle(GUIContent title, SerializedProperty group, SerializedProperty activeField, Action<Vector2> contextAction = null, Func<bool> hasMoreOptions = null, Action toggleMoreOptions = null, string documentationURL = null)
{
var backgroundRect = GUILayoutUtility.GetRect(1f, 17f);

Expand All @@ -483,7 +483,12 @@ public static bool DrawHeaderToggle(GUIContent title, SerializedProperty group,
if (hasMoreOptions != null)
{
moreOptionsRect = backgroundRect;

moreOptionsRect.x += moreOptionsRect.width - 16 - 1 - 16 - 5;

if (!string.IsNullOrEmpty(documentationURL))
moreOptionsRect.x -= 16 + 7;

moreOptionsRect.height = 15;
moreOptionsRect.width = 16;
}
Expand Down Expand Up @@ -526,6 +531,21 @@ public static bool DrawHeaderToggle(GUIContent title, SerializedProperty group,
if (contextAction != null)
GUI.DrawTexture(menuRect, menuIcon);

// Documentation button
if (!String.IsNullOrEmpty(documentationURL))
{
var documentationRect = menuRect;
documentationRect.x -= 16 + 5;
documentationRect.y -= 1;

var documentationTooltip = $"Open Reference for {title.text}.";
var documentationIcon = new GUIContent(EditorGUIUtility.TrIconContent("_Help").image, documentationTooltip);
var documentationStyle = new GUIStyle("IconButton");

if (GUI.Button(documentationRect, documentationIcon, documentationStyle))
System.Diagnostics.Process.Start(documentationURL);
}

// Handle events
var e = Event.current;

Expand Down Expand Up @@ -613,7 +633,7 @@ public static void DrawVector6(GUIContent label, SerializedProperty positive, Se
}

DrawVector3(firstVectorValueRect, k_DrawVector6_Label[0], positive, min, max, false, colors == null ? null : new Color[] { colors[0], colors[1], colors[2] }, multiplicator);

Rect secondVectorValueRect = secondLineRect;
secondVectorValueRect.xMin = firstVectorValueRect.xMin;
secondVectorValueRect.xMax = firstVectorValueRect.xMax;
Expand Down Expand Up @@ -654,7 +674,7 @@ static void DrawVector3(Rect rect, GUIContent[] labels, SerializedProperty value
EditorGUI.indentLevel = 0;
float oldLabelWidth = EditorGUIUtility.labelWidth;
EditorGUIUtility.labelWidth = subLabelWidth;

for (int i = 0; i < 3; ++i)
{
Rect localRect = rect;
Expand Down Expand Up @@ -845,7 +865,7 @@ public static T[] GetAdditionalData<T>(UnityEngine.Object[] targets, Action<T> i
/// <returns>The created object</returns>
static public GameObject CreateGameObject(GameObject parent, string name, params Type[] types)
=> ObjectFactory.CreateGameObject(GameObjectUtility.GetUniqueNameForSibling(parent != null ? parent.transform : null, name), types);

/// <summary>
/// Creates a new GameObject and set it's position to the current view
/// </summary>
Expand Down Expand Up @@ -898,7 +918,7 @@ internal enum Skin
Personnal,
Professional,
}

static Func<int> GetInternalSkinIndex;
static Func<float> GetGUIStatePixelsPerPoint;
static Func<Texture2D, float> GetTexturePixelPerPoint;
Expand Down Expand Up @@ -954,7 +974,7 @@ internal static Texture2D LoadIcon(string path, string name, string extention =
var skin = currentSkin;
if (skin == Skin.Professional)
prefix = "d_";

Texture2D icon = null;
float pixelsPerPoint = GetGUIStatePixelsPerPoint();
if (pixelsPerPoint > 1.0f && !forceLowRes)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,15 @@ public sealed class VolumeComponentListEditor
Dictionary<Type, Type> m_EditorTypes; // Component type => Editor type
List<VolumeComponentEditor> m_Editors;

static Dictionary<Type, string> m_EditorDocumentationURLs;

int m_CurrentHashCode;

static VolumeComponentListEditor()
{
ReloadDocumentation();
}

/// <summary>
/// Creates a new instance of <see cref="VolumeComponentListEditor"/> to use in an
/// existing editor.
Expand Down Expand Up @@ -224,14 +231,17 @@ public void OnGUI()
string title = editor.GetDisplayTitle();
int id = i; // Needed for closure capture below

m_EditorDocumentationURLs.TryGetValue(editor.target.GetType(), out var documentationURL);

CoreEditorUtils.DrawSplitter();
bool displayContent = CoreEditorUtils.DrawHeaderToggle(
title,
editor.baseProperty,
editor.activeProperty,
pos => OnContextClick(pos, editor.target, id),
editor.hasAdvancedMode ? () => editor.isInAdvancedMode : (Func<bool>)null,
() => editor.isInAdvancedMode ^= true
() => editor.isInAdvancedMode ^= true,
documentationURL
);

if (displayContent)
Expand Down Expand Up @@ -471,7 +481,7 @@ internal void ExpandComponents()
}
m_SerializedObject.ApplyModifiedProperties();
}


static bool CanPaste(VolumeComponent targetComponent)
{
Expand Down Expand Up @@ -501,5 +511,32 @@ static void PasteSettings(VolumeComponent targetComponent)
Undo.RecordObject(targetComponent, "Paste Settings");
JsonUtility.FromJsonOverwrite(typeData, targetComponent);
}

static void ReloadDocumentation()
{
if (m_EditorDocumentationURLs == null)
m_EditorDocumentationURLs = new Dictionary<Type, string>();
m_EditorDocumentationURLs.Clear();

string GetVolumeComponentDocumentation(Type component)
{
var attrs = component.GetCustomAttributes(false);
foreach (var attr in attrs)
{
if (attr is HelpURLAttribute attrDocumentation)
return attrDocumentation.URL;
}

// There is no documentation for this volume component.
return null;
}

var componentTypes = CoreUtils.GetAllTypesDerivedFrom<VolumeComponent>();
foreach (var componentType in componentTypes)
{
if (!m_EditorDocumentationURLs.ContainsKey(componentType))
m_EditorDocumentationURLs.Add(componentType, GetVolumeComponentDocumentation(componentType));
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public sealed class VolumeComponentDeprecated : Attribute
/// <example>
/// <code>
/// using UnityEngine.Rendering;
///
///
/// [Serializable, VolumeComponentMenu("Custom/Example Component")]
/// public class ExampleComponent : VolumeComponent
/// {
Expand Down Expand Up @@ -130,15 +130,15 @@ protected virtual void OnDisable()
/// public virtual void Override(VolumeComponent state, float interpFactor)
/// {
/// int count = parameters.Count;
///
///
/// for (int i = 0; i &lt; count; i++)
/// {
/// var stateParam = state.parameters[i];
/// var toParam = parameters[i];
///
///
/// // Keep track of the override state for debugging purpose
/// stateParam.overrideState = toParam.overrideState;
///
///
/// if (toParam.overrideState)
/// stateParam.Interp(stateParam, toParam, interpFactor);
/// }
Expand Down Expand Up @@ -212,7 +212,7 @@ public override int GetHashCode()
}

/// <summary>
/// Unity calls this method before the object is destroyed.
/// Unity calls this method before the object is destroyed.
/// </summary>
protected virtual void OnDestroy() => Release();

Expand Down
2 changes: 2 additions & 0 deletions com.unity.render-pipelines.high-definition/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ The version number for this package has increased due to a version update of a r
### Added
- Added a rough distortion frame setting and and info box on distortion materials.
- Adding support of 4 channel tex coords for ray tracing (case 1265309).
- Added a help button on the volume component toolbar for documentation.

### Fixed
- Fixed an issue where the Exposure Shader Graph node had clipped text. (case 1265057)
Expand All @@ -25,6 +26,7 @@ The version number for this package has increased due to a version update of a r
- Fixed precision issue with the atmospheric fog.
- Fixed issue with TAA and no motion vectors.


### Changed
- Combined occlusion meshes into one to reduce draw calls and state changes with XR single-pass.
- Claryfied doc for the LayeredLit material.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ sealed class ChannelMixerEditor : VolumeComponentEditor
public override void OnEnable()
{
var o = new PropertyFetcher<ChannelMixer>(serializedObject);

m_RedOutRedIn = Unpack(o.Find(x => x.redOutRedIn));
m_RedOutGreenIn = Unpack(o.Find(x => x.redOutGreenIn));
m_RedOutBlueIn = Unpack(o.Find(x => x.redOutBlueIn));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ sealed class LiftGammaGainEditor : VolumeComponentEditor
public override void OnEnable()
{
var o = new PropertyFetcher<LiftGammaGain>(serializedObject);

m_Lift = Unpack(o.Find(x => x.lift));
m_Gamma = Unpack(o.Find(x => x.gamma));
m_Gain = Unpack(o.Find(x => x.gain));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ sealed class MotionBlurEditor : VolumeComponentWithQualityEditor
SerializedDataParameter m_MaxVelocityInPixels;
SerializedDataParameter m_MinVelInPixels;

// Advanced properties
// Advanced properties
SerializedDataParameter m_CameraRotClamp;
SerializedDataParameter m_DepthCmpScale;
SerializedDataParameter m_CameraMotionBlur;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ sealed class ShadowsMidtonesHighlightsEditor : VolumeComponentEditor
SerializedDataParameter m_HighlightsEnd;

readonly TrackballUIDrawer m_TrackballUIDrawer = new TrackballUIDrawer();

// Curve drawing utilities
Rect m_CurveRect;
Material m_Material;
Expand All @@ -27,7 +27,7 @@ sealed class ShadowsMidtonesHighlightsEditor : VolumeComponentEditor
public override void OnEnable()
{
var o = new PropertyFetcher<ShadowsMidtonesHighlights>(serializedObject);

m_Shadows = Unpack(o.Find(x => x.shadows));
m_Midtones = Unpack(o.Find(x => x.midtones));
m_Highlights = Unpack(o.Find(x => x.highlights));
Expand Down Expand Up @@ -86,7 +86,7 @@ public override void OnInspectorGUI()
m_ShadowsEnd.value.floatValue = Mathf.Max(m_ShadowsStart.value.floatValue, m_ShadowsEnd.value.floatValue);

EditorGUILayout.Space();

EditorGUILayout.LabelField("Highlight Limits", EditorStyles.miniLabel);
PropertyField(m_HighlightsStart, EditorGUIUtility.TrTextContent("Start"));
m_HighlightsStart.value.floatValue = Mathf.Min(m_HighlightsStart.value.floatValue, m_HighlightsEnd.value.floatValue);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ sealed class TonemappingEditor : VolumeComponentEditor
public override void OnEnable()
{
var o = new PropertyFetcher<Tonemapping>(serializedObject);

m_Mode = Unpack(o.Find(x => x.mode));
m_ToeStrength = Unpack(o.Find(x => x.toeStrength));
m_ToeLength = Unpack(o.Find(x => x.toeLength));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ public override void OnInspectorGUI()
}

PropertyField(m_Enable);

// If ray tracing is supported display the content of the volume component
if (HDRenderPipeline.pipelineSupportsRayTracing)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ namespace UnityEngine.Rendering.HighDefinition
/// Fog Volume Component.
/// </summary>
[Serializable, VolumeComponentMenu("Fog")]
[HelpURL(Documentation.baseURL + Documentation.version + Documentation.subURL + "Override-Fog" + Documentation.endURL)]
public class Fog : VolumeComponent
{
/// <summary>Enable fog.</summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace UnityEngine.Rendering.HighDefinition
{
[Serializable, VolumeComponentMenu("Material/Diffusion Profile Override")]
[HelpURL(Documentation.baseURL + Documentation.version + Documentation.subURL + "Override-Diffusion-Profile" + Documentation.endURL)]
sealed class DiffusionProfileOverride : VolumeComponent
{
[Tooltip("List of diffusion profiles used inside the volume.")]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ namespace UnityEngine.Rendering.HighDefinition
/// A volume component that holds settings for the global illumination (screen space and ray traced).
/// </summary>
[Serializable, VolumeComponentMenu("Lighting/Screen Space Global Illumination")]
[HelpURL(Documentation.baseURL + Documentation.version + Documentation.subURL + "Ray-Traced-Global-Illumination" + Documentation.endURL)]
public sealed class GlobalIllumination : VolumeComponentWithQuality
{
bool UsesQualityMode()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ namespace UnityEngine.Rendering.HighDefinition
/// Component that allow you to control the indirect specular and diffuse intensity
/// </summary>
[Serializable, VolumeComponentMenu("Lighting/Indirect Lighting Controller")]
[HelpURL(Documentation.baseURL + Documentation.version + Documentation.subURL + "Override-Indirect-Lighting-Controller" + Documentation.endURL)]
public class IndirectLightingController : VolumeComponent
{
/// <summary>Indirect diffuse lighting multiplier, between 0 and 1</summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ namespace UnityEngine.Rendering.HighDefinition
/// A volume component that holds settings for the ambient occlusion.
/// </summary>
[Serializable, VolumeComponentMenu("Lighting/Ambient Occlusion")]
[HelpURL(Documentation.baseURL + Documentation.version + Documentation.subURL + "Override-Ambient-Occlusion" + Documentation.endURL)]
public sealed class AmbientOcclusion : VolumeComponentWithQuality
{
/// <summary>
Expand Down
Loading