using System;
|
using System.Collections;
|
using System.Collections.Generic;
|
using UnityEngine;
|
using UnityEngine.UI;
|
|
public class InputNamePanel : MonoBehaviour
|
{
|
private InputField input;
|
|
private Action<string> callBack;
|
|
// Start is called before the first frame update
|
void Start()
|
{
|
input = transform.Find("InputFieldName").GetComponent<InputField>();
|
transform.Find("OKBtn").GetComponent<Button>().onClick.AddListener(OnClickOKBtn);
|
//transform.Find("ResetNameBtn").GetComponent<Button>().onClick.AddListener(OnClickResetBtn);
|
}
|
|
public void Init(Action<string> ac)
|
{
|
callBack = ac;
|
}
|
|
private void OnClickOKBtn()
|
{
|
if (input.text != "")
|
{
|
if (callBack != null)
|
{
|
callBack(input.text);
|
}
|
Destroy(gameObject);
|
}
|
else
|
{
|
Debug.Log("没有输入名字");
|
}
|
|
}
|
|
private void OnClickResetBtn()
|
{
|
input.text = "";
|
}
|
|
|
}
|