示例#1
0
    void Awake()
    {
        UpgradeCheck(); // if necessary during runtime: do the upgrade "on-the-fly"

        // if we are a child of a ScoreFlashManager, that will handle singleton stuff for us :-)
        if (this.transform.parent != null && this.transform.parent.GetComponent<ScoreFlashManager>() != null) {
            ensureSingleton = false;
        }
        if (instance != null && ((ScoreFlash)instance) != this) {
            if (ensureSingleton && Application.isPlaying) { // don't do this in edit mode!
                Destroy(this.gameObject);
            }
            return;
        } else {
            instance = (IScoreFlash) this;
        }
        if (ensureSingleton && Application.isPlaying) { // don't do this in edit mode!
            DontDestroyOnLoad(this.gameObject);
        }
        #if SERVER
        this.enabled = false;
        #endif // SERVER
        if (skin == null && scoreFlashRenderer == null && font == null) {
            Debug.LogWarning(
                "You have not assigned a GUISkin or Score Flash Renderer or Font - you either need to assign one "
                +"or use a custom renderer or pass GUIStyles when pushing messages!",
                this);
        }
        if (rendering == RenderingType.UnityGUI_GUISkin) {
            if (skin != null && skin.FindStyle(guiStyleName) == null) {
                Debug.LogWarning(
                    string.Format("Your Skin does not have a custom style named '{0}'!", guiStyleName),
                    this.skin);
            }
            if (skinHighDensity != null && skinHighDensity.FindStyle(guiStyleName) == null) {
                Debug.LogWarning(
                    string.Format("Your Skin for High Density does not have a custom style named '{0}'!", guiStyleName),
                    this.skinHighDensity);
            }
        }
        if (Application.isPlaying && warmUpCount > 0 && rendering == RenderingType.CustomRenderer) {
            ScoreMessage msg = null;
            for (int i = 0; i < warmUpCount; i++) {
                msg = PushLocal(".");
                msg.MakeWarmUpMessage();
            }
            StartCoroutine(RemoveWarmupRenderers());
        }
    }
示例#2
0
 /// <summary>
 ///     When we are not in "Singleton-Mode" => clean up instance!
 /// </summary>
 void OnDestroy()
 {
     if (!ensureSingleton) {
         instance = null;
     }
 }
示例#3
0
 /// <summary>
 ///     For internal use only; this is used by the custom inspector GUI
 ///     to show the next ScoreFlash in testing mode.
 /// </summary>
 public void NextFlashInstanceForTesting()
 {
     if (scoreFlashTestInstances.Count == 0 || scoreFlashTestInstances[flashInstanceIndex] == null) {
         nextFlashInstanceForTestMessage = ScoreFlash.Instance;
         return;
     }
     nextFlashInstanceForTestMessage = null;
     for (int attempt = 0; attempt < scoreFlashTestInstances.Count && nextFlashInstanceForTestMessage == null; attempt++) {
         flashInstanceIndex++;
         flashInstanceIndex %= scoreFlashTestInstances.Count;
         nextFlashInstanceForTestMessage = scoreFlashTestInstances[flashInstanceIndex];
     }
     if (nextFlashInstanceForTestMessage == null) {
         nextFlashInstanceForTestMessage = ScoreFlash.Instance;
     }
     if (nextFlashInstanceForTestMessage == null) {
         Debug.LogError("You need at least one ScoreFlash instance in your scene!");
     }
 }