Created
August 24, 2014 05:20
-
-
Save baobao/67f917a332aa42b1c193 to your computer and use it in GitHub Desktop.
選択したUIWidgetのプレビュー機能
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 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 () { | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment