52 lines
1.2 KiB
C#
52 lines
1.2 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine.EventSystems;
|
|
|
|
/// <summary>
|
|
/// 万用表挡位
|
|
/// </summary>
|
|
public class Multimeter_dangwei : MonoBehaviour, IPointerClickHandler
|
|
{
|
|
/// <summary>
|
|
/// 挡位(共14档)
|
|
/// </summary>
|
|
public int dangweiValue = 0;
|
|
|
|
public void OnPointerClick(PointerEventData eventData)
|
|
{
|
|
if (eventData.button == PointerEventData.InputButton.Left)
|
|
{
|
|
ChangeDangwei(true);
|
|
}
|
|
else if(eventData.button == PointerEventData.InputButton.Right)
|
|
{
|
|
ChangeDangwei(false);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 切换挡位
|
|
/// </summary>
|
|
/// <param name="isleft">是否向左转</param>
|
|
public void ChangeDangwei(bool isleft)
|
|
{
|
|
if (isleft)
|
|
{
|
|
if (dangweiValue > 0)
|
|
{
|
|
transform.RotateAroundLocal(Vector3.up, -90f / 7f);
|
|
dangweiValue--;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (dangweiValue < 14)
|
|
{
|
|
transform.RotateAroundLocal(Vector3.up, 90f / 7f);
|
|
dangweiValue++;
|
|
}
|
|
}
|
|
}
|
|
}
|