using UnityEngine;
using System.Collections;
public class selectBackgroundScript : MonoBehaviour {
public UICenterOnChild backgroundRef; // drag the object that has the centeronchild script attached in my case it was the grid
public void Update()
{
if (backgroundRef.centeredObject.name == "grassBackground")
grassBackground ();
else if (backgroundRef.centeredObject.name == "picnicBackground")
picnicBackground ();
else
kitchenBackground ();
}
public void grassBackground()
{
UISprite sprite = GetComponent<UISprite> ();
if (sprite.spriteName != "Grass_Background")
{
sprite.spriteName = "Grass_Background";
}
}
public void picnicBackground()
{
UISprite sprite = GetComponent<UISprite> ();
if (sprite.spriteName != "Picnic_Background") {
sprite.spriteName = "Picnic_Background";
}
}
public void kitchenBackground()
{
UISprite sprite = GetComponent<UISprite> ();
if (sprite.spriteName != "Kitchen_Background")
{
sprite.spriteName = "Kitchen_Background";
}
}
}