using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class studioDesign : MonoBehaviour
{
public Text studioNameText;
public InputField studioNameInput;
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
}
public void studioName()
{
studioNameText.text = studioNameInput.text;
}
}
I am trying to get user input to name their business, and I want their name to display in the text on the side of the building. I am struggling to find the answer. Any help would be appreciated. Here is my script and some screen shots in case you can’t understand what I am asking.
If you’ve assigned the two variables in the inspector properly, then you just need to call your method “studioName” when the continue button is clicked.
You can set that up in the inspector in the button component, or you can do it in code:
public Text studioNameText;
public InputField studioNameInput;
public Button continueButton;
private void OnEnable()
{
continueButton.onClick.AddListener(SetStudioName);
}
private void OnDisable()
{
continueButton.onClick.RemoveListener(SetStudioName);
}
public void SetStudioName()
{
studioNameText.text = studioNameInput.text;
}
Thank you so much! Helped out big time!!!
1 Like