Published: 18 Apr 2019 › Updated: 18 Apr 2019
SceneView 에디터 툴 그리기
인스펙터에도 띄워보고, 팝업 윈도우에도 해보고
하지만 씬뷰에 상시 떠있는 쪽이 편리하더군요.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
#if UNITY_EDITOR
using UnityEditor;
using UnityEditorInternal;
[ExecuteInEditMode]
#endif
public class TestScene : MonoBehaviour
{
#if UNITY_EDITOR
private void OnEnable()
{
TestSceneEditor.Instance.Init(this, 20, 20, 250, 250);
}
private void OnDisable()
{
TestSceneEditor.Instance.Exit();
}
#endif
}
#if UNITY_EDITOR
public class TestSceneEditor
{
public enum EAnchor
{
L_Top = 0,
R_Top,
L_Bottom,
R_Bottom
}
public static TestSceneEditor Instance
{
get
{
if (m_instance == null)
{
m_instance = new TestSceneEditor();
}
return m_instance;
}
}
public static TestSceneEditor m_instance;
public static Vector2 Scroll;
public static TestScene TargetScript;
private static Vector2 Pos = new Vector2(20, 20);
private static Vector2 Size = new Vector2(250, 200);
private static int Anchor = 0;
public void Init(TestScene script, float x, float y, float width, float height, int anchor = 0)
{
TargetScript = script;
Pos = new Vector2(x, y);
Size = new Vector2(width, height);
Anchor = anchor;
SceneView.onSceneGUIDelegate += OnSceneGUI;
}
public void Exit()
{
SceneView.onSceneGUIDelegate -= OnSceneGUI;
}
static void OnSceneGUI(SceneView scn)
{
if (Event.current.type != EventType.Repaint)
{
int controlId = GUIUtility.GetControlID(FocusType.Passive);
GUILayout.Window(controlId, CreateRect(scn, Pos, Size, Anchor), OnDisplay, "Editor");
}
}
static void OnDisplay(int id)
{
Scroll = GUILayout.BeginScrollView(Scroll);
EditorGUILayout.LabelField("Label");
if (GUILayout.Button("Button"))
{
}
GUILayout.EndScrollView();
}
private static Rect CreateRect(SceneView scn, Vector2 pos, Vector2 size, int anchor)
{
Vector2 rc = new Vector2(pos.x, pos.y);
if (scn != null)
{
switch ((EAnchor)anchor)
{
case EAnchor.L_Top: rc = new Vector2(pos.x, pos.y); break;
case EAnchor.R_Top: rc = new Vector2(scn.camera.pixelRect.width - pos.x, pos.y); break;
case EAnchor.L_Bottom: rc = new Vector2(pos.x, scn.camera.pixelRect.height - pos.y); break;
case EAnchor.R_Bottom: rc = new Vector2(scn.camera.pixelRect.width - pos.x, scn.camera.pixelRect.height - pos.y); break;
}
}
return new Rect(rc.x, rc.y, size.x, size.y);
}
}
#endif
Leave SceneView 에디터 툴 그리기 to:
Read more #kr posts
Best Posts From pangcola
We have not curated any of pangcola's posts yet. But you can encourage our curation team to review posts by visiting them regularly and by referring other readers. Because we give priority to frequently read content.
More Posts From pangcola
- 에어팟 프로(AirPods Pro) 100% 증정!!!
- Talken 톡큰 - 암호화폐 커뮤니티, 지갑, 에어드랍, 간편교환
- [toss] 토스 돈상자
- [Bitberry] Ripple(XRP) is now supported on Bitberry
- USDQ - Decentralized Stable Coin
- [비트베리] 비트베리, 리플(XRP) 지갑 지원 안내
- [비트베리] 비트베리의 주요 발자취 (인포그래픽)
- [Airdrop] Initiative Q (paypal)
- [Airdrop] STP 네트워크 에어드롭
- [STP Network] STP 네트워크란?
- [AIRDORP] Bitberry CPT Airdorp (60 CPT)
- [에어드랍] 코인베이스 이벤트 참여하세요 (24000원 상당)
- SceneView 에디터 툴 그리기
- 게이트아이오 “업계 최고 수준의 기술력과 사용자 이익” 중시
- 안드로이드 빌드 시"over 64k methods" 해결 방법
- 게이트아이오 - 2월27일, 콘스탄티노플 업데이트 지원
- 삼성 갤럭시S10, 암호화폐 지갑이 탑재
- SK 텔레콤, 도이치텔레콤과 블록체인 모바일 신분증 상용화
- 디센트레, 코드블럭과 생태계 확장 위한 블록체인 결제사업 제휴
- 3월, KT BaaS 블록체인 플랫폼 출시 및 시범사업 진행