うにてぃブログ

主にUnityとC#に関する記事を書いていきます

【Unity】Unity Editor で ラベルや画像をボタンにする

f:id:hacchi_man:20200208015343g:plain

       // ラベルをボタンにするには ボタンで EditorStyles.label を指定する
        if (GUILayout.Button("Button Text", EditorStyles.label))
        {
            Debug.Log("Click Label");
        }

        EditorGUILayout.Space();
        
        // 画像をボタンにするには ロードしたテクスチャを指定する
        if (GUILayout.Button(EditorGUIUtility.TrIconContent("d_tree_icon_leaf")))
        {
            Debug.Log("Click Image");
        }