Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
a8b3c1c
initial commit for the uxml's
martint-unity Mar 3, 2021
0649efa
updates to widget
martint-unity Mar 3, 2021
a6c66c9
update to uxml for editor part
martint-unity Mar 3, 2021
fe60e22
updates to layout
martint-unity Mar 3, 2021
9944ab2
Added first init of coonverters
martint-unity Mar 5, 2021
6cf0c4b
Updated styling and added new converter item
martint-unity Mar 9, 2021
f244127
Added convert method and restructured code
martint-unity Mar 12, 2021
4e8b454
added test converters. will be removed before done
martint-unity Mar 12, 2021
d4b4c61
Added converter Context
martint-unity Mar 15, 2021
d4c1432
Made the widget root element Bindable
martint-unity Mar 16, 2021
8c11fbe
Moved code into init phase
martint-unity Mar 17, 2021
38c9cb9
updates to the bindings to the Serilized Object
martint-unity Mar 18, 2021
650b811
Updated the naming of core converter
martint-unity Mar 18, 2021
8d364aa
Made sure user doesnt init twize
martint-unity Mar 18, 2021
d8890e9
moved the uxml's and uss to core and the Editor
martint-unity Mar 19, 2021
df2b186
spring cleaning
martint-unity Mar 19, 2021
de3165d
Updated the converter UI to get errors and pending
martint-unity Mar 25, 2021
5f3b773
Added OnClicked method
martint-unity Mar 25, 2021
16f7d92
added status enum
martint-unity Mar 26, 2021
7986ca8
updated the ui a bit
martint-unity Mar 26, 2021
c02175e
changed icon size and removed Visual element
martint-unity Mar 26, 2021
6669e06
Added contextual menu, but commented it out
martint-unity Mar 29, 2021
a5116c7
Added active bool to converteritemstate
martint-unity Mar 30, 2021
366d835
oups, active bool was placed in the wrong statment
martint-unity Mar 30, 2021
366210d
Merge branch 'master' into universal/upgrader/builtin-to-urp-upgrader…
martint-unity Mar 30, 2021
faca1ea
Added manipulator, trying out userData for index
martint-unity Mar 31, 2021
6437db9
cleaned out and documented code
martint-unity Apr 7, 2021
b532a7e
fixed a small bug in init method and list refresh
martint-unity Apr 7, 2021
0836acc
Removed unnecessary files
martint-unity Apr 7, 2021
e2710cd
added some doc strings
martint-unity Apr 7, 2021
2a68e59
Addressed PR Feedback
martint-unity Apr 8, 2021
a46dee6
removed old tests that shouldnt live here
martint-unity Apr 9, 2021
bfbb0ae
PR feedback, split code into files
martint-unity Apr 13, 2021
0c9fcd8
added progressbar and material upgrader
martint-unity Apr 16, 2021
4ecc880
Spring cleaning
martint-unity Apr 16, 2021
f88c9bf
Moved code into folder
martint-unity Apr 19, 2021
e4230a6
New name for Conversion, changed to Container
martint-unity Apr 19, 2021
43bf46a
Updated with PR feedback and Doc strings
martint-unity Apr 20, 2021
3f7d115
Merge branch 'master' into universal/upgrader/builtin-to-urp-upgrader…
martint-unity Apr 20, 2021
689e1ee
Adressed PR feedback
martint-unity Apr 21, 2021
b9198c1
Addressed PR Feedback. Changed message string
martint-unity Apr 22, 2021
a958cac
Moved converter to URP package.
martint-unity Apr 22, 2021
c1efeeb
Made converter and container internal
martint-unity Apr 22, 2021
ae5083c
Adressed PR feedback
martint-unity Apr 27, 2021
2516c9d
Removed member var, returned true instead
martint-unity Apr 27, 2021
a28bebe
Merge branch 'master' into universal/upgrader/builtin-to-urp-upgrader…
martint-unity Apr 28, 2021
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
52 changes: 48 additions & 4 deletions com.unity.render-pipelines.core/Editor/MaterialUpgrader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -270,8 +270,17 @@ public void RenameKeywordToFloat(string oldName, string newName, float setVal, f
m_KeywordFloatRename.Add(new KeywordFloatRename { keyword = oldName, property = newName, setVal = setVal, unsetVal = unsetVal });
}

/// <summary>
/// Checking if the passed in value is a path to a Material.
/// </summary>
/// <param name="path">Path to test.</param>
/// <return>Returns true if the passed in value is a path to a material.</return>
static bool IsMaterialPath(string path)
{
if (string.IsNullOrEmpty(path))
{
throw new ArgumentNullException(nameof(path));
}
return path.EndsWith(".mat", StringComparison.OrdinalIgnoreCase);
}

Expand Down Expand Up @@ -299,7 +308,13 @@ static void SaveAssetsAndFreeMemory()
AssetDatabase.Refresh();
}

private static bool ShouldUpgradeShader(Material material, HashSet<string> shaderNamesToIgnore)
/// <summary>
/// Checking if the passed in value is a path to a Material.
/// </summary>
/// <param name="material">Material to check.</param>
/// <param name="shaderNamesToIgnore">HashSet of strings to ignore.</param>
/// <return>Returns true if the passed in material's shader is not in the passed in ignore list.</return>
static bool ShouldUpgradeShader(Material material, HashSet<string> shaderNamesToIgnore)
{
if (material == null)
return false;
Expand Down Expand Up @@ -392,15 +407,44 @@ public static void Upgrade(Material material, MaterialUpgrader upgrader, Upgrade
/// <param name="flags">Material Upgrader flags.</param>
public static void Upgrade(Material material, List<MaterialUpgrader> upgraders, UpgradeFlags flags)
{
if (material == null)
string message = String.Empty;
if (Upgrade(material, upgraders, flags, ref message))
return;

if (!string.IsNullOrEmpty(message))
{
Debug.Log(message);
}
}

/// <summary>
/// Upgrade a material.
/// </summary>
/// <param name="material">Material to upgrade.</param>
/// <param name="upgraders">List of Material upgraders.</param>
/// <param name="flags">Material upgrader flags.</param>
/// <param name="message">Error message to be outputted when no material upgraders are suitable for given material if the flags <see cref="UpgradeFlags.LogMessageWhenNoUpgraderFound"/> is used.</param>
/// <return>Returns true if the upgrader was found for the passed in material.</return>
public static bool Upgrade(Material material, List<MaterialUpgrader> upgraders, UpgradeFlags flags, ref string message)
{
if (material == null)
return false;

var upgrader = GetUpgrader(upgraders, material);

if (upgrader != null)
{
upgrader.Upgrade(material, flags);
else if ((flags & UpgradeFlags.LogMessageWhenNoUpgraderFound) == UpgradeFlags.LogMessageWhenNoUpgraderFound)
Debug.Log(string.Format("{0} material was not upgraded. There's no upgrader to convert {1} shader to selected pipeline", material.name, material.shader.name));
return true;
}
if ((flags & UpgradeFlags.LogMessageWhenNoUpgraderFound) == UpgradeFlags.LogMessageWhenNoUpgraderFound)
{
message =
$"{material.name} material was not upgraded. There's no upgrader to convert {material.shader.name} shader to selected pipeline";
return false;
}

return true;
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
namespace UnityEditor.Rendering.Universal
{
internal sealed class BuiltInToURPConverterContainer : RenderPipelineConverterContainer
{
public override string name => "Built-in to URP";
public override string info => "The Render Pipeline Conversion Wizard is meant to help Convert projects from built-in to Universal Render Pipeline.";
}
}

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.universal/Editor/Converter.meta

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

Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
namespace UnityEditor.Rendering
{
/// <summary>
/// A structure holding the information for each Item that needs to be Converted.
/// Name = The Name of the asset that is being converted.
/// Info = Information that can be used to store some data. This will also be shown in the UI.
/// WarningMessage = If there are some issues with the converter that we already know about.
/// Example: If we know it is a custom shader, we can not convert it so we add the information here.
/// HelpLink = Link to the documentation of how to convert this asset. Useful if the conversion failed or if we know we can not convert this asset automatically.
/// </summary>
public struct ConverterItemDescriptor
{
/// <summary> Name of the asset being converted. This will be shown in the UI. </summary>
public string name;
/// <summary> Information that can be used to store some data. This will also be shown in the UI. </summary>
public string info;
/// <summary> If there are some issues with the converter that we already know about during init phase. This will be added as a tooltip on the warning icon. </summary>
public string warningMessage;
/// <summary> Link to the documentation of how to convert this asset. Useful if the conversion failed or if we know we can not convert this asset automatically. </summary>
public string helpLink;
}
}

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

Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
namespace UnityEditor.Rendering
{
/// <summary>
/// A structure holding the information for each Item that needs to be Converted.
/// Descriptor = The ConverterItemDescriptor this item contain.
/// Index = The index for this item in the list of converter items.
/// </summary>
public struct ConverterItemInfo
{
/// <summary> The ConverterItemDescriptor this item contain. </summary>
public ConverterItemDescriptor descriptor { get; internal set; }

/// <summary> The index for this item in the list of converter items. </summary>
public int index { get; internal set; }
}
}

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

Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
namespace UnityEditor.Rendering
{
// Storing the index and message of the failed item so that we can show that in the UI.
internal struct FailedItem
{
public int index;
public string message;
}
}

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

Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
using System.Collections.Generic;

namespace UnityEditor.Rendering
{
/// <summary>
/// A structure needed for the initialization step of the converter.
/// Stores data to be visible in the UI.
/// </summary>
public struct InitializeConverterContext
{
/// <summary>
/// Stores the list of ConverterItemDescriptor that will be filled in during the initialization step.
/// </summary>
internal List<ConverterItemDescriptor> items;

/// <summary>
/// Add to the list of assets to be converted.
/// This will be used to display information to the user in the UI.
/// </summary>
/// <param name="item">The item to add to the list items to convert</param>
public void AddAssetToConvert(ConverterItemDescriptor item)
{
items.Add(item);
}
}
}

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

Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
using System;

namespace UnityEditor.Rendering.Universal
{
// Might need to change this name before making it public
internal abstract class RenderPipelineConverter
{
/// <summary>
/// Name of the converter.
/// </summary>
public abstract string name { get; }

/// <summary>
/// The information when hovering over the converter.
/// </summary>
public abstract string info { get; }

/// <summary>
/// A check if the converter is enabled or not. Can be used to do a check if prerequisites are met to have it enabled or disabled.
/// </summary>
public virtual bool IsEnabled => true;

/// <summary>
/// This method getting triggered when clicking the listview item in the UI.
/// </summary>
public virtual void OnClicked(int index)
{
}

// This is so that we can have different segment in our UI, example Unity converters, your custom converters etc..
// This is not implemented yet
public virtual string category { get; }

// This is in which drop down item the converter belongs to.
// Not properly implemented yet
public abstract Type conversion { get; }

/// <summary>
/// This runs when initializing the converter. To gather data for the UI and also for the converter if needed.
/// </summary>
/// <param name="context">The context that will be used to initialize data for the converter.</param>
public abstract void OnInitialize(InitializeConverterContext context);

/// <summary>
/// The method that will be run when converting the assets.
/// </summary>
/// <param name="context">The context that will be used when executing converter.</param>
public abstract void OnRun(ref RunItemContext context);
}
}

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

Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
namespace UnityEditor.Rendering
{
/// <summary>
/// A class to contain converters. This is for a common set of converters.
/// For example: Converters that is for Built-in to URP would have it's own container.
/// </summary>
internal abstract class RenderPipelineConverterContainer
{
/// <summary>
/// The name of the Container. This will show up int the UI.
/// </summary>
public abstract string name { get; }

/// <summary>
/// The information for this container.
/// This will be shown in the UI to tell the user some information about the converters that this container are targeting.
/// </summary>
public abstract string info { get; }
}
}

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

Loading