Quantcast
Channel: Answers for "How to put a list of strings in a Text Unity 4.6 UI element"
Viewing all articles
Browse latest Browse all 6

Answer by TooManySugar

$
0
0
I recognize the code from Quili18 from the PUN FPS tutorial in the second post by OP. I'had the same need to convert the console text to ui 4.6. This works for me: Youcan test by adding a chat entry on keypress. The _UIM is a call to a static script tha holds the ui text object. variables: List chatMessages; int maxChatMessages = 5; private string ChatLine; public void AddChatMessage (string m) { transform.GetComponent().RPC ("AddChatMessage_RPC",PhotonTargets.All,m); //Component comp = overlayComponent; } [PunRPC] void AddChatMessage_RPC (string m) { while (chatMessages.Count >=maxChatMessages){//while there are more messages than we want remove oldest entry chatMessages.RemoveAt (0); _UIM.ui_Online_Console_text.GetComponent().text ="";//reset the printed text } chatMessages.Add (m); foreach(string msg in chatMessages) {//we print the text ChatLine = msg.ToString () + '\n'; _UIM.ui_Online_Console_text.GetComponent().text += ChatLine; }

Viewing all articles
Browse latest Browse all 6

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>