mirror of
https://github.com/GTA-ASM/SanAndreasUnity
synced 2025-02-20 14:58:29 +00:00
extract ChatInputDisplay class
This commit is contained in:
parent
3c9168e295
commit
ad2b733e2a
3 changed files with 52 additions and 15 deletions
Assets/Scripts/UI
39
Assets/Scripts/UI/ChatInputDisplay.cs
Normal file
39
Assets/Scripts/UI/ChatInputDisplay.cs
Normal file
|
@ -0,0 +1,39 @@
|
|||
using UnityEngine;
|
||||
using SanAndreasUnity.Utilities;
|
||||
|
||||
namespace SanAndreasUnity.UI
|
||||
{
|
||||
|
||||
public class ChatInputDisplay : MonoBehaviour
|
||||
{
|
||||
string m_chatText = "";
|
||||
|
||||
|
||||
|
||||
void Start()
|
||||
{
|
||||
PauseMenu.onGUI += this.OnPauseMenuGUI;
|
||||
}
|
||||
|
||||
void OnPauseMenuGUI()
|
||||
{
|
||||
|
||||
string buttonText = "Send";
|
||||
Vector2 buttonSize = GUIUtils.CalcScreenSizeForText(buttonText, GUI.skin.button);
|
||||
Rect rect = GUIUtils.GetCornerRect(ScreenCorner.BottomRight, buttonSize, new Vector2(40, 40));
|
||||
if (GUI.Button(rect, buttonText))
|
||||
{
|
||||
Chat.ChatManager.SendChatMessageToAllPlayersAsLocalPlayer(m_chatText);
|
||||
m_chatText = "";
|
||||
}
|
||||
|
||||
float textInputWidth = 200;
|
||||
rect.xMin -= textInputWidth;
|
||||
rect.xMax -= buttonSize.x + 15;
|
||||
m_chatText = GUI.TextField(rect, m_chatText, 100);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
11
Assets/Scripts/UI/ChatInputDisplay.cs.meta
Normal file
11
Assets/Scripts/UI/ChatInputDisplay.cs.meta
Normal file
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: ae6511ace97a7db4381c0ce08b9ed6da
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -31,7 +31,7 @@ namespace SanAndreasUnity.UI {
|
|||
|
||||
public Color openedWindowTextColor = Color.green;
|
||||
|
||||
string m_chatText = "";
|
||||
public static event System.Action onGUI = delegate {};
|
||||
|
||||
|
||||
|
||||
|
@ -144,21 +144,8 @@ namespace SanAndreasUnity.UI {
|
|||
|
||||
GUI.EndGroup ();
|
||||
|
||||
// chat input
|
||||
|
||||
string buttonText = "Send";
|
||||
Vector2 buttonSize = GUIUtils.CalcScreenSizeForText(buttonText, GUI.skin.button);
|
||||
Rect rect = GUIUtils.GetCornerRect(ScreenCorner.BottomRight, buttonSize, new Vector2(40, 40));
|
||||
if (GUI.Button(rect, buttonText))
|
||||
{
|
||||
Chat.ChatManager.SendChatMessageToAllPlayersAsLocalPlayer(m_chatText);
|
||||
m_chatText = "";
|
||||
}
|
||||
|
||||
float textInputWidth = 200;
|
||||
rect.xMin -= textInputWidth;
|
||||
rect.xMax -= buttonSize.x + 15;
|
||||
m_chatText = GUI.TextField(rect, m_chatText, 100);
|
||||
onGUI();
|
||||
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue