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:
74
Heli_with_panels/Assets/Scripts/Panel3D/Cover3DHrotate.cs
Normal file
74
Heli_with_panels/Assets/Scripts/Panel3D/Cover3DHrotate.cs
Normal file
@@ -0,0 +1,74 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class Cover3DHrotate : MonoBehaviour
|
||||
{
|
||||
/* private string animationName = "horLeft";
|
||||
Animation anim;
|
||||
AnimationClip open;*/
|
||||
// Start is called before the first frame update
|
||||
|
||||
public int numpos;
|
||||
[SerializeField]
|
||||
float eulerAngX;
|
||||
[SerializeField]
|
||||
float eulerAngY;
|
||||
[SerializeField]
|
||||
float eulerAngZ;
|
||||
public float angle = 80;
|
||||
|
||||
void Start()
|
||||
{
|
||||
//anim = GetComponent<Animation>();
|
||||
//anim.Play("horLeft");
|
||||
//AnimationClip open = anim.GetClip("horLeft");
|
||||
//Debug.Log("загрузил " + open);
|
||||
//.Play("horLeft");
|
||||
//anim.Play(open.name);
|
||||
//anim.Play("horLeft");
|
||||
eulerAngX = transform.localEulerAngles.x;
|
||||
eulerAngY = transform.localEulerAngles.y;
|
||||
eulerAngZ = transform.localEulerAngles.z;
|
||||
}
|
||||
|
||||
void OnMouseDown()
|
||||
{
|
||||
//this.GetComponent<Animation>().Play(animationName);
|
||||
////anim.Play();
|
||||
|
||||
|
||||
/*if (!animation.IsPlaying(animationName))
|
||||
{
|
||||
animation.Play(animationName);
|
||||
}
|
||||
Debug.Log("Cube " + this.name + " clicked!");*/
|
||||
}
|
||||
|
||||
public void RotateH(int numpos)
|
||||
|
||||
{
|
||||
if (eulerAngX != 0 && eulerAngX > 0 && eulerAngX < 360)
|
||||
{
|
||||
if (numpos == 1) this.transform.localRotation = Quaternion.Euler(eulerAngX + angle, eulerAngY, eulerAngZ);
|
||||
//if (numpos == 2) this.transform.localRotation = Quaternion.Euler(eulerAngX, eulerAngY, eulerAngZ);
|
||||
}
|
||||
else if (eulerAngY != 0 && eulerAngY > 0 && eulerAngY < 360)
|
||||
{
|
||||
if (numpos == 1 && this.name != "Cover1_0203_3D" && this.name != "Cover1_0201_3D")
|
||||
this.transform.localRotation = Quaternion.Euler(eulerAngX + angle, eulerAngY, eulerAngZ);
|
||||
//if (numpos == 2) this.transform.localRotation = Quaternion.Euler(eulerAngX, eulerAngY, eulerAngZ);
|
||||
else
|
||||
this.transform.localRotation = Quaternion.Euler(eulerAngX - angle, eulerAngY, eulerAngZ); // Делаем исключение для вращаемых крышек 0203 и 0201, которые в другую сторону поворачиваем
|
||||
|
||||
}
|
||||
else if (eulerAngZ != 0 && eulerAngZ > 0 && eulerAngZ < 360)
|
||||
{
|
||||
if (numpos == 1) this.transform.localRotation = Quaternion.Euler(eulerAngX + angle, eulerAngY, eulerAngZ);
|
||||
}
|
||||
|
||||
if (numpos == 2) this.transform.localRotation = Quaternion.Euler(eulerAngX, eulerAngY, eulerAngZ);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user