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