Skip to content

Commit

Permalink
com.unity.render-pipelines.core@10.4.0
Browse files Browse the repository at this point in the history
## [10.4.0] - 2020-01-26

### Added
- Support for the XboxSeries platform has been added.

### Fixed
- Fixed parameters order on inspectors for Volume Components without custom editor
- Fixed the display name of a Volume Parameter when is defined the attribute InspectorName
  • Loading branch information
Unity Technologies committed Jan 26, 2020
1 parent 47a1ffe commit f467e1a
Show file tree
Hide file tree
Showing 19 changed files with 194 additions and 184 deletions.
12 changes: 8 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,16 @@ All notable changes to this package will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

## [10.3.2] - 2021-02-18
## [10.4.0] - 2020-01-26

Version Updated
The version number for this package has increased due to a version update of a related graphics package.
### Added
- Support for the XboxSeries platform has been added.

### Fixed
- Fixed parameters order on inspectors for Volume Components without custom editor
- Fixed the display name of a Volume Parameter when is defined the attribute InspectorName

## [10.3.1] - 2021-01-26
## [10.3.1] - 2020-01-26

Version Updated
The version number for this package has increased due to a version update of a related graphics package.
Expand Down
21 changes: 21 additions & 0 deletions Editor/CoreEditorUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -882,6 +882,27 @@ public static T[] GetAdditionalData<T>(UnityEngine.Object[] targets, Action<T> i
return data;
}

/// <summary>Add the appropriate AdditionalData to the given GameObject and its children containing the original component</summary>
/// <typeparam name="T">The type of the original component</typeparam>
/// <typeparam name="AdditionalT">The type of the AdditionalData component</typeparam>
/// <param name="go">The root object to update</param>
/// <param name="initDefault">[Optional] The default value to use if there is no AdditionalData</param>
public static void AddAdditionalData<T, AdditionalT>(GameObject go, Action<AdditionalT> initDefault = null)
where T : Component
where AdditionalT : Component
{
var components = go.GetComponentsInChildren(typeof(T), true);
foreach (var c in components)
{
if (!c.TryGetComponent<AdditionalT>(out _))
{
var hd = c.gameObject.AddComponent<AdditionalT>();
if (initDefault != null)
initDefault(hd);
}
}
}

/// <summary>Create a game object</summary>
/// <param name="parent">The parent</param>
/// <param name="name">The wanted name (can be updated with a number if a sibling with same name exist</param>
Expand Down
2 changes: 1 addition & 1 deletion Editor/MaterialUpgrader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ public static void UpgradeProjectFolder(List<MaterialUpgrader> upgraders, string
/// <param name="flags">Material Upgrader flags.</param>
public static void UpgradeProjectFolder(List<MaterialUpgrader> upgraders, HashSet<string> shaderNamesToIgnore, string progressBarName, UpgradeFlags flags = UpgradeFlags.None)
{
if (!EditorUtility.DisplayDialog(DialogText.title, "The upgrade will overwrite materials in your project. " + DialogText.projectBackMessage, DialogText.proceed, DialogText.cancel))
if ((!Application.isBatchMode) && (!EditorUtility.DisplayDialog(DialogText.title, "The upgrade will overwrite materials in your project. " + DialogText.projectBackMessage, DialogText.proceed, DialogText.cancel)))
return;

int totalMaterialCount = 0;
Expand Down
129 changes: 72 additions & 57 deletions Editor/Volume/VolumeComponentEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using UnityEditor.AnimatedValues;
using UnityEngine;
using UnityEngine.Assertions;
using UnityEngine.Rendering;
Expand Down Expand Up @@ -150,7 +151,7 @@ static void ReloadDecoratorTypes()
.Where(
t => t.IsDefined(typeof(VolumeParameterDrawerAttribute), false)
&& !t.IsAbstract
);
);

// Store them
foreach (var type in types)
Expand Down Expand Up @@ -179,17 +180,27 @@ internal void Init(VolumeComponent target, Editor inspector)
OnEnable();
}


class ParameterSorter : Comparer<(GUIContent displayName, int displayOrder, SerializedDataParameter param)>
void GetFields(object o, List<(FieldInfo, SerializedProperty)> infos, SerializedProperty prop = null)
{
public override int Compare((GUIContent displayName, int displayOrder, SerializedDataParameter param) x, (GUIContent displayName, int displayOrder, SerializedDataParameter param) y)
if (o == null)
return;

var fields = o.GetType()
.GetFields(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance);

foreach (var field in fields)
{
if (x.displayOrder < y.displayOrder)
return -1;
else if (x.displayOrder == y.displayOrder)
return 0;
else
return 1;
if (field.FieldType.IsSubclassOf(typeof(VolumeParameter)))
{
if ((field.GetCustomAttributes(typeof(HideInInspector), false).Length == 0) &&
((field.GetCustomAttributes(typeof(SerializeField), false).Length > 0) ||
(field.IsPublic && field.GetCustomAttributes(typeof(NonSerializedAttribute), false).Length == 0)))
infos.Add((field, prop == null ?
serializedObject.FindProperty(field.Name) : prop.FindPropertyRelative(field.Name)));
}
else if (!field.FieldType.IsArray && field.FieldType.IsClass)
GetFields(field.GetValue(o), infos, prop == null ?
serializedObject.FindProperty(field.Name) : prop.FindPropertyRelative(field.Name));
}
}

Expand All @@ -202,37 +213,27 @@ public override int Compare((GUIContent displayName, int displayOrder, Serialize
/// </remarks>
public virtual void OnEnable()
{
m_Parameters = new List<(GUIContent, int, SerializedDataParameter)>();

// Grab all valid serializable field on the VolumeComponent
// TODO: Should only be done when needed / on demand as this can potentially be wasted CPU when a custom editor is in use
var fields = target.GetType()
.GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)
.Where(t => t.FieldType.IsSubclassOf(typeof(VolumeParameter)))
.Where(t =>
(t.IsPublic && t.GetCustomAttributes(typeof(NonSerializedAttribute), false).Length == 0) ||
(t.GetCustomAttributes(typeof(SerializeField), false).Length > 0)
)
.Where(t => t.GetCustomAttributes(typeof(HideInInspector), false).Length == 0)
.ToList();

// Prepare all serialized objects for this editor
foreach (var field in fields)
{
var property = serializedObject.FindProperty(field.Name);
var name = "";
var order = 0;
var attr = (DisplayInfoAttribute[])field.GetCustomAttributes(typeof(DisplayInfoAttribute), true);
if (attr.Length != 0)
{
name = attr[0].name;
order = attr[0].order;
}
var fields = new List<(FieldInfo, SerializedProperty)>();
GetFields(target, fields);

m_Parameters = fields
.Select(t => {
var name = "";
var order = 0;
var attr = (DisplayInfoAttribute[])t.Item1.GetCustomAttributes(typeof(DisplayInfoAttribute), true);
if (attr.Length != 0)
{
name = attr[0].name;
order = attr[0].order;
}
var parameter = new SerializedDataParameter(property);
m_Parameters.Add((new GUIContent(name), order, parameter));
}
m_Parameters.Sort(new ParameterSorter());
var parameter = new SerializedDataParameter(t.Item2);
return (new GUIContent(name), order, parameter);
})
.OrderBy(t => t.order)
.ToList();
}

/// <summary>
Expand Down Expand Up @@ -264,7 +265,7 @@ public virtual void OnInspectorGUI()
// Display every field as-is
foreach (var parameter in m_Parameters)
{
if (parameter.displayName.text != "")
if (!string.IsNullOrEmpty(parameter.displayName.text))
PropertyField(parameter.param, parameter.displayName);
else
PropertyField(parameter.param);
Expand Down Expand Up @@ -324,36 +325,50 @@ protected void PropertyField(SerializedDataParameter property)
}

/// <summary>
/// Draws a given <see cref="SerializedDataParameter"/> in the editor using a custom label
/// and tooltip.
/// Handles unity built-in decorators (Space, Header, Tooltips, ...) from <see cref="SerializedDataParameter"/> attributes
/// </summary>
/// <param name="property">The property to draw in the editor.</param>
/// <param name="title">A custom label and/or tooltip.</param>
protected void PropertyField(SerializedDataParameter property, GUIContent title)
/// <param name="property">The property to obtain the attributes and handle the decorators</param>
/// <param name="title">A custom label and/or tooltip that might be updated by <see cref="TooltipAttribute"/> and/or by <see cref="InspectorNameAttribute"/></param>
void HandleDecorators(SerializedDataParameter property, GUIContent title)
{
// Handle unity built-in decorators (Space, Header, Tooltip etc)
foreach (var attr in property.attributes)
{
if (attr is PropertyAttribute)
if (!(attr is PropertyAttribute))
continue;

switch (attr)
{
if (attr is SpaceAttribute)
{
EditorGUILayout.GetControlRect(false, (attr as SpaceAttribute).height);
}
else if (attr is HeaderAttribute)
case SpaceAttribute spaceAttribute:
EditorGUILayout.GetControlRect(false, spaceAttribute.height);
break;
case HeaderAttribute headerAttribute:
{
var rect = EditorGUILayout.GetControlRect(false, EditorGUIUtility.singleLineHeight);
rect.y += 0f;
rect = EditorGUI.IndentedRect(rect);
EditorGUI.LabelField(rect, (attr as HeaderAttribute).header, EditorStyles.miniLabel);
var rect = EditorGUI.IndentedRect(EditorGUILayout.GetControlRect(false, EditorGUIUtility.singleLineHeight));
EditorGUI.LabelField(rect, headerAttribute.header, EditorStyles.miniLabel);
break;
}
else if (attr is TooltipAttribute)
case TooltipAttribute tooltipAttribute:
{
if (string.IsNullOrEmpty(title.tooltip))
title.tooltip = (attr as TooltipAttribute).tooltip;
title.tooltip = tooltipAttribute.tooltip;
break;
}
case InspectorNameAttribute inspectorNameAttribute:
title.text = inspectorNameAttribute.displayName;
break;
}
}
}

/// <summary>
/// Draws a given <see cref="SerializedDataParameter"/> in the editor using a custom label
/// and tooltip.
/// </summary>
/// <param name="property">The property to draw in the editor.</param>
/// <param name="title">A custom label and/or tooltip.</param>
protected void PropertyField(SerializedDataParameter property, GUIContent title)
{
HandleDecorators(property, title);

// Custom parameter drawer
VolumeParameterDrawer drawer;
Expand Down
10 changes: 5 additions & 5 deletions Editor/Volume/VolumeComponentListEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -342,17 +342,17 @@ internal void AddComponent(Type type)
var componentProp = m_ComponentsProperty.GetArrayElementAtIndex(m_ComponentsProperty.arraySize - 1);
componentProp.objectReferenceValue = component;

// Create & store the internal editor object for this effect
CreateEditor(component, componentProp, forceOpen: true);

m_SerializedObject.ApplyModifiedProperties();

// Force save / refresh
if (EditorUtility.IsPersistent(asset))
{
EditorUtility.SetDirty(asset);
AssetDatabase.SaveAssets();
}

// Create & store the internal editor object for this effect
CreateEditor(component, componentProp, forceOpen: true);

m_SerializedObject.ApplyModifiedProperties();
}

internal void RemoveComponent(int id)
Expand Down
2 changes: 1 addition & 1 deletion Editor/Volume/VolumeComponentProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public void CreateComponentTree(List<Element> tree)
{
tree.Add(new GroupElement(0, "Volume Overrides"));

var types = VolumeManager.instance.baseComponentTypes;
var types = VolumeManager.instance.baseComponentTypeArray;
var rootNode = new PathNode();

foreach (var t in types)
Expand Down
2 changes: 1 addition & 1 deletion Runtime/Documentation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public class DocumentationInfo
/// <summary>
/// Current version of the documentation.
/// </summary>
public const string version = "10.3";
public const string version = "10.4";
}

//Need to live in Runtime as Attribute of documentation is on Runtime classes \o/
Expand Down
9 changes: 8 additions & 1 deletion Runtime/RenderGraph/RenderGraphResourcePool.cs
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,15 @@ public void LogResources(RenderGraphLogger logger)

allocationList.Sort((a, b) => a.size < b.size ? 1 : -1);
int index = 0;
float total = 0;
foreach (var element in allocationList)
logger.LogLine("[{0}]\t[{1:#.##} MB]\t{2}", index++, element.size / 1024.0f, element.name);
{
float size = element.size / (1024.0f * 1024.0f);
total += size;
logger.LogLine($"[{index++:D2}]\t[{size:0.00} MB]\t{element.name}");
}

logger.LogLine($"\nTotal Size [{total:0.00}]");
}

static protected bool ShouldReleaseResource(int lastUsedFrameIndex, int currentFrameIndex)
Expand Down
28 changes: 15 additions & 13 deletions Runtime/Textures/RTHandleSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -317,15 +317,17 @@ void DemandResize(RTHandle rth)

// Generate a new name
rt.name = CoreUtils.GetRenderTargetAutoName(
rt.width,
rt.height,
rt.volumeDepth,
rt.format,
rth.m_Name,
mips: rt.useMipMap,
enableMSAA: rth.m_EnableMSAA,
msaaSamples: m_ScaledRTCurrentMSAASamples
);
rt.width,
rt.height,
rt.volumeDepth,
rt.graphicsFormat,
rt.dimension,
rth.m_Name,
mips: rt.useMipMap,
enableMSAA: rth.m_EnableMSAA,
msaaSamples: m_ScaledRTCurrentMSAASamples,
dynamicRes: rt.useDynamicScale
);

// Create the new texture
rt.Create();
Expand Down Expand Up @@ -412,7 +414,7 @@ void Resize(int width, int height, MSAASamples msaaSamples, bool sizeChanged, bo
}

// Regenerate the name
renderTexture.name = CoreUtils.GetRenderTargetAutoName(renderTexture.width, renderTexture.height, renderTexture.volumeDepth, renderTexture.format, rth.m_Name, mips: renderTexture.useMipMap, enableMSAA: rth.m_EnableMSAA, msaaSamples: m_ScaledRTCurrentMSAASamples);
renderTexture.name = CoreUtils.GetRenderTargetAutoName(renderTexture.width, renderTexture.height, renderTexture.volumeDepth, renderTexture.graphicsFormat, renderTexture.dimension, rth.m_Name, mips: renderTexture.useMipMap, enableMSAA: rth.m_EnableMSAA, msaaSamples: m_ScaledRTCurrentMSAASamples, dynamicRes: renderTexture.useDynamicScale);

// Create the render texture
renderTexture.Create();
Expand Down Expand Up @@ -515,7 +517,7 @@ void Resize(int width, int height, MSAASamples msaaSamples, bool sizeChanged, bo
bindTextureMS = bindTextureMS,
useDynamicScale = m_HardwareDynamicResRequested && useDynamicScale,
memorylessMode = memoryless,
name = CoreUtils.GetRenderTargetAutoName(width, height, slices, colorFormat, name, mips: useMipMap, enableMSAA: enableMSAA, msaaSamples: msaaSamples)
name = CoreUtils.GetRenderTargetAutoName(width, height, slices, colorFormat, dimension, name, mips: useMipMap, enableMSAA: enableMSAA, msaaSamples: msaaSamples, dynamicRes: useDynamicScale)
};
}

Expand Down Expand Up @@ -771,7 +773,7 @@ string name
useDynamicScale = m_HardwareDynamicResRequested && useDynamicScale,
memorylessMode = memoryless,
stencilFormat = stencilFormat,
name = CoreUtils.GetRenderTargetAutoName(width, height, slices, colorFormat, name, mips: useMipMap, enableMSAA: allocForMSAA, msaaSamples: m_ScaledRTCurrentMSAASamples)
name = CoreUtils.GetRenderTargetAutoName(width, height, slices, colorFormat, dimension, name, mips: useMipMap, enableMSAA: allocForMSAA, msaaSamples: m_ScaledRTCurrentMSAASamples, dynamicRes: useDynamicScale)
};
}
else
Expand All @@ -792,7 +794,7 @@ string name
bindTextureMS = bindTextureMS,
useDynamicScale = m_HardwareDynamicResRequested && useDynamicScale,
memorylessMode = memoryless,
name = CoreUtils.GetRenderTargetAutoName(width, height, slices, colorFormat, name, mips: useMipMap, enableMSAA: allocForMSAA, msaaSamples: m_ScaledRTCurrentMSAASamples)
name = CoreUtils.GetRenderTargetAutoName(width, height, slices, colorFormat, dimension, name, mips: useMipMap, enableMSAA: allocForMSAA, msaaSamples: m_ScaledRTCurrentMSAASamples, dynamicRes: useDynamicScale)
};
}

Expand Down
Loading

0 comments on commit f467e1a

Please sign in to comment.