This commit is contained in:
李浩 2025-04-14 16:45:08 +08:00
commit 6c0e08c7fe
4 changed files with 45 additions and 48 deletions

View File

@ -2318,7 +2318,7 @@ MonoBehaviour:
m_OnCullStateChanged: m_OnCullStateChanged:
m_PersistentCalls: m_PersistentCalls:
m_Calls: [] m_Calls: []
m_text: "\u6E05\u5C4F" m_text: "\u9690\u85CF"
m_isRightToLeft: 0 m_isRightToLeft: 0
m_fontAsset: {fileID: 11400000, guid: 97936a7b3a86809479ac89371e95b079, type: 2} m_fontAsset: {fileID: 11400000, guid: 97936a7b3a86809479ac89371e95b079, type: 2}
m_sharedMaterial: {fileID: 168401102475399263, guid: 97936a7b3a86809479ac89371e95b079, type: 2} m_sharedMaterial: {fileID: 168401102475399263, guid: 97936a7b3a86809479ac89371e95b079, type: 2}

View File

@ -914,11 +914,11 @@ MonoBehaviour:
m_faceColor: m_faceColor:
serializedVersion: 2 serializedVersion: 2
rgba: 4294967295 rgba: 4294967295
m_fontSize: 10 m_fontSize: 16
m_fontSizeBase: 10 m_fontSizeBase: 16
m_fontWeight: 400 m_fontWeight: 400
m_enableAutoSizing: 1 m_enableAutoSizing: 0
m_fontSizeMin: 10 m_fontSizeMin: 18
m_fontSizeMax: 72 m_fontSizeMax: 72
m_fontStyle: 0 m_fontStyle: 0
m_HorizontalAlignment: 1 m_HorizontalAlignment: 1
@ -1821,8 +1821,8 @@ RectTransform:
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 1} m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 0, y: 1} m_AnchorMax: {x: 0, y: 1}
m_AnchoredPosition: {x: 77.005, y: -16.552} m_AnchoredPosition: {x: 91.4, y: -16.552}
m_SizeDelta: {x: 154.01, y: 33.104} m_SizeDelta: {x: 182.8, y: 33.104}
m_Pivot: {x: 0.5, y: 0.5} m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &8476752034012845522 --- !u!222 &8476752034012845522
CanvasRenderer: CanvasRenderer:
@ -1845,7 +1845,7 @@ MonoBehaviour:
m_Name: m_Name:
m_EditorClassIdentifier: m_EditorClassIdentifier:
m_Material: {fileID: 0} m_Material: {fileID: 0}
m_Color: {r: 1, g: 1, b: 1, a: 1} m_Color: {r: 1, g: 1, b: 1, a: 0}
m_RaycastTarget: 1 m_RaycastTarget: 1
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
m_Maskable: 1 m_Maskable: 1
@ -2489,8 +2489,8 @@ RectTransform:
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 1} m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 0, y: 1} m_AnchorMax: {x: 0, y: 1}
m_AnchoredPosition: {x: 77.005, y: -16.552} m_AnchoredPosition: {x: 91.4, y: -16.552}
m_SizeDelta: {x: 144.01, y: 33} m_SizeDelta: {x: 172.8, y: 33}
m_Pivot: {x: 0.5, y: 0.5} m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &60149285316496278 --- !u!222 &60149285316496278
CanvasRenderer: CanvasRenderer:
@ -2520,17 +2520,17 @@ MonoBehaviour:
m_OnCullStateChanged: m_OnCullStateChanged:
m_PersistentCalls: m_PersistentCalls:
m_Calls: [] m_Calls: []
m_text: 123123123123 m_text:
m_isRightToLeft: 0 m_isRightToLeft: 0
m_fontAsset: {fileID: 11400000, guid: e7da174c677019b49aa681250aa4ded8, type: 2} m_fontAsset: {fileID: 11400000, guid: 97936a7b3a86809479ac89371e95b079, type: 2}
m_sharedMaterial: {fileID: -7878122246201655599, guid: e7da174c677019b49aa681250aa4ded8, type: 2} m_sharedMaterial: {fileID: 168401102475399263, guid: 97936a7b3a86809479ac89371e95b079, type: 2}
m_fontSharedMaterials: [] m_fontSharedMaterials: []
m_fontMaterial: {fileID: 0} m_fontMaterial: {fileID: 0}
m_fontMaterials: [] m_fontMaterials: []
m_fontColor32: m_fontColor32:
serializedVersion: 2 serializedVersion: 2
rgba: 4281479730 rgba: 4278190080
m_fontColor: {r: 0.19607843, g: 0.19607843, b: 0.19607843, a: 1} m_fontColor: {r: 0, g: 0, b: 0, a: 1}
m_enableVertexGradient: 0 m_enableVertexGradient: 0
m_colorMode: 3 m_colorMode: 3
m_fontColorGradient: m_fontColorGradient:
@ -2547,15 +2547,15 @@ MonoBehaviour:
m_faceColor: m_faceColor:
serializedVersion: 2 serializedVersion: 2
rgba: 4294967295 rgba: 4294967295
m_fontSize: 20 m_fontSize: 16
m_fontSizeBase: 20 m_fontSizeBase: 16
m_fontWeight: 400 m_fontWeight: 400
m_enableAutoSizing: 1 m_enableAutoSizing: 0
m_fontSizeMin: 18 m_fontSizeMin: 18
m_fontSizeMax: 20 m_fontSizeMax: 72
m_fontStyle: 0 m_fontStyle: 0
m_HorizontalAlignment: 2 m_HorizontalAlignment: 1
m_VerticalAlignment: 512 m_VerticalAlignment: 8192
m_textAlignment: 65535 m_textAlignment: 65535
m_characterSpacing: 0 m_characterSpacing: 0
m_wordSpacing: 0 m_wordSpacing: 0
@ -2642,7 +2642,7 @@ MonoBehaviour:
m_Name: m_Name:
m_EditorClassIdentifier: m_EditorClassIdentifier:
MarkType: 0 MarkType: 0
CustomComponentName: RootContent CustomComponentName:
CustomComment: CustomComment:
mComponentName: RectTransform mComponentName: RectTransform
--- !u!1 &8280112074671649668 --- !u!1 &8280112074671649668

View File

@ -12,8 +12,9 @@ public class ObjectColorToggle : MonoBehaviour
} }
public Color isOnColor = new Color(86 / 255f, 255 / 255f, 160 / 255f); public Color isOnColor = new Color(86 / 255f, 255 / 255f, 160 / 255f);
public Color isOffColor = new Color(255 / 255f, 255 / 255f, 255 / 255f); public Color isOffColor = new Color(255 / 255f, 255 / 255f, 255 / 255f);
public Color isHoverColor = new Color(185f / 255f, 255 / 255f, 215/ 255f); public Color isHoverColor = new Color(185f / 255f, 255 / 255f, 215 / 255f);
MeshRenderer mesh; MeshRenderer mesh;
private Texture2D savedTexture;
private void Awake() private void Awake()
{ {
mesh = gameObject.GetComponent<MeshRenderer>(); mesh = gameObject.GetComponent<MeshRenderer>();
@ -26,14 +27,19 @@ public class ObjectColorToggle : MonoBehaviour
{ {
case State.On: case State.On:
isOnColor.a = alpha; isOnColor.a = alpha;
savedTexture = mesh.material.mainTexture as Texture2D;
mesh.material.mainTexture = null;
mesh.material.color = isOnColor; mesh.material.color = isOnColor;
break; break;
case State.Off: case State.Off:
isOffColor.a = alpha; isOffColor.a = alpha;
mesh.material.mainTexture = savedTexture;
mesh.material.color = isOffColor; mesh.material.color = isOffColor;
break; break;
case State.Hover: case State.Hover:
isHoverColor.a = alpha; isHoverColor.a = alpha;
savedTexture = mesh.material.mainTexture as Texture2D;
mesh.material.mainTexture = null;
mesh.material.color = isHoverColor; mesh.material.color = isHoverColor;
break; break;
default: default:
@ -56,5 +62,4 @@ public class ObjectColorToggle : MonoBehaviour
SetColor(State.Off); SetColor(State.Off);
} }
} }
} }

View File

@ -217,7 +217,7 @@ namespace QFramework.Example
SearchContent.gameObject.SetActive(true); SearchContent.gameObject.SetActive(true);
Content.gameObject.SetActive(false); Content.gameObject.SetActive(false);
}); });
Input.onEndEdit.AddListener(str => Input.onValueChanged.AddListener(str =>
{ {
if (string.IsNullOrEmpty(str)) if (string.IsNullOrEmpty(str))
{ {
@ -349,34 +349,26 @@ namespace QFramework.Example
GameObject clone = GameObject.Instantiate(SearchItem.gameObject, SearchContent); GameObject clone = GameObject.Instantiate(SearchItem.gameObject, SearchContent);
searchItemMap.Add(clone, child.gameObject); searchItemMap.Add(clone, child.gameObject);
Transform subContent = child.Find("SubContent"); Transform subContent = child.Find("SubContent");
Button btn = clone.transform.Find("Button").GetComponent<Button>();
btn.onClick.AddListener(() =>
{
child.Find("Content/Toggle/Obj").GetComponent<Button>().onClick.Invoke();
});
string grou = string.Empty;
if (subContent.childCount > 0) if (subContent.childCount > 0)
{ {
Button btn = clone.transform.Find("Button").GetComponent<Button>(); grou = "(组)";
btn.onClick.AddListener(() =>
{
child.Find("Content/Toggle/Obj").GetComponent<Toggle>().isOn = true;
});
Transform buttonLabel = btn.transform.Find("Label");
if (buttonLabel != null)
{
TextMeshProUGUI buttonText = buttonLabel.GetComponent<TextMeshProUGUI>();
if (buttonText != null)
{
buttonText.text = "组" + name + ">";
}
}
CheckChildren(subContent, str); CheckChildren(subContent, str);
} }
else
Transform buttonLabel = btn.transform.Find("Label");
if (buttonLabel != null)
{ {
Transform buttonLabel = clone.transform.Find("Button/Label"); TextMeshProUGUI buttonText = buttonLabel.GetComponent<TextMeshProUGUI>();
if (buttonLabel != null) if (buttonText != null)
{ {
TextMeshProUGUI buttonText = buttonLabel.GetComponent<TextMeshProUGUI>(); buttonText.text = grou + name + ">";
if (buttonText != null)
{
buttonText.text = name + ">";
}
} }
} }
} }