Parallax Effect From 2D Course

Hello I was creating a parallax effect by materials applying the knowledge from 2d course but I get this error and here is my code, couldn’t figure out what’s wrong pls help me.

tile ofset not working via script when I try to ofset by hand via inspector I get this error

Screen position out of view frustum (screen pos inf, -inf, 0.000000) (Camera rect 0 0 1920 1080)
UnityEngine.Camera:ScreenToWorldPoint (UnityEngine.Vector3)

using UnityEngine;

public class Parallax : MonoBehaviour
{
    [Header("Assign Objects From Furthest to Closest")]
    [SerializeField] List<SpriteRenderer> sprites = new List<SpriteRenderer>();
    [SerializeField] List<float> speed = new List<float>();

    [SerializeField]List<Material> materials = new List<Material>();

    // Start is called before the first frame update
    void Start()
    {
        foreach(SpriteRenderer sprite in sprites)
        {
            Material mat = sprite.GetComponent<SpriteRenderer>().material;
            materials.Add(mat);
        }
        SetSpriteOrder();
    }

    void SetSpriteOrder()
    {
        for(int i=0, a=sprites.Count * -1; i<sprites.Count; i++, a++)
        {
            sprites[i].sortingOrder = a;
        }
    }

    // Update is called once per frame
    void Update()
    {
        for (int i = 0; i<materials.Count; i++){
            materials[i].mainTextureOffset = new Vector2(0, speed[i]);
        }
    }
}

and here is error

What is the exact error? The above is saying that the value passed into ScreenToWorldPoint is invalid, but I cannot see that in the code

Screen position out of view frustum (screen pos inf, -inf, 0.000000) (Camera rect 0 0 1920 1080)
UnityEngine.Camera:ScreenToWorldPoint (UnityEngine.Vector3)

this is the error as unity logs. and all the code is not working. It was working before (in 2d course) does it relevant to android build or urp or what? I can send whole project as a drive file if you wanna review?

I’m also confused as to how this error is occuring… at least with this script…

Can you paste the full stack trace of the error? (from the bottom of the console by clicking on the error message)

Privacy & Terms