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

Add "ShouldNodeExport" hook #767

Open
wants to merge 54 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
0dba6d0
Add plugin hook for ShouldNodeExport
andybak Jun 18, 2024
4776027
Merge remote-tracking branch 'upstream/main' into feature/should-node…
andybak Jul 24, 2024
04de8ec
feat: allow flipping humanoid rig root bone for VRM-style humanoid ri…
hybridherbst Aug 14, 2024
4bfef28
output throwed execption to log instead of hiding it
pfcDorn Aug 27, 2024
c94e011
Revert automatic whitespace changes
andybak Aug 29, 2024
a79bd75
fixed wrong callback subscription EditorApplication.update > delayCall
pfcDorn Sep 4, 2024
100e6f6
readme update: blend shape known issue rephrased for more clarity
pfcDorn Sep 4, 2024
4ca9035
readme update: added animation pointer import support
pfcDorn Sep 5, 2024
3c38a98
readme update: removed known issue with MAOS maps, is fixed
pfcDorn Sep 4, 2024
0665439
added Asset.ToString methods, added gltf.Asset string to importer and…
pfcDorn Sep 4, 2024
e610bc2
added mesh deduplication on import
pfcDorn Aug 28, 2024
fcdbc47
deduplication fix of meshes with different weights
pfcDorn Aug 29, 2024
e6d92f5
add texture deduplication on import
pfcDorn Aug 29, 2024
9f99aa8
extracted UnityMeshData from SceneImporter
pfcDorn Aug 29, 2024
53c4121
code formatting
pfcDorn Aug 29, 2024
8fe7bc5
made ShaderOverride public on GLTFComponent
pfcDorn Aug 27, 2024
41a6b8e
added simplified sheen function to PBRHelpers
pfcDorn Sep 3, 2024
6ee1446
added Sheen to pbrGraph
pfcDorn Sep 3, 2024
d0d451f
added sheen extension into codebase
pfcDorn Sep 3, 2024
406cfb9
added pbrGraph GUI property visibility for Sheen and Dispersion
pfcDorn Sep 4, 2024
09391cd
changed Sheen to node based to support MaterialX
pfcDorn Sep 5, 2024
f1f31eb
added AnimationCacheData to RefCountedCacheData script
pfcDorn Aug 27, 2024
3446304
changed unity version compiler define for particle bakemesh
pfcDorn Sep 12, 2024
dc6fa9d
Sheen: removed getmainlight (not working on all RPs)
pfcDorn Sep 13, 2024
8325abc
adds warning when UV0 and UV1 have dimension >= 2 as glTF can't offic…
hybridherbst Sep 13, 2024
615ab67
added new SceneImporter constructor variant without gltfroot parameter
pfcDorn Sep 16, 2024
4675d12
added warning when dataloader and gltf filename is missing on import
pfcDorn Sep 16, 2024
0bb8b62
added summary with example to GLTFSceneImporter constructor
pfcDorn Sep 17, 2024
604658e
pbr shadergraph > changes to share sampler states to avoid max ps_4_0…
pfcDorn Sep 19, 2024
68f4321
output throwed execption to log instead of hiding it
pfcDorn Aug 27, 2024
dd8a317
fixed wrong callback subscription EditorApplication.update > delayCall
pfcDorn Sep 4, 2024
2c7c5df
readme update: blend shape known issue rephrased for more clarity
pfcDorn Sep 4, 2024
c28499c
readme update: added animation pointer import support
pfcDorn Sep 5, 2024
5b1b7ad
readme update: removed known issue with MAOS maps, is fixed
pfcDorn Sep 4, 2024
861ae3e
changed unity version compiler define for particle bakemesh
pfcDorn Sep 12, 2024
cba4272
Merge branch 'feature/flip-humanoid-root-bone' into dev
hybridherbst Sep 20, 2024
abef38c
Merge remote-tracking branch 'khronos/enhancement/show-asset-infos-in…
hybridherbst Sep 20, 2024
3953de6
Merge remote-tracking branch 'khronos/enhancement/gltfcomponent-shade…
hybridherbst Sep 20, 2024
0043492
Merge remote-tracking branch 'khronos/fix/missing-cleanup-of-animatio…
hybridherbst Sep 20, 2024
6baabc3
Merge remote-tracking branch 'khronos/fix/load-from-stream' into dev
hybridherbst Sep 20, 2024
de0aeed
Merge remote-tracking branch 'khronos/features/sheen' into dev
hybridherbst Sep 20, 2024
5384213
Merge branch 'feature/resourcededuplication' into dev
hybridherbst Sep 20, 2024
e5091c1
Merge branch 'feature/warn-on-multichannel-uv2-export' into dev
hybridherbst Sep 20, 2024
c05338e
fixes 782 - method not found in webgl build
pfcDorn Sep 20, 2024
472bcd1
fix a number of potential NullReferenceExceptions
hybridherbst Sep 20, 2024
b53e86e
clean up extensions inspector a bit
hybridherbst Sep 20, 2024
9909208
added prebuilded gltf pbrgraph and unlitgraph variant collection
pfcDorn Sep 20, 2024
86c6ee8
clean up variant collection folders
hybridherbst Sep 20, 2024
ccffe2b
Merge remote-tracking branch 'khronos/fix/canvas-export' into dev
hybridherbst Sep 20, 2024
f8d9248
fix(Exporter): Fixed invalid texture hash
Vaso64 Jun 27, 2024
ee956ac
improve null check and readability
hybridherbst Sep 20, 2024
1916b83
Merge remote-tracking branch 'khronos/enhancement/prebuilded-shader-v…
hybridherbst Sep 20, 2024
72cd2f7
check for missing primitives on mesh import
hybridherbst Sep 20, 2024
8427244
Merge remote-tracking branch 'upstream/dev' into feature/should-node-…
andybak Sep 25, 2024
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
12 changes: 8 additions & 4 deletions Editor/Scripts/GLTFImporter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,9 @@ private static void EnsureShadersAreLoaded()

[Tooltip("Turn this off to create an explicit GameObject for the glTF scene. A scene root will always be created if there's more than one root node.")]
[SerializeField] internal bool _removeEmptyRootObjects = true;
[SerializeField] internal float _scaleFactor = 1.0f;
[SerializeField] internal float _scaleFactor = 1.0f;
[Tooltip("Reduces identical resources. e.g. when identical meshes are found, only one will be imported.")]
[SerializeField] internal DeduplicateOptions _deduplicateResources = DeduplicateOptions.None;
[SerializeField] internal int _maximumLod = 300;
[SerializeField] internal bool _readWriteEnabled = true;
[SerializeField] internal bool _generateColliders = false;
Expand All @@ -99,6 +101,7 @@ private static void EnsureShadersAreLoaded()
[SerializeField] internal GLTFImporterNormals _importTangents = GLTFImporterNormals.Import;
[SerializeField] internal CameraImportOption _importCamera = CameraImportOption.ImportAndCameraDisabled;
[SerializeField] internal AnimationMethod _importAnimations = AnimationMethod.Mecanim;
[SerializeField] internal bool _mecanimHumanoidFlip = false;
[SerializeField] internal bool _addAnimatorComponent = false;
[SerializeField] internal bool _animationLoopTime = true;
[SerializeField] internal bool _animationLoopPose = false;
Expand All @@ -110,7 +113,7 @@ private static void EnsureShadersAreLoaded()
[SerializeField] internal bool _useSceneNameIdentifier = false;
[Tooltip("Compress textures after import using the platform default settings. If you need more control, use a .gltf file instead.")]
[SerializeField] internal GLTFImporterTextureCompressionQuality _textureCompression = GLTFImporterTextureCompressionQuality.None;

[SerializeField, Multiline] internal string _gltfAsset = default;
// for humanoid importer
[SerializeField] internal bool m_OptimizeGameObjects = false;
[SerializeField] internal HumanDescription m_HumanDescription = new HumanDescription();
Expand Down Expand Up @@ -526,7 +529,7 @@ string GetUniqueName(string desiredName)

if (gltfScene && _importAnimations == AnimationMethod.MecanimHumanoid)
{
var avatar = HumanoidSetup.AddAvatarToGameObject(gltfScene);
var avatar = HumanoidSetup.AddAvatarToGameObject(gltfScene, _mecanimHumanoidFlip);
if (avatar)
ctx.AddObjectToAsset("avatar", avatar);
}
Expand Down Expand Up @@ -915,6 +918,7 @@ private void CreateGLTFScene(GLTFImportContext context, out GameObject scene,
ImportBlendShapeNames = _importBlendShapeNames,
BlendShapeFrameWeight = _blendShapeFrameWeight,
CameraImport = _importCamera,
DeduplicateResources = _deduplicateResources,
};

using (var stream = File.OpenRead(projectFilePath))
Expand Down Expand Up @@ -959,7 +963,7 @@ private void CreateGLTFScene(GLTFImportContext context, out GameObject scene,
scene = loader.LastLoadedScene;
animationClips = loader.CreatedAnimationClips;


_gltfAsset = loader.Root.Asset.ToString(true);
importer = loader;
}
}
Expand Down
46 changes: 43 additions & 3 deletions Editor/Scripts/GLTFImporterInspector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ public override void OnEnable()
if (m_HasMaterialData.boolValue || m_HasTextureData.boolValue)
AddTab(new GLTFAssetImporterTab(this, "Materials", MaterialInspectorGUI));

AddTab(new GLTFAssetImporterTab(this, "Used Extensions", ExtensionInspectorGUI));
AddTab(new GLTFAssetImporterTab(this, "Extensions", ExtensionInspectorGUI));
AddTab(new GLTFAssetImporterTab(this, "Info", AssetInfoInspectorGUI));

base.OnEnable();
}
Expand Down Expand Up @@ -81,6 +82,7 @@ private void ModelInspectorGUI()
EditorGUILayout.PropertyField(serializedObject.FindProperty(nameof(GLTFImporter._removeEmptyRootObjects)));
EditorGUILayout.PropertyField(serializedObject.FindProperty(nameof(GLTFImporter._scaleFactor)));
EditorGUILayout.PropertyField(serializedObject.FindProperty(nameof(GLTFImporter._importCamera)));
EditorGUILayout.PropertyField(serializedObject.FindProperty(nameof(GLTFImporter._deduplicateResources)));
// EditorGUILayout.PropertyField(serializedObject.FindProperty(nameof(GLTFImporter._maximumLod)), new GUIContent("Maximum Shader LOD"));
EditorGUILayout.Separator();

Expand Down Expand Up @@ -144,6 +146,13 @@ private void AnimationInspectorGUI()

var anim = serializedObject.FindProperty(nameof(GLTFImporter._importAnimations));
EditorGUILayout.PropertyField(anim, new GUIContent("Animation Type"));
if (anim.enumValueIndex == (int)AnimationMethod.MecanimHumanoid)
{
var flip = serializedObject.FindProperty(nameof(GLTFImporter._mecanimHumanoidFlip));
EditorGUI.indentLevel++;
EditorGUILayout.PropertyField(flip, new GUIContent("Flip Forward", "Some formats like VRM have a different forward direction for Avatars. Enable this option if the animation looks inverted."));
EditorGUI.indentLevel--;
}
if (hasAnimationData && anim.enumValueIndex > 0)
{
var loopTime = serializedObject.FindProperty(nameof(GLTFImporter._animationLoopTime));
Expand Down Expand Up @@ -362,23 +371,54 @@ void ExtractAsset(T subAsset, bool importImmediately)
EditorGUILayout.EndFoldoutHeaderGroup();
}

private void ExtensionInspectorGUI()
private static GUIStyle _richTextWordWrap;
private void AssetInfoInspectorGUI()
{
var t = target as GLTFImporter;
if (!t) return;
var assetProp = serializedObject.FindProperty(nameof(GLTFImporter._gltfAsset));
if (assetProp == null)
return;

if (_richTextWordWrap == null)
{
GUIStyle style = new GUIStyle(GUI.skin.label);
style.richText = true;
style.wordWrap = true;
_richTextWordWrap = style;
}

if (string.IsNullOrEmpty(t._gltfAsset))
{
EditorGUILayout.LabelField("<i>No asset information included in file</i>", _richTextWordWrap);
return;
}

EditorGUILayout.Space();
var rect = GUILayoutUtility.GetRect(new GUIContent(t._gltfAsset), _richTextWordWrap);
EditorGUI.SelectableLabel(rect, t._gltfAsset, _richTextWordWrap);

EditorGUILayout.Space();
EditorGUI.BeginDisabledGroup(true);
var mainAssetIdentifierProp = serializedObject.FindProperty(nameof(GLTFImporter._mainAssetIdentifier));
EditorGUILayout.PropertyField(mainAssetIdentifierProp);
}

private void ExtensionInspectorGUI()
{
var t = target as GLTFImporter;
if (!t) return;

EditorGUILayout.PropertyField(serializedObject.FindProperty(nameof(GLTFImporter._extensions)), new GUIContent("Extensions"));
EditorGUILayout.PropertyField(serializedObject.FindProperty(nameof(GLTFImporter._extensions)), new GUIContent("Extensions in file"));
EditorGUI.EndDisabledGroup();

// TODO add list of supported extensions and links to docs
// Gather list of all plugins
var registeredPlugins = GLTFSettings.GetDefaultSettings().ImportPlugins;
var overridePlugins = t._importPlugins;

EditorGUILayout.Space();
EditorGUILayout.LabelField("Available Import Plugins", EditorStyles.boldLabel);
EditorGUILayout.LabelField("OVERRIDE", EditorStyles.miniLabel, GUILayout.Width(60));
EditorGUILayout.BeginHorizontal();
EditorGUILayout.LabelField("", GUILayout.Width(16));
Expand Down
Loading