Unity 查看所有GUI預設樣式,unitygui預設樣式

來源:互聯網
上載者:User

Unity 查看所有GUI預設樣式,unitygui預設樣式
使用預設的一些GUI樣式,可以讓編輯器擴充外觀更佳。Unity內建有很多樣式,當要使用這些樣式時,只要指定其樣式名即可。
所有的樣式名稱,可以寫個指令碼遍曆出來,另外可以將其樣式效果也一併展現出來。這一點已經有外掛程式實現了,即:Editor Style Viewer(https://www.assetstore.unity3d.com/en/#!/content/3282)

查看器代碼如下:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
using UnityEngine;
using UnityEditor;

public class EditorStyleViewer : EditorWindow
{
    private Vector2 scrollPosition = Vector2.zero;
    private string search = string.Empty;

    [MenuItem("Tools/GUI樣式查看器")]
    public static void Init()
    {
        EditorWindow.GetWindow(typeof(EditorStyleViewer));
    }

    void OnGUI()
    {
        GUILayout.BeginHorizontal("HelpBox");
        GUILayout.Label("單擊樣本將複製其名到剪貼簿", "label");
        GUILayout.FlexibleSpace();
        GUILayout.Label("尋找:");
        search = EditorGUILayout.TextField(search);
        GUILayout.EndHorizontal();

        scrollPosition = GUILayout.BeginScrollView(scrollPosition);

        foreach (GUIStyle style in GUI.skin)
        {
            if (style.name.ToLower().Contains(search.ToLower()))
            {
                GUILayout.BeginHorizontal("PopupCurveSwatchBackground");
                GUILayout.Space(7);
                if (GUILayout.Button(style.name, style))
                {
                    EditorGUIUtility.systemCopyBuffer = "\"" + style.name + "\"";
                }
                GUILayout.FlexibleSpace();
                EditorGUILayout.SelectableLabel("\"" + style.name + "\"");
                GUILayout.EndHorizontal();
                GUILayout.Space(11);
            }
        }

        GUILayout.EndScrollView();
    }
}

如下:


右上方可以進行搜尋,單擊每個樣式的左側效果時,可以複製其樣式名到剪貼簿。



Unity中GUIBox裡面裡面放有多個GUIButton,怎通過滑鼠實現實作類別似翻頁的效果來看到GUIButton

通過滑鼠滑動可能會稍微複雜一些,需要判斷游標的手勢。
通過上下頁按鈕簡單一些,可以用一個變數來記錄當前的頁如page,如果page為0就畫1-3的按鈕,1就畫4-6依次類推
 
【Unity3D】教:guibutton的透明度怎設定,系統預設button好像是半透明的

好吧 在圖片屬性裡面有 阿爾法通道的 不信可以在PS開啟看看
預設 阿爾法通道 黑色的透明 灰色是半透明 白色的完全顯示。
只要更改一下阿爾法通道裡面的顏色 就可以了。
 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.