五月天青色头像情侣网名,国产亚洲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ó)家法律
宾阳县| 枣庄市| 光泽县| 墨竹工卡县| 伊吾县| 沿河| 从化市| 南木林县| 黎川县| 滦南县| 昌江| 商南县| 保定市| 铅山县| 遂昌县| 花莲县| 镇康县| 石狮市| 红桥区| 濮阳县| 图木舒克市| 东明县| 怀柔区| 麦盖提县| 华宁县| 洛浦县| 化州市| 宁城县| 桐梓县| 明水县| 榕江县| 调兵山市| 龙泉市| 勐海县| 黄平县| 翁源县| 疏附县| 牡丹江市| 万荣县| 青州市| 彝良县|