Skip to content

Commit

Permalink
fix humanoid importer inspector not being shown when model doesn't ha…
Browse files Browse the repository at this point in the history
…ve animation data

fixes prefrontalcortex#120
  • Loading branch information
hybridherbst committed Nov 8, 2023
1 parent 7d1817e commit 4cf7734
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions Editor/Scripts/GLTFImporterInspector.cs
Expand Up @@ -29,9 +29,7 @@ public override void OnEnable()
if (m_HasSceneData.boolValue)
AddTab(new GltfAssetImporterTab(this, "Model", ModelInspectorGUI));

var m_HasAnimationData = serializedObject.FindProperty(nameof(GLTFImporter.m_HasAnimationData));
if (m_HasAnimationData.boolValue)
AddTab(new GltfAssetImporterTab(this, "Animation", AnimationInspectorGUI));
AddTab(new GltfAssetImporterTab(this, "Animation", AnimationInspectorGUI));

var m_HasMaterialData = serializedObject.FindProperty(nameof(GLTFImporter.m_HasMaterialData));
var m_HasTextureData = serializedObject.FindProperty(nameof(GLTFImporter.m_HasTextureData));
Expand Down Expand Up @@ -123,9 +121,16 @@ private void AnimationInspectorGUI()
var t = target as GLTFImporter;
if (!t) return;

var hasAnimationData = serializedObject.FindProperty(nameof(GLTFImporter.m_HasAnimationData)).boolValue;

if (!hasAnimationData)
{
EditorGUILayout.HelpBox("File doesn't contain animation data.", MessageType.None);
}

var anim = serializedObject.FindProperty(nameof(GLTFImporter._importAnimations));
EditorGUILayout.PropertyField(anim, new GUIContent("Animation Type"));
if (anim.enumValueIndex > 0)
if (hasAnimationData && anim.enumValueIndex > 0)
{
var loopTime = serializedObject.FindProperty(nameof(GLTFImporter._animationLoopTime));
EditorGUILayout.PropertyField(loopTime, new GUIContent("Loop Time"));
Expand All @@ -136,7 +141,7 @@ private void AnimationInspectorGUI()
EditorGUI.indentLevel--;
}
}

// show animations for clip import editing
var animations = serializedObject.FindProperty("m_Animations");
if (animations.arraySize > 0)
Expand Down

0 comments on commit 4cf7734

Please sign in to comment.