server geaddet

This commit is contained in:
kingjuulian06
2023-11-19 22:34:42 +01:00
parent 7bde443b18
commit 94db24346a
989 changed files with 413157 additions and 250 deletions
@@ -0,0 +1,33 @@
// --------------------------------------------------------------------------------------------------------------------
// <copyright company="Exit Games GmbH"/>
// <summary>Demo code for Photon Chat in Unity.</summary>
// <author>developer@exitgames.com</author>
// --------------------------------------------------------------------------------------------------------------------
using Photon.Realtime;
namespace Photon.Chat.Demo
{
public static class AppSettingsExtensions
{
public static ChatAppSettings GetChatSettings(this AppSettings appSettings)
{
return new ChatAppSettings
{
AppIdChat = appSettings.AppIdChat,
AppVersion = appSettings.AppVersion,
FixedRegion = appSettings.IsBestRegion ? null : appSettings.FixedRegion,
NetworkLogging = appSettings.NetworkLogging,
Protocol = appSettings.Protocol,
EnableProtocolFallback = appSettings.EnableProtocolFallback,
Server = appSettings.IsDefaultNameServer ? null : appSettings.Server,
Port = (ushort)appSettings.Port,
ProxyServer = appSettings.ProxyServer
// values not copied from AppSettings class: AuthMode
// values not needed from AppSettings class: EnableLobbyStatistics
};
}
}
}
@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: 4fcf4818ecc9abf4e9b7e0c37af9b851
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 119922
packageName: PUN 2 - FREE
packageVersion: 2.43
assetPath: Assets/Photon/PhotonChat/Demos/DemoChat/AppSettingsExtensions.cs
uploadId: 609016
@@ -0,0 +1,32 @@
// --------------------------------------------------------------------------------------------------------------------
// <copyright company="Exit Games GmbH"/>
// <summary>Demo code for Photon Chat in Unity.</summary>
// <author>developer@exitgames.com</author>
// --------------------------------------------------------------------------------------------------------------------
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.UI;
namespace Photon.Chat.Demo
{
public class ChannelSelector : MonoBehaviour, IPointerClickHandler
{
public string Channel;
public void SetChannel(string channel)
{
this.Channel = channel;
Text t = this.GetComponentInChildren<Text>();
t.text = this.Channel;
}
public void OnPointerClick(PointerEventData eventData)
{
ChatGui handler = FindObjectOfType<ChatGui>();
handler.ShowChannel(this.Channel);
}
}
}
@@ -0,0 +1,17 @@
fileFormatVersion: 2
guid: 48caa72710147fc4f9389b0b5ec6137d
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 119922
packageName: PUN 2 - FREE
packageVersion: 2.43
assetPath: Assets/Photon/PhotonChat/Demos/DemoChat/ChannelSelector.cs
uploadId: 609016
@@ -0,0 +1,60 @@
// --------------------------------------------------------------------------------------------------------------------
// <copyright company="Exit Games GmbH"/>
// <summary>Demo code for Photon Chat in Unity.</summary>
// <author>developer@exitgames.com</author>
// --------------------------------------------------------------------------------------------------------------------
using UnityEngine;
using UnityEngine.UI;
#if PHOTON_UNITY_NETWORKING
using Photon.Pun;
#endif
namespace Photon.Chat.Demo
{
/// <summary>
/// This is used in the Editor Splash to properly inform the developer about the chat AppId requirement.
/// </summary>
[ExecuteInEditMode]
public class ChatAppIdCheckerUI : MonoBehaviour
{
public Text Description;
public bool WizardOpenedOnce; // avoid opening the wizard again and again
// TODO: maybe this can run on Start(), not on Update()?!
public void Update()
{
bool showWarning = false;
string descriptionText = string.Empty;
#if PHOTON_UNITY_NETWORKING
showWarning = string.IsNullOrEmpty(PhotonNetwork.PhotonServerSettings.AppSettings.AppIdChat);
if (showWarning)
{
descriptionText = "<Color=Red>WARNING:</Color>\nPlease setup a Chat AppId in the PhotonServerSettings file.";
}
#else
ChatGui cGui = FindObjectOfType<ChatGui>(); // TODO: this could be a serialized reference instead of finding this each time
showWarning = cGui == null || string.IsNullOrEmpty(cGui.chatAppSettings.AppIdChat);
if (showWarning)
{
descriptionText = "<Color=Red>Please setup the Chat AppId.\nOpen the setup panel: Window, Photon Chat, Setup.</Color>";
#if UNITY_EDITOR
if (!WizardOpenedOnce)
{
WizardOpenedOnce = true;
UnityEditor.EditorApplication.ExecuteMenuItem("Window/Photon Chat/Setup");
}
#endif
}
#endif
this.Description.text = descriptionText;
}
}
}
@@ -0,0 +1,17 @@
fileFormatVersion: 2
guid: 4eb1284704a754507acb17b07b888086
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 119922
packageName: PUN 2 - FREE
packageVersion: 2.43
assetPath: Assets/Photon/PhotonChat/Demos/DemoChat/ChatAppIdCheckerUI.cs
uploadId: 609016
@@ -0,0 +1,665 @@
// --------------------------------------------------------------------------------------------------------------------
// <copyright company="Exit Games GmbH"/>
// <summary>Demo code for Photon Chat in Unity.</summary>
// <author>developer@exitgames.com</author>
// --------------------------------------------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using Photon.Chat;
using Photon.Realtime;
using AuthenticationValues = Photon.Chat.AuthenticationValues;
#if PHOTON_UNITY_NETWORKING
using Photon.Pun;
#endif
namespace Photon.Chat.Demo
{
/// <summary>
/// This simple Chat UI demonstrate basics usages of the Chat Api
/// </summary>
/// <remarks>
/// The ChatClient basically lets you create any number of channels.
///
/// some friends are already set in the Chat demo "DemoChat-Scene", 'Joe', 'Jane' and 'Bob', simply log with them so that you can see the status changes in the Interface
///
/// Workflow:
/// Create ChatClient, Connect to a server with your AppID, Authenticate the user (apply a unique name,)
/// and subscribe to some channels.
/// Subscribe a channel before you publish to that channel!
///
///
/// Note:
/// Don't forget to call ChatClient.Service() on Update to keep the Chatclient operational.
/// </remarks>
public class ChatGui : MonoBehaviour, IChatClientListener
{
public string[] ChannelsToJoinOnConnect; // set in inspector. Demo channels to join automatically.
public string[] FriendsList;
public int HistoryLengthToFetch; // set in inspector. Up to a certain degree, previously sent messages can be fetched for context
public string UserName { get; set; }
private string selectedChannelName; // mainly used for GUI/input
public ChatClient chatClient;
#if !PHOTON_UNITY_NETWORKING
public ChatAppSettings ChatAppSettings
{
get { return this.chatAppSettings; }
}
[SerializeField]
#endif
protected internal ChatAppSettings chatAppSettings;
public GameObject missingAppIdErrorPanel;
public GameObject ConnectingLabel;
public RectTransform ChatPanel; // set in inspector (to enable/disable panel)
public GameObject UserIdFormPanel;
public InputField InputFieldChat; // set in inspector
public Text CurrentChannelText; // set in inspector
public Toggle ChannelToggleToInstantiate; // set in inspector
public GameObject FriendListUiItemtoInstantiate;
private readonly Dictionary<string, Toggle> channelToggles = new Dictionary<string, Toggle>();
private readonly Dictionary<string,FriendItem> friendListItemLUT = new Dictionary<string, FriendItem>();
public bool ShowState = true;
public GameObject Title;
public Text StateText; // set in inspector
public Text UserIdText; // set in inspector
// private static string WelcomeText = "Welcome to chat. Type \\help to list commands.";
private static string HelpText = "\n -- HELP --\n" +
"To subscribe to channel(s) (channelnames are case sensitive) : \n" +
"\t<color=#E07B00>\\subscribe</color> <color=green><list of channelnames></color>\n" +
"\tor\n" +
"\t<color=#E07B00>\\s</color> <color=green><list of channelnames></color>\n" +
"\n" +
"To leave channel(s):\n" +
"\t<color=#E07B00>\\unsubscribe</color> <color=green><list of channelnames></color>\n" +
"\tor\n" +
"\t<color=#E07B00>\\u</color> <color=green><list of channelnames></color>\n" +
"\n" +
"To switch the active channel\n" +
"\t<color=#E07B00>\\join</color> <color=green><channelname></color>\n" +
"\tor\n" +
"\t<color=#E07B00>\\j</color> <color=green><channelname></color>\n" +
"\n" +
"To send a private message: (username are case sensitive)\n" +
"\t\\<color=#E07B00>msg</color> <color=green><username></color> <color=green><message></color>\n" +
"\n" +
"To change status:\n" +
"\t\\<color=#E07B00>state</color> <color=green><stateIndex></color> <color=green><message></color>\n" +
"<color=green>0</color> = Offline " +
"<color=green>1</color> = Invisible " +
"<color=green>2</color> = Online " +
"<color=green>3</color> = Away \n" +
"<color=green>4</color> = Do not disturb " +
"<color=green>5</color> = Looking For Group " +
"<color=green>6</color> = Playing" +
"\n\n" +
"To clear the current chat tab (private chats get closed):\n" +
"\t<color=#E07B00>\\clear</color>";
public void Start()
{
DontDestroyOnLoad(this.gameObject);
this.UserIdText.text = "";
this.StateText.text = "";
this.StateText.gameObject.SetActive(true);
this.UserIdText.gameObject.SetActive(true);
this.Title.SetActive(true);
this.ChatPanel.gameObject.SetActive(false);
this.ConnectingLabel.SetActive(false);
if (string.IsNullOrEmpty(this.UserName))
{
this.UserName = "user" + Environment.TickCount%99; //made-up username
}
#if PHOTON_UNITY_NETWORKING
this.chatAppSettings = PhotonNetwork.PhotonServerSettings.AppSettings.GetChatSettings();
#endif
bool appIdPresent = !string.IsNullOrEmpty(this.chatAppSettings.AppIdChat);
this.missingAppIdErrorPanel.SetActive(!appIdPresent);
this.UserIdFormPanel.gameObject.SetActive(appIdPresent);
if (!appIdPresent)
{
Debug.LogError("You need to set the chat app ID in the PhotonServerSettings file in order to continue.");
}
}
public void Connect()
{
this.UserIdFormPanel.gameObject.SetActive(false);
this.chatClient = new ChatClient(this);
#if !UNITY_WEBGL
this.chatClient.UseBackgroundWorkerForSending = true;
#endif
this.chatClient.AuthValues = new AuthenticationValues(this.UserName);
this.chatClient.ConnectUsingSettings(this.chatAppSettings);
this.ChannelToggleToInstantiate.gameObject.SetActive(false);
Debug.Log("Connecting as: " + this.UserName);
this.ConnectingLabel.SetActive(true);
}
/// <summary>To avoid that the Editor becomes unresponsive, disconnect all Photon connections in OnDestroy.</summary>
public void OnDestroy()
{
if (this.chatClient != null)
{
this.chatClient.Disconnect();
}
}
/// <summary>To avoid that the Editor becomes unresponsive, disconnect all Photon connections in OnApplicationQuit.</summary>
public void OnApplicationQuit()
{
if (this.chatClient != null)
{
this.chatClient.Disconnect();
}
}
public void Update()
{
if (this.chatClient != null)
{
this.chatClient.Service(); // make sure to call this regularly! it limits effort internally, so calling often is ok!
}
// check if we are missing context, which means we got kicked out to get back to the Photon Demo hub.
if ( this.StateText == null)
{
Destroy(this.gameObject);
return;
}
this.StateText.gameObject.SetActive(this.ShowState); // this could be handled more elegantly, but for the demo it's ok.
}
public void OnEnterSend()
{
if (Input.GetKey(KeyCode.Return) || Input.GetKey(KeyCode.KeypadEnter))
{
this.SendChatMessage(this.InputFieldChat.text);
this.InputFieldChat.text = "";
}
}
public void OnClickSend()
{
if (this.InputFieldChat != null)
{
this.SendChatMessage(this.InputFieldChat.text);
this.InputFieldChat.text = "";
}
}
public int TestLength = 2048;
private byte[] testBytes = new byte[2048];
private void SendChatMessage(string inputLine)
{
if (string.IsNullOrEmpty(inputLine))
{
return;
}
if ("test".Equals(inputLine))
{
if (this.TestLength != this.testBytes.Length)
{
this.testBytes = new byte[this.TestLength];
}
this.chatClient.SendPrivateMessage(this.chatClient.AuthValues.UserId, this.testBytes, true);
}
bool doingPrivateChat = this.chatClient.PrivateChannels.ContainsKey(this.selectedChannelName);
string privateChatTarget = string.Empty;
if (doingPrivateChat)
{
// the channel name for a private conversation is (on the client!!) always composed of both user's IDs: "this:remote"
// so the remote ID is simple to figure out
string[] splitNames = this.selectedChannelName.Split(new char[] { ':' });
privateChatTarget = splitNames[1];
}
//UnityEngine.Debug.Log("selectedChannelName: " + selectedChannelName + " doingPrivateChat: " + doingPrivateChat + " privateChatTarget: " + privateChatTarget);
if (inputLine[0].Equals('\\'))
{
string[] tokens = inputLine.Split(new char[] {' '}, 2);
if (tokens[0].Equals("\\help"))
{
this.PostHelpToCurrentChannel();
}
if (tokens[0].Equals("\\state"))
{
int newState = 0;
List<string> messages = new List<string>();
messages.Add ("i am state " + newState);
string[] subtokens = tokens[1].Split(new char[] {' ', ','});
if (subtokens.Length > 0)
{
newState = int.Parse(subtokens[0]);
}
if (subtokens.Length > 1)
{
messages.Add(subtokens[1]);
}
this.chatClient.SetOnlineStatus(newState,messages.ToArray()); // this is how you set your own state and (any) message
}
else if ((tokens[0].Equals("\\subscribe") || tokens[0].Equals("\\s")) && !string.IsNullOrEmpty(tokens[1]))
{
this.chatClient.Subscribe(tokens[1].Split(new char[] {' ', ','}));
}
else if ((tokens[0].Equals("\\unsubscribe") || tokens[0].Equals("\\u")) && !string.IsNullOrEmpty(tokens[1]))
{
this.chatClient.Unsubscribe(tokens[1].Split(new char[] {' ', ','}));
}
else if (tokens[0].Equals("\\clear"))
{
if (doingPrivateChat)
{
this.chatClient.PrivateChannels.Remove(this.selectedChannelName);
}
else
{
ChatChannel channel;
if (this.chatClient.TryGetChannel(this.selectedChannelName, doingPrivateChat, out channel))
{
channel.ClearMessages();
}
}
}
else if (tokens[0].Equals("\\msg") && !string.IsNullOrEmpty(tokens[1]))
{
string[] subtokens = tokens[1].Split(new char[] {' ', ','}, 2);
if (subtokens.Length < 2) return;
string targetUser = subtokens[0];
string message = subtokens[1];
this.chatClient.SendPrivateMessage(targetUser, message);
}
else if ((tokens[0].Equals("\\join") || tokens[0].Equals("\\j")) && !string.IsNullOrEmpty(tokens[1]))
{
string[] subtokens = tokens[1].Split(new char[] { ' ', ',' }, 2);
// If we are already subscribed to the channel we directly switch to it, otherwise we subscribe to it first and then switch to it implicitly
if (this.channelToggles.ContainsKey(subtokens[0]))
{
this.ShowChannel(subtokens[0]);
}
else
{
this.chatClient.Subscribe(new string[] { subtokens[0] });
}
}
#if CHAT_EXTENDED
else if ((tokens[0].Equals("\\nickname") || tokens[0].Equals("\\nick") ||tokens[0].Equals("\\n")) && !string.IsNullOrEmpty(tokens[1]))
{
if (!doingPrivateChat)
{
this.chatClient.SetCustomUserProperties(this.selectedChannelName, this.chatClient.UserId, new Dictionary<string, object> {{"Nickname", tokens[1]}});
}
}
#endif
else
{
Debug.Log("The command '" + tokens[0] + "' is invalid.");
}
}
else
{
if (doingPrivateChat)
{
this.chatClient.SendPrivateMessage(privateChatTarget, inputLine);
}
else
{
this.chatClient.PublishMessage(this.selectedChannelName, inputLine);
}
}
}
public void PostHelpToCurrentChannel()
{
this.CurrentChannelText.text += HelpText;
}
public void DebugReturn(ExitGames.Client.Photon.DebugLevel level, string message)
{
if (level == ExitGames.Client.Photon.DebugLevel.ERROR)
{
Debug.LogError(message);
}
else if (level == ExitGames.Client.Photon.DebugLevel.WARNING)
{
Debug.LogWarning(message);
}
else
{
Debug.Log(message);
}
}
public void OnConnected()
{
if (this.ChannelsToJoinOnConnect != null && this.ChannelsToJoinOnConnect.Length > 0)
{
this.chatClient.Subscribe(this.ChannelsToJoinOnConnect, this.HistoryLengthToFetch);
}
this.ConnectingLabel.SetActive(false);
this.UserIdText.text = "Connected as "+ this.UserName;
this.ChatPanel.gameObject.SetActive(true);
if (this.FriendsList!=null && this.FriendsList.Length>0)
{
this.chatClient.AddFriends(this.FriendsList); // Add some users to the server-list to get their status updates
// add to the UI as well
foreach(string _friend in this.FriendsList)
{
if (this.FriendListUiItemtoInstantiate != null && _friend!= this.UserName)
{
this.InstantiateFriendButton(_friend);
}
}
}
if (this.FriendListUiItemtoInstantiate != null)
{
this.FriendListUiItemtoInstantiate.SetActive(false);
}
this.chatClient.SetOnlineStatus(ChatUserStatus.Online); // You can set your online state (without a mesage).
}
public void OnDisconnected()
{
Debug.Log("OnDisconnected()");
this.ConnectingLabel.SetActive(false);
}
public void OnChatStateChange(ChatState state)
{
// use OnConnected() and OnDisconnected()
// this method might become more useful in the future, when more complex states are being used.
this.StateText.text = state.ToString();
}
public void OnSubscribed(string[] channels, bool[] results)
{
// in this demo, we simply send a message into each channel. This is NOT a must have!
foreach (string channel in channels)
{
this.chatClient.PublishMessage(channel, "says 'hi'."); // you don't HAVE to send a msg on join but you could.
if (this.ChannelToggleToInstantiate != null)
{
this.InstantiateChannelButton(channel);
}
}
Debug.Log("OnSubscribed: " + string.Join(", ", channels));
/*
// select first subscribed channel in alphabetical order
if (this.chatClient.PublicChannels.Count > 0)
{
var l = new List<string>(this.chatClient.PublicChannels.Keys);
l.Sort();
string selected = l[0];
if (this.channelToggles.ContainsKey(selected))
{
ShowChannel(selected);
foreach (var c in this.channelToggles)
{
c.Value.isOn = false;
}
this.channelToggles[selected].isOn = true;
AddMessageToSelectedChannel(WelcomeText);
}
}
*/
// Switch to the first newly created channel
this.ShowChannel(channels[0]);
}
/// <inheritdoc />
public void OnSubscribed(string channel, string[] users, Dictionary<object, object> properties)
{
Debug.LogFormat("OnSubscribed: {0}, users.Count: {1} Channel-props: {2}.", channel, users.Length, properties.ToStringFull());
}
private void InstantiateChannelButton(string channelName)
{
if (this.channelToggles.ContainsKey(channelName))
{
Debug.Log("Skipping creation for an existing channel toggle.");
return;
}
Toggle cbtn = (Toggle)Instantiate(this.ChannelToggleToInstantiate);
cbtn.gameObject.SetActive(true);
cbtn.GetComponentInChildren<ChannelSelector>().SetChannel(channelName);
cbtn.transform.SetParent(this.ChannelToggleToInstantiate.transform.parent, false);
this.channelToggles.Add(channelName, cbtn);
}
private void InstantiateFriendButton(string friendId)
{
GameObject fbtn = (GameObject)Instantiate(this.FriendListUiItemtoInstantiate);
fbtn.gameObject.SetActive(true);
FriendItem _friendItem = fbtn.GetComponent<FriendItem>();
_friendItem.FriendId = friendId;
fbtn.transform.SetParent(this.FriendListUiItemtoInstantiate.transform.parent, false);
this.friendListItemLUT[friendId] = _friendItem;
}
public void OnUnsubscribed(string[] channels)
{
foreach (string channelName in channels)
{
if (this.channelToggles.ContainsKey(channelName))
{
Toggle t = this.channelToggles[channelName];
Destroy(t.gameObject);
this.channelToggles.Remove(channelName);
Debug.Log("Unsubscribed from channel '" + channelName + "'.");
// Showing another channel if the active channel is the one we unsubscribed from before
if (channelName == this.selectedChannelName && this.channelToggles.Count > 0)
{
IEnumerator<KeyValuePair<string, Toggle>> firstEntry = this.channelToggles.GetEnumerator();
firstEntry.MoveNext();
this.ShowChannel(firstEntry.Current.Key);
firstEntry.Current.Value.isOn = true;
}
}
else
{
Debug.Log("Can't unsubscribe from channel '" + channelName + "' because you are currently not subscribed to it.");
}
}
}
public void OnGetMessages(string channelName, string[] senders, object[] messages)
{
if (channelName.Equals(this.selectedChannelName))
{
// update text
this.ShowChannel(this.selectedChannelName);
}
}
public void OnPrivateMessage(string sender, object message, string channelName)
{
// as the ChatClient is buffering the messages for you, this GUI doesn't need to do anything here
// you also get messages that you sent yourself. in that case, the channelName is determinded by the target of your msg
this.InstantiateChannelButton(channelName);
byte[] msgBytes = message as byte[];
if (msgBytes != null)
{
Debug.Log("Message with byte[].Length: "+ msgBytes.Length);
}
if (this.selectedChannelName.Equals(channelName))
{
this.ShowChannel(channelName);
}
}
/// <summary>
/// New status of another user (you get updates for users set in your friends list).
/// </summary>
/// <param name="user">Name of the user.</param>
/// <param name="status">New status of that user.</param>
/// <param name="gotMessage">True if the status contains a message you should cache locally. False: This status update does not include a
/// message (keep any you have).</param>
/// <param name="message">Message that user set.</param>
public void OnStatusUpdate(string user, int status, bool gotMessage, object message)
{
Debug.LogWarning("status: " + string.Format("{0} is {1}. Msg:{2}", user, status, message));
if (this.friendListItemLUT.ContainsKey(user))
{
FriendItem _friendItem = this.friendListItemLUT[user];
if ( _friendItem!=null) _friendItem.OnFriendStatusUpdate(status,gotMessage,message);
}
}
public void OnUserSubscribed(string channel, string user)
{
Debug.LogFormat("OnUserSubscribed: channel=\"{0}\" userId=\"{1}\"", channel, user);
}
public void OnUserUnsubscribed(string channel, string user)
{
Debug.LogFormat("OnUserUnsubscribed: channel=\"{0}\" userId=\"{1}\"", channel, user);
}
/// <inheritdoc />
public void OnChannelPropertiesChanged(string channel, string userId, Dictionary<object, object> properties)
{
Debug.LogFormat("OnChannelPropertiesChanged: {0} by {1}. Props: {2}.", channel, userId, Extensions.ToStringFull(properties));
}
public void OnUserPropertiesChanged(string channel, string targetUserId, string senderUserId, Dictionary<object, object> properties)
{
Debug.LogFormat("OnUserPropertiesChanged: (channel:{0} user:{1}) by {2}. Props: {3}.", channel, targetUserId, senderUserId, Extensions.ToStringFull(properties));
}
/// <inheritdoc />
public void OnErrorInfo(string channel, string error, object data)
{
Debug.LogFormat("OnErrorInfo for channel {0}. Error: {1} Data: {2}", channel, error, data);
}
public void AddMessageToSelectedChannel(string msg)
{
ChatChannel channel = null;
bool found = this.chatClient.TryGetChannel(this.selectedChannelName, out channel);
if (!found)
{
Debug.Log("AddMessageToSelectedChannel failed to find channel: " + this.selectedChannelName);
return;
}
if (channel != null)
{
channel.Add("Bot", msg,0); //TODO: how to use msgID?
}
}
public void ShowChannel(string channelName)
{
if (string.IsNullOrEmpty(channelName))
{
return;
}
ChatChannel channel = null;
bool found = this.chatClient.TryGetChannel(channelName, out channel);
if (!found)
{
Debug.Log("ShowChannel failed to find channel: " + channelName);
return;
}
this.selectedChannelName = channelName;
this.CurrentChannelText.text = channel.ToStringMessages();
Debug.Log("ShowChannel: " + this.selectedChannelName);
foreach (KeyValuePair<string, Toggle> pair in this.channelToggles)
{
pair.Value.isOn = pair.Key == channelName ? true : false;
}
}
public void OpenDashboard()
{
Application.OpenURL("https://dashboard.photonengine.com");
}
}
}
@@ -0,0 +1,17 @@
fileFormatVersion: 2
guid: 02d148d0890b2d44dbdf7f1c1b39a499
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 119922
packageName: PUN 2 - FREE
packageVersion: 2.43
assetPath: Assets/Photon/PhotonChat/Demos/DemoChat/ChatGui.cs
uploadId: 609016
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,13 @@
fileFormatVersion: 2
guid: ec07267f6a28fb044ac89845274e79af
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 119922
packageName: PUN 2 - FREE
packageVersion: 2.43
assetPath: Assets/Photon/PhotonChat/Demos/DemoChat/DemoChat-Scene.unity
uploadId: 609016
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: c33037d6755b1134db073d59feb6f7d9
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,279 @@
#if !PHOTON_UNITY_NETWORKING
using System;
using Photon.Chat;
using Photon.Chat.Demo;
using Photon.Realtime;
using UnityEditor;
using UnityEngine;
[InitializeOnLoad]
public class ChatEditor : EditorWindow
{
static ChatEditor()
{
EditorApplication.update += OnEditorUpdate;
}
private static void OnEditorUpdate()
{
EditorApplication.update -= OnEditorUpdate;
//ChatSettings settings = ChatSettings.Load();
//if (settings != null && !settings.WizardDone && string.IsNullOrEmpty(settings.AppId))
//{
// OpenWizard();
//}
}
[MenuItem("Window/Photon Chat/Setup")]
public static void OpenWizard()
{
//currentSettings = ChatSettings.Load();
//currentSettings.WizardDone = true;
//EditorUtility.SetDirty(currentSettings);
ChatEditor editor = (ChatEditor)EditorWindow.GetWindow(typeof (ChatEditor), false, "Photon Chat");
editor.minSize = editor.preferredSize;
}
private ChatGui cGui;
internal string mailOrAppId;
internal bool showDashboardLink = false;
internal bool showRegistrationDone = false;
internal bool showRegistrationError = false;
private readonly Vector2 preferredSize = new Vector2(350, 400);
internal static string UrlCloudDashboard = "https://dashboard.photonengine.com/en-US/";
public string WelcomeText = "Thanks for importing Photon Chat.\nThis window should set you up.\n\nYou will need a free Photon Account to setup a Photon Chat application.\nOpen the Photon Dashboard (webpage) to access your account (see button below).\n\nCopy and paste a Chat AppId into the field below and click \"Setup\".";
//public string AlreadyRegisteredInfo = "The email is registered so we can't fetch your AppId (without password).\n\nPlease login online to get your AppId and paste it above.";
//public string RegisteredNewAccountInfo = "We created a (free) account and fetched you an AppId.\nWelcome. Your Photon Chat project is setup.";
//public string FailedToRegisterAccount = "This wizard failed to register an account right now. Please check your mail address or try via the Dashboard.";
//public string AppliedToSettingsInfo = "Your AppId is now applied to this project.";
public string SetupCompleteInfo = "<b>Done!</b>\nYour Chat AppId is now stored in the <b>Scripts</b> object, Chat App Settings.";
public string CloseWindowButton = "Close";
public string OpenCloudDashboardText = "Photon Dashboard Login";
public string OpenCloudDashboardTooltip = "Review Cloud App information and statistics.";
public void OnGUI()
{
if (this.cGui == null)
{
cGui = FindObjectOfType<ChatGui>();
}
GUI.skin.label.wordWrap = true;
GUI.skin.label.richText = true;
if (string.IsNullOrEmpty(mailOrAppId))
{
mailOrAppId = string.Empty;
}
GUILayout.Label("Chat Settings", EditorStyles.boldLabel);
GUILayout.Label(this.WelcomeText);
GUILayout.Space(15);
GUILayout.Label("Chat AppId");
string input = EditorGUILayout.TextField(this.mailOrAppId);
if (GUI.changed)
{
this.mailOrAppId = input.Trim();
}
//bool isMail = false;
bool minimumInput = false;
bool isAppId = false;
if (IsValidEmail(this.mailOrAppId))
{
// this should be a mail address
minimumInput = true;
//isMail = true;
}
else if (IsAppId(this.mailOrAppId))
{
// this should be an appId
minimumInput = true;
isAppId = true;
}
EditorGUI.BeginDisabledGroup(!minimumInput);
GUILayout.BeginHorizontal();
GUILayout.FlexibleSpace();
bool setupBtn = GUILayout.Button("Setup", GUILayout.Width(205));
GUILayout.FlexibleSpace();
GUILayout.EndHorizontal();
if (setupBtn)
{
this.showDashboardLink = false;
this.showRegistrationDone = false;
this.showRegistrationError = false;
//if (isMail)
//{
// EditorUtility.DisplayProgressBar("Fetching Account", "Trying to register a Photon Cloud Account.", 0.5f);
// AccountService service = new AccountService();
// //service.RegisterByEmail(this.mailOrAppId, AccountService.Origin.Pun);
// //EditorUtility.ClearProgressBar();
// //if (service.ReturnCode == 0)
// //{
// // currentSettings.AppId = service.AppId;
// // EditorUtility.SetDirty(currentSettings);
// // this.showRegistrationDone = true;
// // Selection.objects = new UnityEngine.Object[] { currentSettings };
// //}
// //else
// //{
// // if (service.Message.Contains("registered"))
// // {
// // this.showDashboardLink = true;
// // }
// // else
// // {
// // this.showRegistrationError = true;
// // }
// //}
//}
//else
if (isAppId)
{
//currentSettings.AppId = this.mailOrAppId;
//EditorUtility.SetDirty(currentSettings);
if (this.cGui != null)
{
this.cGui.ChatAppSettings.AppIdChat = this.mailOrAppId;
EditorUtility.SetDirty(this.cGui);
}
showRegistrationDone = true;
}
//EditorGUIUtility.PingObject(currentSettings);
}
EditorGUI.EndDisabledGroup();
GUILayout.BeginHorizontal();
GUILayout.FlexibleSpace();
if (GUILayout.Button(new GUIContent(OpenCloudDashboardText, OpenCloudDashboardTooltip), GUILayout.Width(205)))
{
EditorUtility.OpenWithDefaultApp(UrlCloudDashboard);
}
GUILayout.FlexibleSpace();
GUILayout.EndHorizontal();
//if (this.showDashboardLink)
//{
// // button to open dashboard and get the AppId
// GUILayout.Space(15);
// GUILayout.Label(AlreadyRegisteredInfo);
// GUILayout.BeginHorizontal();
// GUILayout.FlexibleSpace();
// if (GUILayout.Button(new GUIContent(OpenCloudDashboardText, OpenCloudDashboardTooltip), GUILayout.Width(205)))
// {
// EditorUtility.OpenWithDefaultApp(UrlCloudDashboard + Uri.EscapeUriString(this.mailOrAppId));
// this.mailOrAppId = string.Empty;
// this.showDashboardLink = false;
// }
// GUILayout.FlexibleSpace();
// GUILayout.EndHorizontal();
//}
//if (this.showRegistrationError)
//{
// GUILayout.Space(15);
// GUILayout.Label(FailedToRegisterAccount);
// GUILayout.BeginHorizontal();
// GUILayout.FlexibleSpace();
// if (GUILayout.Button(new GUIContent(OpenCloudDashboardText, OpenCloudDashboardTooltip), GUILayout.Width(205)))
// {
// EditorUtility.OpenWithDefaultApp(UrlCloudDashboard + Uri.EscapeUriString(this.mailOrAppId));
// this.mailOrAppId = string.Empty;
// this.showDashboardLink = false;
// }
// GUILayout.FlexibleSpace();
// GUILayout.EndHorizontal();
//}
if (this.showRegistrationDone)
{
GUILayout.Space(15);
//GUILayout.Label("Registration done");
////if (isMail)
////{
//// GUILayout.Label(RegisteredNewAccountInfo);
////}
////else
////{
// GUILayout.Label(AppliedToSettingsInfo);
////}
// setup-complete info
GUILayout.Space(15);
GUILayout.Label(SetupCompleteInfo);
// close window (done)
GUILayout.BeginHorizontal();
GUILayout.FlexibleSpace();
if (GUILayout.Button(CloseWindowButton, GUILayout.Width(205)))
{
this.Close();
}
GUILayout.FlexibleSpace();
GUILayout.EndHorizontal();
}
}
public static bool IsAppId(string val)
{
if (string.IsNullOrEmpty(val) || val.Length < 16)
{
return false;
}
try
{
new Guid(val);
}
catch
{
return false;
}
return true;
}
// https://stackoverflow.com/a/1374644/1449056
private static bool IsValidEmail(string email)
{
if (string.IsNullOrEmpty(email) || !email.Contains("@"))
{
return false;
}
try
{
System.Net.Mail.MailAddress addr = new System.Net.Mail.MailAddress(email);
return email.Equals(addr.Address);
}
catch
{
return false;
}
}
}
#endif
@@ -0,0 +1,15 @@
fileFormatVersion: 2
guid: 0ef7cc863c103cf44930b0411a10ad1f
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
AssetOrigin:
serializedVersion: 1
productId: 119922
packageName: PUN 2 - FREE
packageVersion: 2.43
assetPath: Assets/Photon/PhotonChat/Demos/DemoChat/Editor/ChatEditor.cs
uploadId: 609016
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: c73bd05f7e3a006418e6398b47511e49
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
Binary file not shown.

After

Width:  |  Height:  |  Size: 103 KiB

@@ -0,0 +1,95 @@
fileFormatVersion: 2
guid: 2fb83ea89df639b43a22d707d3c22af1
TextureImporter:
fileIDToRecycleName: {}
externalObjects: {}
serializedVersion: 9
mipmaps:
mipMapMode: 0
enableMipMap: 1
sRGBTexture: 1
linearTexture: 0
fadeOut: 0
borderMipMap: 0
mipMapsPreserveCoverage: 0
alphaTestReferenceValue: 0.5
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
isReadable: 0
streamingMipmaps: 0
streamingMipmapsPriority: 0
grayScaleToAlpha: 0
generateCubemap: 6
cubemapConvolution: 0
seamlessCubemap: 0
textureFormat: -2
maxTextureSize: 256
textureSettings:
serializedVersion: 2
filterMode: 0
aniso: 16
mipBias: -100
wrapU: 1
wrapV: 1
wrapW: 1
nPOTScale: 0
lightmap: 0
compressionQuality: 50
spriteMode: 1
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spritePixelsToUnits: 100
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spriteGenerateFallbackPhysicsShape: 1
alphaUsage: 1
alphaIsTransparency: 1
spriteTessellationDetail: -1
textureType: 8
textureShape: 1
singleChannelComponent: 0
maxTextureSizeSet: 0
compressionQualitySet: 0
textureFormatSet: 0
platformSettings:
- serializedVersion: 2
buildTarget: DefaultTexturePlatform
maxTextureSize: 256
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
spriteSheet:
serializedVersion: 2
sprites: []
outline: []
physicsShape: []
bones: []
spriteID: 9f2a0d94850205c449718d6a65b6da2c
vertices: []
indices:
edges: []
weights: []
spritePackingTag:
pSDRemoveMatte: 0
pSDShowRemoveMatteOption: 0
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 119922
packageName: PUN 2 - FREE
packageVersion: 2.43
assetPath: Assets/Photon/PhotonChat/Demos/DemoChat/Files/Gradient.png
uploadId: 609016
@@ -0,0 +1,31 @@
fileFormatVersion: 2
guid: 5abfb0a229c98b3499cffa6c59c2ffb4
TrueTypeFontImporter:
externalObjects: {}
serializedVersion: 4
fontSize: 16
forceTextureCase: -2
characterSpacing: 0
characterPadding: 1
includeFontData: 1
fontName: Jura
fontNames:
- Jura
fallbackFontReferences:
- {fileID: 12800000, guid: e00995507c2406448b4c8429136104dd, type: 3}
- {fileID: 12800000, guid: 4a4df204c321f9c40b0dbfb1baaffb4c, type: 3}
customCharacters:
fontRenderingMode: 0
ascentCalculationMode: 1
useLegacyBoundsCalculation: 0
shouldRoundAdvanceValue: 1
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 119922
packageName: PUN 2 - FREE
packageVersion: 2.43
assetPath: Assets/Photon/PhotonChat/Demos/DemoChat/Files/Jura-Medium.ttf
uploadId: 609016
Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

@@ -0,0 +1,95 @@
fileFormatVersion: 2
guid: ea7134547a5488b41a6bb5243b4ec2f1
TextureImporter:
fileIDToRecycleName: {}
externalObjects: {}
serializedVersion: 9
mipmaps:
mipMapMode: 0
enableMipMap: 0
sRGBTexture: 1
linearTexture: 0
fadeOut: 0
borderMipMap: 0
mipMapsPreserveCoverage: 0
alphaTestReferenceValue: 0.5
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
isReadable: 0
streamingMipmaps: 0
streamingMipmapsPriority: 0
grayScaleToAlpha: 0
generateCubemap: 6
cubemapConvolution: 0
seamlessCubemap: 0
textureFormat: -3
maxTextureSize: 1024
textureSettings:
serializedVersion: 2
filterMode: 0
aniso: 16
mipBias: -100
wrapU: 1
wrapV: 1
wrapW: 1
nPOTScale: 0
lightmap: 0
compressionQuality: 50
spriteMode: 1
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spritePixelsToUnits: 100
spriteBorder: {x: 1, y: 1, z: 1, w: 1}
spriteGenerateFallbackPhysicsShape: 1
alphaUsage: 1
alphaIsTransparency: 1
spriteTessellationDetail: -1
textureType: 8
textureShape: 1
singleChannelComponent: 0
maxTextureSizeSet: 0
compressionQualitySet: 0
textureFormatSet: 0
platformSettings:
- serializedVersion: 2
buildTarget: DefaultTexturePlatform
maxTextureSize: 1024
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 0
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
spriteSheet:
serializedVersion: 2
sprites: []
outline: []
physicsShape: []
bones: []
spriteID: 0ca28098c6f2a0a4ba4f7e88ae619ca9
vertices: []
indices:
edges: []
weights: []
spritePackingTag:
pSDRemoveMatte: 0
pSDShowRemoveMatteOption: 0
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 119922
packageName: PUN 2 - FREE
packageVersion: 2.43
assetPath: Assets/Photon/PhotonChat/Demos/DemoChat/Files/OutlinedSquaredBox.png
uploadId: 609016
Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

@@ -0,0 +1,95 @@
fileFormatVersion: 2
guid: 37b0a18b391c6ae468b5bcc74bba2c1a
TextureImporter:
fileIDToRecycleName: {}
externalObjects: {}
serializedVersion: 9
mipmaps:
mipMapMode: 0
enableMipMap: 0
sRGBTexture: 1
linearTexture: 0
fadeOut: 0
borderMipMap: 0
mipMapsPreserveCoverage: 0
alphaTestReferenceValue: 0.5
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
isReadable: 0
streamingMipmaps: 0
streamingMipmapsPriority: 0
grayScaleToAlpha: 0
generateCubemap: 6
cubemapConvolution: 0
seamlessCubemap: 0
textureFormat: -2
maxTextureSize: 128
textureSettings:
serializedVersion: 2
filterMode: -1
aniso: 1
mipBias: -100
wrapU: 1
wrapV: 1
wrapW: 1
nPOTScale: 0
lightmap: 0
compressionQuality: 50
spriteMode: 1
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spritePixelsToUnits: 100
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spriteGenerateFallbackPhysicsShape: 1
alphaUsage: 1
alphaIsTransparency: 1
spriteTessellationDetail: -1
textureType: 8
textureShape: 1
singleChannelComponent: 0
maxTextureSizeSet: 0
compressionQualitySet: 0
textureFormatSet: 0
platformSettings:
- serializedVersion: 2
buildTarget: DefaultTexturePlatform
maxTextureSize: 128
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
spriteSheet:
serializedVersion: 2
sprites: []
outline: []
physicsShape: []
bones: []
spriteID: 10108fb3311b5d345a644c65ddc43a0d
vertices: []
indices:
edges: []
weights: []
spritePackingTag:
pSDRemoveMatte: 0
pSDShowRemoveMatteOption: 0
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 119922
packageName: PUN 2 - FREE
packageVersion: 2.43
assetPath: Assets/Photon/PhotonChat/Demos/DemoChat/Files/PunIcon-White-129.png
uploadId: 609016
@@ -0,0 +1,30 @@
fileFormatVersion: 2
guid: 4345225956e176043b2f73b9ee1b0f2b
TrueTypeFontImporter:
externalObjects: {}
serializedVersion: 4
fontSize: 16
forceTextureCase: -2
characterSpacing: 0
characterPadding: 1
includeFontData: 1
fontName: eurofurence light
fontNames:
- eurofurence light
fallbackFontReferences:
- {fileID: 12800000, guid: 954746d370bc8934299c8c8267543f4f, type: 3}
customCharacters:
fontRenderingMode: 0
ascentCalculationMode: 1
useLegacyBoundsCalculation: 0
shouldRoundAdvanceValue: 1
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 119922
packageName: PUN 2 - FREE
packageVersion: 2.43
assetPath: Assets/Photon/PhotonChat/Demos/DemoChat/Files/eurof35.ttf
uploadId: 609016
@@ -0,0 +1,21 @@
------------------------------------------------------------------------
The eurofurence typeface family by tobias b koehler (unci@tigerden.com)
------------------------------------------------------------------------
This is a family of geometric rounded sans serif fonts consisting of
three weights (light, medium, bold) in upright and italic styles,
originally designed for EuroFurence, the first European furry convention
1995 in Kaiser-Wilhelm-Koog.
The character set includes Roman, Greek and Cyrillic characters.
File format is TrueType for PC (under Windows, Linux etc).
These fonts are freeware and can be distributed as long as they are
together with this text file. I would appreciate it though if you could
contact me at unci@tigerden.com if you put them on a server. Free
samples from commercial users are always very welcome. :)
For more information, please see the uncifonts WWW page at:
http://mercurio.iet.unipi.it/users/tobias/uncifonts.html
Have fun! tobias b koehler, 2000-04-02
@@ -0,0 +1,14 @@
fileFormatVersion: 2
guid: e96690bd3586cf643a223def4feaa4d4
TextScriptImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 119922
packageName: PUN 2 - FREE
packageVersion: 2.43
assetPath: Assets/Photon/PhotonChat/Demos/DemoChat/Files/eurof_tt.txt
uploadId: 609016
@@ -0,0 +1,84 @@
// --------------------------------------------------------------------------------------------------------------------
// <copyright company="Exit Games GmbH"/>
// <summary>Demo code for Photon Chat in Unity.</summary>
// <author>developer@exitgames.com</author>
// --------------------------------------------------------------------------------------------------------------------
using UnityEngine;
using UnityEngine.UI;
namespace Photon.Chat.Demo
{
/// <summary>
/// Friend UI item used to represent the friend status as well as message.
/// It aims at showing how to share health for a friend that plays on a different room than you for example.
/// But of course the message can be anything and a lot more complex.
/// </summary>
public class FriendItem : MonoBehaviour
{
[HideInInspector]
public string FriendId
{
set { this.NameLabel.text = value; }
get { return this.NameLabel.text; }
}
public Text NameLabel;
public Text StatusLabel;
public Text Health;
public void Awake()
{
this.Health.text = string.Empty;
}
public void OnFriendStatusUpdate(int status, bool gotMessage, object message)
{
string _status;
switch (status)
{
case 1:
_status = "Invisible";
break;
case 2:
_status = "Online";
break;
case 3:
_status = "Away";
break;
case 4:
_status = "Do not disturb";
break;
case 5:
_status = "Looking For Game/Group";
break;
case 6:
_status = "Playing";
break;
default:
_status = "Offline";
break;
}
this.StatusLabel.text = _status;
if (gotMessage)
{
string _health = string.Empty;
if (message != null)
{
string[] _messages = message as string[];
if (_messages != null && _messages.Length >= 2)
{
_health = (string)_messages[1] + "%";
}
}
this.Health.text = _health;
}
}
}
}
@@ -0,0 +1,17 @@
fileFormatVersion: 2
guid: 660b16ba396d0465b98be14947420288
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 119922
packageName: PUN 2 - FREE
packageVersion: 2.43
assetPath: Assets/Photon/PhotonChat/Demos/DemoChat/FriendItem.cs
uploadId: 609016
@@ -0,0 +1,20 @@
// --------------------------------------------------------------------------------------------------------------------
// <copyright company="Exit Games GmbH"/>
// <summary>Demo code for Photon Chat in Unity.</summary>
// <author>developer@exitgames.com</author>
// --------------------------------------------------------------------------------------------------------------------
using UnityEngine;
namespace Photon.Chat.Demo
{
public class IgnoreUiRaycastWhenInactive : MonoBehaviour, ICanvasRaycastFilter
{
public bool IsRaycastLocationValid(Vector2 screenPoint, Camera eventCamera)
{
return this.gameObject.activeInHierarchy;
}
}
}
@@ -0,0 +1,17 @@
fileFormatVersion: 2
guid: 4ba4c747f6975ea46bcc0a55ffe3bfe8
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 119922
packageName: PUN 2 - FREE
packageVersion: 2.43
assetPath: Assets/Photon/PhotonChat/Demos/DemoChat/IgnoreUiRaycastWhenInactive.cs
uploadId: 609016
@@ -0,0 +1,55 @@
// --------------------------------------------------------------------------------------------------------------------
// <copyright company="Exit Games GmbH"/>
// <summary>Demo code for Photon Chat in Unity.</summary>
// <author>developer@exitgames.com</author>
// --------------------------------------------------------------------------------------------------------------------
using UnityEngine;
using UnityEngine.UI;
namespace Photon.Chat.Demo
{
[RequireComponent(typeof(ChatGui))]
public class NamePickGui : MonoBehaviour
{
private const string UserNamePlayerPref = "NamePickUserName";
public ChatGui chatNewComponent;
public InputField idInput;
public void Start()
{
this.chatNewComponent = FindObjectOfType<ChatGui>();
string prefsName = PlayerPrefs.GetString(UserNamePlayerPref);
if (!string.IsNullOrEmpty(prefsName))
{
this.idInput.text = prefsName;
}
}
// new UI will fire "EndEdit" event also when loosing focus. So check "enter" key and only then StartChat.
public void EndEditOnEnter()
{
if (Input.GetKey(KeyCode.Return) || Input.GetKey(KeyCode.KeypadEnter))
{
this.StartChat();
}
}
public void StartChat()
{
ChatGui chatNewComponent = FindObjectOfType<ChatGui>();
chatNewComponent.UserName = this.idInput.text.Trim();
chatNewComponent.Connect();
this.enabled = false;
PlayerPrefs.SetString(UserNamePlayerPref, chatNewComponent.UserName);
}
}
}
@@ -0,0 +1,17 @@
fileFormatVersion: 2
guid: 696a5174ff5e707479b3540eb56d14b7
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 119922
packageName: PUN 2 - FREE
packageVersion: 2.43
assetPath: Assets/Photon/PhotonChat/Demos/DemoChat/NamePickGui.cs
uploadId: 609016