Skip to content

Instantly share code, notes, and snippets.

@masa795
Created October 28, 2013 15:44
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save masa795/7199222 to your computer and use it in GitHub Desktop.
Save masa795/7199222 to your computer and use it in GitHub Desktop.
ボタンなどの画像サイズを変える
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