Author Topic: Changing backgrounds  (Read 709 times)


  • Full Member
  • ***
  • Posts: 104
    • View Profile
Changing backgrounds
« on: December 23, 2017, 12:44:26 AM »
I think I asked this before, but wanted to go more in depth. Is there anyway to change background textures? I couldn't get 2d sprites to scroll so I set to a plane mesh with the intended background sprite as the background material. This was the only method I could find tutorials for. I basically split the levels into three scenes. It works for one level but how would i change it for subsequent levels?


  • Junior Playmaker
  • **
  • Posts: 51
    • View Profile
Re: Changing backgrounds
« Reply #1 on: December 23, 2017, 06:10:59 AM »
Simplest way I found to change sprites at runtime is make a c# script and use the Playmaker Call Method to access when needed. You will need to make a Resources Folder and then a sub-folder to hold your sprites. In the example we called our sub-folder test.

Code: [Select]
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class SpriteTest : MonoBehaviour {
    //this is the folder in the first level of your Resources Folder
    private string spriteFolder = "test"; //<--Change this string to match folder name

    //The number in the array where the sprite is 0,1,2 etc.
    public int spriteVersion;

    //to get the sprite render component
    private SpriteRenderer spriteR;

    //to dump the sprites into an array from the folder listed above. Note that the sprites get added in order that they are in the folder. First sprite is 0, second is 1, etc.
    private Sprite[] sprites;

// Use this for initialization
void Start () {
        //Get the renderer of the sprite that this script is on.
        spriteR = this.GetComponent<SpriteRenderer>();

        //load the sprites from the Resources Folder for the folder you specified above
        sprites = Resources.LoadAll<Sprite>(spriteFolder);

    //call this function to update your sprite. use 0,1,2 etc to define which sprite you want to pull from the array.
    public void ChangeBackground(int background)
        spriteR.sprite = sprites[background];


  • Administrator
  • Hero Member
  • *****
  • Posts: 4373
    • View Profile
    • jinxtergames
Re: Changing backgrounds
« Reply #2 on: December 23, 2017, 06:43:39 AM »
I am not exactly sure what you mean.

But i believe you need to look into using 'scene' actions.

You can check this unity video, it will explain how the scene management works.
Even it is using scripts i think you can understand how this would work in playmaker,
If not let me know.


There are some actions on the Ecosystem that you can use like for example :
  • Resource Load
  • Resource Load All
  • Swap Sprite
  • Set Sprite
Search for Resource and Sprite to see more actions.

It is not recommended to use Call Method.
(from a post from Jean)
CallMethod or invoke or SendMessage action, they are all relying on Reflections which always worse then a direct call using a regular script ( a custom action is a regular script).

 The same applies with SetProperty and GetProperty.
FOR HIRE:Playmaker/C#

Playmaker Samples <-------------> Easy Exporter <---------------------> TPA Actions