EasyTalk API
Loading...
Searching...
No Matches
EasyTalk.Animation.UIAnimator Class Reference

The UIAnimator can be used to animate UI components with fading or sliding animations. More...

Public Types

enum  SlideDirection {
  NONE , LEFT , RIGHT , UP ,
  DOWN
}
 An enum of possible slide animation directions. More...
 
enum  Animation {
  NONE , SLIDE_LEFT , SLIDE_RIGHT , SLIDE_UP ,
  SLIDE_DOWN , FADE
}
 An enum of supported animation types. More...
 

Static Public Member Functions

static bool IsItemAnimating (int id)
 Returns true if the specified UI element is currently being animated.
 
static bool IsItemAnimating (GameObject gameObject)
 Returns true if the specified GameObject is currently being animated.
 
static IEnumerator FadeText (Text text, float duration, float finalAlpha, AnimationCurve curve=null)
 Fades text to a specified alpha value over the specified time period.
 
static void FadeTextImmediately (Text text, float finalAlpha)
 Fade text to a specified alpha value immediately.
 
static IEnumerator FadeTextIn (Text text, float duration, AnimationCurve curve=null)
 Fade text in to its original alpha value. (This assumes that the original alpha value is stored)
 
static void FadeTextInImmediately (Text text)
 Fades text in to its original alpha value immediately.
 
static IEnumerator FadeTextOut (Text text, float duration, AnimationCurve curve=null)
 Fades text out to be completely transparent over a specified duration.
 
static void FadeTextOutImmediately (Text text)
 Fades text out to be completely transparent immediately.
 
static IEnumerator FadeImage (Image image, float duration, float finalAlpha, AnimationCurve curve=null)
 Fades an image to a specified alpha value over time.
 
static void FadeImageImmediately (Image image, float finalAlpha)
 Fades an image to the specified alpha value immediately.
 
static IEnumerator FadeImageIn (Image image, float duration, AnimationCurve curve=null)
 Fades an image in to its original alpha value. (This assumes that the original alpha value is stored)
 
static void FadeImageInImmediately (Image image)
 Fades an image in to its stored alpha value immediately.
 
static IEnumerator FadeImageOut (Image image, float duration, AnimationCurve curve=null)
 Fades an image out to be completely transparent over a specified duration.
 
static void FadeImageOutImmediately (Image image)
 Fades an image out to be completely transparent immediately.
 
static IEnumerator Fade (GameObject gameObject, float duration, float finalAlpha, AnimationCurve curve=null)
 Fades all text and image components which are components of, or child components of the specified GameObject to an alpha value over a specified duration.
 
static void FadeImmediately (GameObject gameObject, float finalAlpha)
 Immediately fades all text and image elements which are components of, or child components of the specified GameObject to the specified alpha value.
 
static void ClearStoredAlpha (int instanceID)
 Clears the stored alpha values for the specified instance ID.
 
static void ClearStoredAlphas (GameObject gameObject)
 Clears the stored alpha values for all components and child components of the specified GameObject.
 
static void ClearAllStoredAlphas ()
 Clears all stored alpha values.
 
static IEnumerator FadeIn (GameObject gameObject, float duration, AnimationCurve curve=null)
 Fades in the components and child components of the specified GameObject to their original stored alpha values over the specified duration.
 
static void FadeInImmediately (GameObject gameObject)
 Fades in all text and image components and child components of the specified GameObject to their original stored alpha values immediately.
 
static IEnumerator FadeOut (GameObject gameObject, float duration, AnimationCurve curve=null)
 Fades out all text and image components and child components of the specified GameObject to be completely transparent over the specified duration.
 
static void FadeOutImmediately (GameObject gameObject)
 Fades out all text and image components and child components of the specified GameObject to be completely transparent immediately.
 
static void StoreOriginalOpacities (GameObject gameObject)
 Stores opacity values for each text and image component in the specified GameObject.
 
static IEnumerator SlideInComponent (Canvas canvas, RectTransform transform, float duration, AnimationCurve curve=null, float margin=0.0f)
 Slides the specified RectTransform into a Canvas' bounds over a specified period of time.
 
static void SlideInComponentImmediately (Canvas canvas, RectTransform transform, float margin=0.0f)
 Slides the specified RectTransform into a Canvas' bounds immediately.
 
static IEnumerator SlideOutComponent (Canvas canvas, RectTransform transform, SlideDirection direction, float duration, AnimationCurve curve=null)
 Slides the specified RectTransform out of a Canvas' bounds over a specified period of time.
 
static void SlideOutComponentImmediately (Canvas canvas, RectTransform transform, SlideDirection direction)
 Slides the specified RectTransform out of a Canvas' bounds immediately.
 
static IEnumerator SlideComponentToPosition (RectTransform transform, Vector3 newPos, float duration, AnimationCurve curve=null)
 Slides the specified RectTransform to a position over the specified duration.
 
static void SlideComponentToPositionImmediately (RectTransform transform, Vector3 newPos)
 Slides the specified RectTransform to a position immediately.
 
static UIAnimator.SlideDirection GetSlideDirection (UIAnimator.Animation animation)
 Returns the corresponding SlideDirection associated with the specified Animation type.
 

Static Public Attributes

static Dictionary< int, int > itemsAnimationCounter = new Dictionary<int, int>()
 Mapping used to keep track of the number of animations running for a given UI element.
 

Static Private Member Functions

static void StartingItemAnimation (int id)
 Increments the running animation counter for the specified ID.
 
static void FinishedItemAnimation (int id)
 Decrements the running animation counter for the specified ID.
 
static float GetOriginalOpacity (int instanceId)
 Returns the original opacity value which is stored for the specified instance ID, or a value of 1.0 if no stored value is found.
 
static void StoreOriginalOpacity (Object obj, float opacity)
 Stores an opacity value for the specified object instance.
 
static Vector3 FindPositionToHide (Canvas canvas, RectTransform transform, SlideDirection direction)
 Calculates the position to move the specified RectTransform to in order for it to be hidden and outside of the Canvas provided.
 
static Vector3 FindPositionToShow (Canvas canvas, RectTransform transform, float margin=0.0f)
 Calculates the position to move the specified RectTransform to in order for it to be shown inside the Canvas provided.
 

Static Private Attributes

static Dictionary< int, float > storedElementAlphas = new Dictionary<int, float>()
 A mapping of component instance IDs to the original alpha values of various UI elements.
 

Detailed Description

The UIAnimator can be used to animate UI components with fading or sliding animations.

Member Enumeration Documentation

◆ Animation

An enum of supported animation types.

Enumerator
NONE 
SLIDE_LEFT 
SLIDE_RIGHT 
SLIDE_UP 
SLIDE_DOWN 
FADE 

◆ SlideDirection

An enum of possible slide animation directions.

Enumerator
NONE 
LEFT 
RIGHT 
UP 
DOWN 

Member Function Documentation

◆ ClearAllStoredAlphas()

static void EasyTalk.Animation.UIAnimator.ClearAllStoredAlphas ( )
static

Clears all stored alpha values.

◆ ClearStoredAlpha()

static void EasyTalk.Animation.UIAnimator.ClearStoredAlpha ( int instanceID)
static

Clears the stored alpha values for the specified instance ID.

Parameters
instanceIDThe instance ID of the component or GameObject to clear.

◆ ClearStoredAlphas()

static void EasyTalk.Animation.UIAnimator.ClearStoredAlphas ( GameObject gameObject)
static

Clears the stored alpha values for all components and child components of the specified GameObject.

Parameters
gameObjectThe GameObject to clear stored alpha values for.

◆ Fade()

static IEnumerator EasyTalk.Animation.UIAnimator.Fade ( GameObject gameObject,
float duration,
float finalAlpha,
AnimationCurve curve = null )
static

Fades all text and image components which are components of, or child components of the specified GameObject to an alpha value over a specified duration.

Parameters
gameObjectThe GameObject to fade.
durationThe duration of the fade animation, in seconds.
finalAlphaThe final desired alpha value for the components being faded.
curveAn animation curve used to control the animation timing.
Returns

◆ FadeImage()

static IEnumerator EasyTalk.Animation.UIAnimator.FadeImage ( Image image,
float duration,
float finalAlpha,
AnimationCurve curve = null )
static

Fades an image to a specified alpha value over time.

Parameters
imageThe image to animate.
durationThe duration of the fade animation, in seconds.
finalAlphaThe final alpha value to fade to.
curveAn animation curve used to control the animation timing.
Returns

◆ FadeImageImmediately()

static void EasyTalk.Animation.UIAnimator.FadeImageImmediately ( Image image,
float finalAlpha )
static

Fades an image to the specified alpha value immediately.

Parameters
imageThe image to fade.
finalAlphaThe final alpha value to use.

◆ FadeImageIn()

static IEnumerator EasyTalk.Animation.UIAnimator.FadeImageIn ( Image image,
float duration,
AnimationCurve curve = null )
static

Fades an image in to its original alpha value. (This assumes that the original alpha value is stored)

Parameters
imageThe image to fade in.
durationThe duration of the fade in animation, in seconds.
curveThe animation curve used to control the animation timing.
Returns

◆ FadeImageInImmediately()

static void EasyTalk.Animation.UIAnimator.FadeImageInImmediately ( Image image)
static

Fades an image in to its stored alpha value immediately.

Parameters
imageThe image to fade in.

◆ FadeImageOut()

static IEnumerator EasyTalk.Animation.UIAnimator.FadeImageOut ( Image image,
float duration,
AnimationCurve curve = null )
static

Fades an image out to be completely transparent over a specified duration.

Parameters
imageThe image to fade out.
durationThe duration of the animation in seconds.
curveAn animation curve used to control the animation timing.
Returns

◆ FadeImageOutImmediately()

static void EasyTalk.Animation.UIAnimator.FadeImageOutImmediately ( Image image)
static

Fades an image out to be completely transparent immediately.

Parameters
imageThe image to make transparent.

◆ FadeImmediately()

static void EasyTalk.Animation.UIAnimator.FadeImmediately ( GameObject gameObject,
float finalAlpha )
static

Immediately fades all text and image elements which are components of, or child components of the specified GameObject to the specified alpha value.

Parameters
gameObjectThe GameObject to fade.
finalAlphaThe final desired alpha value.

◆ FadeIn()

static IEnumerator EasyTalk.Animation.UIAnimator.FadeIn ( GameObject gameObject,
float duration,
AnimationCurve curve = null )
static

Fades in the components and child components of the specified GameObject to their original stored alpha values over the specified duration.

Parameters
gameObjectThe GameObject to fade in.
durationThe duration of the fade in animation, in seconds.
curveAn animation curve used to control the animation timing.
Returns

◆ FadeInImmediately()

static void EasyTalk.Animation.UIAnimator.FadeInImmediately ( GameObject gameObject)
static

Fades in all text and image components and child components of the specified GameObject to their original stored alpha values immediately.

Parameters
gameObjectThe GameObject to fade in.

◆ FadeOut()

static IEnumerator EasyTalk.Animation.UIAnimator.FadeOut ( GameObject gameObject,
float duration,
AnimationCurve curve = null )
static

Fades out all text and image components and child components of the specified GameObject to be completely transparent over the specified duration.

Parameters
gameObjectThe GameObject to fade out.
durationThe duration of the fade out animation, in seconds.
curveAn animation curve used to control the animation timing.
Returns

◆ FadeOutImmediately()

static void EasyTalk.Animation.UIAnimator.FadeOutImmediately ( GameObject gameObject)
static

Fades out all text and image components and child components of the specified GameObject to be completely transparent immediately.

Parameters
gameObjectThe GameObject to fade out.

◆ FadeText()

static IEnumerator EasyTalk.Animation.UIAnimator.FadeText ( Text text,
float duration,
float finalAlpha,
AnimationCurve curve = null )
static

Fades text to a specified alpha value over the specified time period.

Parameters
textThe text element to animate the alpha value of.
durationThe duration, in seconds, to spend animating the text.
finalAlphaThe final alpha value desired for the text.
curveAn animation curve controlling how quickly the text is faded.
Returns

◆ FadeTextImmediately()

static void EasyTalk.Animation.UIAnimator.FadeTextImmediately ( Text text,
float finalAlpha )
static

Fade text to a specified alpha value immediately.

Parameters
textThe text element to fade.
finalAlphaThe final alpha value.

◆ FadeTextIn()

static IEnumerator EasyTalk.Animation.UIAnimator.FadeTextIn ( Text text,
float duration,
AnimationCurve curve = null )
static

Fade text in to its original alpha value. (This assumes that the original alpha value is stored)

Parameters
textThe text element to fade in.
durationThe duration of the fade in animation in seconds.
curveThe animation curve used to control the animation timing.
Returns

◆ FadeTextInImmediately()

static void EasyTalk.Animation.UIAnimator.FadeTextInImmediately ( Text text)
static

Fades text in to its original alpha value immediately.

Parameters
textThe text element to fade in.

◆ FadeTextOut()

static IEnumerator EasyTalk.Animation.UIAnimator.FadeTextOut ( Text text,
float duration,
AnimationCurve curve = null )
static

Fades text out to be completely transparent over a specified duration.

Parameters
textThe text element to fade out.
durationThe duration of the animation, in seconds.
curveThe animation curve used to control the animation timing.
Returns

◆ FadeTextOutImmediately()

static void EasyTalk.Animation.UIAnimator.FadeTextOutImmediately ( Text text)
static

Fades text out to be completely transparent immediately.

Parameters
textThe text element to fade out.

◆ FindPositionToHide()

static Vector3 EasyTalk.Animation.UIAnimator.FindPositionToHide ( Canvas canvas,
RectTransform transform,
SlideDirection direction )
staticprivate

Calculates the position to move the specified RectTransform to in order for it to be hidden and outside of the Canvas provided.

Parameters
canvasThe Canvas which the RectTransform should be hidden in.
transformThe RectTransform to hide.
directionThe direction to slide the RectTransform in when hiding it.
Returns
The position to move the RectTransform to so that it is hidden.

◆ FindPositionToShow()

static Vector3 EasyTalk.Animation.UIAnimator.FindPositionToShow ( Canvas canvas,
RectTransform transform,
float margin = 0::0f )
staticprivate

Calculates the position to move the specified RectTransform to in order for it to be shown inside the Canvas provided.

Parameters
canvasThe Canvas which the RectTransform should be shown in.
transformThe RectTransform to show.
marginAn option margin offset.
Returns
The position which the RectTransform should be moved to in order to show it.

◆ FinishedItemAnimation()

static void EasyTalk.Animation.UIAnimator.FinishedItemAnimation ( int id)
staticprivate

Decrements the running animation counter for the specified ID.

Parameters
idThe isntance ID of the object an animation is ending on.

◆ GetOriginalOpacity()

static float EasyTalk.Animation.UIAnimator.GetOriginalOpacity ( int instanceId)
staticprivate

Returns the original opacity value which is stored for the specified instance ID, or a value of 1.0 if no stored value is found.

Parameters
instanceIdThe instance ID to retrieve a stored opacity value for.
Returns
The original opacity value of the specified instance ID, or 1.0 if no value is stored.

◆ GetSlideDirection()

static UIAnimator.SlideDirection EasyTalk.Animation.UIAnimator.GetSlideDirection ( UIAnimator::Animation animation)
static

Returns the corresponding SlideDirection associated with the specified Animation type.

Parameters
animationThe animation type to get a slide direction for.
Returns
The associated slide direction for the specified animation, or NONE if there is none.

◆ IsItemAnimating() [1/2]

static bool EasyTalk.Animation.UIAnimator.IsItemAnimating ( GameObject gameObject)
static

Returns true if the specified GameObject is currently being animated.

Parameters
gameObjectThe GameObject to check.
Returns
Whether the specified GameObject is animating.

◆ IsItemAnimating() [2/2]

static bool EasyTalk.Animation.UIAnimator.IsItemAnimating ( int id)
static

Returns true if the specified UI element is currently being animated.

Parameters
idThe instance ID of the UI element to check.
Returns
Whether the specified UI element is animating.

◆ SlideComponentToPosition()

static IEnumerator EasyTalk.Animation.UIAnimator.SlideComponentToPosition ( RectTransform transform,
Vector3 newPos,
float duration,
AnimationCurve curve = null )
static

Slides the specified RectTransform to a position over the specified duration.

Parameters
transformThe RectTransform to slide.
newPosThe position to move the RectTransform to.
durationThe duration of the animation.
curveAn animation curve used to control the animation timing.
Returns

◆ SlideComponentToPositionImmediately()

static void EasyTalk.Animation.UIAnimator.SlideComponentToPositionImmediately ( RectTransform transform,
Vector3 newPos )
static

Slides the specified RectTransform to a position immediately.

Parameters
transformThe RectTransform to slide.
newPosThe position to move the RectTransform to.

◆ SlideInComponent()

static IEnumerator EasyTalk.Animation.UIAnimator.SlideInComponent ( Canvas canvas,
RectTransform transform,
float duration,
AnimationCurve curve = null,
float margin = 0::0f )
static

Slides the specified RectTransform into a Canvas' bounds over a specified period of time.

Parameters
canvasThe Canvas which the transform should slide into.
transformThe RectTransform of the component to slide in.
durationThe duration of the slide animation.
curveAn animation curve used to control the animation timing.
marginAn optional additional margin offset for the final slide in position.
Returns

◆ SlideInComponentImmediately()

static void EasyTalk.Animation.UIAnimator.SlideInComponentImmediately ( Canvas canvas,
RectTransform transform,
float margin = 0::0f )
static

Slides the specified RectTransform into a Canvas' bounds immediately.

Parameters
canvasThe Canvas which the transform should slide into.
transformThe RectTransform of the component to slide in.
marginAn optional additional margin offset for the final slide in position.

◆ SlideOutComponent()

static IEnumerator EasyTalk.Animation.UIAnimator.SlideOutComponent ( Canvas canvas,
RectTransform transform,
SlideDirection direction,
float duration,
AnimationCurve curve = null )
static

Slides the specified RectTransform out of a Canvas' bounds over a specified period of time.

Parameters
canvasThe Canvas which the transform should slide out of.
transformThe RectTransform of the component to slide out.
directionThe direction that the component should slide out.
durationThe duration of the animation, in seconds.
curveAn animation curve used to control the animation timing.
Returns

◆ SlideOutComponentImmediately()

static void EasyTalk.Animation.UIAnimator.SlideOutComponentImmediately ( Canvas canvas,
RectTransform transform,
SlideDirection direction )
static

Slides the specified RectTransform out of a Canvas' bounds immediately.

Parameters
canvasThe Canvas which the transform should slide out of.
transformThe RectTransform of the component to slide out.
directionThe direction that the component should slide out.

◆ StartingItemAnimation()

static void EasyTalk.Animation.UIAnimator.StartingItemAnimation ( int id)
staticprivate

Increments the running animation counter for the specified ID.

Parameters
idThe instance ID of the object an animation is starting on.

◆ StoreOriginalOpacities()

static void EasyTalk.Animation.UIAnimator.StoreOriginalOpacities ( GameObject gameObject)
static

Stores opacity values for each text and image component in the specified GameObject.

Parameters
gameObjectThe GameObject to store opacity values of.

◆ StoreOriginalOpacity()

static void EasyTalk.Animation.UIAnimator.StoreOriginalOpacity ( Object obj,
float opacity )
staticprivate

Stores an opacity value for the specified object instance.

Parameters
objThe object to store an opacity value of.
opacityThe opacity value to store.

Member Data Documentation

◆ itemsAnimationCounter

Dictionary<int, int> EasyTalk.Animation.UIAnimator.itemsAnimationCounter = new Dictionary<int, int>()
static

Mapping used to keep track of the number of animations running for a given UI element.

◆ storedElementAlphas

Dictionary<int, float> EasyTalk.Animation.UIAnimator.storedElementAlphas = new Dictionary<int, float>()
staticprivate

A mapping of component instance IDs to the original alpha values of various UI elements.