五月天青色头像情侣网名,国产亚洲av片在线观看18女人,黑人巨茎大战俄罗斯美女,扒下她的小内裤打屁股

歡迎光臨散文網(wǎng) 會(huì)員登陸 & 注冊(cè)

【Unity Tips】關(guān)于GridBackground的正確用法

2023-03-30 14:28 作者:YouSing  | 我要投稿

前言

????????最近重構(gòu)一下自己寫(xiě)的連連看的通用編輯器,發(fā)現(xiàn)GridBackground一直都是黑的,根本沒(méi)格網(wǎng)。

https://docs.unity.cn/cn/2022.1/ScriptReference/Experimental.GraphView.GridBackground.html

壓根等于沒(méi)寫(xiě)

解決方案

????????UIElements其實(shí)有個(gè)類(lèi)似css的文件,也就是后綴名為uss的文件。很多UIElements組件的樣式,需要你自己寫(xiě)uss來(lái)實(shí)現(xiàn)修改。其實(shí)原本一個(gè)腳本可以搞定,你現(xiàn)在就要分兩個(gè)地方寫(xiě)了。

https://docs.unity3d.com/cn/2021.2/Manual/UIE-USS.html

????????那么,我們所需要的uss文件內(nèi)容,大概如下:

GridBackground{

????--spacing: 25;

????--thick-lines: 10;

????--line-color: #232323;

????--thick-line-color: #FF0000;

????--grid-background-color: #7F7F7F;

}

????????測(cè)試的代碼如下:

using UnityEditor;

using UnityEditor.Experimental.GraphView;

using UnityEngine.UIElements;

public class GridBackgroundTest:GraphViewEditorWindow {

? ? public class GraphView

? ? ? ? :UnityEditor.Experimental.GraphView.GraphView

? ? {

? ? ? ? public GraphView() {

? ? ? ? ? ? style.flexGrow=1;

? ? ? ? ? ? //

? ? ? ? ? ? var bg=new GridBackground();

? ? ? ? ? ? var obj=AssetDatabase.LoadAssetAtPath<StyleSheet>("Assets/Editor/GridBackgroundTest.uss");

? ? ? ? ? ? if(obj!=null) {bg.styleSheets.Add(obj);}

? ? ? ? ? ? Insert(0,bg);

? ? ? ? ? ? //

? ? ? ? ? ? SetupZoom(ContentZoomer.DefaultMinScale,2.0f);

? ? ? ? ? ? this.AddManipulator(new ContentDragger());

? ? ? ? ? ? this.AddManipulator(new SelectionDragger());

? ? ? ? ? ? this.AddManipulator(new RectangleSelector());

? ? ? ? }

? ? }


? ? public GraphView graphView;

? ? [MenuItem("Test/GridBackground")]

? ? public static void Open() {

? ? ? ? GridBackgroundTest w=GetWindow<GridBackgroundTest>("GridBackgroundTest");

? ? ? ? if(w.graphView==null) {

? ? ? ? ? ? w.graphView=new GraphView();

? ? ? ? ? ? w.rootVisualElement.Add(w.graphView);

? ? }

? ? w.Show();

? ? }

}

完結(jié)撒花

感言

????????Unity在文檔方面,感覺(jué)越來(lái)越不填坑??磥?lái)有時(shí)候,還是需要把踩過(guò)的坑記錄一下,避免重復(fù)跌倒。


【Unity Tips】關(guān)于GridBackground的正確用法的評(píng)論 (共 條)

分享到微博請(qǐng)遵守國(guó)家法律
潍坊市| 大方县| 龙江县| 象州县| 汉阴县| 蒲江县| 伊金霍洛旗| 楚雄市| 浦北县| 长海县| 丰顺县| 曲靖市| 堆龙德庆县| 中西区| 昌平区| 永泰县| 潮州市| 武冈市| 雅江县| 桑日县| 航空| 六安市| 上蔡县| 驻马店市| 濮阳县| 衡阳县| 利津县| 遵化市| 长顺县| 青冈县| 揭阳市| 维西| 增城市| 准格尔旗| 海南省| 陆丰市| 巩留县| 五大连池市| 漳州市| 湖北省| 光泽县|