Files
MI-38/Heli_with_panels/Assets/Scripts/Panel3D/Switch3DRotate.cs
2022-07-04 13:15:35 +03:00

73 lines
3.5 KiB
C#
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Switch3DRotate : MonoBehaviour
{
//public int pos;
public int numpos;
[SerializeField]
float eulerAngX ;
[SerializeField]
float eulerAngY ;
[SerializeField]
float eulerAngZ ;
public float angle = 30;
bool isStarted = false;
void Start()
{
if (isStarted) return;
//Debug.Log( this.name + " На ком висим");
// Задаем текущий Rotation объекта по осям
eulerAngX = transform.localEulerAngles.x;
eulerAngY = transform.localEulerAngles.y;
eulerAngZ = transform.localEulerAngles.z;
isStarted = true;
}
public void RotateVertikalSwitch(int numpos) //int pos,
{
//Debug.Log(pos + " сколько позиций");
//Debug.Log(this.name + " кто");
// !!!!!!!!!!!!! Исправить !!!! У нас rotation по Y
/* if (pos == 5)
{
if (numpos == 1) this.transform.localRotation = Quaternion.Euler(eulerAngX+0, eulerAngY+0, 0);
if (numpos == 2) this.transform.localRotation = Quaternion.Euler(eulerAngX+30, eulerAngY+0, 0);
if (numpos == 3) this.transform.localRotation = Quaternion.Euler(eulerAngX+0, eulerAngY+30, 0);
if (numpos == 4) this.transform.localRotation = Quaternion.Euler(eulerAngX-30, eulerAngY+0, 0);
if (numpos == 5) this.transform.localRotation = Quaternion.Euler(eulerAngX+0, eulerAngY-30, 0);
}
if (pos == 2)
{
if (numpos == 1) this.transform.localRotation = Quaternion.Euler(eulerAngX,eulerAngY-30, eulerAngZ+0);
if (numpos == 2) this.transform.localRotation = Quaternion.Euler(eulerAngX,eulerAngY+30, eulerAngZ+0);
}
if (pos == 3)
{
if (numpos == 3) this.transform.localRotation = Quaternion.Euler(eulerAngX, eulerAngY+30, eulerAngZ+0);
if (numpos == 2) this.transform.localRotation = Quaternion.Euler(eulerAngX, eulerAngY-30, eulerAngZ+0);
if (numpos == 1) this.transform.localRotation = Quaternion.Euler(eulerAngX,eulerAngY+0, eulerAngZ+0);
}*/
/* Вариант последний после правок Кирилла по двум передаваемым параметрам,которые заменили на один
if (numpos == 1) this.transform.localRotation = Quaternion.Euler(eulerAngX, eulerAngY + 30 + 10, eulerAngZ + 0); // вверх
if (numpos == 0) this.transform.localRotation = Quaternion.Euler(eulerAngX, eulerAngY - 30 + 10, eulerAngZ + 0); // вниз
if (numpos == 2) this.transform.localRotation = Quaternion.Euler(eulerAngX, eulerAngY + 0 +10, eulerAngZ + 0); // центр
if (numpos > 3) // upd if (numpos > 2) нумерация концовок названий спрайтов с 1 начинается
Debug.Log("Switch3DRotate error: numpos > 3");
*/
if (!isStarted) Start();
if (numpos == 1) this.transform.localRotation = Quaternion.Euler(eulerAngX, eulerAngY + 30 + 10, eulerAngZ + 0); // вверх
if (numpos == 0) this.transform.localRotation = Quaternion.Euler(eulerAngX, eulerAngY - 30 + 10, eulerAngZ + 0); // вниз
if (numpos == 2) this.transform.localRotation = Quaternion.Euler(eulerAngX, eulerAngY + 0 + 10, eulerAngZ + 0); // центр
if (numpos > 2) Debug.Log("Switch3DRotate error: numpos > 3");
}
}