SpriteRendererComponent

Outputs the sprite or animation clip.

# Properties

[{"index":"Dictionary ActionSheet (Deprecated) (HideFromInspector)","0":"This property is no longer used."}]

[{"index":"string ClipName (Deprecated) (ReadOnly) (HideFromInspector)","0":"This property is deprecated."}]

[{"index":"Color Color (Sync)","0":"Colors the Sprite."}]

[{"index":"SpriteDrawMode DrawMode (Sync)","0":"Sets the Sprite's draw mode. Simple, Sliced, and Tiled can be used."}]

[{"index":"int32 EndFrameIndex (Sync)","0":"The last frame of the animation to be played."}]

[{"index":"boolean FlipX (Sync)","0":"Determines whether the sprite is inverted relative to the X axis."}]

[{"index":"boolean FlipY (Sync)","0":"Determines whether the sprite is inverted relative to the Y axis."}]

[{"index":"boolean IgnoreMapLayerCheck (Sync)","0":"Doesn't perform automatic replace when designating the Map Layer name into SortingLayer."}]

[{"index":"string MaterialID (Sync)","0":"Specifies the Id of the material to be applied to the renderer."}]

[{"index":"int32 OrderInLayer (Sync)","0":"Determines the priority within the same Layer. A greater number indicates higher priority."}]

[{"index":"float PlayRate (Sync)","0":"For animation resources, you can specify the playback speed. It supports at least a value of 0 or more, and the higher the number, the faster it is."}]

[{"index":"RenderSettingType RenderSetting (Deprecated) (HideFromInspector)","0":"This property is no longer used."}]

[{"index":"string SortingLayer (Sync)","0":"When two or more Entities overlap, the priority is determined according to the Sorting Layer."}]

[{"index":"string SpriteRUID (Sync)","0":"The RUID of the sprite or animation clip."}]

[{"index":"int32 StartFrameIndex (Sync)","0":"The starting frame of the animation to be played."}]

[{"index":"Vector2 TiledSize (Sync)","0":"Sets the size of an area where the sprite will be drawn when DrawMode is Tiled, Sliced."}]

##### inherited from Component:

[{"index":"boolean Enable (Sync)","0":"Checks whether Component is activated or not."}]

[{"index":"boolean EnableInHierarchy (ReadOnly) (HideFromInspector)","0":"Displays whether this Component is Enable in the hierarchy. If Entity Enable is false regardless of Component Enable, returns false."}]

[{"index":"Entity Entity (ReadOnly)","0":"The Entity that owns this component."}]

# Methods

[{"index":"void ChangeMaterial(string materialId)","0":"Replaces the material to be applied to the renderer."}]

[{"index":"void SetAlpha(float alpha)","0":"Sets the alpha value of the sprite."}]

##### inherited from Component:

[{"index":"boolean IsClient()","0":"Returns whether the current execution environment is a client or not."}]

[{"index":"boolean IsServer()","0":"Returns whether the current execution environment is a server or not."}]

# Events

[{"index":"OrderInLayerChangedEvent","0":"This event occurs when changing the Component's OrderInLayer."}]

[{"index":"SortingLayerChangedEvent","0":"This event occurs when changing the component's SortingLayer."}]

[{"index":"SpriteAnimPlayerChangeFrameEvent","0":"This event is raised when changing the sprite animation's frame."}]

[{"index":"SpriteAnimPlayerEndEvent","0":"This event is raised when finishing the sprite animation's playback."}]

[{"index":"SpriteAnimPlayerEndFrameEvent","0":"This event is raised when playing the last frame of sprite animation."}]

[{"index":"SpriteAnimPlayerStartEvent","0":"This event is raised when starting the sprite animation's playback."}]

[{"index":"SpriteAnimPlayerStartFrameEvent","0":"This event is raised when playing the first frame of sprite animation."}]

# Examples

The following is an example of randomly determining the meso value of a meso item and applying a different Sprite according to the value range.
    
    
    @Component
    script RandomMesoInitializer extends Component
        @Sync
        property number Meso = 0
    
        @ExecSpace("ServerOnly")
        method void OnBeginPlay()
        self.Meso = _UtilLogic:RandomIntegerRange(1, 1500)
        local sprite = self.Entity.SpriteRendererComponent
    
        if self.Meso < 50 then
        	sprite.SpriteRUID = "000000"
        elseif self.Meso < 100 then
        	sprite.SpriteRUID = "000000"
        elseif self.Meso < 1000 then
        	sprite.SpriteRUID = "000000"
        else
        	sprite.SpriteRUID = "000000"
        end
        end
    end
    

# SeeAlso

  * UtilLogic
  * [Making Animations](/docs?postId=595)
  * [Sprite Color Adjustment](/docs?postId=116)