PixelRendererComponent

Designates colors by each pixel to provide a feature of creating sprites as desired. We recommend using a size of less than 16x16.

# Properties

[{"index":"int32 Height (ReadOnly)","0":"The height of the sprite."}]

[{"index":"boolean IgnoreMapLayerCheck","0":"Does not perform automatic substitution when the Map Layer's name is specified in SortingLayer."}]

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

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

[{"index":"int32 Width (ReadOnly)","0":"The width of the sprite."}]

##### 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 FillColor(Color color) (ClientOnly)","0":"Fills the whole sprite with the color you've entered."}]

[{"index":"Color GetPixel(int32 x, int32 y) (ClientOnly)","0":"Returns the pixel value of the location you've entered. Bottom left is (1, 1)."}]

[{"index":"table GetPixels() (ClientOnly)","0":"Returns the values of all pixels. Row comes first. (Row-major)"}]

[{"index":"table GetPixelsAsRGBAInt() (ClientOnly)","0":"Returns all pixel values as RGBA represented as integers. Prioritizes rows. (Row-major)"}]

[{"index":"void ResetWithColor(int32 width, int32 height, Color color) (ClientOnly)","0":"Resets the sprite to be customized to the size you've entered and fills it with the color."}]

[{"index":"void ResetWithColors(int32 width, int32 height, table pixels) (ClientOnly)","0":"Resets the sprite to be customized to the size you've entered and sets the values of the pixels according to the values of the tables you've entered. The number of table elements must be the same as the number of all pixels (Width*Height). Row comes first. (Row-major)"}]

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

[{"index":"void SetPixel(int32 x, int32 y, Color color) (ClientOnly)","0":"Sets the pixel value of the location you've entered. Bottom left is (1, 1)."}]

[{"index":"void SetPixels(table pixels) (ClientOnly)","0":"Sets the values of pixels with the values of tables you've entered. The number of table elements must be the same as the number of all pixels (Width * Height). Row comes first. (Row-major)"}]

[{"index":"void SetPixelsByRGBAInt(table pixels) (ClientOnly)","0":"Sets all pixels values as RGBA represented as integers. The length of the table must be the same as the total pixel count (Width*Height) and prioritizes rows. (Row-major)"}]

##### 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."}]

# Examples

This is an example of randomly blinking pixels when the F key on the keyboard is pressed.
    
    
    @Component
    script PuzzleSequencer extends Component
        property table puzzles = {}
        property any pixelRendererComp = nil
        property table puzzlePos = {}
    
        @ExecSpace("ClientOnly")
        method void OnBeginPlay()
        self.pixelRendererComp = self.Entity.PixelRendererComponent
        self.pixelRendererComp:FillColor(Color.black)
    
        for i=1, 9 do
        	local xPos = _UtilLogic:RandomIntegerRange(1, 3)
        	local yPos = _UtilLogic:RandomIntegerRange(1, 3)
        	self.puzzles[i] = Vector2(xPos, yPos)
        end
        end
    
        @ExecSpace("ClientOnly")
        method void StartPuzzle(number index)
        if index > #self.puzzles then return end
    
        self.pixelRendererComp:SetPixel(self.puzzles[index].x, self.puzzles[index].y, Color.yellow)
        wait(0.35)
        self.pixelRendererComp:SetPixel(self.puzzles[index].x, self.puzzles[index].y, Color.black)
        wait(0.1)
        self:StartPuzzle(index + 1)
        end
    
        @EventSender("Self")
        handler HandleKeyDownEvent(KeyDownEvent event)
        --------------- Native Event Sender Info ----------------
        -- Sender: InputService
        -- Space: Client
        ---------------------------------------------------------
    
        -- Parameters
        local key = event.key
        ---------------------------------------------------------
        if key == KeyboardKey.F then
        	self:StartPuzzle(1)
        end
        end
    end
    

# SeeAlso

  * UtilLogic
  * [Setting Sprite Color by Pixel](/docs?postId=693)