Loading Assets/Scenes/Main.unity +4 −1 Original line number Diff line number Diff line Loading @@ -1987,6 +1987,9 @@ MonoBehaviour: m_Name: m_EditorClassIdentifier: inputField: {fileID: 23275626} unlockedSprite: {fileID: 6091405373536128358, guid: e70f17ed9e81410418db04270295ae3c, type: 3} lockedSprite: {fileID: 21300000, guid: d8f3c281772d8ce428ce642723fa4ef9, type: 3} button: {fileID: 1152326135} --- !u!114 &1152326134 MonoBehaviour: m_ObjectHideFlags: 0 Loading Loading @@ -2063,7 +2066,7 @@ MonoBehaviour: m_OnCullStateChanged: m_PersistentCalls: m_Calls: [] m_Sprite: {fileID: 6091405373536128358, guid: e70f17ed9e81410418db04270295ae3c, type: 3} m_Sprite: {fileID: 21300000, guid: d8f3c281772d8ce428ce642723fa4ef9, type: 3} m_Type: 0 m_PreserveAspect: 0 m_FillCenter: 1 Loading Assets/Scripts/Messaging/Composer/SendButton.cs +18 −1 Original line number Diff line number Diff line using System; using UnityEngine; using UnityEngine.Serialization; using UnityEngine.UI; namespace Messaging.Composer { public class SendButton : MonoBehaviour { [SerializeField] private InputField inputField; [SerializeField] private Sprite unlockedSprite; [SerializeField] private Sprite lockedSprite; private bool _locked; [SerializeField] private Image button; private MessageManager _messageManager; private void Awake() { _messageManager = FindObjectOfType<MessageManager>(); } public void Lock() { _locked = true; button.sprite = lockedSprite; } public void Unlock() { _locked = false; button.sprite = unlockedSprite; } public void SendEmojis() { if (CanSendText()) { _messageManager.CreateMessage(inputField.Text, true); Loading @@ -20,7 +36,8 @@ namespace Messaging.Composer { } private bool CanSendText() { return !string.IsNullOrEmpty(inputField.Text) && !string.IsNullOrWhiteSpace(inputField.Text); bool isInputEmpty = string.IsNullOrEmpty(inputField.Text) || string.IsNullOrWhiteSpace(inputField.Text); return !isInputEmpty && !_locked; } } } No newline at end of file Assets/Scripts/Messaging/Typer/MessageManager.cs +5 −1 Original line number Diff line number Diff line Loading @@ -31,12 +31,14 @@ namespace Messaging { private readonly Regex _emojiGetter = new("<([a-z]+)(?![^>]*\\/>)[^>]*>"); private const int NumEmojis = 35; private EmojiButtonManager _emojiButtonManager; private SendButton _sendButton; private void Awake() { _messages = messageStructureGenerator.GenerateMessages(); _jokesBag = new List<TextAsset>(jokes); _lives = FindObjectOfType<Lives>(); _emojiButtonManager = FindObjectOfType<EmojiButtonManager>(); _sendButton = FindObjectOfType<SendButton>(); } private void Start() { Loading @@ -44,8 +46,10 @@ namespace Messaging { } private async void SendRandomJoke(float delay) { //TODO: Lock send button here _sendButton.Lock(); await Task.Delay((int)(delay * 1000)); _sendButton.Unlock(); _currentJoke = GetRandomJoke(); CreateMessage(_currentJoke.QuestionMessage.Key, false); _emojiButtonManager.SetButtonImages(GenerateButtonOptions()); Loading Assets/Sprites/enviarapagado.png.meta +3 −3 Original line number Diff line number Diff line Loading @@ -34,7 +34,7 @@ TextureImporter: maxTextureSize: 2048 textureSettings: serializedVersion: 2 filterMode: 1 filterMode: 0 aniso: 1 mipBias: 0 wrapU: 1 Loading @@ -48,7 +48,7 @@ TextureImporter: spriteMeshType: 1 alignment: 0 spritePivot: {x: 0.5, y: 0.5} spritePixelsToUnits: 100 spritePixelsToUnits: 16 spriteBorder: {x: 0, y: 0, z: 0, w: 0} spriteGenerateFallbackPhysicsShape: 1 alphaUsage: 1 Loading @@ -72,7 +72,7 @@ TextureImporter: maxTextureSize: 2048 resizeAlgorithm: 0 textureFormat: -1 textureCompression: 1 textureCompression: 0 compressionQuality: 50 crunchedCompression: 0 allowsAlphaSplitting: 0 Loading Loading
Assets/Scenes/Main.unity +4 −1 Original line number Diff line number Diff line Loading @@ -1987,6 +1987,9 @@ MonoBehaviour: m_Name: m_EditorClassIdentifier: inputField: {fileID: 23275626} unlockedSprite: {fileID: 6091405373536128358, guid: e70f17ed9e81410418db04270295ae3c, type: 3} lockedSprite: {fileID: 21300000, guid: d8f3c281772d8ce428ce642723fa4ef9, type: 3} button: {fileID: 1152326135} --- !u!114 &1152326134 MonoBehaviour: m_ObjectHideFlags: 0 Loading Loading @@ -2063,7 +2066,7 @@ MonoBehaviour: m_OnCullStateChanged: m_PersistentCalls: m_Calls: [] m_Sprite: {fileID: 6091405373536128358, guid: e70f17ed9e81410418db04270295ae3c, type: 3} m_Sprite: {fileID: 21300000, guid: d8f3c281772d8ce428ce642723fa4ef9, type: 3} m_Type: 0 m_PreserveAspect: 0 m_FillCenter: 1 Loading
Assets/Scripts/Messaging/Composer/SendButton.cs +18 −1 Original line number Diff line number Diff line using System; using UnityEngine; using UnityEngine.Serialization; using UnityEngine.UI; namespace Messaging.Composer { public class SendButton : MonoBehaviour { [SerializeField] private InputField inputField; [SerializeField] private Sprite unlockedSprite; [SerializeField] private Sprite lockedSprite; private bool _locked; [SerializeField] private Image button; private MessageManager _messageManager; private void Awake() { _messageManager = FindObjectOfType<MessageManager>(); } public void Lock() { _locked = true; button.sprite = lockedSprite; } public void Unlock() { _locked = false; button.sprite = unlockedSprite; } public void SendEmojis() { if (CanSendText()) { _messageManager.CreateMessage(inputField.Text, true); Loading @@ -20,7 +36,8 @@ namespace Messaging.Composer { } private bool CanSendText() { return !string.IsNullOrEmpty(inputField.Text) && !string.IsNullOrWhiteSpace(inputField.Text); bool isInputEmpty = string.IsNullOrEmpty(inputField.Text) || string.IsNullOrWhiteSpace(inputField.Text); return !isInputEmpty && !_locked; } } } No newline at end of file
Assets/Scripts/Messaging/Typer/MessageManager.cs +5 −1 Original line number Diff line number Diff line Loading @@ -31,12 +31,14 @@ namespace Messaging { private readonly Regex _emojiGetter = new("<([a-z]+)(?![^>]*\\/>)[^>]*>"); private const int NumEmojis = 35; private EmojiButtonManager _emojiButtonManager; private SendButton _sendButton; private void Awake() { _messages = messageStructureGenerator.GenerateMessages(); _jokesBag = new List<TextAsset>(jokes); _lives = FindObjectOfType<Lives>(); _emojiButtonManager = FindObjectOfType<EmojiButtonManager>(); _sendButton = FindObjectOfType<SendButton>(); } private void Start() { Loading @@ -44,8 +46,10 @@ namespace Messaging { } private async void SendRandomJoke(float delay) { //TODO: Lock send button here _sendButton.Lock(); await Task.Delay((int)(delay * 1000)); _sendButton.Unlock(); _currentJoke = GetRandomJoke(); CreateMessage(_currentJoke.QuestionMessage.Key, false); _emojiButtonManager.SetButtonImages(GenerateButtonOptions()); Loading
Assets/Sprites/enviarapagado.png.meta +3 −3 Original line number Diff line number Diff line Loading @@ -34,7 +34,7 @@ TextureImporter: maxTextureSize: 2048 textureSettings: serializedVersion: 2 filterMode: 1 filterMode: 0 aniso: 1 mipBias: 0 wrapU: 1 Loading @@ -48,7 +48,7 @@ TextureImporter: spriteMeshType: 1 alignment: 0 spritePivot: {x: 0.5, y: 0.5} spritePixelsToUnits: 100 spritePixelsToUnits: 16 spriteBorder: {x: 0, y: 0, z: 0, w: 0} spriteGenerateFallbackPhysicsShape: 1 alphaUsage: 1 Loading @@ -72,7 +72,7 @@ TextureImporter: maxTextureSize: 2048 resizeAlgorithm: 0 textureFormat: -1 textureCompression: 1 textureCompression: 0 compressionQuality: 50 crunchedCompression: 0 allowsAlphaSplitting: 0 Loading