Message System

Posted: 29 Jun 2020 15:13
by Nysalie

Time to be a bit more ambitious. I'm working on a message system to be implemented in some sort of in-game mobile phone or chat application, however I have some initial concerns regarding Characters and TextPrinters. I realize that this is very specific and beyond the essential purpose of Naninovel but i feel that an extension like this would benefit some projects and someone might find it useful as well. Also, considering my skill level, I might be biting a lot more than I can chew right now, but at least it's forcing me to learn the engine on a deeper level and my computer hasn't exploded...yet.

I'll be using the available Chat printer as a base, however I would like to expand a few things on it.

The first one would be the ability to also send pictures/emojis. The sprites could be a resource handled by a provider in a Configuration, much like the items from the Inventory extension. I would need to create another ChatMessage prototype prefab to include an empty container for image components to be displayed if a "picture" parameter was set on the printer in the .nani script. The image would need to be fitted to the width of the messages container and clicking on it would display it in full screen, this could be implemented with a simple CustomUI with a single Image component.

Now the trickier part. Keep a message log for each character. Like a real phone, each contact has it's own message history and there are only two persons interacting in each one, the player (ourselves) and the other npc (contact). Thinking in Naninovel scripts, this could mean a single script for each character conversation that could be called whenever it would be appropriate during gameplay. A little notification on the right bottom corner of the screen with a small preview of the content of the last message would also be an interesting thing to add.

My main concern is the separation of the messages from the regular text flow of the game. If i understand correctly, Naninovel's scripts send text to print on a single "text stream". If I print some text in a Dialogue printer during regular gameplay, then to "receive" a message, my ideia is to create a custom PhoneUI with a Messages panel, this panel is a contact list with each npc that the player has encountered, clicking on a particular npc would switch the panel to a Chat printer with the picked character's message history. Closing the PhoneUI would return to regular gameplay with the Dialogue printer displaying the previous state before accessing the phone. Essentially, making messages/message history independent actors, and in practice they wouldn't show up on the LogUI.

Is this even realistically feasible without drastically changing the framework's design? Which interfaces should I look for to achieve this? I'm studying ChatPrinterPanel implementation of the UITextPrinterPanel class, digging references and implementations,etc. I believe it's a good starting point.

PS: Sorry about the long post :oops:


Re: Message System

Posted: 29 Jun 2020 15:25
by Elringus

That should be completely possible without changing anything in the package sources.

You can either create a custom text printer or custom UI. The latter should be easier to implement (you won't be limited by the printer actor interface), but you'll loose all the printer-related features (eg, message sounds, shake printer effect, etc).

As for the emojis, take a look at TMPro's sprite capabilities: http://digitalnativestudios.com/textmes ... s/sprites/ or some third party libs for it, eg: https://forum.unity.com/threads/full-em ... en.660310/


Re: Message System

Posted: 29 Jun 2020 15:33
by Elringus

Hm, I've searched for an example chat / instant messenger UI for Unity and surprisingly found none... Maybe I'll make one with an optional Naninovel integration in the future.


Re: Message System

Posted: 29 Jun 2020 16:41
by Nysalie

Was completely unaware that TMP supported emojis, that will be extremely helpful. I think I'll keep the pictures sent via message as separate resources, though, like the inventory items, it's probably easier to manage than messing with atlas and will be good practice to deal with your resource providers.

I like the visual candy of the chat printer (delay, revealable text, etc.) so I think I will try to implement a custom printer. I'm still trying to figure out a way to make it character independent and serialize states properly.

I'm not sure about the demand for it but i've seen some games with some kind of messaging system, it makes for a more interactive experience but it starts to enter the adventure/sandbox realm, I personally love it in a VN but I understand that it's not for everyone's taste. If you run out of ideas for features to integrate it would be a great add-on for sure. Scene navigation (map, rooms, etc.) and a simple quest system are also some things I want to try out with Naninovel's engine.


Re: Message System

Posted: 29 Jun 2020 16:52
by Elringus

I'll probably wait for UIElements runtime release (designed to eventually replace uGUI), which is expected with Unity 2020.1 and make the chat with it. Will also serve as en example for integrating UIElements with Naninovel.


Re: Message System

Posted: 29 Jun 2020 17:36
by Nysalie

Indeed, it's a nice project to test the new framework.