πMessage Popups
Package with message popups system so you can easy connect it to your game
What for
When player clicks on locked button or we want to send player tips it's good to make it with message popups. Message will be shown for N seconds (+-2s by default) and then automaticaly disappear.
Here is examples of default popups (you can change its visuals with prefabs), 3 types:



How to use
It works only in canvas with screen space mode = Overlay Create separate canvas with this mode if you dont have one.
Add MessagePopups.prefab under your scene UI canvas
Reference to MessagePopups somewhere to call message popups later
Use these methods in MessagePopups.cs to call popup:
public void Show(string text, MessageTypes messageType);
public void Show(string text, MessageTypes messageType, Vector2 atScreenPosition);Settings of base implementation

Fit In Screen boolean used by MessagePopups manager to fit popup in user resolution even if target position out of screen (rect size delta of message will be used)
Fit Screen Padding is offset from screen border to fit in
Text is reference to default text (replace it with TMP if you need in MessagePopup.cs)
Animation is implementation of PopupAnimation abstract class. PopupDefaultAnimation is implemented in this package, you can add your own and setup correspond fields
How add more popups:
Add new popup type in enum MessageTypes.cs
Create prefab variant from BaseMessage.prefab or completely new and add MessagePopup script to it
Setup visuals for it in prefab
Optional if you need special animation for this type then make a class that derives from PopupAnimation and implement it's methods. See PopupDefaultAnimation implementation for reference how it can be. Your PopupAnimation implementation should support replacement in target screen position (I set rectTransform.position of message with argument value and recalculate animation offsets)
Last updated