Created
October 28, 2013 15:44
-
-
Save masa795/7199222 to your computer and use it in GitHub Desktop.
ボタンなどの画像サイズを変える
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 FileIconTest2 : EditorWindow | |
{ | |
Vector2 scrollPosition; | |
[MenuItem("Window/File Icon2")] | |
public static void Init() | |
{ | |
FileIconTest2.GetWindow<FileIconTest2>(false, "FileIcon"); | |
} | |
void OnGUI() | |
{ | |
GUIContent contents = new GUIContent(); | |
scrollPosition = GUILayout.BeginScrollView(scrollPosition, false, false); | |
Texture tTexture = (Texture)AssetDatabase.LoadAssetAtPath("Assets/crystal.gif", typeof(Texture2D)); | |
contents.image = tTexture; | |
contents.text = "button2"; | |
EditorGUIUtility.SetIconSize(Vector2.one * 30); | |
if (GUILayout.Button(tTexture, GUILayout.Width(100), GUILayout.Height(100))) { } | |
EditorGUIUtility.SetIconSize(Vector2.one * 50); | |
if (GUILayout.Button(tTexture, GUILayout.Width(100), GUILayout.Height(100))) { } | |
EditorGUIUtility.SetIconSize(Vector2.one * 100); | |
if (GUILayout.Button(tTexture, GUILayout.Width(100), GUILayout.Height(100))) { } | |
EditorGUIUtility.SetIconSize(Vector2.zero); | |
GUILayout.EndScrollView(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment