This commit is contained in:
CortexCore
2024-06-17 14:38:09 +08:00
parent 3d447499fe
commit 65f9e40105
8 changed files with 86 additions and 14 deletions

View File

@@ -4,7 +4,8 @@
"references": [
"GUID:14fe60d984bf9f84eac55c6ea033a8f4",
"GUID:f51ebe6a0ceec4240a699833d6309b23",
"GUID:49b49c76ee64f6b41bf28ef951cb0e50"
"GUID:49b49c76ee64f6b41bf28ef951cb0e50",
"GUID:d8b63aba1907145bea998dd612889d6b"
],
"includePlatforms": [],
"excludePlatforms": [],

View File

@@ -16,6 +16,13 @@ namespace BITKit.Net.Kcp
[SerializeField] private ushort m_port;
[SerializeField] private bool connectOnStart;
[SerializeField] private bool autoReconnect;
[SerializeField]
[ReadOnly]private Vector2 traffic;
[SerializeField]
[ReadOnly]private string upTraffic;
[SerializeField]
[ReadOnly]private string downTraffic;
#if UNITY_EDITOR
[SerializeField] private Optional<string> allowDebugHost;
[SerializeField] private Optional<ushort> allowDebugPort;
@@ -157,6 +164,7 @@ namespace BITKit.Net.Kcp
public void Tick()
{
_netProviderImplementation.Tick();
}
public void HandShake()
@@ -219,6 +227,9 @@ namespace BITKit.Net.Kcp
timer.Update(obj);
rate = timer;
Tick();
traffic = client.Traffic;
upTraffic = NetUtils.GetFileSize((long)traffic.x);
downTraffic = NetUtils.GetFileSize((long)traffic.y);
}
[BIT]
private void EditorConnect()

View File

@@ -133,22 +133,14 @@ namespace BITKit
};
if (fieldInfo is not null && Attribute.IsDefined(fieldInfo, typeof(ReadOnlyAttribute), true))
{
var attribute = fieldInfo.GetCustomAttribute<ReadOnlyAttribute>();
field.pickingMode = PickingMode.Ignore;
field.SetEnabled(false);
field.style.opacity = 1;
var x = field.Q("unity-text-input");
var clearColor = new Color(0, 0, 0, 0);
if (x is not null)
field.AddToClassList("readonly");
if (attribute.HideLabel)
{
x.style.backgroundColor = clearColor;
x.style.borderTopColor = clearColor;
x.style.borderBottomColor = clearColor;
x.style.borderLeftColor = clearColor;
x.style.borderRightColor = clearColor;
foreach (var visualElement in field.Children())
{
visualElement.pickingMode = PickingMode.Ignore;
}
field.AddToClassList("hide-label");
}
}

View File

@@ -13,3 +13,15 @@
border-top-color: rgb(149, 149, 149);
border-bottom-color: rgb(149, 149, 149);
}
.readonly #unity-text-input {
background-color: rgba(0, 0, 0, 0);
border-left-color: rgba(0, 0, 0, 0);
border-right-color: rgba(0, 0, 0, 0);
border-top-color: rgba(0, 0, 0, 0);
border-bottom-color: rgba(0, 0, 0, 0);
}
.readonly .hide-label TextField Label {
display: none;
}

View File

@@ -0,0 +1,11 @@
<ui:UXML xmlns:ui="UnityEngine.UIElements" xmlns:uie="UnityEditor.UIElements" xsi="http://www.w3.org/2001/XMLSchema-instance" engine="UnityEngine.UIElements" editor="UnityEditor.UIElements" noNamespaceSchemaLocation="../UIElementsSchema/UIElements.xsd" editor-extension-mode="False">
<Style src="project://database/Assets/BITKit/Unity/UX/BITInspector.uss?fileID=7433441132597879392&amp;guid=3a78fb5b182fa434781baf5c9f733586&amp;type=3#BITInspector" />
<ui:Button text="Button" parse-escape-sequences="true" display-tooltip-when-elided="true" />
<ui:TextField picking-mode="Ignore" label="Text Field" value="filler text" />
<ui:VisualElement class="readonly">
<ui:VisualElement class="hide-label" style="flex-grow: 1;">
<ui:TextField picking-mode="Ignore" label="Text Field" value="filler text" />
</ui:VisualElement>
<ui:TextField picking-mode="Ignore" label="Text Field" value="filler text" />
</ui:VisualElement>
</ui:UXML>

View File

@@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: a61f70effbd22d74999cc16a508f5bc3
ScriptedImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 2
userData:
assetBundleName:
assetBundleVariant:
script: {fileID: 13804, guid: 0000000000000000e000000000000000, type: 0}