using UnityEngine;
using System.Collections;
using UnityEditor;
/// <summary>
/// 選択したWidget内にある画像を表示する
/// </summary>
public class SelectedWidgetImage : EditorWindow
{
[MenuItem("Window/SelectedWidgetImage")]
static public void Init ()
{
EditorWindow w = EditorWindow.GetWindow<SelectedWidgetImage> ();
w.Show ();
w.title = "SelectedWidgetImage";
}
void OnGUI ()
{
// Texture2D img = Resources.Load ("Img") as Texture2D;
// GUI.DrawTexture (new Rect (0, 0, 30f, 30f), img);
GameObject[] goList = Selection.gameObjects;
for (int i = 0; i < goList.Length; i++)
{
var go = goList [i];
var sp = go.GetComponent<UISprite> ();
var tex = go.GetComponent<UITexture> ();
if (sp != null) {
// GUI.DrawTexture (new Rect (0, 0, 30f, 30f), tex.mainTexture);
GUI.DrawTexture (new Rect (0, 0, 200f, 200f), sp.mainTexture);
Texture2D t = sp.mainTexture as Texture2D;
// Graphics.Blit ()
// new Material ().
}
}
}
private RenderTexture _rTex;
private RenderTexture GetRenderTexture ()
{
if (_rTex == null) {
_rTex = new RenderTexture (64, 64);
}
return _rTex;
}
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
}
}