Home > Blockchain >  Background loop doesn`t work properly in Unity
Background loop doesn`t work properly in Unity

Time:01-15

Problem consist in incorrect background looping. Instead of scrolling the picture horizontally, it distort over time. This script correctly work with another material, but not with that one.

How it`s looks like (Right side is distorted): enter image description here

I have this backgroundObject:

This background script:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class BackgroundLoop : MonoBehaviour
{
    public float bgSpeed;
    public Renderer bgRend;

    void Update()
    {
        bgRend.material.mainTextureOffset  = new Vector2(bgSpeed * Time.deltaTime, 0f);
    }
}

Thanks for any help.

CodePudding user response:

  1. Select the texture in the project window.

  2. Then in the inspector window set Wrap Mode to Repeat (or Mirror)

  3. Click Apply

  •  Tags:  
  • Related