ui: avoid alpha 0 on images with Mask dependency across PledgerSkin
This commit is contained in:
1 parent
5486a9c033
commit
58bf83d08e
2 files changed
+19
-7
No files matched your search
@@ -27,8 +27,16 @@ namespace Decentralized
|
|||||||
public static readonly Color Paper = new Color(0.847f, 0.855f, 0.816f); // #D8DAD0
|
public static readonly Color Paper = new Color(0.847f, 0.855f, 0.816f); // #D8DAD0
|
||||||
public static readonly Color RowNormal = new Color(0f, 0f, 0f, 0.04f);
|
public static readonly Color RowNormal = new Color(0f, 0f, 0f, 0.04f);
|
||||||
public static readonly Color Transparent = new Color(0f, 0f, 0f, 0f);
|
public static readonly Color Transparent = new Color(0f, 0f, 0f, 0f);
|
||||||
|
public static readonly Color MaskClear = new Color(0f, 0f, 0f, 0.004f);
|
||||||
public static readonly Color Separator = new Color(0.12f, 0.12f, 0.14f, 0.18f);
|
public static readonly Color Separator = new Color(0.12f, 0.12f, 0.14f, 0.18f);
|
||||||
|
|
||||||
|
/// <summary>透明化底图:若附带 Mask 组件则保留极微小 alpha(0.004),避免 Mask 模板 alpha 为 0 导致子内容被整裁。</summary>
|
||||||
|
public static void SetClear(Image img)
|
||||||
|
{
|
||||||
|
if (img == null) return;
|
||||||
|
img.color = (img.GetComponent<Mask>() != null) ? MaskClear : Transparent;
|
||||||
|
}
|
||||||
|
|
||||||
private static readonly Dictionary<string, Sprite> Sliced = new Dictionary<string, Sprite>();
|
private static readonly Dictionary<string, Sprite> Sliced = new Dictionary<string, Sprite>();
|
||||||
|
|
||||||
/// <summary>把本 mod 的像素图做成九宫格贴到 Image 上:边角 border 像素不拉伸,一个像素放大成 3 个界面单位。</summary>
|
/// <summary>把本 mod 的像素图做成九宫格贴到 Image 上:边角 border 像素不拉伸,一个像素放大成 3 个界面单位。</summary>
|
||||||
@@ -116,7 +124,7 @@ namespace Decentralized
|
|||||||
foreach (var name in new[] { "header", "rule" })
|
foreach (var name in new[] { "header", "rule" })
|
||||||
{
|
{
|
||||||
var img = win.root.transform.Find(name)?.GetComponent<Image>();
|
var img = win.root.transform.Find(name)?.GetComponent<Image>();
|
||||||
if (img != null) img.color = Transparent;
|
if (img != null) SetClear(img);
|
||||||
}
|
}
|
||||||
if (win.frame?.titleText != null)
|
if (win.frame?.titleText != null)
|
||||||
{
|
{
|
||||||
@@ -193,18 +201,18 @@ namespace Decentralized
|
|||||||
foreach (var scroll in screen.GetComponentsInChildren<ScrollRect>(true))
|
foreach (var scroll in screen.GetComponentsInChildren<ScrollRect>(true))
|
||||||
{
|
{
|
||||||
var bg = scroll.GetComponent<Image>();
|
var bg = scroll.GetComponent<Image>();
|
||||||
if (bg != null) bg.color = Transparent;
|
if (bg != null) SetClear(bg);
|
||||||
if (scroll.viewport != null)
|
if (scroll.viewport != null)
|
||||||
{
|
{
|
||||||
var vpImg = scroll.viewport.GetComponent<Image>();
|
var vpImg = scroll.viewport.GetComponent<Image>();
|
||||||
// 视口的图是 Mask 的模板:alpha 为 0 会把整个内容裁掉,只能压到几乎看不见
|
// 视口的图是 Mask 的模板:alpha 为 0 会把整个内容裁掉,只能压到几乎看不见
|
||||||
if (vpImg != null) vpImg.color = new Color(0f, 0f, 0f, 0.004f);
|
if (vpImg != null) SetClear(vpImg);
|
||||||
}
|
}
|
||||||
if (scroll.verticalScrollbar != null)
|
if (scroll.verticalScrollbar != null)
|
||||||
{
|
{
|
||||||
var sb = scroll.verticalScrollbar;
|
var sb = scroll.verticalScrollbar;
|
||||||
var track = sb.GetComponent<Image>();
|
var track = sb.GetComponent<Image>();
|
||||||
if (track != null) track.color = Transparent;
|
if (track != null) SetClear(track);
|
||||||
if (sb.handleRect != null)
|
if (sb.handleRect != null)
|
||||||
{
|
{
|
||||||
var handleImg = sb.handleRect.GetComponent<Image>();
|
var handleImg = sb.handleRect.GetComponent<Image>();
|
||||||
@@ -217,11 +225,15 @@ namespace Decentralized
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 清理辅助 Panel 底图
|
// 清理辅助 Panel 底图与任何残留原生灰色边框的容器
|
||||||
if (clear != null)
|
if (clear != null)
|
||||||
{
|
{
|
||||||
foreach (var img in clear)
|
foreach (var img in clear)
|
||||||
if (img != null) img.color = Transparent;
|
if (img != null) SetClear(img);
|
||||||
|
}
|
||||||
|
foreach (var img in screen.GetComponentsInChildren<Image>(true))
|
||||||
|
{
|
||||||
|
if (img.sprite == MachineryStyle.BevelFrame) SetClear(img);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 数据表行:反色高亮与整行点击
|
// 数据表行:反色高亮与整行点击
|
||||||
|
|||||||
@@ -195,7 +195,7 @@ namespace Decentralized
|
|||||||
OnClick = () => { dev.Asset = x.asset; dev.Note = null; Open(dev); }
|
OnClick = () => { dev.Asset = x.asset; dev.Note = null; Open(dev); }
|
||||||
});
|
});
|
||||||
PledgerSkin.Apply(win, screen, bezel, paper, _picked, _clear, rows);
|
PledgerSkin.Apply(win, screen, bezel, paper, _picked, _clear, rows);
|
||||||
if (plate != null) plate.color = PledgerSkin.Transparent;
|
if (plate != null) PledgerSkin.SetClear(plate);
|
||||||
// 签名要按住 ✓:在按键上挂一个按住计时
|
// 签名要按住 ✓:在按键上挂一个按住计时
|
||||||
if (ok != null && dev.Screen == Screen.Review && ok.GetComponent<HoldToSign>() == null) ok.AddComponent<HoldToSign>().Device = dev.Address;
|
if (ok != null && dev.Screen == Screen.Review && ok.GetComponent<HoldToSign>() == null) ok.AddComponent<HoldToSign>().Device = dev.Address;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user