Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
ボタンに画像を使う
using UnityEngine;
using UnityEditor;
using System.Collections;
using System.Collections.Generic;
public class FileIconTest : EditorWindow {
Vector2 scrollPosition;
[MenuItem ("Window/File Icon")]
public static void Init () {
FileIconTest.GetWindow<FileIconTest>(false, "FileIcon");
}
void OnGUI () {
Texture icon = null;
GUIContent contents = new GUIContent();
scrollPosition = GUILayout.BeginScrollView(scrollPosition, false, false);
icon = AssetDatabase.GetCachedIcon("Assets/Documentation.pdf");
contents.image = icon;
contents.text = "button";
if (GUILayout.Button(contents, GUILayout.Height(30)))
{
}
Texture tTexture = (Texture)AssetDatabase.LoadAssetAtPath("Assets/crystal.gif", typeof(Texture2D));
contents.image = tTexture;
contents.text = "button2";
if (GUILayout.Button(contents, GUILayout.Width(200), GUILayout.Height(200)))
{
}
if (GUILayout.Button(tTexture, GUILayout.Width(100), GUILayout.Height(100)))
{
}
GUILayout.EndScrollView();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment