Created
August 1, 2019 07:50
-
-
Save TJHeuvel/f74acbbbcfe8e84e59fa41ebff774f35 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Reflection; | |
using UnityEditor; | |
using UnityEditor.Experimental.AssetImporters; | |
using UnityEngine; | |
[CustomEditor(typeof(TextureImporter))] | |
[CanEditMultipleObjects] | |
//https://github.com/Unity-Technologies/UnityCsReference/blob/9034442437e6b5efe28c51d02e978a96a3ce5439/Editor/Mono/ImportSettings/TextureImporterInspector.cs | |
internal class TextureImporterEditor : AssetImporterEditor | |
{ | |
#region Original texture importer editor support | |
private readonly Assembly editorAssembly = Assembly.GetAssembly(typeof(AssetImporterEditor)); | |
private AssetImporterEditor originalEditor; | |
public override void OnEnable() | |
{ | |
Editor origAsEditor = originalEditor as Editor; | |
CreateCachedEditor(targets, editorAssembly.GetType("UnityEditor.TextureImporterInspector"), ref origAsEditor); | |
originalEditor = origAsEditor as AssetImporterEditor; | |
originalEditor.OnEnable(); | |
} | |
public override void OnDisable() | |
{ | |
originalEditor.OnDisable(); | |
} | |
public override bool showImportedObject => false; | |
public override bool HasModified() | |
{ | |
return originalEditor.HasModified(); | |
} | |
protected override void ResetValues() | |
{ | |
callProtectedMethod(originalEditor, nameof(ResetValues)); | |
} | |
protected override void Apply() | |
{ | |
callProtectedMethod(originalEditor, nameof(Apply)); | |
} | |
private void callProtectedMethod(object target, string methodName) | |
{ | |
//target.GetType().GetMethod(methodName, BindingFlags.NonPublic | BindingFlags.Instance).Invoke(target, null); | |
} | |
#endregion | |
bool showAdvancedImporter; | |
public override void OnInspectorGUI() | |
{ | |
originalEditor.OnInspectorGUI(); | |
//do your custom UI | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi Julien, i never tried. But perhaps if you make the CustomEditor attribute use the ModelImporter type (https://docs.unity3d.com/ScriptReference/ModelImporter.html) it would work!