美文网首页
Editor-Window

Editor-Window

作者: 叫我颜先生 | 来源:发表于2019-04-02 14:47 被阅读0次

简介


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.csdn.net/qq992817263/article/details/79654398

相关文章

  • Editor-Window

    简介 参考 https://blog.csdn.net/qq992817263/article/details/7...

网友评论

      本文标题:Editor-Window

      本文链接:https://www.haomeiwen.com/subject/mylgbqtx.html