Pufferfiz

Sprite Flasher

Apr 10th, 2014
289
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using UnityEngine;
  2. using System.Collections;
  3.  
  4. //@Made by Pufferfiz
  5. /// <summary>
  6. /// Flasher.
  7. /// </summary>
  8. public class Flasher {
  9.  
  10.     /// <summary>
  11.     /// Action Turn Sprite White
  12.     /// </summary>
  13.     private static System.Action<object> ActionTurnWhite = new System.Action<object> (TurnWhite);
  14.     /// <summary>
  15.     /// Action Turn Sprite back to full color.
  16.     /// </summary>
  17.     private static System.Action<object> ActionTurnColor = new System.Action<object> (TurnColor);
  18.  
  19.     /// <summary>
  20.     /// Flash the specified inObj. MUST USE FLASH ENABLED SHADER
  21.     /// </summary>
  22.     /// <param name="inObj">In object.</param>
  23.     static public void Flash ( GameObject inObj, float Speed)
  24.     {
  25.        
  26.         LeanTween.value(inObj,Vector2.zero,new Vector2(0,1),Speed).setOnComplete (ActionTurnWhite, inObj);
  27.         LeanTween.value(inObj,Vector2.zero,new Vector2(0,1),Speed).setDelay(Speed * 2 + (Speed/2.0f)).setOnComplete (ActionTurnColor, inObj);
  28.         LeanTween.value(inObj,Vector2.zero,new Vector2(0,1),Speed).setDelay(Speed * 3 + (Speed/2.0f)).setOnComplete (ActionTurnWhite, inObj);
  29.         LeanTween.value(inObj,Vector2.zero,new Vector2(0,1),Speed).setDelay(Speed * 4 + (Speed/2.0f)).setOnComplete (ActionTurnColor, inObj);
  30.         //Can be modified to make it flash more or less.
  31.     }
  32.  
  33.     /// <summary>
  34.     /// Turns the sprite white.
  35.     /// </summary>
  36.     /// <param name="obj">Object.</param>
  37.     static public void TurnWhite(object obj)
  38.     {
  39.         GameObject temp = obj as GameObject;
  40.         temp.GetComponent<SpriteRenderer> ().material.SetInt ("_AltColorAmount", 1);
  41.     }
  42.     /// <summary>
  43.     /// Turns the sprite full color.
  44.     /// </summary>
  45.     /// <param name="obj">Object.</param>
  46.     static public void TurnColor(object obj)
  47.     {
  48.         GameObject temp = obj as GameObject;
  49.         temp.GetComponent<SpriteRenderer> ().material.SetInt ("_AltColorAmount", 0);
  50.     }
  51. }
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×