I’ve search all throughout google and can’t seem to find a fix for what I believe is most likely the easiest fix ever for someone that knows coding, I however am more of an artist, than coder so any help is appreciated.
I have a scene which has 6 backgrounds. There are 6 buttons in the UI which when pressed will change the background to the images of the character they saw on the button(s). My issue is, I have the layers sorted 1-6, but once you go past the 1st layer, the buttons will no longer bring the background back to the front. Essentially, what I have right now is buttons that work once, but I would like to be able to cycle through and anytime I press a button, it will bring it’s image to the front.
the way I currently have it setup is each button opens a new scene, which works, but I don’t like the split second load it does in between. I rather it be smooth. is there an easier alternative to what I’m trying to do with minimal code?
Okay, my turn to be confused. Nowhere in your original post do you mention separate scenes or split second load lags. Are we talking about the same issue?
sorry - So what I meant to say is, the way I had it originally was with each button opening a separate scene. Thats not the way I want it to function, and it makes no sense to open a new scene, just for a background image to change.
My goal is to have it function where pressing on any of the buttons will change the background image, in any order they’re pressed so that it doesn’t stop working once the last layer is opened.
Have a single scene with a UI canvas & an Imagr that will be the background & your buttons.
Write a script that has two variables an Image & a Sprite.
Add a function that is public that sets the Images sprite to the sprite variable.
Now for each button add that script & set the sprite to the background image you would like & the Image to the UI Image. Make each button call there scripts function.
is there a simple script you could point me to or a tutorial somewhere? Again, I’m a beginner when it comes to coding as I mainly do artwork, so even something like this goes over my head easily.
Here is the API for UI.Image: https://docs.unity3d.com/ScriptReference/UI.Image.html
You can see there is a property called sprite, so you’d just need to write a script with reference to the UI.Image, a reference to a sprite asset, and a method to set the sprite property. Make that function a listener for button press event.