小编art*_*ien的帖子

如何在 Unity 中在运行时更改对象的层?

我有 WallCreator 脚本来在 Unity 中放置墙,另一个是 WallCreatorSwitcher 通过检查切换来打开/关闭 WallCreator。我也想通过使用更改Wallprefab的图层GetComponent<WallCreator>().wallPrefab.layer = LayerMask.NameToLayer("LayerName");,因此当检查切换时(WallCreator On)图层是“忽略射频” - 它可以工作,并且如果未选中切换(WallCreator Off)图层是“默认” - 但是问题是,在这种情况下它不会改变图层。

public class WallCreatorSwitcher : MonoBehaviour {

public Toggle toggle;
public Text text;


// Use this for initialization
void Start () {

}

// Update is called once per frame
void Update () {
    if (toggle.isOn)
    {
        GetComponent<WallCreator>().enabled = true;
        Debug.Log("Wall Creator is ON");
        text.enabled = true;
        GetComponent<WallCreator>().wallPrefab.layer = LayerMask.NameToLayer("Ignore Raycast");

    }

    else
    {
        GetComponent<WallCreator>().enabled = false;
        Debug.Log("Wall Creator is OFF");
        text.enabled = …
Run Code Online (Sandbox Code Playgroud)

c# runtime unity-game-engine

9
推荐指数
1
解决办法
3万
查看次数

输入类型的模式=具有最小和最大数字的"文本"

如何编写输入类型="文本"的模式(它不能是数字,验证不能用JS),只允许我输入数字,最小值:1和最大值:5000?

    <input type="text" name="someName" id="someId" required pattern=""/>
Run Code Online (Sandbox Code Playgroud)

html regex validation

5
推荐指数
1
解决办法
2万
查看次数

如何将子项附加到层次结构中的父对象

我有一些物品,一个叫做"父母",一个叫做"儿童"(图中第一个).如何在运行时将"Child"对象作为"Parent"对象的实际子对象(图片中的Nr.2)?

图片

c# unity-game-engine

-1
推荐指数
1
解决办法
270
查看次数

标签 统计

c# ×2

unity-game-engine ×2

html ×1

regex ×1

runtime ×1

validation ×1