ZoeRobotIngles/Assets/Scripts/ShowPswBtn.cs

34 lines
952 B
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class ShowPswBtn : MonoBehaviour
{
private Button thisBtn;
private InputField passwordInputField;
private Animator thisAnim;
private void Awake()
{
thisAnim = GetComponent<Animator>();
thisBtn = GetComponent<Button>();
passwordInputField = GetComponentInParent<InputField>();
thisBtn.onClick.AddListener(AlternatePsw);
}
public void AlternatePsw()
{
if(passwordInputField.contentType == InputField.ContentType.Standard)
{
passwordInputField.contentType = InputField.ContentType.Password;
thisAnim.SetTrigger("Close");
}
else
{
thisAnim.SetTrigger("Open");
passwordInputField.contentType = InputField.ContentType.Standard;
}
passwordInputField.ForceLabelUpdate();
}
}