Комментарии:
send message has no receiver help
ОтветитьIf Input Field doesn't work, make sure that the SCENE has EventSystem (an Empty Object with Event System and Standalone Player Movement)
ОтветитьHow to save chat history? For all new players.
ОтветитьAnyone have advice for how to do this and not have the UI elements be a component of the player prefab?
The issue I'm having when I have the UI outside the player prefab is I start running into client/server authority issues. OnStartAuthority() never gets called--I believe because the player does not "own" the UI elements. Then the [Client], [Command], and [ClientRpc] tags generate all manner of horrible errors. "InvalidProgramException: Invalid IL code in ChatBehavior:Send (string): IL_000f: call 0x0a0001ee"
code
ОтветитьCan we use this script to implement chat system on client server method ?
ОтветитьMy inputfield is not interectable for some reason
Ответитьhow to spawn different prefabs over network?
Ответитьhow do we add names from later episodes?
ОтветитьBad Please Coding With PHP
ОтветитьI understand the idea of using a string but why not just use a list. You can easily run a loop to populate the screen with each string and its more organized.
ОтветитьI'm also confused how do you determine which port Mirror uses?
ОтветитьSo nothing works that you posted in the video. I really recommend you type code as you go instead of prebuilding code. Really creates a lot of confusion
ОтветитьWould it be possible to instead use a SyncList storing the chat messages instead of Rpc? Is there a reason why you are not doing it that way?
ОтветитьHi, I was following along but it wont let me click to type in the chat box
ОтветитьWhen I try to press on the Input Chat it doesn't work. Please help.
ОтветитьMy chat isn't working because my input isn't being stored. It will only work when I take the nullorwhitespace filter off. What am I doing wrong?
Ответитьyour code does not work!!!!!!!!!!!!!!!!!!!!!
ОтветитьI was able to get this to work with the following changes:
1. Add the following includes to ChatBehavior.cs:
"using System;
using TMPro;
using Mirror;"
2. Create an EventSystem in the scene. Right click in the hierarchy, then UI -> EventSystem
3. In the Send function, replace "message" with "inputField.text" in the following lines:
"if (string.IsNullOrWhiteSpace(message)) { return; }"
"CmdSendMessage(message);"
Will this chat have issues with code injection?
Ответить"Trying to send command for object without authority. ChatBehaviour.CmdSendMessage" - I can't send messages as the host?
ОтветитьFor Input Field chat and pressing enter
The issue you may run into is "nothing happens". That is because the parameter "message" is empty.
Under "On End Edit", there are TWO "Send" message.
Set yours to the Send under Dynamic string
subbed and liked thx man for the script i looked for script to download and i find what i was looking for
ОтветитьWhen I try to follow along with this my Send never gets hit and the error shows up: InvalidProgramException: Invalid IL code in ChatBehavior:SendChat (): IL_000f: call 0x0a000042. If I take the [Client] decorator off of my Send function it doesn't throw that error, but instead throws: Trying to send command for object without authority in my Command method. Anyone get this and figure it out?
ОтветитьPlease write the script as you go, you did this in the first two videos. I know, I write tutorials too, it's so much easier to show it after, but in the end it just makes it feel more like copying than actually following the steps on how to do something.
ОтветитьHello! Can you please tell me if you can change the standard Lana buttons to your own buttons to your liking? It seems to me that this is impossible !?
Ответитьvery cool!
ОтветитьWhat about voice chat
ОтветитьThis may be a dumb question or whatever but is there a difference between these:
if(!Input.GetKeyDown(KeyCode.Return)) { return; }
if(!Input.GetKeyDown(KeyCode.Return)) return;
Nothing that you just wrote here, worked... sorry to say, and i copypasta everything...
ОтветитьThis was alot of help for my voice hangout game
ОтветитьThe Input field isn't working
ОтветитьHave no word ahah really fast and great tutorial ! Have you a solution to use Enter and not the Mouse to open chat and send the text ? <3
Ответитьi setup it on with steam so now the chta shows there steam name as there chat name
ОтветитьITS WORKING!!! THAANKS!!!
Ответитьdidnt work fucked me up
Ответитьand in a online game? how make?
Ответитьhey, every time i click on the input field it doesnt work? help please
ОтветитьYou actually may have filtering on both client or server. Server may have banned words such as can't say N word even if you have profanity off or it gives a warning and to the client and prevents the message from being sent to other clients. Where a client filter would have a filter for normal curse words.
Ответитьwhat does static do in that action? it feels weird to me like if all clients had that static action, wown't invoking a static action on one client, invoke the other ones too because the static action is the same???? huh
[EDIT : cleared up my misunderstanding]
Static variables are only shared between classes on the same client. This means that across clients, you're not gonna have the same values.
Can you please tell us how to make it show usernames instead of numbers?
Ответитьvery good. thank you
ОтветитьIf you're using the new input system and having trouble with checking if OnEndEdit was from pressing Enter or clicking off:
The TMP_InputField has an event called onSubmit that is exactly what you're looking for, it pass the text string when Enter is pressed only
You can't serialize it from the Inspector but with a reference to the inputfield you can easily access it and write something like "inputField.onSubmit.AddListener(Send);" and "inputField.onSubmit.RemoveListener(Send);" to subscribe and unsubscribe
congratulations for the previous videos, I just wanted to point out that unfortunately in this video I can't figure out which objects are the ones already created in the video, "input chat" I don't know what's inside as a child object, and "text chat".
ОтветитьCode:
using Mirror;
using UnityEngine;
using System;
using TMPro;
using Unity.VisualScripting;
public class Chat : NetworkBehaviour
{
[SerializeField] private GameObject chatUI = null;
[SerializeField] private TMP_Text chatText = null;
[SerializeField] private TMP_InputField inputField = null;
private static event Action<string> onMessage;
public override void OnStartAuthority()
{
chatUI.SetActive(true);
onMessage += HandleNewMessage;
}
[ClientCallback]
private void OnDestroy()
{
if (!hasAuthority) { return; }
onMessage -= HandleNewMessage;
}
private void HandleNewMessage(String messsage)
{
chatText.text += messsage;
}
[Client]
public void Send(String message)
{
if (!Input.GetKeyDown(KeyCode.Return)) { return; }
if (string.IsNullOrWhiteSpace(message)) { return; }
CmdSendMessage(inputField.text);
inputField.text = String.Empty;
}
[Command]
private void CmdSendMessage(String message)
{
RpcHandleMessage($"[{connectionToClient.connectionId}]: {message}");
}
[ClientRpc]
private void RpcHandleMessage(String message)
{
onMessage?.Invoke($"\n{message}");
}
}
How to make multiplayer search bar to find people to add as friend in unity
ОтветитьHey, is it possible to also add custom emojis in the chat, and also when a user writes a message, its puts a message bubble over the player’s face kinda like in roblox. If u can make a tutorial for that that would be great. Thanks for the tutorial
Ответить