mirror of
https://gitea.msk.dinamika-avia.ru/Constanta-Design/MI-38.git
synced 2026-01-24 05:45:38 +03:00
04.07.2022
This commit is contained in:
72
Heli_with_panels/Assets/Scripts/Panel3D/Switch3DRotate.cs
Normal file
72
Heli_with_panels/Assets/Scripts/Panel3D/Switch3DRotate.cs
Normal file
@@ -0,0 +1,72 @@
|
||||
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");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user