Hi I’m noob in this forum, I hope don’t make a mistake posting in 2d section.
First of all apologise my English writing.
I cannot find anything about it, or at least not as accurate .
How can I manage multiple backgrounds , (say mi game’s backgrounds are style …" Jetpack Joyride "), I have at least 2 or 3 textures created in 4096 x 512 and using MainTextureOffset to scroll effect.
If I use dimensions higher than 4096px. images don´t render well .
I’m using a quad with the textures , located inside the MainCamera and i don’t know how to fade transitions, not only suddenly change the MainTexture.
¿What’s the best way to concatenate them and make the scroll continues perfectly?
With regards to dimensions above 4096, have you set the import size correctly? In Unity 5, you can set the “Max Size” up to 8192. If you go above this limit Unity will downscale your texture to fit, which would explain why it doesn’t render the way you want it. If you are making a game for phone/tablets, keep in mind that older hardware might not support huge textures. So it might be better to use several smaller textures instead.
As to concatenation… That depends on how you are doing your parallax. Do you have a smaller quad and scroll using the texture offset or do you have a large quad that you move? The easiest way to go from one background to another is probably to have two quads, one with the old texture and one with the new. Here’s a shot demo:
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
public class ScrollQuad : MonoBehaviour
{
public GameObject background1;
public GameObject background2;
public float speed = 0.1f;
private float rightCameraEdge;
private float width1;
private float width2;
void Start ()
{
// Width of quads
width1 = background1.GetComponent<Renderer>().bounds.extents.x;
width2 = background2.GetComponent<Renderer>().bounds.extents.x;
// This demo assumes a static camera. If that's not the case
// this needs to be updated each frame
// Position of the right camera edge
rightCameraEdge = Camera.main.ViewportToWorldPoint(Vector2.one).x;
// Position of left camera edge
Vector2 pos = Camera.main.ViewportToWorldPoint(Vector2.zero);
// Where to place first quad, align it with the camera's edge
float posx = pos.x + width1;
pos = background1.transform.position;
pos.x = posx;
background1.transform.position = pos;
setSecond();
}
void Update ()
{
Vector2 pos;
// Scroll them
pos = background1.transform.position;
pos.x -= speed;
background1.transform.position=pos;
pos = background2.transform.position;
pos.x -= speed;
background2.transform.position = pos;
// Have we scrolled the entire second quad?
if (pos.x + width2 < rightCameraEdge)
{
// Swap the quads
// If you want to change texture on the
// second one, this is the place to do it
GameObject temp = background1;
background1 = background2;
background2 = temp;
// Reset their positions
setSecond();
}
}
void setSecond()
{
// Where to place second quad
float posx = background1.transform.position.x + width1 * 2;
Vector2 pos = background2.transform.position;
pos.x = posx;
background2.transform.position = pos;
}
}
Yes I use renderer.maintextureoffset for the parallax, I have rigidbody2D.velocity too so I use a script to follow the character(rigidbody 2D) and put the quad into the MainCamera.
I try several ways to concatenate:
I will study your demo, and decide to change or not to a static camera (at this moment still dynamic).