-
Notifications
You must be signed in to change notification settings - Fork 79
#USDU-155 Create import/export helpers to clean the UsdMenu #237
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
Conversation
| namespace Unity.Formats.USD | ||
| { | ||
| public class UsdMenu : MonoBehaviour | ||
| public class UsdMenu |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
make the class static maybe ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in 3cd29eb
| #if UNITY_EDITOR | ||
| public static Scene InitForSave(string defaultName, string fileExtension = "usd,usda,usdc") | ||
| { | ||
| var filePath = EditorUtility.SaveFilePanel("Export USD File", "", defaultName, fileExtension); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would split this function differently:
The only editor only function is EditorUtility.SaveFilePanel: add that in the editor assembly and keep the rest of of this function as a runtime function.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in 3cd29eb
| { | ||
| Scene scene = null; | ||
|
|
||
| foreach (GameObject go in Selection.gameObjects) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Selection exists only in the editor. Make a function that exports a list of GOs and call that with the selection from the editor assembly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in 3cd29eb
| } | ||
| catch (SceneImporter.ImportException) | ||
| { | ||
| Object.DestroyImmediate(root); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if it makes a difference: in playmode you wanna call Destroy, and out of playmode DestroyImmediate. Make yourself an utility function that abstracts this.
| } | ||
|
|
||
| #if UNITY_EDITOR | ||
| public static void ImportAsPrefab(Scene scene) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Return the import results.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in 53a493c
| } | ||
| } | ||
|
|
||
| public static void ImportAsTimelineClip(Scene scene) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Return the import result.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in 53a493c
| /// </summary> | ||
| static string GetSelectedAssetPath() | ||
| { | ||
| Object[] selectedAsset = Selection.GetFiltered(typeof(Object), SelectionMode.Assets); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Think Selection is Editor only
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed 53a493c
222b79c to
3cd29eb
Compare
mfe
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Did some testing on 2020.2 (win), change looks indeed transparent.
mfe
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Purpose of this PR
Ticket/Jira #: https://jira.unity3d.com/browse/USDU-155
Preparatory work for the mesh import/conversion layer fixes.
UsdMenu used to contain a lot of import logic making it hard to reuse and test. All the logic has been moved to 2 new static classes ImportHelpers and ExportHelpers.
Testing
Functional Testing status:
Tried to cover 100% of the Import/ExportHelpers.
Performance Testing status:
N/A
Overall Product Risks
Complexity:
Low
Halo Effect:
Low
Additional information
Note to reviewers:
Reminder: