-
Notifications
You must be signed in to change notification settings - Fork 858
Universal converter / upgrader framework #4103
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
phi-lira
merged 46 commits into
master
from
universal/upgrader/builtin-to-urp-upgrader-framework
Apr 29, 2021
Merged
Changes from 32 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 0649efa
updates to widget
martint-unity a6c66c9
update to uxml for editor part
martint-unity fe60e22
updates to layout
martint-unity 9944ab2
Added first init of coonverters
martint-unity 6cf0c4b
Updated styling and added new converter item
martint-unity f244127
Added convert method and restructured code
martint-unity 4e8b454
added test converters. will be removed before done
martint-unity d4b4c61
Added converter Context
martint-unity d4c1432
Made the widget root element Bindable
martint-unity 8c11fbe
Moved code into init phase
martint-unity 38c9cb9
updates to the bindings to the Serilized Object
martint-unity 650b811
Updated the naming of core converter
martint-unity 8d364aa
Made sure user doesnt init twize
martint-unity d8890e9
moved the uxml's and uss to core and the Editor
martint-unity df2b186
spring cleaning
martint-unity de3165d
Updated the converter UI to get errors and pending
martint-unity 5f3b773
Added OnClicked method
martint-unity 16f7d92
added status enum
martint-unity 7986ca8
updated the ui a bit
martint-unity c02175e
changed icon size and removed Visual element
martint-unity 6669e06
Added contextual menu, but commented it out
martint-unity a5116c7
Added active bool to converteritemstate
martint-unity 366d835
oups, active bool was placed in the wrong statment
martint-unity 366210d
Merge branch 'master' into universal/upgrader/builtin-to-urp-upgrader…
martint-unity faca1ea
Added manipulator, trying out userData for index
martint-unity 6437db9
cleaned out and documented code
martint-unity b532a7e
fixed a small bug in init method and list refresh
martint-unity 0836acc
Removed unnecessary files
martint-unity e2710cd
added some doc strings
martint-unity 2a68e59
Addressed PR Feedback
martint-unity a46dee6
removed old tests that shouldnt live here
martint-unity bfbb0ae
PR feedback, split code into files
martint-unity 0c9fcd8
added progressbar and material upgrader
martint-unity 4ecc880
Spring cleaning
martint-unity f88c9bf
Moved code into folder
martint-unity e4230a6
New name for Conversion, changed to Container
martint-unity 43bf46a
Updated with PR feedback and Doc strings
martint-unity 3f7d115
Merge branch 'master' into universal/upgrader/builtin-to-urp-upgrader…
martint-unity 689e1ee
Adressed PR feedback
martint-unity b9198c1
Addressed PR Feedback. Changed message string
martint-unity a958cac
Moved converter to URP package.
martint-unity c1efeeb
Made converter and container internal
martint-unity ae5083c
Adressed PR feedback
martint-unity 2516c9d
Removed member var, returned true instead
martint-unity a28bebe
Merge branch 'master' into universal/upgrader/builtin-to-urp-upgrader…
martint-unity File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
com.unity.render-pipelines.core/Editor/RenderPipelineConversion.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| namespace UnityEditor.Rendering | ||
| { | ||
| /// <summary> | ||
| /// A class for different conversions. | ||
| /// </summary> | ||
| public abstract class RenderPipelineConversion | ||
| { | ||
| /// <summary> | ||
| /// Name = The name of the conversion. | ||
| /// </summary> | ||
| public abstract string name { get; } | ||
alex-vazquez marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| /// <summary> | ||
| /// Info = The information for this conversion. | ||
| /// </summary> | ||
| public abstract string info { get; } | ||
| } | ||
| } | ||
11 changes: 11 additions & 0 deletions
11
com.unity.render-pipelines.core/Editor/RenderPipelineConversion.cs.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
196 changes: 196 additions & 0 deletions
196
com.unity.render-pipelines.core/Editor/RenderPipelineConverter.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,196 @@ | ||
| using System; | ||
| using System.Collections.Generic; | ||
| using System.Runtime.CompilerServices; | ||
| using UnityEngine; | ||
| using UnityEngine.UIElements; | ||
|
|
||
| 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 | ||
martint-unity marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| { | ||
| public string name; | ||
alex-vazquez marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| public string info; | ||
| public string warningMessage; | ||
| public string helpLink; | ||
| } | ||
|
|
||
| /// <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 | ||
| { | ||
| public ConverterItemDescriptor descriptor { get; internal set; } | ||
| public int index { get; internal set; } | ||
| } | ||
|
|
||
| // 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; | ||
| } | ||
|
|
||
| internal struct SuccessfulItem | ||
| { | ||
| public int index; | ||
| } | ||
|
|
||
| /// <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); | ||
| } | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// A structure needed for the conversion part of the converter. | ||
| /// This holds the index for failed and successful items converted. | ||
| /// </summary> | ||
| public struct RunConverterContext | ||
| { | ||
| List<ConverterItemInfo> m_Items; | ||
|
|
||
| internal List<FailedItem> m_FailedItems; | ||
alex-vazquez marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| internal List<SuccessfulItem> m_SuccessfulItems; | ||
|
|
||
| /// <summary> | ||
| /// These are the items that the converter needs to iterate over. | ||
| /// The UI will make this list of items only the ones that are ticked and should be converted. | ||
| /// </summary> | ||
| public IEnumerable<ConverterItemInfo> items => m_Items; | ||
|
|
||
| internal int failedCount => m_FailedItems.Count; | ||
| internal int successfulCount => m_SuccessfulItems.Count; | ||
|
|
||
| internal FailedItem GetFailedItemAtIndex(int index) | ||
martint-unity marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| { | ||
| if (index < 0 || index > failedCount) | ||
| throw new ArgumentOutOfRangeException(); | ||
| return m_FailedItems[index]; | ||
| } | ||
|
|
||
| internal SuccessfulItem GetSuccessfulItemAtIndex(int index) | ||
| { | ||
| if (index < 0 || index > successfulCount) | ||
| throw new ArgumentOutOfRangeException(); | ||
| return m_SuccessfulItems[index]; | ||
| } | ||
|
|
||
|
|
||
|
|
||
| /// <summary> | ||
| /// These are the items that the converter needs to iterate over. | ||
| /// The UI will make this list of items only the ones that are ticked and should be converted. | ||
| /// </summary> | ||
| /// <param name="items">The items the converter will operate on.</param> | ||
| public RunConverterContext(List<ConverterItemInfo> items) | ||
| { | ||
| m_Items = items; | ||
|
|
||
| m_FailedItems = new List<FailedItem>(); | ||
| m_SuccessfulItems = new List<SuccessfulItem>(); | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Mark the converter item index as failed. | ||
| /// </summary> | ||
| /// <param name="index">The index that will be marked as failed.</param> | ||
| public void MarkFailed(int index) | ||
| { | ||
| MarkFailed(index, "Failed"); | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Mark the converter item index as failed. | ||
| /// </summary> | ||
| /// <param name="index">The index that will be marked as failed.</param> | ||
| /// <param name="message">The message that will be shown for the failed item.</param> | ||
| public void MarkFailed(int index, string message) | ||
| { | ||
| m_FailedItems.Add(new FailedItem(){index = index, message = message}); | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Mark the converter item index as successful. | ||
| /// </summary> | ||
| /// <param name="index">The index that will be marked as successful.</param> | ||
| public void MarkSuccessful(int index) | ||
| { | ||
| m_SuccessfulItems.Add(new SuccessfulItem(){index = index}); | ||
martint-unity marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| } | ||
| } | ||
|
|
||
| // Might need to change this name before making it public | ||
| public 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 Enabled() | ||
| { | ||
| return true; | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// This method getting triggered when clicking the listview item in the UI. | ||
| /// </summary> | ||
| public virtual void OnClicked(int index) | ||
martint-unity marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| { | ||
| } | ||
|
|
||
| // 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(RunConverterContext context); | ||
| } | ||
| } | ||
11 changes: 11 additions & 0 deletions
11
com.unity.render-pipelines.core/Editor/RenderPipelineConverter.cs.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.