public class BackgroundManager01 : MonoBehaviour {
GameObject background;
GameObject[] backgroundinstance = new GameObject[2];
public float firstbackground_x;
public float secondbackground_x;
// Use this for initialization
void Start () {
background = Resources.Load ("Prefabs/background") as GameObject;
backgroundinstance[0] = Instantiate (background, new Vector3 (firstbackground_x, 1.2f, 0), background.transform.rotation) as GameObject;
backgroundinstance[1] = Instantiate (background, new Vector3 (secondbackground_x, 1.2f, 0), background.transform.rotation) as GameObject;
}
// Update is called once per frame
void Update () {
}
}
public class BackgroundManager02 : MonoBehaviour {
GameObject background;
GameObject[] backgroundinstance = new GameObject[2];
public float backgroundspeed;
public float firstbackground_x;
public float secondbackground_x;
public float changebackground_x;
public Camera m_camera;
// Use this for initialization
void Start () {
background = Resources.Load ("Prefabs/background") as GameObject;
backgroundinstance[0] = Instantiate (background, new Vector3 (firstbackground_x, 1.2f, 0), background.transform.rotation) as GameObject;
backgroundinstance[1] = Instantiate (background, new Vector3 (secondbackground_x, 1.2f, 0), background.transform.rotation) as GameObject;
//as 연산자는 뒤에 붙어있는 형으로 형변환 연산자입니다. 지정된 타입의 인스턴스 값으로 형변환하여 반환하지만 만약 형변환이 불가능하다면 null을 반환하게 된다.
}
// Update is called once per frame
void Update () {
for (int i =0; i<2; i++) {
backgroundinstance[i].transform.position -= new Vector3 (backgroundspeed, 0,0);
if(backgroundinstance[i].transform.position.x <= changebackground_x + m_camera.transform.position.x){
backgroundinstance[i].transform.position = new Vector3(secondbackground_x + m_camera.transform.position.x,1.2f,0);
}
}
}
}
public class MidgroundManager01 : MonoBehaviour {
GameObject Midground;
GameObject[] Midgroundinstance = new GameObject[2];
public float firstMidground_x;
public float secondMidground_x;
// Use this for initialization
void Start () {
Midground = Resources.Load ("Prefabs/Midground") as GameObject;
Midgroundinstance[0] = Instantiate (Midground, new Vector3 (firstMidground_x, 1.2f, 0), Midground.transform.rotation) as GameObject;
Midgroundinstance[1] = Instantiate (Midground, new Vector3 (secondMidground_x, 1.2f, 0), Midground.transform.rotation) as GameObject;
}
// Update is called once per frame
void Update () {
}
}
public class MidgroundManager01 : MonoBehaviour {
GameObject Midground;
GameObject[] Midgroundinstance = new GameObject[2];
public float firstMidground_x;
public float secondMidground_x;
// Use this for initialization
void Start () {
Midground = Resources.Load ("Prefabs/Midground") as GameObject;
Midgroundinstance[0] = Instantiate (Midground, new Vector3 (firstMidground_x, 1.2f, 0), Midground.transform.rotation) as GameObject;
Midgroundinstance[1] = Instantiate (Midground, new Vector3 (secondMidground_x, 1.2f, 0), Midground.transform.rotation) as GameObject;
}
// Update is called once per frame
void Update () {
}
}
public class ForegroundManager01 : MonoBehaviour {
GameObject Foreground;
GameObject[] Foregroundinstance = new GameObject[2];
public float firstForeground_x;
public float secondForeground_x;
// Use this for initialization
void Start () {
Foreground = Resources.Load ("Prefabs/Foreground") as GameObject;
Foregroundinstance[0] = Instantiate (Foreground, new Vector3 (firstForeground_x, 1.2f, 0), Foreground.transform.rotation) as GameObject;
Foregroundinstance[1] = Instantiate (Foreground, new Vector3 (secondForeground_x, 1.2f, 0), Foreground.transform.rotation) as GameObject;
}
// Update is called once per frame
void Update () {
}
}
public class ForegroundManager02 : MonoBehaviour {
GameObject Foreground;
GameObject[] Foregroundinstance = new GameObject[2];
public float Foregroundspeed;
public float firstForeground_x;
public float secondForeground_x;
public float changeForeground_x;
public Camera m_camera;
// Use this for initialization
void Start () {
Foreground = Resources.Load ("Prefabs/Foreground") as GameObject;
Foregroundinstance[0] = Instantiate (Foreground, new Vector3 (firstForeground_x, 1.2f, 0), Foreground.transform.rotation) as GameObject;
Foregroundinstance[1] = Instantiate (Foreground, new Vector3 (secondForeground_x, 1.2f, 0), Foreground.transform.rotation) as GameObject;
}
// Update is called once per frame
void Update () {
for (int i =0; i<2; i++) {
Foregroundinstance[i].transform.position -= new Vector3 (Foregroundspeed, 0,0);
if(Foregroundinstance[i].transform.position.x <= changeForeground_x + m_camera.transform.position.x){
Foregroundinstance[i].transform.position = new Vector3(secondForeground_x + m_camera.transform.position.x,1.2f,0);
}
}
}
}