using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
//当没有效果时 看看材质是否为fade 或图片颜色是否为白色透明(如果是没效果更换带颜色的其他texture),或者调调Tiling 的xy以及offet的xy
public class Main_manager : MonoBehaviour {
public Material ailou;
public Material gaolou;
public Material lu_1;
public Material lu_2;
public Material jiedao;
public GameObject exit;
public GameObject skybox;
private float rot;
Vector2 ailou_offet;
Vector2 gaolou_offet;
Vector2 lu_1_offet;
Vector2 lu_2_offet;
Vector2 jiedao_offet;
public float speed;
private void Start()
{
exit.GetComponent<Button>().onClick.AddListener(Exit_scence);
}
// Update is called once per frame
void Update () {
Meath_uv();
Change_sky();
}
//uv 运动
void Meath_uv()
{
ailou_offet = ailou.GetTextureOffset("_MainTex");
gaolou_offet = gaolou.GetTextureOffset("_MainTex");
lu_1_offet = ailou.GetTextureOffset("_MainTex");
lu_2_offet = gaolou.GetTextureOffset("_MainTex");
jiedao_offet = jiedao.GetTextureOffset("_MainTex");
//-----------------------------------------------
if (ailou_offet.y <= 1f)
{
ailou_offet.y += Time.deltaTime * speed * 0.5f;
}
else
{
ailou_offet.y -= 2f;
}
//-----------------------------------------------
if (gaolou_offet.y >= -1f)
{
gaolou_offet.y -= Time.deltaTime * speed * 2;
}
else if (gaolou_offet.y <= -1f)
{
gaolou_offet.y += 2f;
}
//-----------------------------------------------
if (lu_1_offet.y <= 1f)
{
lu_1_offet.y += Time.deltaTime * speed * 0.002f;
}
else
{
lu_1_offet.y -= 1f;
}
//-----------------------------------------------
if (lu_2_offet.y <= 1f)
{
lu_2_offet.y += Time.deltaTime * 0.0001f;
}
else
{
lu_2_offet.y -= 1f;
}
//-----------------------------------------------
if (jiedao_offet.x <= 1f)
{
jiedao_offet.x += Time.deltaTime * speed * 1f;
}
else
{
jiedao_offet.x -= 1f;
}
ailou.SetTextureOffset("_MainTex", ailou_offet);
gaolou.SetTextureOffset("_MainTex", gaolou_offet);
lu_1.SetTextureOffset("_MainTex", lu_1_offet);
lu_2.SetTextureOffset("_MainTex", lu_2_offet);
jiedao.SetTextureOffset("_MainTex", jiedao_offet);
}
//天空盒旋转 在相机上加载skybox组件获取天空盒
void Change_sky()
{
rot += 0.7f * Time.deltaTime;
rot %= 360;
skybox.GetComponent<Skybox>().material.SetFloat("_Rotation", rot);
}
public void Exit_scence()
{
Application.Quit();
}
}