Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

unity chat system

void TaskOnClick()
    {
        // When the user clicks the Submit button,
        // create a JSON object from input field input
        JSONInformation publishMessage = new JSONInformation();
        publishMessage.username = string.Concat(UsernameInput.text, ": ");
        publishMessage.text = TextInput.text;
        string publishMessageToJSON = JsonUtility.ToJson(publishMessage);

        // Publish the JSON object to the assigned PubNub Channel
        pubnub.Publish()
            .Channel("chatchannel")
            .Message(publishMessageToJSON)
            .Async((result, status) =>
            {
                if (status.Error)
                {
                    Debug.Log(status.Error);
                    Debug.Log(status.ErrorData.Info);
                }
                else
                {
                    Debug.Log(string.Format(result.Timetoken));
                }
            });

        // Reset the text field to be blank
        TextInput.text = "";
    }
Comment

PREVIOUS NEXT
Code Example
Csharp :: int to ascii c# 
Csharp :: C# .net core convert string to enum 
Csharp :: list of string to string c# 
Csharp :: c# get last item in list 
Csharp :: unity create gameobject 
Csharp :: how to convert string to int in c# 
Csharp :: unity default cube mesh 
Csharp :: if unity 
Csharp :: base64 decode how used in c# 
Csharp :: make window not resizable wpf 
Csharp :: how to add ground Check in unity 3d 
Csharp :: key value pair in c# 
Csharp :: decalre an int list mvc 
Csharp :: increase timeout in .net core web app 
Csharp :: find-text-in-string-with-c-sharp 
Csharp :: c# if statement one line 
Csharp :: c# list subfolders 
Csharp :: how to get the hour on c# 
Csharp :: c# web api return image file 
Csharp :: how delete multiple row from relation in laravel 
Csharp :: yanderedev 
Csharp :: switch case c# 
Csharp :: unity rotate direction by angle 
Csharp :: how to look for substring in string in c# 
Csharp :: change dot net core web api routing 
Csharp :: getcomponent unity 
Csharp :: c# for loop next iteration 
Csharp :: c# input 
Csharp :: dotnet new api 
Csharp :: count number of properties on an object C# 
ADD CONTENT
Topic
Content
Source link
Name
3+5 =