ColorFlashManager#
- NAMESPACE:
UnityUtils.ScriptUtils.Objects.ColorFlash
Apply a ColorFlashManager script to an object and call its functions to flash it a certain color for a certain time. It works by changing the material of the specified object and changing the new materials color, then switching back to the default material after its done.
Warning
Do not modify a objects material while flashing, as it may interfere with the flashing. You can check if an object is flashing by calling IsFlashing().
Example Usage#
using UnityEngine;
using UnityUtils.ScriptUtils.Objects.ColorFlash;
public class ExampleScript : MonoBehaviour
{
public ColorFlashManager object;
public Material otherMat;
void Start()
{
// Flashes the applied using its default flash
object.Flash();
// Create a new color flash and set the duration to 2 seconds and the color to red
ColorFlash flash = ColorFlash.CreateDefaultFlash();
flash.durationSeconds = 2;
flash.color = Color.red;
object.Flash(flash);
// Set the original material that is switched to after flashing
object.SetOriginalMaterial(otherMat);
// Check if the object is currently flashing
bool isFlashing = object.IsFlashing();
}
}
Warning
ColorFlashManager only currently works with SpriteRenderers, but other compatibility is coming soon.
Functions#
- UnityUtils.ScriptUtils.Objects.ColorFlash.ColorFlashManager : MonoBehaviour
Public Functions
-
bool IsFlashing()#
Determines whether a flashing operation is currently active.
- Returns:
true if the object is flashing; otherwise, false.
-
void SetOriginalMaterial(Material mat)#
Sets the material that is switched back to after a flash is finished.
- Parameters:
mat – Material to switch originalMaterial to
-
Coroutine Flash(ColorFlash colorFlash)#
Flashes the object using the provided ColorFlash variables. If a flash is already active, a warning is logged and no new flash is started.
- Parameters:
colorFlash – The color flash to use when flashing
- Returns:
The coroutine started by the flash
-
Coroutine Flash()#
Calls Flash(ColorFlash) using the default colorFlash variables.
- Returns:
The coroutine started by the flash
Public Members
-
ColorFlash colorFlash = ColorFlash.CreateDefaultFlash()#
The default ColorFlash to use when flashing.
-
bool logFlash = false#
If true, will Debug.Log the color and duration when flashing.
-
bool IsFlashing()#