Skip to content
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

[Draft][USDU-331] Make package samples more user friendly #367

Draft
wants to merge 36 commits into
base: dev
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
c4b7a8b
Ignores two unstable test cases until a fix has been found
lee-aandrew Mar 21, 2023
464ea5b
Merge branch 'dev' of https://github.com/Unity-Technologies/usd-unity…
lee-aandrew Mar 29, 2023
7af60ed
Merge branch 'dev' of https://github.com/Unity-Technologies/usd-unity…
lee-aandrew Mar 31, 2023
20dc1c7
Merge branch 'dev' of https://github.com/Unity-Technologies/usd-unity…
lee-aandrew Apr 12, 2023
4236bd0
Merge branch 'dev' of https://github.com/Unity-Technologies/usd-unity…
lee-aandrew Apr 14, 2023
2d14b87
Merge branch 'dev' of https://github.com/Unity-Technologies/usd-unity…
lee-aandrew Apr 18, 2023
bb60d3e
Merge branch 'dev' of https://github.com/Unity-Technologies/usd-unity…
lee-aandrew Apr 19, 2023
fa6e626
HelloUSD to be a bit more user-friendly
lee-aandrew Apr 4, 2023
c354a2a
Make Samples more user-friendly: ExportMesh, ImportProcessor, UsdTime…
lee-aandrew Apr 4, 2023
8ec4518
fix formatting issue
lee-aandrew Apr 4, 2023
8f76aee
Set up Samples properly according to Unity documentation
lee-aandrew Apr 13, 2023
24392f2
add removal of Samples.meta file
lee-aandrew Apr 13, 2023
8399af7
Revert "add removal of Samples.meta file"
lee-aandrew Apr 20, 2023
bbd2308
Revert "Set up Samples properly according to Unity documentation"
lee-aandrew Apr 20, 2023
9656bc2
Update HelloUSD and Separated out + updated ExportMeshWithAnimation s…
lee-aandrew Apr 21, 2023
5bc6608
Adds Export Mesh Example
lee-aandrew Apr 25, 2023
7eff80c
Applies code review comments & fixes formatting issue
lee-aandrew Apr 25, 2023
786ea4b
fixes variable naming miss
lee-aandrew Apr 25, 2023
9891944
Quick clean up of non-used using references and Additional comments
lee-aandrew Apr 25, 2023
e02a734
Adds ExportMeshTransformOverride Sample
lee-aandrew Apr 25, 2023
9588f2c
Removes hard coded color codes & adds more comments where needed
lee-aandrew Apr 25, 2023
92da6e3
Removed tree object from Export Mesh example as the tree object was a…
lee-aandrew Apr 26, 2023
33e3782
Quick Scene update for ExportMeshTransformOverride
lee-aandrew Apr 26, 2023
be78943
Fix naming issues
lee-aandrew Apr 26, 2023
721337d
Changes ExportMeshExample and ExportMeshWithAnimationExample back to …
lee-aandrew Apr 28, 2023
5d5827b
Redo HelloUSD to be more informative
lee-aandrew Apr 28, 2023
fcba3e5
Applies Vicky's PR Review suggestions
lee-aandrew Apr 28, 2023
e9f8a52
Apply formatting fix
lee-aandrew Apr 28, 2023
fba3a79
Adds Import Materials Sample Sample changes
lee-aandrew May 2, 2023
b446bff
Update Copyright comments
lee-aandrew May 2, 2023
94483f0
Changes Import Mesh Sample to only be Import Mesh
lee-aandrew May 2, 2023
04d33ab
Changes Import Processort Samples
lee-aandrew May 2, 2023
eddf389
Adds ExportAnimationWithRecorder sample
lee-aandrew May 3, 2023
149d34f
Change UsdTimelinePlayable Sample
lee-aandrew May 4, 2023
8891a7b
Apply review suggestions
lee-aandrew May 5, 2023
5f6ce5a
Apply review suggestion for ExportAnimationWithRecorderExample
lee-aandrew May 5, 2023
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
55 changes: 55 additions & 0 deletions package/com.unity.formats.usd/Editor/Utils/SampleUtils.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
using System;
using System.IO;
using System.Runtime.CompilerServices;
using UnityEditor;
using UnityEngine;

namespace Unity.Formats.USD
{
public static class SampleUtils
{
/// <summary>
/// Utils functions for the package Samples
/// </summary>

public static string SampleArtifactDirectory => Path.Combine(Application.dataPath, "Samples");
public static string SampleArtifactRelativeDirectory => "Assets/Samples";

private static EditorWindow GetConsoleWindow()
{
var editorWindowTypes = TypeCache.GetTypesDerivedFrom<EditorWindow>();
foreach (var type in editorWindowTypes)
{
if (type.Name == "ConsoleWindow")
{
return EditorWindow.GetWindow(type);
}
}

throw new System.Exception("Error could not find ConsoleWindow type");
}

public static void FocusConsoleWindow()
{
#if UNITY_EDITOR
var consoleWindow = GetConsoleWindow();
consoleWindow.Focus();
#endif
}

public static string SetTextColor(string color, string text)
{
return $"<color={color}>{text}</color>";
}

public struct TextColor
{
public const string Red = "#FF2D2D";
public const string Green = "#00FF00";
public static string Yellow = EditorGUIUtility.isProSkin ? "#FFFF00" : "#FFBF00";
public static string Blue = EditorGUIUtility.isProSkin ? "#00A2FF" : "#0008FC";

public static Color Default => EditorGUIUtility.isProSkin ? Color.white : Color.black;
}
}
}
11 changes: 11 additions & 0 deletions package/com.unity.formats.usd/Editor/Utils/SampleUtils.cs.meta

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

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,4 @@
{
"displayName" : "ExportAnimationWithRecorder",
"description" : "A sample showing how to use the USD integration in USD Recorder to export Unity GameObject as USD file with animation."
}

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,62 @@
// Copyright 2023 Unity Technologies. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.


using UnityEditor;
#if UNITY_RECORDER
using UnityEditor.Recorder;
#endif
using UnityEngine;

namespace Unity.Formats.USD.Examples
{
[CustomEditor(typeof(ExportAnimationWithRecorderExample))]
public class ExportAnimationWithRecorderExampleEditor : Editor
{
public override void OnInspectorGUI()
{
DrawDefaultInspector();

// Empty blank line
GUILayout.Label("");

#if !UNITY_RECORDER
var labelStyle = new GUIStyle() { alignment = TextAnchor.MiddleCenter, wordWrap = true };
labelStyle.normal.textColor = Color.red;

GUILayout.Label($"Unity 'Recorder' package is required for this sample.\nPlease install the <b>'Recorder' package (com.unity.recorder)</b> from the 'Unity Package Manager'", labelStyle);
if (GUILayout.Button("Link"))
{
Application.OpenURL("https://docs.unity3d.com/Packages/[email protected]/manual/index.html");
}
#else
if (GUILayout.Button("Open Unity 'Recorder' window."))
{
var recorderWindow = (RecorderWindow)EditorWindow.GetWindow(typeof(RecorderWindow));
}

var labelStyle = new GUIStyle() { alignment = TextAnchor.MiddleLeft, wordWrap = true };
labelStyle.normal.textColor = SampleUtils.TextColor.Default;

GUILayout.Label($"1. Select the '{SampleUtils.SetTextColor(SampleUtils.TextColor.Green, "START RECORDING")}' button to enter Play Mode, the Recorder will automatically record the animation.", labelStyle);
GUILayout.Label($"2. Select the '{SampleUtils.SetTextColor(SampleUtils.TextColor.Red, "STOP RECORDING")}' button to Stop your recording - You may also exit Play Mode.", labelStyle);
GUILayout.Label($"\n<b>Note:</b>", labelStyle);
GUILayout.Label($" - Set 'Format' > '{SampleUtils.SetTextColor(SampleUtils.TextColor.Blue, "Export Format")}' to your desired USD format.", labelStyle);
GUILayout.Label($" - Set 'Format' > '{SampleUtils.SetTextColor(SampleUtils.TextColor.Blue, "Override Setting")}' to either '{SampleUtils.SetTextColor(SampleUtils.TextColor.Yellow, "Export In Full")}' or '{SampleUtils.SetTextColor(SampleUtils.TextColor.Yellow, "Export Transform Overrides Only")}'.", labelStyle);
GUILayout.Label($" - Set 'Output File' > '{SampleUtils.SetTextColor(SampleUtils.TextColor.Blue, "Path")}' to your desired location.", labelStyle);
GUILayout.Label($" - The resulting exported USD file should be at your designated directory.", labelStyle);
#endif
}
}
}

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,23 @@
// Copyright 2023 Unity Technologies. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

using UnityEngine;

namespace Unity.Formats.USD.Examples
{
public class ExportAnimationWithRecorderExample : MonoBehaviour
{
// Empty script needed for Editor script ExportAnimationWithRecorderExampleEditor
}
}

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

Loading