ScoreFlash ClassScoreFlash API Documentation V4.6.0
ScoreFlash is gives you an easy way to let scores "flash up" on the screen, like a news flash. For detailed documentation of the various methods to push methods on screen, see IScoreFlash.
Inheritance Hierarchy

OnlineSystem Object
  Object
    Component
      Behaviour
        MonoBehaviour
          NarayanaGames.ScoreFlashComponent ScoreFlashBase
            (Default Namespace) ScoreFlash

Namespace: (Default Namespace)
Assembly: Assembly-CSharp-firstpass (in Assembly-CSharp-firstpass.dll) Version: 0.0.0.0
Syntax

public class ScoreFlash : ScoreFlashBase, IScoreFlash, 
	IScoreFlashLayout
Remarks

Simply add the prefab to your scene and use ScoreFlash.Push(object msg) (Push(Object)) from anywhere in your project to push messages on screen.

For a PDF file explaining all about setting up score flash, see Online PDF: First Steps with Score Flash.

For a basic introduction to ScoreFlash, see Online ScoreFlash on the Unity Asset Store - Product Video. Note that instead of using ScoreFlash.Instance.Show(...) as shown in the video, you now use ScoreFlash.Push or ScoreFlash.Instance.PushLocal!

To learn how to work with GUISkins, GUIStyles and fonts (only applicable when you're not using a custom renderer), see Online ScoreFlash-Tutorial: GUISkins, GUIStyles and Fonts. It's now also possible to directly assign a font using rendering (under Main Layout) set to UnityGUI_Font and assigning a font to Main Layout / Font (font), and if you want to use ScoreFlash with high density screens (e.g. Retina), you should assign the same font with twice the size to Font High Density (fontHighDensity.

For a tutorial on working with colors in ScoreFlash, see Online ScoreFlash-Tutorial: Working with Colors. There's another option now, and that is passing the color as parameter to the push-method (see examples below).

ScoreFlash has a very nice feature that allows you to conveniently test and set up how messages look with a test mode (Testing / Autogenerate messages?, see isTestAutogenerateMessages) and you can keep any changes you made to ScoreFlash or ScoreFlashFollow3D in their respective test modes after playing by using the checkboxes Keep Changes after Play? and Store immediately? which are visible at the bottom of the inspector while playing. For a tutorial on persisting your changes made in play mode see Online ScoreFlash-Tutorial: Persisting Changes after Playing

To be able to use Push(Object) you need to assign a GUI skin with custom style: ScoreFlash which needs to define the correct font (usually a very large font, like 96pt) and Alignment: MiddleCenter (with wrong alignment, messages don't appear in the center of the screen which looks weird). Optionally, you can also add a skin for high density displays (e.g. Retina display). You can change the name of the custom style being used with guiStyleName (Main Layout / Name of GUIStyle).

Alternatively, you can use Push(Object, GUIStyle) or Push(Object, GUIStyle, GUIStyle) when you want to control everything related to GUISkins yourself. This gives you more flexibility but also requires more coding on your side.

By default, ScoreFlash renders everything using Unity's built-in GUI system. So there are no dependencies on other packages. However, you can also use ScoreFlash with so-called "custom renderers", for example for NGUI and EZ GUI (included), or you could write your own custom renderer using ScoreFlashRendererBase as base class (instead of MonoBehaviour). To use those, unpack the packages you find in Plugins/NarayanaGames/ScoreFlash/CustomRendering, and pull the prefabs into the slot Score Flash Renderer under Main Layout, which becomes available as soon as you switch Rendering to CustomRenderer (see rendering). For a tutorial on using ScoreFlash with NGUI, see Online ScoreFlash with NGUI - Single Drawcall Messages

Examples

There's several ways of using ScoreFlash, here's the most simple example in C# (but ScoreFlash also can be called from JavaScript and Boo):
ScoreFlash.Push("Hello World!");
Examples

If, instead of using the colors provided by the ScoreFlash instance, you want each message to have a specific color, you can use another method that also has a Color parameter. You could use this, for example, to easily have red messages when a player loses score or health, and green messages, when a player gains score or health, and white messages for chat messages. When using this, the alpha value is multiplied with the current value from the fade animation of the message (so you could make messages appear very "light" without having to change the ScoreFlash configuration - and yet you can still use the fade in / keep / fade out animation of ScoreFlash):
Color colorRed = new Color(1F, 0F, 0F, 1F);
ScoreFlash.Push("Hello World!", colorRed);
Examples

For a much more powerful and clean interface, when you only want to work with a single instance of ScoreFlash, use ScoreFlash.Instance. This gives you all the methods available through IScoreFlash. One great advantage of using this is that with Intellisense, you only see the methods available through ScoreFlash (instead of all "stuff" that ScoreFlash inherits from MonoBehaviour). For example if you want to draw a message at the current location of the object the script with the following code is attached to:
Vector2 offset = Vector2.zero;
ScoreFlash.Instance.PushWorld(transform.position, offset, "I am here, now!");
Or, if you have ScoreFlashFollow3D attached to the same object, you can also do:
ScoreFlashFollow3D follow3D = GetComponent<ScoreFlashFollow3D>();
ScoreFlash.Instance.PushWorld(follow3D, "Some message");
If, on the other hand, you want to put a message on a specific location on screen, you can use PushScreen(Vector2, Object), e.g. to put a message with the coordinates of where a use clicked with the mouse at that location on screen:
void Update() {
    if (Input.GetMouseButtonDown(0)) {
        Vector2 screenPosition = new Vector2(Input.mousePosition.x, Input.mousePosition.y);
        string text = string.Format("({0:000}, {1:000})", screenPosition.x, screenPosition.y);

        ScoreFlash.Instance.PushScreen(screenPosition, text);
    }
}
Examples

Finally, if you want to use multiple instances of ScoreFlash, use the ScoreFlashManager instead of going through Instance. That way, you could easily use a completely different style for each message and you still have all the methods available that IScoreFlash offers, and the inspector of ScoreFlashManager provides a button Copy Ref which lets you easily copy the full reference to any ScoreFlash instance controlled by a ScoreFlashManager into your code. The final example illustrates how to use multiple instances of ScoreFlash. You'd use this in a scene with a ScoreFlashManager that has three instances of ScoreFlash as children, named SF_Amadeus, SF_Destroy and SF_Eraser.
using UnityEngine;
using System.Collections;

public class ExampleCSharpMultipleInstances : MonoBehaviour {

    public void OnGUI() {
        if (GUI.Button(new Rect(Screen.width - 180F, 10F, 170F, 30F), "Push to Amadeus")) {
            ScoreFlashManager.Get("SF_Amadeus").PushLocal("Amadeus, yay!");
        }

        if (GUI.Button(new Rect(Screen.width - 180F, 50F, 170F, 30F), "Push to Destroy")) {
            ScoreFlashManager.Get("SF_Destroy").PushLocal("Destroy, you see?");
        }

        if (GUI.Button(new Rect(Screen.width - 180F, 90F, 170F, 30F), "Push to Eraser")) {
            ScoreFlashManager.Get("SF_Eraser").PushLocal("Eraser, play with me!");
        }

     }
 }
See Also