So, I’ve been reading around Google and the Unity Forums, and I’ve come to the conclusion that the old posts I’ve been reading no longer apply in RC2… Maybe if I update to RC3 it’ll be there…
Anyways, I’m trying to add a listener to an InputFields OnSubmit event, but the event is of type void, and obviously doesn’t have an AddListener method… How does one get around this? I need to be able to call OnSubmit from another script…
Essentially, I’m making a chat window for a multiplayer game.
All help would be greatly appreciated!!
This is what I’m using as of right now, and it is simply not working… For instance, if someone is typing a chat message and then clicks out of the inputField it sends the chat anyways…
Okay, I just re-read through the release notes and realized that onSubmit was replaced with onEndEdit since onEndEdit was being called with onSubmit anyways… At least, that’s how I understood it.
Now, my question… How could I get my inputField to fire an event ONLY when the “Return/Enter” key is pressed? I DO NOT want it to fire the event whenever someone clicks out of the inputField, as that would send the chat message and we obviously don’t want that xP
This has been asked before. The answer still is you’d have to modify the inputfield class to not set the end when they click away. its not currently supported out of the box.
Okay, do you have any documentation on how I’d do something like this? I know i’d probably have to extend the class, which is okay. Also, just a suggestion, it’d be pretty tight if we could modify text color from inside the string like NGUI does. What I mean is embedding colors in RrGgBb format… Here’s a quote from their site:
You already can modify the color of the text using html markup. you just need to make sure your Text component has rich text enabled. I’d take a look at the documentation or example projects for reference.
Ahh, thank you soo much! I didn’t know it was HTML markup was all, I figured if you were to implement it, then it would be BB code markup like NGUI. Thank you so much for that info! My chat window is going to look so beautiful now, all thanks to you! xP
Hm, i added a method to the listener. In this method i’m checking if (Input.GetKeyDown(KeyCode.Return)). If true i launch submit action. Else (it means Enter key wasn’t pressed) nothing happens. Work perfect for me.