ボタンに画像を使う
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 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