Playmaker Forum

PlayMaker News => General Discussion => Topic started by: Bitterfish on April 02, 2014, 10:24:23 AM

Title: Change sorting layer on GameObject var w/PlayMaker?[SOLVED]
Post by: Bitterfish on April 02, 2014, 10:24:23 AM
Hello,

I am trying to figure out the best & most efficient way to set/change a game object's sorting layer on the fly using PlayMaker.

Here is the scenario:


The problem:

FWIW - The powerups are being spawned through PoolManager 5, but I could also simply spawn prefabs without any pool management & have the same issue.

I know I can make an FSM to do what I want here, just by using some redundant structures for each possible powerup and/or screen location. Or possibly by just making "Top" and "Bottom" variants of each powerup. I was hoping to keep it simple, efficient, and streamlined, though, so I am wondering if there's another option I am missing?

I hope this all makes sense. :)
Title: Re: Change sorting layer on GameObject var w/PlayMaker?
Post by: jeanfabre on April 04, 2014, 07:37:12 AM
Hi,

from a gameobject, you can get an object ( Sprite Renderer in our case).

 use "Get Component". if you have an Fsm Object set to type "SpriteRenderer", it will find it, and then you can use Set property to change the layer and order as you whish.

bye,

 Jean
Title: Re: Change sorting layer on GameObject var w/PlayMaker?
Post by: Bitterfish on April 09, 2014, 07:40:32 AM
Thanks Jean!
Title: Re: Change sorting layer on GameObject var w/PlayMaker?[SOLVED]
Post by: velketor on June 24, 2018, 08:10:06 PM
This doesn't work if you publish to WebGL.  Sprite Renderer never works.  Is there a way to Set Sorting Layer in PlayMaker without using Set Property?
Title: Re: Change sorting layer on GameObject var w/PlayMaker?[SOLVED]
Post by: djaydino on June 25, 2018, 07:04:27 AM
Hi.
If you use Get/Set properties action you also need to use the Linker Wizard (http://hutonggames.com/playmakerforum/index.php?topic=11126.0)

There is a custom action on the Ecosystem (https://hutonggames.fogbugz.com/default.asp?W1181) called 'Set Sorting Renderer Layer'

Maybe that's what you are looking for?
Title: Re: Change sorting layer on GameObject var w/PlayMaker?[SOLVED]
Post by: velketor on January 06, 2019, 05:18:21 PM
You are right!  I downloaded the code for this custom action SetSortingRendererLayer.cs here:

https://github.com/jeanfabre/PlayMakerCustomActions_U4/blob/master/Assets/PlayMaker%20Custom%20Actions/Renderer/SetSortingRendererLayer.cs (https://github.com/jeanfabre/PlayMakerCustomActions_U4/blob/master/Assets/PlayMaker%20Custom%20Actions/Renderer/SetSortingRendererLayer.cs)

Then I pasted that code into a brand new C# script and placed it in my Playmaker actions folder.  I was able to use it as an Action in Playmaker and I can confirm it does work on WebGL for sorting layers.  You can even select objects that have no renderer, such as non-GUI text, and it will still assign it whatever sorting layer you tell it.  Pretty neat!  Thanks again =)