小编Ak *_*saf的帖子

在 Unity 中更改按钮的文本

我试图在 Unity 中打开场景时更改 Button 的文本。我尝试了不同的方法来更改 Button 的文本。

这是我的代码:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using TMPro;

public class script : MonoBehaviour {

    public Button b1;
    public TMP_Text b1text;


    void Start()
    {
        GameObject b1object = (GameObject)Instantiate(b1);
        b1text = b1object.GetComponentInChildren<TMP_Text>(true);
        btnValue();
    }

    public void btnValue()
    {
        b1text.text = "sdfa";
    }

}
Run Code Online (Sandbox Code Playgroud)

c# button unity-game-engine

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

Android 键盘在统一按下输入字段时不显示?

我有一个简单的统一场景,其中有一个输入字段。当我在 Android 设备中运行场景并按下输入字段时,Android 键盘不显示。我使用 Unity Remote 5 应用程序通过 USB 连接到我的笔记本电脑。

这是我的代码:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using TMPro;

public class InputNumber : MonoBehaviour {

    public InputField input;

    // Use this for initialization
    void Start () {
        if (input)
        {
            TouchScreenKeyboard.Open("", TouchScreenKeyboardType.Default, false, false, true);
        }
        input.keyboardType = TouchScreenKeyboardType.NumberPad;
    }

    // Update is called once per frame
    void Update () {

    }
}
Run Code Online (Sandbox Code Playgroud)

keyboard android unity-game-engine

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

标签 统计

unity-game-engine ×2

android ×1

button ×1

c# ×1

keyboard ×1