You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

67 lines
1.6 KiB

8 months ago
using System;
using System.Collections;
using System.Collections.Generic;
using DG.Tweening;
using UnityEngine;
using UnityEngine.UI;
public class GuangQu : MonoBehaviour
{
public Button left;
public Button right;
public Button sure;
public Transform gq;
public MeshRenderer render;
private MaterialPropertyBlock mpb;
private Color color = Color.red;
private int rotate = 2;
private void Awake()
{
mpb = new MaterialPropertyBlock();
left.onClick.AddListener(() =>
{
rotate -= 1;
gq.DOLocalRotate(gq.localEulerAngles - Vector3.forward * 45, 0.1f);
if (rotate == 0 || rotate % 8==0)
{
color = Color.yellow;
}
else
{
color = Color.red;
}
});
right.onClick.AddListener(() =>
{
rotate += 1;
gq.DOLocalRotate(gq.localEulerAngles + Vector3.forward * 45, 0.1f);
if (rotate == 0 || rotate % 8==0)
{
color = Color.yellow;
}
else
{
color = Color.red;
}
});
sure.onClick.AddListener(() =>
{
if (rotate == 0 || rotate % 8==0)
{
render.gameObject.SetActive(false);
TimeLineManager.Instance.gq.Play();
gameObject.SetActive(false);
}
});
}
private void Update()
{
mpb.SetColor("_LineColor",color);
mpb.SetFloat("_LineWidth",0.03f);
render.SetPropertyBlock(mpb);
}
}