Use this component to show impact banners over the map. You can show different banners, each one with different look and effects. Also you can add any number of texts to any banner, and they will simply queue (if scrolling is enabled).
Similarly to the World Map Calculator component, you may enable this component in two ways:
-
From the Editor, clicking on the “Open Ticker” button at the bottom of the World Map inspector.
-
From code, using any of its API through map.ticker accessor. The first time you use its API, it will automatically add the component to the map gameObject.
On the Inspector you will see the following custom editor:
The top half of the inspector corresponds to the Ticker Bands configurator. You may customize the look&feel of the 9 available ticker bands (this number could be incremented if needed though). Notes:
- Ticker bands are where the ticker texts (second half of the inspector) scrolls or appears.
- A ticker band can be of two types: scrollable or static. You make a ticker band static setting its scroll speed to zero.
- Auto-hide will make the ticker band invisible when there’re no remaining texts on the band.
- The fade speed controls how quickly should the band appear/disappear. Set it to zero to disable the fade effect.
It’s important to note that everything you change on the inspector can be done using the API (more below).
In the second half of the inspector you can configure and create a sample ticker text. Notes:
- Horizontal offset allows you to control the horizontal position of the text (0 equals to zero longitude, being the range -0.5 to 0.5).
- Setting fade duration to zero will disable fading effect.
- Setting blink interval to zero will disable blinking and setting repetitions to zero will make the text blink forever.
The API can be accessed through map.ticker property and exposes the following methods/fields:
map.ticker.NUM_TICKERS: number of available bands (slots).
map.ticker.overlayMode: when enabled, ticker texts will be displayed on top of everything at nearclip distance of main camera.
map.ticker.tickerBands: array with the ticker bands objects. Modifying any of its properties has effect immediately.
map.ticker.GetTickerTextCount(): returns the number of ticker texts currently on the scene. When a ticker text scrolls outside the ticker band it’s removed so it helps to determine if the ticker bands are empty.
map.ticker.GetTickerTextCount(tickerBandIndex): same but for one specific ticker band.
map.ticker.GetTickerBandsActiveCount(): returns the number of active (visible) ticker bands.
map.ticker.ResetTickerBands(): will reset all ticker bands to their default values and removes any ticker text they contain.
map.ticker.ResetTickerBand(tickerBandIndex): same but for an specific ticker band.
map.ticker.AddTickerText(tickerText object): adds one ticker text object to a ticker band. The ticker text object contains all the neccesary information.
The demo.cs script used in the Demo scene contains the following code showing how to use the API:
// Sample code to show how tickers work
void TickerSample() {
map.ticker.ResetTickerBands();
// Configure 1st ticker band: a red band in the northern hemisphere
TickerBand tickerBand = map.ticker.tickerBands[0];
tickerBand.verticalOffset = 0.2f;
tickerBand.backgroundColor = new Color(1,0,0,0.9f);
tickerBand.scrollSpeed = 0; // static band
tickerBand.visible = true;
tickerBand.autoHide = true;
// Prepare a static, blinking, text for the red band
TickerText tickerText = new TickerText(0, "WARNING!!");
tickerText.textColor = Color.yellow;
tickerText.blinkInterval = 0.2f;
tickerText.horizontalOffset = 0.1f;
tickerText.duration = 10.0f;
// Draw it!
map.ticker.AddTickerText(tickerText);
// Configure second ticker band (below the red band)
tickerBand = map.ticker.tickerBands[1];
tickerBand.verticalOffset = 0.1f;
tickerBand.verticalSize = 0.05f;
tickerBand.backgroundColor = new Color(0,0,1,0.9f);
tickerBand.visible = true;
tickerBand.autoHide = true;
// Prepare a ticker text
tickerText = new TickerText(1, "INCOMING MISSLE!!");
tickerText.textColor = Color.white;
// Draw it!
map.ticker.AddTickerText(tickerText);
}