UI替换与对应代码进行调整
This commit is contained in:
@@ -22,7 +22,12 @@ namespace TcgEngine.UI
|
||||
[Header("Login")]
|
||||
public UIPanel login_panel;
|
||||
public InputField login_user;
|
||||
public Button clear_user_button;
|
||||
|
||||
public InputField login_password;
|
||||
public Button show_password_button;
|
||||
private ToggleImage _passwordToggle;
|
||||
|
||||
public Button login_button;
|
||||
public GameObject login_bottom;
|
||||
public Text error_msg;
|
||||
@@ -199,6 +204,17 @@ namespace TcgEngine.UI
|
||||
SelectField(login_password);
|
||||
}
|
||||
|
||||
if (clear_user_button != null)
|
||||
{
|
||||
clear_user_button.onClick.AddListener(ClearNameText);
|
||||
}
|
||||
|
||||
if (show_password_button != null)
|
||||
{
|
||||
show_password_button.onClick.AddListener(ShowPassword);
|
||||
_passwordToggle = show_password_button.GetComponent<ToggleImage>();
|
||||
}
|
||||
|
||||
RefreshLogin();
|
||||
}
|
||||
|
||||
@@ -398,6 +414,26 @@ namespace TcgEngine.UI
|
||||
SceneNav.GoTo(scene);
|
||||
}
|
||||
|
||||
private void ClearNameText()
|
||||
{
|
||||
login_user.text = "";
|
||||
}
|
||||
|
||||
private void ShowPassword()
|
||||
{
|
||||
var isShow = _passwordToggle.GetButtonStatus();
|
||||
if (isShow)
|
||||
{
|
||||
login_password.contentType = InputField.ContentType.Standard;
|
||||
login_password.lineType = InputField.LineType.SingleLine;
|
||||
}
|
||||
else
|
||||
{
|
||||
login_password.contentType = InputField.ContentType.Password;
|
||||
}
|
||||
login_password.ForceLabelUpdate();
|
||||
}
|
||||
|
||||
public static LoginMenu Get()
|
||||
{
|
||||
return instance;
|
||||
|
||||
@@ -14,7 +14,7 @@ namespace TcgEngine.UI
|
||||
{
|
||||
public string group;
|
||||
public bool active;
|
||||
// public GameObject highlight;
|
||||
public GameObject highlight;
|
||||
public UIPanel ui_panel;
|
||||
|
||||
public UnityAction onClick;
|
||||
@@ -47,8 +47,8 @@ namespace TcgEngine.UI
|
||||
|
||||
void Update()
|
||||
{
|
||||
// if (highlight != null)
|
||||
// highlight.SetActive(active);
|
||||
if (highlight != null)
|
||||
highlight.SetActive(active);
|
||||
}
|
||||
|
||||
private void OnClick()
|
||||
|
||||
44
Assets/TcgEngine/Scripts/UI/ToggleImage.cs
Normal file
44
Assets/TcgEngine/Scripts/UI/ToggleImage.cs
Normal file
@@ -0,0 +1,44 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace TcgEngine.UI
|
||||
{
|
||||
public class ToggleImage : MonoBehaviour
|
||||
{
|
||||
public Sprite onSprite;
|
||||
public Sprite offSprite;
|
||||
|
||||
private Button _button;
|
||||
private Image _image;
|
||||
private bool _isShowOnSprite = false;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
_button = GetComponent<Button>();
|
||||
if (_button != null)
|
||||
{
|
||||
_button.onClick.AddListener(SwitchButtonStatus);
|
||||
_image = _button.GetComponent<Image>();
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogError("请检查是否存在按钮!");
|
||||
}
|
||||
}
|
||||
|
||||
private void SwitchButtonStatus()
|
||||
{
|
||||
_isShowOnSprite = !_isShowOnSprite;
|
||||
|
||||
_image.sprite = _isShowOnSprite ? onSprite : offSprite;
|
||||
}
|
||||
|
||||
public bool GetButtonStatus()
|
||||
{
|
||||
return _isShowOnSprite;
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/TcgEngine/Scripts/UI/ToggleImage.cs.meta
Normal file
11
Assets/TcgEngine/Scripts/UI/ToggleImage.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 59aa0138a79f8154991279d70c301fb2
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -15,6 +15,12 @@ namespace TcgEngine.UI
|
||||
public Color on_color = Color.yellow;
|
||||
public Color off_color = Color.white;
|
||||
|
||||
public int on_size = 42;
|
||||
public int off_size = 36;
|
||||
|
||||
[Header("判断启用文字颜色选中还是文字大小选中")]
|
||||
public bool is_color = true;
|
||||
|
||||
private Toggle toggle;
|
||||
private Text toggle_txt;
|
||||
|
||||
@@ -28,6 +34,8 @@ namespace TcgEngine.UI
|
||||
|
||||
private void Start()
|
||||
{
|
||||
on_size = toggle_txt.fontSize;
|
||||
off_size = (int)(toggle_txt.fontSize * 0.8f);
|
||||
Refresh();
|
||||
}
|
||||
|
||||
@@ -39,8 +47,17 @@ namespace TcgEngine.UI
|
||||
|
||||
private void Refresh()
|
||||
{
|
||||
toggle_txt.color = toggle.isOn ? on_color : off_color;
|
||||
if (is_color)
|
||||
{
|
||||
toggle_txt.color = toggle.isOn ? on_color : off_color;
|
||||
}
|
||||
else
|
||||
{
|
||||
toggle_txt.fontSize = toggle.isOn ? on_size : off_size;
|
||||
toggle_txt.fontStyle = toggle.isOn ? FontStyle.Bold : FontStyle.Normal;
|
||||
}
|
||||
previous = toggle.isOn;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user