feat(auth): add reusable auth button and input field components
This commit is contained in:
parent
ea005e4477
commit
c947a84477
8 changed files with 142 additions and 12 deletions
|
|
@ -451,9 +451,9 @@ MonoBehaviour:
|
||||||
m_Script: {fileID: 11500000, guid: 3955dbe39e234b7a84bffd5f053855ff, type: 3}
|
m_Script: {fileID: 11500000, guid: 3955dbe39e234b7a84bffd5f053855ff, type: 3}
|
||||||
m_Name:
|
m_Name:
|
||||||
m_EditorClassIdentifier:
|
m_EditorClassIdentifier:
|
||||||
loginButton: {fileID: 489976505}
|
loginButton: {fileID: 489976508}
|
||||||
usernameInputField: {fileID: 535676077}
|
usernameInputField: {fileID: 535676080}
|
||||||
passwordInputField: {fileID: 234502803}
|
passwordInputField: {fileID: 234502806}
|
||||||
--- !u!1 &184757597
|
--- !u!1 &184757597
|
||||||
GameObject:
|
GameObject:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
|
|
@ -498,6 +498,7 @@ GameObject:
|
||||||
- component: {fileID: 234502805}
|
- component: {fileID: 234502805}
|
||||||
- component: {fileID: 234502804}
|
- component: {fileID: 234502804}
|
||||||
- component: {fileID: 234502803}
|
- component: {fileID: 234502803}
|
||||||
|
- component: {fileID: 234502806}
|
||||||
m_Layer: 5
|
m_Layer: 5
|
||||||
m_Name: Password_IF
|
m_Name: Password_IF
|
||||||
m_TagString: Untagged
|
m_TagString: Untagged
|
||||||
|
|
@ -665,6 +666,19 @@ CanvasRenderer:
|
||||||
m_PrefabAsset: {fileID: 0}
|
m_PrefabAsset: {fileID: 0}
|
||||||
m_GameObject: {fileID: 234502801}
|
m_GameObject: {fileID: 234502801}
|
||||||
m_CullTransparentMesh: 1
|
m_CullTransparentMesh: 1
|
||||||
|
--- !u!114 &234502806
|
||||||
|
MonoBehaviour:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 234502801}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: cc52e32da9f14d4596cc527b7496815a, type: 3}
|
||||||
|
m_Name:
|
||||||
|
m_EditorClassIdentifier:
|
||||||
|
errorText: {fileID: 0}
|
||||||
--- !u!1 &330585543
|
--- !u!1 &330585543
|
||||||
GameObject:
|
GameObject:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
|
|
@ -1280,6 +1294,7 @@ GameObject:
|
||||||
- component: {fileID: 489976507}
|
- component: {fileID: 489976507}
|
||||||
- component: {fileID: 489976506}
|
- component: {fileID: 489976506}
|
||||||
- component: {fileID: 489976505}
|
- component: {fileID: 489976505}
|
||||||
|
- component: {fileID: 489976508}
|
||||||
m_Layer: 5
|
m_Layer: 5
|
||||||
m_Name: Login_BT
|
m_Name: Login_BT
|
||||||
m_TagString: Untagged
|
m_TagString: Untagged
|
||||||
|
|
@ -1390,6 +1405,18 @@ CanvasRenderer:
|
||||||
m_PrefabAsset: {fileID: 0}
|
m_PrefabAsset: {fileID: 0}
|
||||||
m_GameObject: {fileID: 489976503}
|
m_GameObject: {fileID: 489976503}
|
||||||
m_CullTransparentMesh: 1
|
m_CullTransparentMesh: 1
|
||||||
|
--- !u!114 &489976508
|
||||||
|
MonoBehaviour:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 489976503}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: f2fb03888bd1498daadd244b4646b820, type: 3}
|
||||||
|
m_Name:
|
||||||
|
m_EditorClassIdentifier:
|
||||||
--- !u!1 &535676075
|
--- !u!1 &535676075
|
||||||
GameObject:
|
GameObject:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
|
|
@ -1402,6 +1429,7 @@ GameObject:
|
||||||
- component: {fileID: 535676079}
|
- component: {fileID: 535676079}
|
||||||
- component: {fileID: 535676078}
|
- component: {fileID: 535676078}
|
||||||
- component: {fileID: 535676077}
|
- component: {fileID: 535676077}
|
||||||
|
- component: {fileID: 535676080}
|
||||||
m_Layer: 5
|
m_Layer: 5
|
||||||
m_Name: Username_IF
|
m_Name: Username_IF
|
||||||
m_TagString: Untagged
|
m_TagString: Untagged
|
||||||
|
|
@ -1569,6 +1597,19 @@ CanvasRenderer:
|
||||||
m_PrefabAsset: {fileID: 0}
|
m_PrefabAsset: {fileID: 0}
|
||||||
m_GameObject: {fileID: 535676075}
|
m_GameObject: {fileID: 535676075}
|
||||||
m_CullTransparentMesh: 1
|
m_CullTransparentMesh: 1
|
||||||
|
--- !u!114 &535676080
|
||||||
|
MonoBehaviour:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 535676075}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: cc52e32da9f14d4596cc527b7496815a, type: 3}
|
||||||
|
m_Name:
|
||||||
|
m_EditorClassIdentifier:
|
||||||
|
errorText: {fileID: 0}
|
||||||
--- !u!1 &555582722
|
--- !u!1 &555582722
|
||||||
GameObject:
|
GameObject:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
using _Hub.Scripts.Network;
|
using _Network.Auth;
|
||||||
using TMPro;
|
using TMPro;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.UI;
|
using UnityEngine.UI;
|
||||||
|
|
@ -13,9 +13,9 @@ namespace _Hub.Scripts.UI
|
||||||
|
|
||||||
private const int _maxUsernameLength = 15;
|
private const int _maxUsernameLength = 15;
|
||||||
private const int _maxPasswordLength = 15;
|
private const int _maxPasswordLength = 15;
|
||||||
[SerializeField] private Button loginButton;
|
[SerializeField] private AuthButton loginButton;
|
||||||
[SerializeField] private TMP_InputField usernameInputField;
|
[SerializeField] private AuthInputField usernameInputField;
|
||||||
[SerializeField] private TMP_InputField passwordInputField;
|
[SerializeField] private AuthInputField passwordInputField;
|
||||||
private string _username = String.Empty;
|
private string _username = String.Empty;
|
||||||
private string _password = String.Empty;
|
private string _password = String.Empty;
|
||||||
|
|
||||||
|
|
@ -23,11 +23,16 @@ namespace _Hub.Scripts.UI
|
||||||
|
|
||||||
#region Unity
|
#region Unity
|
||||||
|
|
||||||
private void Awake()
|
private void Start()
|
||||||
{
|
{
|
||||||
loginButton.onClick.AddListener(OnLoginClick);
|
AddListeners();
|
||||||
usernameInputField.onValueChanged.AddListener(UpdateUsername);
|
}
|
||||||
passwordInputField.onValueChanged.AddListener(UpdatePassword);
|
|
||||||
|
private void AddListeners()
|
||||||
|
{
|
||||||
|
loginButton.Button.onClick.AddListener(OnLoginClick);
|
||||||
|
usernameInputField.InputField.onValueChanged.AddListener(UpdateUsername);
|
||||||
|
passwordInputField.InputField.onValueChanged.AddListener(UpdatePassword);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnLoginClick()
|
private void OnLoginClick()
|
||||||
|
|
@ -59,7 +64,7 @@ namespace _Hub.Scripts.UI
|
||||||
|
|
||||||
private void EnableLoginButton(bool interactable)
|
private void EnableLoginButton(bool interactable)
|
||||||
{
|
{
|
||||||
loginButton.interactable = interactable;
|
loginButton.SetInteractable(interactable);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
|
||||||
8
Playvoi.Client/Assets/_Network.meta
Normal file
8
Playvoi.Client/Assets/_Network.meta
Normal file
|
|
@ -0,0 +1,8 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: edb52cd058b3ca540abe98e6753e88b5
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
8
Playvoi.Client/Assets/_Network/Auth.meta
Normal file
8
Playvoi.Client/Assets/_Network/Auth.meta
Normal file
|
|
@ -0,0 +1,8 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: abb1ea9e4295c5f43b5a59e431512163
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
26
Playvoi.Client/Assets/_Network/Auth/AuthButton.cs
Normal file
26
Playvoi.Client/Assets/_Network/Auth/AuthButton.cs
Normal file
|
|
@ -0,0 +1,26 @@
|
||||||
|
using System;
|
||||||
|
using UnityEngine;
|
||||||
|
using UnityEngine.UI;
|
||||||
|
|
||||||
|
namespace _Network.Auth
|
||||||
|
{
|
||||||
|
public class AuthButton : MonoBehaviour
|
||||||
|
{
|
||||||
|
public Button Button
|
||||||
|
{
|
||||||
|
get { return _button; }
|
||||||
|
}
|
||||||
|
|
||||||
|
private Button _button;
|
||||||
|
|
||||||
|
private void Awake()
|
||||||
|
{
|
||||||
|
_button = GetComponent<Button>();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SetInteractable(bool value)
|
||||||
|
{
|
||||||
|
_button.interactable = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
3
Playvoi.Client/Assets/_Network/Auth/AuthButton.cs.meta
Normal file
3
Playvoi.Client/Assets/_Network/Auth/AuthButton.cs.meta
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: f2fb03888bd1498daadd244b4646b820
|
||||||
|
timeCreated: 1768648667
|
||||||
36
Playvoi.Client/Assets/_Network/Auth/AuthInputField.cs
Normal file
36
Playvoi.Client/Assets/_Network/Auth/AuthInputField.cs
Normal file
|
|
@ -0,0 +1,36 @@
|
||||||
|
using System;
|
||||||
|
using TMPro;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
namespace _Network.Auth
|
||||||
|
{
|
||||||
|
public class AuthInputField : MonoBehaviour
|
||||||
|
{
|
||||||
|
public TMP_InputField InputField
|
||||||
|
{
|
||||||
|
get { return _inputField; }
|
||||||
|
}
|
||||||
|
|
||||||
|
private TMP_InputField _inputField;
|
||||||
|
|
||||||
|
[SerializeField] private TMP_Text errorText;
|
||||||
|
|
||||||
|
|
||||||
|
private void Awake()
|
||||||
|
{
|
||||||
|
_inputField = GetComponent<TMP_InputField>();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Error(bool show)
|
||||||
|
{
|
||||||
|
if (show)
|
||||||
|
{
|
||||||
|
errorText.gameObject.SetActive(true);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
errorText.gameObject.SetActive(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,3 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: cc52e32da9f14d4596cc527b7496815a
|
||||||
|
timeCreated: 1768647887
|
||||||
Loading…
Reference in a new issue