Skip to content

Instantly share code, notes, and snippets.

@masa795
Created May 21, 2013 15:51
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save masa795/5620895 to your computer and use it in GitHub Desktop.
ボタンに画像を使う
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