Messagemanager: A Full Color, Fading, Messaging System [OBSO

This is the place to post add-on scripts you have written that use EZ GUI. Please remember only to post your add-on content and not the original EZ GUI scripts.
Forum rules
Only post your own add-on content and not any of the original EZ GUI scripts.

Messagemanager: A Full Color, Fading, Messaging System [OBSO

Postby Little Angel » Mon Oct 25, 2010 10:42 am

I've written a Full Color, Fading, Drop Shadowed Messaging System for EZGui that support an infinite amount of messages (limited only by the size of your display screen or any limit to the .Text field in SpriteText). It will batch with your existing EZGui typeface/font material, as it uses SpriteText for display.

Image


To use, create a two new GameObjects.
Drag the script "MessageManager" onto the first GameObject.
Apply a Sprite Text Component onto the second GameObject, and set the typeface/font.

To setup MessageManager:
Image
Message Display is the slot for your SpriteText object that you set up below.
Fade Delay is how long the message is displayed before it fades off.
Fade Speed is how fast the message fades.
Drop Shadow is the optional drop shadow layer. This will batch as it's also Sprite Text, just a different color.
Drop Shadow Offset is the amount of displacement for the drop shadow.

To setup the SpriteText (Label):
Image
Set the typeface/font material in the mesh renderer.
Set the character size, spacing, anchor etc. to format your display text.
Set the layer of the GameObject to your UILayer.
Place the GameObject in the scene where you need it to display.

To Send Messages:
MessageManager has singelton support, so (and these comments are saved within the script, so you can reference it from there)...

MessageManager can be cached on start:
Create a new variable in the script that needs to reference MessageManager: private MessageManager messageManager;
In Start() add the line: messageManager = MessageManager.Instance();
Once cached, sending a message requires function calls such as: messageManager.Message(message, color);, where message is string and color is Color

EG:
Code: Select all
messageManager.Message ("Target is Dead", Color.red);


or:
Code: Select all
messageManager.Message ("Cannot attack this target",  new Color(1.0f, 0.5f, 0.0f, 1.0f));


or:
Code: Select all
messageManager.Message("Cannot Equip this Item!\nThe " + equipped[i].slotType + " slot is full.", Color.yellow);


or (As this has different methods that can be overloaded) you can simply send a basic message with no color:
Code: Select all
messageManager.Message("Oscar Wilde, it's clobberin' time!")

... and this will be displayed as the default color.

Let me know what improvements or changes you need. This works fine for my purposes, but I could imagine other people needing different functionality.

-

Now, if I've helped you out or saved you time and you are in the position to do so, please donate to help offset the time I spend setting up these helper tools for distribution.
A donation would really help me continue to provide these and more tools to the community.


Image

MessageManager-1.00.zip
(3.01 KiB) Downloaded 584 times
Last edited by Little Angel on Mon Oct 25, 2010 11:46 am, edited 3 times in total.
Little Angel
 
Posts: 772
Joined: Thu Sep 02, 2010 10:23 pm

Re: Full Color, Fading, Messaging System for EZGui

Postby Brady » Mon Oct 25, 2010 11:11 am

Neato! Thanks for posting this, LA!
Brady
 
Posts: 5361
Joined: Tue Jul 06, 2010 11:33 pm

Re: Full Color, Fading, Messaging System for EZGui

Postby zhx » Tue Oct 26, 2010 4:07 am

thanks for creating and sharing! :-)

EDIT:
wow, this is a very cool script!

have you shared any other great scripts you've created for unity? If so, are they are this forum, the Unity forums, or others?
zhx
 
Posts: 5
Joined: Tue Oct 05, 2010 9:09 am

Re: Full Color, Fading, Messaging System for EZGui

Postby jrricky » Thu Nov 04, 2010 2:58 pm

Hey, I dont get a Unity Package when I unload this zip, is that the way its supposed to be?
jrricky
 
Posts: 45
Joined: Mon Sep 27, 2010 3:09 pm

Re: Full Color, Fading, Messaging System for EZGui

Postby Little Angel » Thu Nov 04, 2010 3:06 pm

Hmmm...

Just tried to d/l it in Safari and I got a unity package auto-unzipped in the downloads folder:
Image

Could this be your browser? Or try manually downloading (eg: control-click on the link and "save target as..." etc.)
Little Angel
 
Posts: 772
Joined: Thu Sep 02, 2010 10:23 pm

Re: Full Color, Fading, Messaging System for EZGui

Postby jrricky » Thu Nov 04, 2010 5:58 pm

Solved it. Its great, but things that can be added would be other transitions like, zoom in, pop in, dash in, spin in and other stuff...
jrricky
 
Posts: 45
Joined: Mon Sep 27, 2010 3:09 pm

Re: Full Color, Fading, Messaging System for EZGui

Postby Little Angel » Sun Nov 07, 2010 10:04 pm

Unfortunately, those types of complex animations are beyond the scope of this system. To keep this system simple and the load light on the device, all the text is situated in one SpriteText field. That one SpriteText is manipulated to make it appear that there are individual messages, not just one.

That being said, a SpriteText based system with a large number of individual SpriteText objects in an array or instantiating-destroying prefabs could be created. This would require animation methods as well, so this pushes the complexity of a messaging system substantially from what we have here.
Little Angel
 
Posts: 772
Joined: Thu Sep 02, 2010 10:23 pm

Re: Full Color, Fading, Messaging System for EZGui

Postby outtoplay » Mon Nov 08, 2010 2:53 am

Wow... this is pretty darn cool. Question, could this be used in conjunction with a narrator.mp3 or other type sound file?
Basically imagine a background image or a storybook page, the text fades up, and the 'narrator' reads the text.

And for the extra point, I don't suppose individual words, could be 'highlighted' as if timed to the narrator's reading. (obviously this would be manually animated if possible at the word level).

Great stuff,
brendang
outtoplay
 
Posts: 31
Joined: Tue Aug 10, 2010 3:37 pm

Re: Full Color, Fading, Messaging System for EZGui

Postby Brady » Mon Nov 08, 2010 4:16 am

I haven't dug too deep into this system myself yet, but the capability to color individual words is certainly there in theory as SpriteText allows tagging any portion of the text at will with a different color.
Brady
 
Posts: 5361
Joined: Tue Jul 06, 2010 11:33 pm

Re: Full Color, Fading, Messaging System for EZGui

Postby Little Angel » Mon Nov 08, 2010 9:16 am

Outtoplay: This definitely could be done with EZGui. This system could be taken for a base to start with, but it would take some jiggering.

The base methods for this system are Message(string message) and Message (string message, Color color) which push the current message into an array/list, and where UpdateDisplay () takes all of the current messages from the array and does foreach (Message message in messages) { formattedMessages += message.color + message.text + "\n"; } Finally there is a FadeMessage() coroutine that has a reference to an individual message and lerps the alpha channel over time, updating the display every frame.

For this system to work for your purposes with the most minimal surgery, the text would have to be parsed and split into individual words, creating an array of the text to be written, then that array iterated over changing the color of each word's tag. For polish, there'd need to be some fading coroutines. Timing it to the sound file would take some thought and play... But I'm sure it could be done.

Let me know if I can be of more help.
Little Angel
 
Posts: 772
Joined: Thu Sep 02, 2010 10:23 pm

Next

Return to EZ GUI Add-ons

Who is online

Users browsing this forum: No registered users and 3 guests

cron