Skip to content

Instantly share code, notes, and snippets.

@sokuhatiku
Created March 29, 2020 13:26
Show Gist options
  • Save sokuhatiku/06f6f9f5eab07541af4479a9e234e5ab to your computer and use it in GitHub Desktop.
Save sokuhatiku/06f6f9f5eab07541af4479a9e234e5ab to your computer and use it in GitHub Desktop.
using UnityEngine;
using UnityEditor;
public class AssetTypeCheckerWindow : EditorWindow
{
Object obj;
string msg;
[MenuItem("Window/AssetType Checker")]
static void Init()
{
var window = GetWindow<AssetTypeCheckerWindow>(true, "AssetType Checker", true);
window.Show();
}
public void OnGUI()
{
EditorGUI.BeginDisabledGroup(true);
EditorGUILayout.ObjectField("Script", MonoScript.FromScriptableObject(this), typeof(MonoScript), false);
EditorGUI.EndDisabledGroup();
var newobj = EditorGUILayout.ObjectField("Drop Here", obj, typeof(Object), true, GUILayout.Height(30f));
if (newobj != obj)
{
obj = newobj;
msg = newobj != null ? "Type = <b>" + newobj.GetType() + "</b>\nPath = " + AssetDatabase.GetAssetPath(newobj) + "" : "";
}
var boxStyle = GUI.skin.GetStyle("HelpBox");
boxStyle.richText = true;
boxStyle.fontSize = 12;
EditorGUILayout.TextArea(msg, boxStyle);
EditorGUILayout.Space();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment