Added a background image via script now I can not see my sprites anymore

Hi

I have started to work with unity and tried to figure out my problem with google.
But have not find the right solution yet.

I have add a script to my main camera:

using UnityEngine;
using System.Collections;

public class cameraS : MonoBehaviour {

    public Texture backgroundTexture;
   
    void OnGUI()
    {
        GUI.DrawTexture (new Rect (0, 0, Screen.width, Screen.height), backgroundTexture);
    }

}

But now I can not see all my sprites which I have added. I don’t want to add all my sprites via script code.
I have tried to change the depth of my main camera and have add a second camera… but I can not see all my sprites.
Can anyone tell me what I am doing wrong?

The goal was only to add a fix background screen which have the right size for all mobile devices.

I think it’s because gui shows on top of your scene so I’d say you need to remove the background from the gui

Hi, thx for your reply.
I have removed the background from the gui.
But now I have the “old” problem again.
My background image is 2048x1536px.
On iPad the background looks very well everything is ok but on iPhone/iPod Touch the image is really small and have not the right size… see a black fill background around the image. I have googled a lot and change the settings of the image in unity to:
filter mode: point
override for iPhone: yes
max size: 2048

Can you get the screen height & width at run time & scale your background using that? it will probably cause weird warping of the image though simply because you will have the image in unity at one set of dimensions & then have to stretch it on both axis to fit what the screen has exactly. Either that or you enlarge it so the biggest dimension fits but then you will get bits that are cut off on the display in the other axis. It’s sort of like watching old TV shows on different wide screen TVs. They were made for 4:3 screens so you either watch it at that & have black bars either side, you stretch it to fit the new screen so people end up looking short & wide due to the stretching, or it fills the screen & everyone/thing is properly proportioned but you then miss seeing bits that are now offscreen.