TmpGuiEnable

This commit is contained in:
ousttrue 2021-02-25 17:47:00 +09:00
parent 761d5f454e
commit 9b4e9a23e2
3 changed files with 25 additions and 9 deletions

View File

@ -12,7 +12,7 @@ namespace UniGLTF
public class GltfScriptedImporter : ScriptedImporter
{
[SerializeField]
Axises m_reverseAxis;
Axises m_reverseAxis = default;
const string TextureDirName = "Textures";
const string MaterialDirName = "Materials";

View File

@ -1,4 +1,5 @@
using System.Collections.Generic;
using System;
using System.Collections.Generic;
using System.Linq;
using UnityEditor;
using UnityEditor.Experimental.AssetImporters;
@ -51,11 +52,30 @@ namespace UniGLTF
static bool s_foldMaterials;
static bool s_foldTextures;
class TmpGuiEnable : IDisposable
{
bool m_backup;
public TmpGuiEnable(bool enable)
{
m_backup = GUI.enabled;
GUI.enabled = enable;
}
public void Dispose()
{
GUI.enabled = m_backup;
}
}
static void OnGUIMaterial(GltfScriptedImporter importer, GltfParser parser)
{
if (GUILayout.Button("Extract Materials And Textures ..."))
var canExtract = !importer.GetExternalObjectMap().Any(x => x.Value is Material || x.Value is Texture2D);
using (new TmpGuiEnable(canExtract))
{
importer.ExtractMaterialsAndTextures();
if (GUILayout.Button("Extract Materials And Textures ..."))
{
importer.ExtractMaterialsAndTextures();
}
}
// ObjectMap
@ -96,11 +116,6 @@ namespace UniGLTF
EditorGUILayout.BeginHorizontal();
EditorGUILayout.PrefixLabel(name);
map.TryGetValue(name, out T value);
if (map.Any() && value == null)
{
var a = 0;
// Debug.Log($"{name}: {value}");
}
var asset = EditorGUILayout.ObjectField(value, typeof(T), true) as T;
if (asset != value)
{

View File

@ -131,6 +131,7 @@ namespace UniGLTF
{
Path = targetPath,
sRGB = true,
IsNormalMap = param.TextureType == GetTextureParam.NORMAL_PROP,
});
}
}