gpt4 book ai didi

unity3d - 统一 : Use automatic navigation in explicit navigation

转载 作者:行者123 更新时间:2023-12-04 12:01:22 26 4
gpt4 key购买 nike

我想对应用程序中的所有按钮使用显式导航。
但是对于某些按钮,我希望保留“右侧选择”以使用自动导航(例如:我知道向左、向上和向下的下一个按钮,但我不知道下一个向右的按钮)。

最佳答案

您需要创建一个自定义 Selectable如果设置了值,则可以使用显式导航。您可以将此代码用于您的案例,只需在需要使用自动导航的检查器中留下空白字段即可。

using UnityEngine;
using UnityEngine.UI;

namespace UI.CustomSelectable
{
public class CustomSelectable : Selectable
{
[SerializeField]
private Selectable upSelectable;

[SerializeField]
private Selectable downSelectable;

[SerializeField]
private Selectable leftSelectable;

[SerializeField]
private Selectable rightSelectable;

public override Selectable FindSelectableOnUp()
{
return upSelectable != null ? upSelectable : base.FindSelectableOnUp();
}

public override Selectable FindSelectableOnDown()
{
return downSelectable != null ? downSelectable : base.FindSelectableOnDown();
}

public override Selectable FindSelectableOnLeft()
{
return leftSelectable != null ? leftSelectable : base.FindSelectableOnLeft();
}

public override Selectable FindSelectableOnRight()
{
return rightSelectable != null ? rightSelectable : base.FindSelectableOnRight();
}
}
}

关于unity3d - 统一 : Use automatic navigation in explicit navigation,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48075615/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com