Skip to content

Commit

Permalink
Hide experimental texture remapping by default
Browse files Browse the repository at this point in the history
  • Loading branch information
hybridherbst committed Aug 26, 2023
1 parent b14bb02 commit cacb3ec
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions Editor/Scripts/GLTFImporterInspector.cs
Expand Up @@ -36,7 +36,7 @@ public override void OnEnable()
var m_HasMaterialData = serializedObject.FindProperty(nameof(GLTFImporter.m_HasMaterialData));
var m_HasTextureData = serializedObject.FindProperty(nameof(GLTFImporter.m_HasTextureData));
if (m_HasMaterialData.boolValue || m_HasTextureData.boolValue)
AddTab(new GltfAssetImporterTab(this, "Materials and Textures", MaterialInspectorGUI));
AddTab(new GltfAssetImporterTab(this, "Materials", MaterialInspectorGUI));

AddTab(new GltfAssetImporterTab(this, "Extensions", ExtensionInspectorGUI));

Expand Down Expand Up @@ -101,6 +101,14 @@ private void ModelInspectorGUI()
TextureWarningsGUI(t);
}

private const string TextureRemappingKey = nameof(GLTFImporterInspector) + "_TextureRemapping";
private bool EnableTextureRemapping
{
get => SessionState.GetBool(TextureRemappingKey + target.GetInstanceID(), false);
set => SessionState.SetBool(TextureRemappingKey + target.GetInstanceID(), value);
}
private static readonly GUIContent RemapTexturesToggleContent = new GUIContent("Experimental", "(experimental) Remap textures inside the glTF to textures that are already in your project.");

private void AnimationInspectorGUI()
{
var t = target as GLTFImporter;
Expand Down Expand Up @@ -148,8 +156,13 @@ private void MaterialInspectorGUI()
RemappingUI<Material>(t, importedMaterials, "Materials", ".mat");
}

// There's a bunch of known edge cases with texture remapping that can go wrong,
// So it's disabled for now.
var current = EnableTextureRemapping;
var val = EditorGUILayout.Toggle(RemapTexturesToggleContent, EnableTextureRemapping);
if (val != current) EnableTextureRemapping = val;
var importedTextures = serializedObject.FindProperty("m_Textures");
if (importedTextures.arraySize > 0)
if (EnableTextureRemapping && importedTextures.arraySize > 0)
{
RemappingUI<Texture>(t, importedTextures, "Textures", ".asset");
}
Expand Down

0 comments on commit cacb3ec

Please sign in to comment.