Editor-Window

简介

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
using System;

public class TestWindow : EditorWindow
{
    [MenuItem("Window/TestWindow")]
    private static void Open()
    {
        TestWindow win = GetWindow<TestWindow>("lalala");
        win.Show();
    }

    private void OnGUI()
    {
        //标题
        TopGUI();
        //左侧区域
        LeftGUI();
        //右侧区域
        RightGUI();
    }

    private int _offsetw = 5;
    private int _offseth = 5;
    private int _btnw = 100;
    private int _btnh = 30;

    private void TopGUI()
    {
        //button
        for (int i = 0; i < 4; i++)
        {
            ButtonGUI(i, i.ToString());
        }

        //toggle
        if (GUI.Toggle(new Rect((int)position.width-105,5,100,35),false,"toggle"))
        {

        }
    }

    private void ButtonGUI(int index, string name)
    {
        if (GUI.Button(new Rect(index * _btnw + _offsetw, _offseth, _btnw, _btnh), name))
        {
            switch (name)
            {
                case "1": Debug.LogError("1"); break;
                default:Debug.LogError("0");break;
            }
        }
    }


    private void LeftGUI()
    {

    }

    private void RightGUI()
    {

    }

}
参考

https://blog.youkuaiyun.com/qq992817263/article/details/79654398

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值