Sprite Factory

ReadMe
Release Notes
Overview
Using the Editor
Upgrading

Concepts
Sprites
Master Sprites
Sprite Groups
Colliders
Locators
Material Sets
SpriteUpdater
SpriteCamera

Advanced
Working in Multiple Projects

Classes
Runtime Classes

Videos
Overview
Creating Sprites
Sprite Inspector
Frame Events
Collision System
Locator System
Material Sets

Links
Sprite Factory Site
Web Documentation
Support
Contact

SpriteFactory.Sprite

Namespace: SpriteFactory
Inherits from MonoBehaviour

This component is the main Sprite class responsible for displaying and animating the sprite and spawning and manipulating generated colliders and locators. This class contains everything for in-game Sprite control.

NOTE: In Unity 4.3+, you must explicitly type SpriteFactory.Sprite every time you use the Sprite class to avoid conflicts with Unity's Sprite class.

See Sprites for more information about Sprites in general.

Variables

       
Name   Type   Description
selfUpdate   bool   True = Sprite runs Update() on itself to drive animation.
spriteUpdater   SpriteUpdater   The SpriteUpdater assigned to run the update cycle on this Sprite.
playAnimationOnStart   bool   True = Sprite begins playing the default animation on Start()
playDefaultAnimWhenIdle   bool   True = Sprite plays the default animation whenever no animation is being played.
playbackSpeed   float   Animation playback speed. (0 - infinity)
animateOffCamera   bool   True = Continue animating when not visible by any camera.
defaultAnimationOverride   int   Overrides the MasterSprite's default animation with an animation in this Sprite at the index.
currentMaterialSetIndex   int   The index of the current material set.
materialOverride   Material   Overrides the material on the Sprite.
isBillboard   bool   True = Sprite is a billboard sprite.
billboardUpAxis   Sprite.BillboardUpAxis   The up hint axis for the billboad Sprite.
useBatchScaling   bool   True = Scale Sprite by modifying the mesh instead of using transform scale.
scaleToActualPixelSize   bool   True = Scale Sprite so that 1 texel equals 1 screen pixel. *(See SpriteCamera if you want to render all Sprites at actual pixel size.)
activateLocatorsRecursively   bool   True = Activate/deactivate locator children recusively when activated/deactivated.
         

Properties

       
Name   Type   Description
masterSprite   GameMasterSprite   The Master Sprite parent of this sprite. (Read-only)
isStaticSprite   bool   Is the Sprite static or animated? (Read-only)
isActive
  bool   Is the Sprite active? (Read-only)
isPlaying   bool   Is an animation playing? (Read-only)
isPaused   bool   Is playback paused? (Read-only)
isVisible   bool   Is the Sprite visible to any camera? (Read-only)
isFlipped   bool   Is the Sprite flipped on an axis? (Read-only)
isFlippedX   bool   Is the Sprite flipped horizontally? (Read-only)
isFlippedY   bool   Is the Sprite flipped vertically? (Read-only)
animationCount   int   Number of animations. (Read-only)
materialSetCount   int   Number of material sets. (Read-only)
colliderCount   int   Number of colliders. (Read-only)
locatorCount   int   Number of locators. (Read-only)
meshBounds   Bounds   Bounds of the currently displayed mesh. (Read-only)
currentAnimation   string   Name of the current animation. (Read-only)
currentAnimationIndex   int   Index of the current animation. (Read-only)
currentFrameIndex   int   Index of the current frame in the current animation. (Read-only)
defaultAnimation   string   Name of the default animation.
defaultAnimationIndex   int   Index of the default animation.
currentAnimationSpeed   float   Playback speed of the current animation.
currentAnimationFrameCount   int   The number of frames in the current animation.
batchScale   Vector3   The scale when useBatchScaling = True.
sortingLayerID   int   The ID of the sorting layer this Sprite will be drawn on. (Unity 4.3+)
sortingLayerName   string   The name of the sorting layer this Sprite will be drawn on. (Unity 4.3+)
sortingOrder   int   The render order within the current sorting layer. (Unity 4.3+)
castShadows   bool   Does the Sprite cast shadows?
shadowCastingMode   ShadowCastingMode   The Sprite shadow casting mode. (Unity 5+)
receiveShadows   bool   Does the Sprite receive shadows?
spriteMaterial   SpriteMaterial   Helps you modify materials and shaders on the Sprite. Useful for animating shader properties for effects. (Read-only)

 

Functions

Animation Functions    
Name   Description
Play   Play an animation.
PlayAtFrame   Play an animation at a specific frame.
PlayDefaultAnimation   Play the default animation.
Stop   Stop playing animation.
Pause   Pause animation playback.
Unpause   Unpause animation playback.
Rewind   Rewind the current animation to the first frame.
Reverse   Reverse playback of currently playing animation.
IsAnimationPlaying   Check if an animation playing.
GetAnimationSpeed   Get the playback speed of an animation.
SetAnimationSpeed   Set the playback speed of an animation.
SetAnimationStartedCallback   Assign a callback to run when an animation starts playing.
SetAnimationFinishedCallback   Assign a callback to run when an animation finishes playing.
SetAnimationEndedCallback   Assign a callback to run when an animation ends playing even if it has not finished.
GetAnimationWrapMode   Get the wrap mode of an animation.
GetAnimationFrameCount   Get the number of frames in an animation.
     
Other Functions    
UpdateSprite   The main Sprite update function that updates animation.
ChangeMaterialSet   Change the current material set.
SetMaterialOverride   Assign an override material and enable it.
EnableMaterialOverride   Switch to the override material if one has been set.
DisableMaterialOverride   Revert to original material.
Flip   Flip Sprite horizontally and/or vertically.
FlipX   Flip Sprite horizontally.
FlipY   Flip Sprite vertically.
SetFlippedState   Set flipped states individually.
ScaleToActualPixelSize   Scale the Sprite so that 1 texel equals 1 pixel on screen. *(See SpriteCamera if you want to render all Sprites at actual pixel size.)
GetColliders   Get all colliders.
GetCollider   Get a specific collider.
GetRigidbody   Get a specific rigidbody.
GetLocator   Get a specific locator.
GetAnimationNames   Get all animation names.
GetMaterialSetNames   Get all material set names.
GetAnimationFrameCounts   Get all animation frame counts.
GetColliderNames   Get all collider names.
IgnoreCollisions   Ignore collisions with all generated colliders.
SetActiveRecursively   Set active state on Sprite and all children recursively.
SetSpriteUpdater   Register this Sprite with the SpriteUpdater.
SetUseBatchScaling   Enable/disable batch scaling.
     
Internal Use Functions   You should never need to call any of these functions.
GetEditorPreviewFrameData   Get data from the editor preview frame for use in custom inspector.
Render   Force the Sprite to update the current display mesh.
ColliderEnabled   Called when a child SpriteCollider is enabled.
LocatorEnabled   Called when a child SpriteLocator is enabled.
SpriteUpdaterCallback   Called by SpriteUpdater when assigning a Sprite to a SpriteUpdater.

 

Messages Sent

Name   Description
OnSpriteFrameStart   If the current frame has a frame event, this message will be sent when the frame begins playing.
OnSpriteFrameEnd   If the current frame has a frame event, this message will be sent when the frame finishes playing.

 

Inherited Variables and Functions

All variables and functions in MonoBehaviour are inherited by this class.

 

Classes

Name   Description
Locator   Sprite locator class.
SpriteMaterial   SpriteMaterial class. Used to modify materials and shaders on a Sprite.
FrameEvent   Contains information about a frame event.

 

Enumerations

Name   Description
BillboardUpAxis   Up axis hint vector for billboard sprites.
WrapMode   Animation playback wrap modes.