Skip to content
James Thomas edited this page Feb 25, 2018 · 3 revisions

Juice Docs

Note that several args in these methods are optional. I'll update these docs later - this is more or less a quick view into what's in Juice currently. While all of these are great, to be honest I use Juice.Instance.Delay() the most, it's just so useful in so many places.

UI

Blink

Usage: Blink(aGroup, aNumPulses, aTimeBetweenPulses, aTimeLitUp, aCallback)

Blinks a CanvasGroup a number of times.

Name Description
aGroup UnityEngine.CanvasGroup
A CanvasGroup
aNumPulses System.Int32
How many blinks to perform (-1 = infinite)
aTimeBetweenPulses System.Single
How long to pause between blinks
aTimeLitUp System.Single
How long to stay lit
aCallback System.Action
What logic to execute after the last blink, if any

FadeGroup

Usage: FadeGroup(aGroup, aTime, aTarget, aScaledTime, aCallback)

Fades a CanvasGroup to a target alpha.

Name Description
aGroup UnityEngine.CanvasGroup
The CanvasGroup
aTime System.Single
The time it should take
aTarget System.Single
The end alpha
aScaledTime System.Boolean
Should this be scaled with Time.TimeScale?
aCallback System.Action
Any logic to execute once the target state is reached

FadeInSprite

Usage: FadeInSprite(aSprite, aTime)

Fades a Sprite in.

Name Description
aSprite UnityEngine.SpriteRenderer
The Sprite
aTime System.Single
The time it should take

FadeOutSprite

Usage: FadeOutSprite(aSprite, aTime)

Fades a Sprite out.

Name Description
aSprite UnityEngine.SpriteRenderer
The Sprite
aTime System.Single
The time it should take

FadeSprite

Usage: FadeSprite(aSprite, aTime, aTarget)

Fades a Sprite to a target alpha.

Name Description
aSprite UnityEngine.SpriteRenderer
The Sprite
aTime System.Single
The time it should take
aTarget System.Single
The end alpha

FillImage

Usage: FillImage(aImage, aTime, aTargetValue, aCurve, aCallback)

Fills (or unfills) an image over time (think progress bars)

Name Description
aImage UnityEngine.UI.Image
An image to fill
aTime System.Single
How long this should take
aTargetValue System.Single
A target fill value
aCurve UnityEngine.AnimationCurve
An AnimationCurve to fill on
aCallback System.Action
What to do at the end, if anything

LerpSpriteColor

Usage: LerpSpriteColor(aSprite, aTime, aTarget, aScaledTime, aCallback)

Lerps a sprite's color to a target color over time.

Name Description
aSprite UnityEngine.SpriteRenderer
The spriterenderer
aTime System.Single
How long should this take?
aTarget UnityEngine.Color
What color are we going to?
aScaledTime System.Boolean
Should this be affected by scaled time?
aCallback System.Action
Now what?

Stretch

Usage: Stretch(aRect, aTime, aSize, aCurve, aCallback)

Stretch a RectTransform to a specified size over time

Name Description
aRect UnityEngine.RectTransform
The RectTransform to me stretched
aTime System.Single
The time it should take to complete
aSize UnityEngine.Vector2
A size: Vector2(width,height)
aCurve UnityEngine.AnimationCurve
How should the animation look?
aCallback System.Action
Should anything happen after we finish?

Tween

Usage: Tween(aRect, aTime, aDistance, aCurve, aCallback)

Tween moves a RectTransform a certain distance in a certain time.

Name Description
aRect UnityEngine.RectTransform
The RectTransform to me moved
aTime System.Single
The time it should take to complete
aDistance UnityEngine.Vector2
A distance: Vector2(width,height)
aCurve UnityEngine.AnimationCurve
How should the animation look?
aCallback System.Action
Should anything happen after we finish?

MoveSlider

Usage: MoveSlider(aSlider, aTime, aTargetValue, aCurve, aCallback)

Slides a Slider object to a specified value over X time

Name Description
aSlider UnityEngine.UI.Slider
The slider to move
aTime System.Single
How long should this process take?
aTargetValue System.Single
Where should the slider land?
aCurve UnityEngine.AnimationCurve
What type of animation should we apply?
aCallback System.Action
Anything to perform after it's all over (if anything)

NumberCounter

Usage: NumberCounter(aText, aStartingNumber, aModifierNumber, aTime, aScale, aScaledTime, aCallback)

Quickly increase a Text element's number value

Name Description
aText UnityEngine.UI.Text
The text element
aStartingNumber System.Int32
The starting number
aModifierNumber System.Int32
The amount to increase or decrease aStartingNumber by
aTime System.Single
How long should this take?
aScale UnityEngine.AnimationCurve
Should we change the size over time?
aScaledTime System.Boolean
Should this be affected by scaled time?
aCallback System.Action
Now what?

PulseGroup

Usage: PulseGroup(aGroup, aRepeatTime, aLowAlpha, aHighAlpha, aUp, aTime)

Pulses a CanvasGroup by fading it's alpha in and out

Name Description
aGroup UnityEngine.CanvasGroup
The CanvasGroup
aRepeatTime System.Single
How long should one entire pulse take?
aLowAlpha System.Single
How transparent is the group at it's lowest point?
aHighAlpha System.Single
How transparent is the group at it's highest point?
aUp System.Boolean
Set to true start the pulse on an "up" beat
aTime System.Single
How long do we pulse for? (0 = infinity)

ResizeLayoutElement

Usage: ResizeLayoutElement(aElement, aSize, aTime, aCurve, aCallback)

Currently used to resize a Unity UI LayoutElement Vertically.

Name Description
aElement UnityEngine.UI.LayoutElement
LayoutElement to resize
aSize System.Single
How tall should it become?
aTime System.Single
How long should it take?
aCurve UnityEngine.AnimationCurve
How should it look?
aCallback System.Action
What should happen after we're done, if anything?

Rotate

Usage: Rotate(aRect, aTime, aRotationAmount, aDirection, aCurve, aCallback)

Rotates the object a number of degrees in a specified direction.

Name Description
aRect UnityEngine.RectTransform
The RectTransform to be rotated
aTime System.Single
The time it should take to complete
aRotationAmount UnityEngine.Vector3
In how many euler angles to rotate
aDirection System.Int32
should we rotate positive or negative (i.e., right or left)
aCurve UnityEngine.AnimationCurve
How should the animation look?
aCallback System.Action
Should anything happen after we finish?

Utilities

Delay

Usage: Delay(aTime, aCallback, aCaller)

Delays a delegated action.

Name Description
aTime System.Single
How long to wait before executing the action
aCallback System.Action
What logic to execute after the delay
aCaller UnityEngine.Object
Pass in a caller to prevent the callback from invoking if the caller is destroyed during the delay

FadeVolume

Usage: FadeVolume(aSource, aTime, aVolume, aCurve, aCallback)

Fades the volume on an AudioSource over time

Name Description
aSource UnityEngine.AudioSource
An AudioSource to fade
aTime System.Single
How long the fade should take
aVolume System.Single
A target volume
aCurve UnityEngine.AnimationCurve
Optionally, an AnimationCurve to fade the volume through
aCallback System.Action
What happens after we're finished fading, if anything?

LerpMaterialProptery

Usage: LerpMaterialProptery(aMaterial, aTime, aTarget, aPropertyType, aPropertyName, aTargetColor, aTargetValue, aScaledTime, aCallback)

Lerps a material's color to a target color over time.

Name Description
aMaterial UnityEngine.Material
The material instance
aTime System.Single
How long should this take?
aTarget Juice.MaterialPropertyType
What color are we going to?
aPropertyType System.String
What is the property's type?
aPropertyName UnityEngine.Color
What is the property's name?
aTargetColor System.Single
If it's a color, what color are we going to
aTargetValue System.Boolean
If it's a float, what float are we going to
aScaledTime UnityEngine.AnimationCurve
Should this be affected by scaled time?
aCallback System.Action
Now what?

Transforms

ApplyForce

Usage: ApplyForce(aTransform, aTime, aPos, aLocalPos, aCurve, aCallback)

Moves a transform to any given position over a specified time, but respects other forces of movement, unlike MoveTo

Name Description
aTransform UnityEngine.Transform
The transform to move
aTime System.Single
How long it should take to complete the move
aPos UnityEngine.Vector3
A position to end up at, relative to the start pos
aLocalPos System.Boolean
Should we use transform.localPosition? If false, this will use transform.position.
aCurve UnityEngine.AnimationCurve
How should it look?
aCallback System.Action
What should happen after we're done, if anything?

MoveTo

Usage: MoveTo(aTransform, aTime, aPos, aLocalPos, aCurve, aCallback)

Moves a transform to any given position over a specified time

Name Description
aTransform UnityEngine.Transform
The transform to move
aTime System.Single
How long it should take to complete the move
aPos UnityEngine.Vector3
Where should we move this transform to?
aLocalPos System.Boolean
Should we use transform.localPosition? If false, this will use transform.position.
aCurve UnityEngine.AnimationCurve
How should it look?
aCallback System.Action
What should happen after we're done, if anything?

Scale

Usage: Scale(aTransform, aScale, aTime, aCurve, aCallback)

Scales the transform to it's current scale plus aScale

Name Description
aTransform UnityEngine.Transform
The transform to scale
aScale UnityEngine.Vector3
How much should we scale this transform ("Ex new Vector3(1,1,1) will add to it's scale by 1)
aTime System.Single
The time it takes to scale
aCurve UnityEngine.AnimationCurve
A curve to follow
aCallback System.Action
What to do at the end, if anything

Spin

Usage: Spin(aTransform, aTime, aSpeed, aAxis, aCurve, aScaledTime, aCallback)

Spin a transform on any axis!

Name Description
aTransform UnityEngine.Transform
A transform to spin
aTime System.Single
How long do we spin for?
aSpeed System.Single
How fast should we spin?
aAxis UnityEngine.Vector3
A vector3 axis to spin on
aCurve UnityEngine.AnimationCurve
An animationCurve to spin on
aScaledTime System.Boolean
Should this respect scaled time?
aCallback System.Action
What to do at the end, if anything