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 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