playMaker

Author Topic: Sprite / SetOrderInLayer  (Read 454 times)

Thore

  • Sr. Member
  • ****
  • Posts: 253
    • View Profile
Sprite / SetOrderInLayer
« on: September 06, 2018, 04:38:13 PM »
SetOrderInLayer.cs
Gets the SpriteRenderer of suitable GameObject, and sets the "Order in Layer" property to an integer you provide.

Purpose
In 2D games with a camera set to orthographic projection, the Z axis is ignored. The layers are used to roughly sort what is background, foreground etc. But within those layers, you use order in layer to determine what is in front of something else. With this action, you can change that order.

Example
In my case, a character carries a weapon on their back. When the weapon is drawn, it needs to change order in layer so it's drawn in front of the character.
« Last Edit: September 06, 2018, 04:42:05 PM by Thore »

krmko

  • Beta Group
  • Hero Member
  • *
  • Posts: 987
    • View Profile
    • Fat Pug Studio
Re: Sprite / SetOrderInLayer
« Reply #1 on: September 06, 2018, 11:47:02 PM »
Excellent, thanks!

PlaymakerNOOB

  • Full Member
  • ***
  • Posts: 176
    • View Profile
Re: Sprite / SetOrderInLayer
« Reply #2 on: September 07, 2018, 04:22:23 AM »
Awesome thanks!