mirror of
https://gitea.msk.dinamika-avia.ru/Constanta-Design/MI-38.git
synced 2026-01-24 05:35:38 +03:00
04.07.2022
This commit is contained in:
8
Heli_with_panels/Assets/Scripts/Panel2D/0112.meta
Normal file
8
Heli_with_panels/Assets/Scripts/Panel2D/0112.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5a7929b6b9f250541823c41e705ef7f0
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
193
Heli_with_panels/Assets/Scripts/Panel2D/0112/drCol112.cs
Normal file
193
Heli_with_panels/Assets/Scripts/Panel2D/0112/drCol112.cs
Normal file
@@ -0,0 +1,193 @@
|
||||
<<<<<<< HEAD
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class drCol112 : MonoBehaviour
|
||||
{
|
||||
protected Vector3 mousePosition;
|
||||
protected Vector2 a; // Vector2 deltaPosition
|
||||
public string typeDrag = null;
|
||||
public float dragMin, dragMax;
|
||||
public bool clamp = false;
|
||||
|
||||
[HideInInspector] public Vector2 dd;//для передачи в connection
|
||||
[HideInInspector] public bool _delta = false;//для передачи в connection
|
||||
|
||||
[HideInInspector] public bool isDrag = false;
|
||||
Manager man;
|
||||
|
||||
Camera cam;//камера для канваса с панелями
|
||||
private void Awake()
|
||||
{
|
||||
dd = new Vector2(transform.localPosition.x, transform.localPosition.y);
|
||||
if (man == null) man = GameObject.Find("Manager").GetComponent<Manager>();
|
||||
cam = man.cam;
|
||||
}
|
||||
public void OnMouseDown()
|
||||
{
|
||||
calculationBegin();
|
||||
}
|
||||
public void OnMouseDrag()
|
||||
{
|
||||
calculationDrag();
|
||||
|
||||
}
|
||||
|
||||
public void OnMouseUp()
|
||||
{
|
||||
dd = new Vector2(transform.localPosition.x, transform.localPosition.y);
|
||||
if (typeDrag == "x" && (dd.x == dragMin || dd.x == dragMax))
|
||||
{
|
||||
_delta = true;
|
||||
}
|
||||
else if (typeDrag == "y" && (dd.y == dragMin || dd.y == dragMax))
|
||||
{
|
||||
_delta = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
_delta = false;
|
||||
}
|
||||
isDrag = false;
|
||||
}
|
||||
public void calculationBegin()
|
||||
{
|
||||
//a = new Vector2(Input.mousePosition.x - transform.localPosition.x, Input.mousePosition.y - transform.localPosition.y);
|
||||
mousePosition = cam.ScreenToWorldPoint(Input.mousePosition);//mousePosition = Input.mousePosition;
|
||||
a = new Vector2(mousePosition.x - transform.localPosition.x, mousePosition.y - transform.localPosition.y);
|
||||
isDrag = true;
|
||||
}
|
||||
public void calculationDrag()
|
||||
{
|
||||
if (man.mode == "scedit" || man.mode == "play")
|
||||
return;
|
||||
mousePosition = cam.ScreenToWorldPoint(Input.mousePosition);//mousePosition = Input.mousePosition;
|
||||
Vector2 q = new Vector2(mousePosition.x, mousePosition.y);
|
||||
Vector3 b = new Vector3(q.x - a.x, q.y - a.y, transform.localPosition.z);
|
||||
|
||||
if (typeDrag == "x")
|
||||
{
|
||||
b.x = (clamp) ? Mathf.Clamp(b.x, dragMin, dragMax) : b.x;
|
||||
transform.localPosition = new Vector3(b.x, transform.localPosition.y, transform.localPosition.z);
|
||||
}
|
||||
else
|
||||
if (typeDrag == "y")
|
||||
{
|
||||
b.y = (clamp) ? Mathf.Clamp(b.y, dragMin, dragMax) : b.y;
|
||||
transform.localPosition = new Vector3(transform.localPosition.x, b.y, transform.localPosition.z);
|
||||
}
|
||||
else
|
||||
{
|
||||
transform.localPosition = b;
|
||||
}
|
||||
}
|
||||
public void SetState(int b)
|
||||
{
|
||||
float bf = (clamp) ? Mathf.Clamp((float)b/100f, dragMin, dragMax) : b/100;
|
||||
//b += (int)(dragMax - dragMin) / 2;
|
||||
if (typeDrag == "x")
|
||||
transform.localPosition = new Vector3(bf, transform.localPosition.y, transform.localPosition.z);
|
||||
else
|
||||
if (typeDrag == "y")
|
||||
transform.localPosition = new Vector3(transform.localPosition.x, bf, transform.localPosition.z);
|
||||
}
|
||||
|
||||
}
|
||||
=======
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class drCol112 : MonoBehaviour
|
||||
{
|
||||
protected Vector3 mousePosition;
|
||||
protected Vector2 a; // Vector2 deltaPosition
|
||||
public string typeDrag = null;
|
||||
public float dragMin, dragMax;
|
||||
public bool clamp = false;
|
||||
|
||||
[HideInInspector] public Vector2 dd;//для передачи в connection
|
||||
[HideInInspector] public bool _delta = false;//для передачи в connection
|
||||
|
||||
[HideInInspector] public bool isDrag = false;
|
||||
Manager man;
|
||||
|
||||
Camera cam;//камера для канваса с панелями
|
||||
private void Awake()
|
||||
{
|
||||
dd = new Vector2(transform.localPosition.x, transform.localPosition.y);
|
||||
if (man == null) man = GameObject.Find("Manager").GetComponent<Manager>();
|
||||
cam = man.cam;
|
||||
}
|
||||
public void OnMouseDown()
|
||||
{
|
||||
calculationBegin();
|
||||
}
|
||||
public void OnMouseDrag()
|
||||
{
|
||||
calculationDrag();
|
||||
|
||||
}
|
||||
|
||||
public void OnMouseUp()
|
||||
{
|
||||
dd = new Vector2(transform.localPosition.x, transform.localPosition.y);
|
||||
if (typeDrag == "x" && (dd.x == dragMin || dd.x == dragMax))
|
||||
{
|
||||
_delta = true;
|
||||
}
|
||||
else if (typeDrag == "y" && (dd.y == dragMin || dd.y == dragMax))
|
||||
{
|
||||
_delta = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
_delta = false;
|
||||
}
|
||||
isDrag = false;
|
||||
}
|
||||
public void calculationBegin()
|
||||
{
|
||||
//a = new Vector2(Input.mousePosition.x - transform.localPosition.x, Input.mousePosition.y - transform.localPosition.y);
|
||||
mousePosition = cam.ScreenToWorldPoint(Input.mousePosition);//mousePosition = Input.mousePosition;
|
||||
a = new Vector2(mousePosition.x - transform.localPosition.x, mousePosition.y - transform.localPosition.y);
|
||||
isDrag = true;
|
||||
}
|
||||
public void calculationDrag()
|
||||
{
|
||||
if (man.mode == "scedit" || man.mode == "play")
|
||||
return;
|
||||
mousePosition = cam.ScreenToWorldPoint(Input.mousePosition);//mousePosition = Input.mousePosition;
|
||||
Vector2 q = new Vector2(mousePosition.x, mousePosition.y);
|
||||
Vector3 b = new Vector3(q.x - a.x, q.y - a.y, transform.localPosition.z);
|
||||
|
||||
if (typeDrag == "x")
|
||||
{
|
||||
b.x = (clamp) ? Mathf.Clamp(b.x, dragMin, dragMax) : b.x;
|
||||
transform.localPosition = new Vector3(b.x, transform.localPosition.y, transform.localPosition.z);
|
||||
}
|
||||
else
|
||||
if (typeDrag == "y")
|
||||
{
|
||||
b.y = (clamp) ? Mathf.Clamp(b.y, dragMin, dragMax) : b.y;
|
||||
transform.localPosition = new Vector3(transform.localPosition.x, b.y, transform.localPosition.z);
|
||||
}
|
||||
else
|
||||
{
|
||||
transform.localPosition = b;
|
||||
}
|
||||
}
|
||||
public void SetState(int b)
|
||||
{
|
||||
float bf = (clamp) ? Mathf.Clamp((float)b/100f, dragMin, dragMax) : b/100;
|
||||
//b += (int)(dragMax - dragMin) / 2;
|
||||
if (typeDrag == "x")
|
||||
transform.localPosition = new Vector3(bf, transform.localPosition.y, transform.localPosition.z);
|
||||
else
|
||||
if (typeDrag == "y")
|
||||
transform.localPosition = new Vector3(transform.localPosition.x, bf, transform.localPosition.z);
|
||||
}
|
||||
|
||||
}
|
||||
>>>>>>> 3b1b9479a46e90d056b92897ea9f8422b25fc052
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ebc4de7888e30984680948b2b1c6b5d0
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
8
Heli_with_panels/Assets/Scripts/Panel2D/0115.meta
Normal file
8
Heli_with_panels/Assets/Scripts/Panel2D/0115.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: fcc0046aa8c948d419b8c9b95e2af94a
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
186
Heli_with_panels/Assets/Scripts/Panel2D/0115/ArrowToText.cs
Normal file
186
Heli_with_panels/Assets/Scripts/Panel2D/0115/ArrowToText.cs
Normal file
@@ -0,0 +1,186 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using TMPro;
|
||||
|
||||
public class ArrowToText : MonoBehaviour//frame1 0115
|
||||
{
|
||||
public GameObject arrow;//стрелочка на шкале
|
||||
//public Text speed;//счетчик
|
||||
public TextMeshPro speed;//счетчик
|
||||
public GameObject frame;//цветная рамка
|
||||
|
||||
float rotateZ; //предыдущее значение rotateZ
|
||||
float d, d1; //коэффициенты d (0-100), d1 (100-350)
|
||||
float k; //текущее значение счетчика в float
|
||||
bool reverse = false; //направление
|
||||
(int scale,int count) min = ( 0, 40 );//минимальное значение счетчика
|
||||
int max = 350;//максимальное значение счетчика
|
||||
float waitTime = 0.005f;//время для корутины
|
||||
bool point = false;//нажатие на счетчик
|
||||
private Coroutine coroutine;
|
||||
|
||||
|
||||
private void Start()
|
||||
{
|
||||
//Debug.Log($"min.Item1 = {min.scale}");
|
||||
d = 100 / (125-112);
|
||||
d1 = 4.7f;
|
||||
|
||||
OnK();
|
||||
scaleText();
|
||||
Rever();
|
||||
}
|
||||
private void Update()
|
||||
{
|
||||
if (rotateZ != arrow.gameObject.transform.eulerAngles.z)
|
||||
{
|
||||
ref readonly bool dragArrow = ref arrow.gameObject.GetComponent<Handler>().drag;
|
||||
if (dragArrow)
|
||||
{
|
||||
if (coroutine != null)
|
||||
{
|
||||
StopCoroutine(coroutine);
|
||||
point = false;
|
||||
}
|
||||
OnK();
|
||||
scaleText();
|
||||
Rever();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private void scaleText()
|
||||
{
|
||||
|
||||
int ko = (int)k;
|
||||
if (ko <320)
|
||||
{
|
||||
speed.color = Color.white;
|
||||
if (frame.gameObject.GetComponent<ButtonCheckable3>() != null)
|
||||
{
|
||||
frame.gameObject.GetComponent<ButtonCheckable3>().EnableSprite(0);
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
speed.color = Color.red;
|
||||
if (frame.gameObject.GetComponent<ButtonCheckable3>() != null)
|
||||
{
|
||||
frame.gameObject.GetComponent<ButtonCheckable3>().EnableSprite(1);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
ko = ko / 10 * 10;
|
||||
|
||||
if (ko < min.count)
|
||||
{
|
||||
//speed.text = "";
|
||||
speed.SetText("");
|
||||
}
|
||||
else
|
||||
{
|
||||
//speed.text = ko.ToString();
|
||||
speed.SetText(ko.ToString());
|
||||
}
|
||||
}
|
||||
private void OnK()
|
||||
{
|
||||
rotateZ = arrow.gameObject.transform.eulerAngles.z;
|
||||
if(rotateZ > 111)
|
||||
{
|
||||
//Debug.Log($"здесь до 100");
|
||||
k = (125 - rotateZ) * d;
|
||||
}
|
||||
if (rotateZ < 111&& rotateZ != 111)
|
||||
{
|
||||
//Debug.Log($"здесь после 100");
|
||||
k = (90 - rotateZ) * d1+200;
|
||||
}
|
||||
|
||||
if (rotateZ > 110.4&&rotateZ< 111.4)
|
||||
{
|
||||
//Debug.Log($"111 = 100");
|
||||
k = 100f;
|
||||
}
|
||||
|
||||
}
|
||||
private void OnMouseDown()//нажатие на счетчик
|
||||
{
|
||||
//Debug.Log("кликнули");
|
||||
point = !point;
|
||||
if (point)
|
||||
{
|
||||
Rever();
|
||||
if (reverse)
|
||||
{
|
||||
k--;
|
||||
coroutine = StartCoroutine(AltNumber());
|
||||
}
|
||||
else
|
||||
{
|
||||
k++;
|
||||
coroutine = StartCoroutine(AltNumber());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (coroutine != null) StopCoroutine(coroutine);
|
||||
}
|
||||
|
||||
}
|
||||
private void Rever()
|
||||
{
|
||||
if (k <= min.scale)
|
||||
{
|
||||
reverse = false;
|
||||
}
|
||||
else if (k >= max)
|
||||
{
|
||||
reverse = true;
|
||||
}
|
||||
}
|
||||
IEnumerator AltNumber()
|
||||
{
|
||||
while (point)
|
||||
{
|
||||
scaleText();
|
||||
|
||||
if (k<100)
|
||||
{
|
||||
//Debug.Log($"здесь до 100");
|
||||
rotateZ = 125f - k / d;
|
||||
}
|
||||
if (k>100)
|
||||
{
|
||||
//Debug.Log($"здесь после 100");
|
||||
rotateZ = 90 - (k - 200) / d1;
|
||||
}
|
||||
|
||||
if (k >99&&k<101)
|
||||
{
|
||||
//Debug.Log($"111 = 100");
|
||||
rotateZ =111;
|
||||
}
|
||||
|
||||
arrow.gameObject.transform.localRotation = Quaternion.Euler(0f, 0f, rotateZ);
|
||||
|
||||
if (reverse)
|
||||
{
|
||||
k--;
|
||||
}
|
||||
else
|
||||
{
|
||||
k++;
|
||||
}
|
||||
Rever();
|
||||
|
||||
yield return new WaitForSeconds(waitTime);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: afc158455bff7b24d823abb363d0f527
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
45
Heli_with_panels/Assets/Scripts/Panel2D/0115/BarPressure.cs
Normal file
45
Heli_with_panels/Assets/Scripts/Panel2D/0115/BarPressure.cs
Normal file
@@ -0,0 +1,45 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using TMPro;
|
||||
//TextBarPressure
|
||||
public class BarPressure : MonoBehaviour
|
||||
{
|
||||
[HideInInspector]
|
||||
public string textValue_="";
|
||||
|
||||
private (string, string) defaultValue_ = ("766 мм рт.ст", "1013 гѕ");
|
||||
private TextMeshPro text_;
|
||||
//private Text text_;
|
||||
void Start()
|
||||
{
|
||||
text_ = this.GetComponent<TextMeshPro>();
|
||||
var txt= (textValue_ == "") ? defaultValue_.Item1 : textValue_;
|
||||
text_.SetText(txt);
|
||||
/*text_ = this.gameObject.GetComponent<Text>();
|
||||
|
||||
text_.text = (textValue_ == "") ? defaultValue_.Item1 : textValue_;*/
|
||||
}
|
||||
|
||||
private void OnMouseDown()//нажатие на счетчик
|
||||
{
|
||||
if(textValue_ == "")
|
||||
{
|
||||
var txt = (text_.text == defaultValue_.Item2) ? defaultValue_.Item1 : defaultValue_.Item2;
|
||||
text_.SetText(txt);
|
||||
}
|
||||
else
|
||||
{
|
||||
text_.SetText(textValue_);
|
||||
}
|
||||
/*if(textValue_ == "")
|
||||
{
|
||||
text_.text = (text_.text == defaultValue_.Item2) ? defaultValue_.Item1 : defaultValue_.Item2;
|
||||
}
|
||||
else
|
||||
{
|
||||
text_.text = textValue_;
|
||||
}*/
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3f14814a73c530147842864cd374c0af
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
132
Heli_with_panels/Assets/Scripts/Panel2D/0115/ColliderIgnore.cs
Normal file
132
Heli_with_panels/Assets/Scripts/Panel2D/0115/ColliderIgnore.cs
Normal file
@@ -0,0 +1,132 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class ColliderIgnore : MonoBehaviour
|
||||
{
|
||||
/* Collider2D[] colliders;
|
||||
[ContextMenuItem("0115", "On0115")]
|
||||
// [ContextMenuItem("0107", "On0107")]
|
||||
// [ContextMenuItem("0108", "On0108")]
|
||||
// [ContextMenuItem("0124", "On0124")]
|
||||
// [ContextMenuItem("0125", "On0125")]
|
||||
[ContextMenuItem("0112", "On0112")]
|
||||
[ContextMenuItem("0114", "On0114")]
|
||||
[ContextMenuItem("0117", "On0117")]
|
||||
[ContextMenuItem("0204", "On0204")]
|
||||
[ContextMenuItem("0207", "On0207")]
|
||||
[ContextMenuItem("0601", "On0601")]
|
||||
[ContextMenuItem("0507", "On0507")]
|
||||
[SerializeField] private string[] nameColliders;
|
||||
void On0115() => nameColliders = new string[] { "Arrow0115", "Button2_0115", "RotateAvia", "index0115", "TextBarPressure", "Frame2Text_115", "Frame2_0115", "Frame3Text115", "Frame3_0115", "Frame4_0115", "Frame4Text", "Poplavok0115" };
|
||||
//void On0107() => nameColliders = new string[] { "Handle4_0107", "Handle5_0107" };
|
||||
//void On0108() => nameColliders = new string[] { "Handle4_0108", "Handle5_0108" };
|
||||
//void On0124() => nameColliders = new string[] { "Handle4_0124", "Handle5_0124" };
|
||||
//void On0125() => nameColliders = new string[] { "Handle4_0125", "Handle5_0125" };
|
||||
void On0112() => nameColliders = new string[] { "handle0112", "blenker0112_1", "blenker0112_2", "airPlane0112", "poplavok0112" };
|
||||
void On0114() => nameColliders = new string[] { "Arrow0114", "Scale1_0114_2", "Scale1_0114_1" };
|
||||
void On0117() => nameColliders = new string[] { "arrow1_0117_4", "arrow1_0117_3", "arrow1_0117_2", "arrow2_0117_2" };
|
||||
void On0204() => nameColliders = new string[] { "Handle1_0204_2", "Handle2_0204_2" };
|
||||
void On0207() => nameColliders = new string[] { "Handle1_0207_2", "Handle2_0207_2" };
|
||||
void On0601() => nameColliders = new string[] { "bazatop_0601" };
|
||||
void On0507() => nameColliders = new string[] { "Button1_0507_1", "Button2_0507_1", "Button3_0507_1" };
|
||||
private void Awake()
|
||||
{
|
||||
colliders = transform.parent.GetComponentsInChildren<Collider2D>();
|
||||
//nameColliders = new string[] { "Button2_0115", "RotateAvia", "index0115", "TextBarPressure", "Frame2Text_115", "Frame2_0115", "Frame3Text115", "Frame3_0115", "Frame4_0115", "Frame4Text", "Poplavok0115" };
|
||||
|
||||
for (int k = 0; k < nameColliders.Length; k++)
|
||||
{
|
||||
for (int i = 0; i < colliders.Length; i++)
|
||||
{
|
||||
if (colliders[i].name == nameColliders[k] && colliders[i].gameObject.GetComponent<ExitColliderIgnore>() == null)
|
||||
{
|
||||
colliders[i].gameObject.AddComponent<ExitColliderIgnore>();
|
||||
colliders[i].gameObject.GetComponent<ExitColliderIgnore>().pan = this.gameObject.GetComponent<ColliderIgnore>();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
private void Start()
|
||||
{
|
||||
//cam = GameObject.Find("Camera").GetComponent<Camera>();
|
||||
if (man == null) man = GameObject.Find("Manager").GetComponent<Manager>();
|
||||
cam = man.cam;
|
||||
}
|
||||
|
||||
public void OnMouseEnter()
|
||||
{
|
||||
ChangeColliderIgnore(false);
|
||||
}
|
||||
public void OnMouseExit()
|
||||
{
|
||||
ChangeColliderIgnore(true);
|
||||
}
|
||||
public void ChangeColliderIgnore(bool enableCollider, string colliderTrue)
|
||||
{
|
||||
|
||||
if (enableCollider)
|
||||
{
|
||||
for (int i = 0; i < colliders.Length; i++)
|
||||
{
|
||||
colliders[i].enabled = enableCollider;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
for (int k = 0; k < nameColliders.Length; k++)
|
||||
{
|
||||
for (int i = 0; i < colliders.Length; i++)
|
||||
{
|
||||
if (colliders[i].name != colliderTrue)
|
||||
{
|
||||
colliders[i].enabled = enableCollider;
|
||||
}
|
||||
else
|
||||
{
|
||||
colliders[i].enabled = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Camera cam;
|
||||
Manager man;
|
||||
|
||||
|
||||
void Update()
|
||||
{
|
||||
if (!cam.gameObject.activeSelf) return;
|
||||
Vector2 CurMousePos = cam.ScreenToWorldPoint(Input.mousePosition);
|
||||
|
||||
if (Input.GetMouseButtonUp(0))
|
||||
{
|
||||
RaycastHit2D[] allHits = Physics2D.RaycastAll(CurMousePos, Vector2.zero);
|
||||
|
||||
bool flag = true;
|
||||
for (int k = 0; k < nameColliders.Length; k++)
|
||||
{
|
||||
for (int i = 0; i < allHits.Length; i++)
|
||||
{
|
||||
if (allHits[i].transform.name != nameColliders[k])
|
||||
{
|
||||
|
||||
ChangeColliderIgnore(flag, "");
|
||||
// Debug.Log($"flag = {flag} allHits[i].transform.name = {allHits[i].transform.name}");
|
||||
}
|
||||
else
|
||||
{
|
||||
flag = false;
|
||||
ChangeColliderIgnore(flag, nameColliders[k]);
|
||||
//Debug.Log($"flag = {flag} allHits[i].transform.name = {allHits[i].transform.name}");
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!flag) break;
|
||||
}
|
||||
}
|
||||
}*/
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 61f3ed9fcc3f8e343957de775a8bbc3a
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,12 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class ExitColliderIgnore : MonoBehaviour
|
||||
{
|
||||
/* public ColliderIgnore pan;
|
||||
public void OnMouseExit()
|
||||
{
|
||||
pan.ChangeColliderIgnore(true, "");
|
||||
}*/
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b5f185c6060b5384c99eae696e9d2c38
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
22
Heli_with_panels/Assets/Scripts/Panel2D/0115/HLightParent.cs
Normal file
22
Heli_with_panels/Assets/Scripts/Panel2D/0115/HLightParent.cs
Normal file
@@ -0,0 +1,22 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class HLightParent : MonoBehaviour
|
||||
{
|
||||
private HlightBtn arrow;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
arrow = transform.GetComponentInParent<HlightBtn>();
|
||||
|
||||
}
|
||||
public void OnMouseEnter()
|
||||
{
|
||||
arrow.OnMouseEnter();
|
||||
}
|
||||
public void OnMouseExit()
|
||||
{
|
||||
arrow.OnMouseExit();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e06d96d0bad5b0648810607139c93874
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
36
Heli_with_panels/Assets/Scripts/Panel2D/0115/HlightBtn.cs
Normal file
36
Heli_with_panels/Assets/Scripts/Panel2D/0115/HlightBtn.cs
Normal file
@@ -0,0 +1,36 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class HlightBtn : MonoBehaviour
|
||||
{
|
||||
private SpriteRenderer arrow;
|
||||
private SpriteRenderer arrowDown;
|
||||
private void Awake()
|
||||
{
|
||||
arrow = transform.GetComponent<SpriteRenderer>();
|
||||
arrow.enabled = false;
|
||||
var nameA = this.name.Substring(0, this.name.Length) + "_arrow";
|
||||
arrowDown = transform.Find(nameA).gameObject.GetComponent<SpriteRenderer>();
|
||||
arrowDown.enabled = false;
|
||||
}
|
||||
public void OnMouseEnter()
|
||||
{
|
||||
arrow.enabled = true;
|
||||
}
|
||||
public void OnMouseExit()
|
||||
{
|
||||
arrow.enabled = false;
|
||||
}
|
||||
private void OnMouseDown()
|
||||
{
|
||||
arrowDown.enabled = true;
|
||||
arrow.enabled = false;
|
||||
|
||||
}
|
||||
private void OnMouseUp()
|
||||
{
|
||||
arrowDown.enabled = false;
|
||||
arrow.enabled = true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 85a678afbbf56f84eb33baa4163a54d8
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
13
Heli_with_panels/Assets/Scripts/Panel2D/0115/IndexH.cs
Normal file
13
Heli_with_panels/Assets/Scripts/Panel2D/0115/IndexH.cs
Normal file
@@ -0,0 +1,13 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class IndexH : MonoBehaviour//index0115
|
||||
{
|
||||
[SerializeField]
|
||||
private GameObject connectScale;
|
||||
[SerializeField]
|
||||
public GameObject frame;
|
||||
|
||||
|
||||
}
|
||||
11
Heli_with_panels/Assets/Scripts/Panel2D/0115/IndexH.cs.meta
Normal file
11
Heli_with_panels/Assets/Scripts/Panel2D/0115/IndexH.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: aa1408457d090864cb68232e029a14b7
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
129
Heli_with_panels/Assets/Scripts/Panel2D/0115/ScaleToText.cs
Normal file
129
Heli_with_panels/Assets/Scripts/Panel2D/0115/ScaleToText.cs
Normal file
@@ -0,0 +1,129 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using TMPro;
|
||||
|
||||
public class ScaleToText : MonoBehaviour//frame3 0115
|
||||
{
|
||||
public GameObject scale;//шкала
|
||||
//public Text altitude;//счетчик
|
||||
public TextMeshPro altitude;//счетчик
|
||||
public GameObject frame;
|
||||
float Y; //пердыдущее значение y
|
||||
float d; //коэффициент
|
||||
float k; //текущее значение счетчика в float
|
||||
bool reverse = false; //направление
|
||||
int min = -130;//минимальное значение счетчика
|
||||
int max = 6760;//максимальное значение счетчика
|
||||
float waitTime = 0.005f;//время для корутины
|
||||
[HideInInspector] public bool point = false;//нажатие на счетчик
|
||||
private Coroutine coroutine;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
d = 3450 / 1800f;
|
||||
OnK();
|
||||
scaleText();
|
||||
Rever();
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (Y != scale.gameObject.transform.localPosition.y)
|
||||
{
|
||||
OnK();
|
||||
scaleText();
|
||||
Rever();
|
||||
}
|
||||
}
|
||||
private void scaleText()
|
||||
{
|
||||
|
||||
int ko = (int)k;
|
||||
if (ko >= 0)
|
||||
{
|
||||
altitude.color = Color.white;
|
||||
if (frame.gameObject.GetComponent<ButtonCheckable3>()!= null)
|
||||
{
|
||||
frame.gameObject.GetComponent<ButtonCheckable3>().EnableSprite(0);
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
altitude.color = Color.yellow;
|
||||
if (frame.gameObject.GetComponent<ButtonCheckable3>() != null)
|
||||
{
|
||||
frame.gameObject.GetComponent<ButtonCheckable3>().EnableSprite(1);
|
||||
}
|
||||
|
||||
}
|
||||
if (ko > 100 || ko < -100)
|
||||
{
|
||||
ko = ko / 10 * 10;
|
||||
}
|
||||
|
||||
//altitude.text = ko.ToString();
|
||||
altitude.SetText(ko.ToString());
|
||||
}
|
||||
private void OnK()
|
||||
{
|
||||
Y = scale.gameObject.transform.localPosition.y;
|
||||
k = -Y * d + 3310f;
|
||||
}
|
||||
private void OnMouseDown()//нажатие на счетчик
|
||||
{
|
||||
point = !point;
|
||||
if (point)
|
||||
{
|
||||
Rever();
|
||||
if (reverse)
|
||||
{
|
||||
k--;
|
||||
coroutine = StartCoroutine(AltNumber());
|
||||
}
|
||||
else
|
||||
{
|
||||
k++;
|
||||
coroutine = StartCoroutine(AltNumber());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(coroutine!=null)StopCoroutine(coroutine);
|
||||
}
|
||||
|
||||
}
|
||||
private void Rever()
|
||||
{
|
||||
if (k <= min)
|
||||
{
|
||||
reverse = false;
|
||||
}else if(k >= max)
|
||||
{
|
||||
reverse = true;
|
||||
}
|
||||
}
|
||||
IEnumerator AltNumber()
|
||||
{
|
||||
while (point)
|
||||
{
|
||||
scaleText();
|
||||
Y = (k - 3310f) / -d;
|
||||
scale.gameObject.transform.localPosition = new Vector3(scale.gameObject.transform.localPosition.x, Y, scale.gameObject.transform.localPosition.z);
|
||||
if (reverse)
|
||||
{
|
||||
k--;
|
||||
}
|
||||
else
|
||||
{
|
||||
k++;
|
||||
}
|
||||
Rever();
|
||||
|
||||
yield return new WaitForSeconds(waitTime);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c31b2b42328c5cb46b49cb6fffeee26d
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
170
Heli_with_panels/Assets/Scripts/Panel2D/0115/ScaleToText4.cs
Normal file
170
Heli_with_panels/Assets/Scripts/Panel2D/0115/ScaleToText4.cs
Normal file
@@ -0,0 +1,170 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using TMPro;
|
||||
using UnityEditor;
|
||||
//[AddComponentMenu("Transform/Follow Transform")]
|
||||
[RequireComponent(typeof(TextMeshPro))]
|
||||
[RequireComponent(typeof(Collider2D))]
|
||||
public class ScaleToText4 : MonoBehaviour
|
||||
{
|
||||
|
||||
[Header("Objects")]
|
||||
public GameObject scale;//шкала с которой связан счетчик
|
||||
public TextMeshPro countNumber;//счетчик
|
||||
public GameObject frame;//рамка
|
||||
[SerializeField] private GameObject Panel;// родительская панель
|
||||
|
||||
private float Y; // (оставила название) предыдущее значение изменяемой координаты, в данном случае y
|
||||
private float d; //коэффициент
|
||||
private float k; //текущее значение счетчика в float
|
||||
private bool reverse = false; //направление
|
||||
|
||||
[Header("Variables")]
|
||||
[SerializeField] private int min = -340;// минимальное значение счетчика для frame3 =-130
|
||||
[SerializeField] private int max = 340;// максимальное значение счетчика для frame3 =6760
|
||||
[SerializeField] private float deltaScale = 15f;// дельта шкалы для frame3 =3450
|
||||
[SerializeField] private float deltaCoorScale = 105f;// дельта координат шкалы (сколько юнитов координат в deltaScale) для frame3 =1800
|
||||
[SerializeField] private float startCoorScale = 1263f;// координаты шкалы для счетчика 0
|
||||
[Space(15)]
|
||||
[Tooltip("x or y")] [SerializeField] private string typeXY="y";// тип сериализуемый
|
||||
|
||||
|
||||
[Space(10)]
|
||||
[SerializeField] private float waitTime = 0.05f;//время для корутины
|
||||
[HideInInspector] public bool point = false;//нажатие на счетчик
|
||||
private Coroutine coroutine;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
countNumber = transform.GetComponent<TextMeshPro>();
|
||||
d = deltaCoorScale / deltaScale;//высчитывается дельта координат к дельте шкалы
|
||||
OnK();
|
||||
scaleText();
|
||||
Rever();
|
||||
waitTime = 0.005f;
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if ((typeXY == "x"&&Y != scale.gameObject.transform.localPosition.x)|| (typeXY == "y" && Y != scale.gameObject.transform.localPosition.y))//проверка типа
|
||||
{
|
||||
OnK();
|
||||
scaleText();
|
||||
Rever();
|
||||
}
|
||||
}
|
||||
|
||||
private void scaleText()
|
||||
{
|
||||
//Debug.Log($"k = {k}");
|
||||
int ko = (int)k;
|
||||
//Debug.Log($"ko = {ko}");
|
||||
if (typeXY == "y" && Panel.transform.name == "Panel0115")//проверка типа начало
|
||||
{
|
||||
if (ko >= 0)
|
||||
{
|
||||
countNumber.color = Color.white;
|
||||
if (frame.gameObject.GetComponent<ButtonCheckable3>() != null)
|
||||
{
|
||||
frame.gameObject.GetComponent<ButtonCheckable3>().EnableSprite(0);
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
countNumber.color = Color.yellow;
|
||||
if (frame.gameObject.GetComponent<ButtonCheckable3>() != null)
|
||||
{
|
||||
frame.gameObject.GetComponent<ButtonCheckable3>().EnableSprite(1);
|
||||
}
|
||||
|
||||
}
|
||||
if (ko > 100 || ko < -100)
|
||||
{
|
||||
ko = ko / 10 * 10;
|
||||
}
|
||||
} else if (typeXY == "x" && Panel.transform.name == "Panel0115"){
|
||||
if (ko < 0)
|
||||
{
|
||||
ko = 360 + ko;
|
||||
}
|
||||
}
|
||||
//проверка типа конец
|
||||
// altitude.text = ko.ToString();
|
||||
countNumber.SetText(ko.ToString());
|
||||
}
|
||||
private void OnK()
|
||||
{
|
||||
Y = (typeXY == "x")? scale.gameObject.transform.localPosition.x: scale.gameObject.transform.localPosition.y;//проверка типа
|
||||
k = -(Y- startCoorScale) / d;//дельта
|
||||
}
|
||||
private void OnMouseDown()//нажатие на счетчик
|
||||
{
|
||||
/*point = !point;
|
||||
//Debug.Log($"point = {point}");
|
||||
if (point)
|
||||
{
|
||||
Rever();
|
||||
if (reverse)
|
||||
{
|
||||
k-=0.5f;
|
||||
coroutine = StartCoroutine(AltNumber());
|
||||
}
|
||||
else
|
||||
{
|
||||
k+=0.5f;
|
||||
coroutine = StartCoroutine(AltNumber());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (coroutine != null) StopCoroutine(coroutine);
|
||||
}*/
|
||||
|
||||
}
|
||||
private void Rever()
|
||||
{
|
||||
//Debug.Log($" вне условия k = {k}; min = {min}; max = {max}");
|
||||
if (k <= min)
|
||||
{
|
||||
//Debug.Log($"1. k <= min; {k}<= {min}");
|
||||
reverse = false;
|
||||
}
|
||||
else if (k >= max)
|
||||
{
|
||||
//Debug.Log($"2. k >= max; {k}>= {max}");
|
||||
reverse = true;
|
||||
}
|
||||
}
|
||||
IEnumerator AltNumber()
|
||||
{
|
||||
while (point)
|
||||
{
|
||||
scaleText();
|
||||
Y = -(k *d) + startCoorScale;//дельта
|
||||
if (typeXY == "x")
|
||||
{
|
||||
scale.gameObject.transform.localPosition = new Vector3(Y, scale.gameObject.transform.localPosition.y, scale.gameObject.transform.localPosition.z);
|
||||
//Debug.Log($"scale.gameObject.transform.localPosition = {scale.gameObject.transform.localPosition}");
|
||||
}
|
||||
else if(typeXY == "y"){
|
||||
scale.gameObject.transform.localPosition = new Vector3(scale.gameObject.transform.localPosition.x, Y, scale.gameObject.transform.localPosition.z);
|
||||
}
|
||||
//scale.gameObject.transform.localPosition = new Vector3(scale.gameObject.transform.localPosition.x, Y, scale.gameObject.transform.localPosition.z);//проверка типа
|
||||
if (reverse)
|
||||
{
|
||||
k-=0.5f;
|
||||
}
|
||||
else
|
||||
{
|
||||
k+=0.5f;
|
||||
}
|
||||
Rever();
|
||||
|
||||
yield return new WaitForSeconds(waitTime);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ec232e97710198048af530ebc0ed7609
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
118
Heli_with_panels/Assets/Scripts/Panel2D/0115/Variometer.cs
Normal file
118
Heli_with_panels/Assets/Scripts/Panel2D/0115/Variometer.cs
Normal file
@@ -0,0 +1,118 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using TMPro;
|
||||
|
||||
public class Variometer : MonoBehaviour//frame2 0115
|
||||
{
|
||||
public GameObject arrow;
|
||||
[HideInInspector]
|
||||
public string textValue_ = "";
|
||||
|
||||
private string defaultValue_ = "0";
|
||||
//private Text text_;
|
||||
private TextMeshPro text_;
|
||||
private int k=0; //текущее значение счетчика в float
|
||||
private int max = 30;
|
||||
private int min = -30;
|
||||
bool reverse = false; //направление
|
||||
float waitTime = 0.2f;//время для корутины
|
||||
bool point = false;//нажатие на счетчик
|
||||
private Coroutine coroutine;
|
||||
|
||||
void Start()
|
||||
{
|
||||
//text_ = this.gameObject.GetComponent<Text>();
|
||||
//text_.text = (textValue_ == "") ? defaultValue_ : textValue_;
|
||||
text_ = this.GetComponent<TextMeshPro>();
|
||||
var txt = (textValue_ == "") ? defaultValue_ : textValue_;
|
||||
text_.SetText(txt);
|
||||
|
||||
}
|
||||
private void VarText()
|
||||
{
|
||||
|
||||
if (k >= 0)
|
||||
{
|
||||
if (arrow.gameObject.GetComponent<ButtonCheckable3>() != null)
|
||||
{
|
||||
arrow.gameObject.GetComponent<ButtonCheckable3>().EnableSprite(0);
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
if (arrow.gameObject.GetComponent<ButtonCheckable3>() != null)
|
||||
{
|
||||
arrow.gameObject.GetComponent<ButtonCheckable3>().EnableSprite(1);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
textValue_ = k.ToString();
|
||||
if (k < 0)
|
||||
{
|
||||
//text_.text = textValue_.Substring(1, textValue_.Length - 1);
|
||||
var txt = textValue_.Substring(1, textValue_.Length - 1);
|
||||
text_.SetText(txt);
|
||||
}
|
||||
else
|
||||
{
|
||||
//text_.text = textValue_;
|
||||
text_.SetText(textValue_);
|
||||
}
|
||||
}
|
||||
private void OnMouseDown()//нажатие на счетчик
|
||||
{
|
||||
|
||||
point = !point;
|
||||
if (point)
|
||||
{
|
||||
Rever();
|
||||
if (reverse)
|
||||
{
|
||||
k--;
|
||||
coroutine = StartCoroutine(VarNumber());
|
||||
}
|
||||
else
|
||||
{
|
||||
k++;
|
||||
coroutine = StartCoroutine(VarNumber());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (coroutine != null) StopCoroutine(coroutine);
|
||||
}
|
||||
}
|
||||
private void Rever()
|
||||
{
|
||||
if (k <= min)
|
||||
{
|
||||
reverse = false;
|
||||
}
|
||||
else if (k >= max)
|
||||
{
|
||||
reverse = true;
|
||||
}
|
||||
}
|
||||
IEnumerator VarNumber()
|
||||
{
|
||||
while (point)
|
||||
{
|
||||
VarText();
|
||||
if (reverse)
|
||||
{
|
||||
k--;
|
||||
}
|
||||
else
|
||||
{
|
||||
k++;
|
||||
}
|
||||
Rever();
|
||||
|
||||
yield return new WaitForSeconds(waitTime);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: faea90728be5e6b48ad7baff2eb5ff1f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
8
Heli_with_panels/Assets/Scripts/Panel2D/0509.meta
Normal file
8
Heli_with_panels/Assets/Scripts/Panel2D/0509.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 23d9ff4a5f222bc47b56f83d9e756d3e
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,26 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using TMPro;
|
||||
|
||||
public class AngleToNumber : MonoBehaviour
|
||||
{
|
||||
public Handler handle;//крутилка
|
||||
|
||||
public TextMeshPro number;//счетчик
|
||||
|
||||
private void Start()
|
||||
{
|
||||
handle = this.gameObject.GetComponent<Handler>();
|
||||
|
||||
}
|
||||
private void LateUpdate()
|
||||
{
|
||||
if (handle.drag)
|
||||
{
|
||||
var k = handle.gameObject.transform.localEulerAngles.z;
|
||||
int count = 9-(int)(handle.gameObject.transform.localEulerAngles.z / 36);
|
||||
number.text = count.ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: bf0f870d3d9c0584e974de7e474657bd
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
21
Heli_with_panels/Assets/Scripts/Panel2D/AngleCollider.cs
Normal file
21
Heli_with_panels/Assets/Scripts/Panel2D/AngleCollider.cs
Normal file
@@ -0,0 +1,21 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class AngleCollider : MonoBehaviour
|
||||
{
|
||||
|
||||
public int countA;
|
||||
public GameObject parObject;
|
||||
Manager man;
|
||||
|
||||
|
||||
public void OnMouseDown()
|
||||
{
|
||||
man = GameObject.Find("Manager").GetComponent<Manager>();
|
||||
if (man.mode == "scedit" || man.mode == "play")
|
||||
return;
|
||||
|
||||
parObject.gameObject.GetComponent<RotateAngle>().OnCollider(countA);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0dc76b077141a1f4290434561f864fd4
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
165
Heli_with_panels/Assets/Scripts/Panel2D/ButtonCheckable.cs
Normal file
165
Heli_with_panels/Assets/Scripts/Panel2D/ButtonCheckable.cs
Normal file
@@ -0,0 +1,165 @@
|
||||
<<<<<<< HEAD
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class ButtonCheckable : MonoBehaviour
|
||||
{
|
||||
Dictionary<string, GameObject> buttonStatesList = new Dictionary<string, GameObject>();
|
||||
|
||||
// int posCount;
|
||||
// int currentPos;
|
||||
GameObject goUp;
|
||||
GameObject goDown;
|
||||
public bool isChecked = false;
|
||||
public bool isStarted = false;
|
||||
Image goUp_Img=null, goDown_Img=null;
|
||||
SpriteRenderer goUp_SR = null, goDown_SR = null;
|
||||
Manager man;
|
||||
|
||||
void Start()
|
||||
{
|
||||
man = GameObject.Find("Manager").GetComponent<Manager>();
|
||||
// Debug.Log(go.name);
|
||||
Transform[] buttonStates = this.GetComponentsInChildren<Transform>();
|
||||
// Debug.Log(btnList.Length);
|
||||
// goUp = new GameObject();
|
||||
// goDown = new GameObject();
|
||||
for (int i = 0; i < buttonStates.Length; i++)
|
||||
{
|
||||
if (i == 0) continue;
|
||||
if (string.Compare(buttonStates[i].name.Substring(buttonStates[i].name.Length - 2), "up") == 0) // this.name.Length - 3
|
||||
goUp = buttonStates[i].gameObject;
|
||||
if (string.Compare(buttonStates[i].name.Substring(buttonStates[i].name.Length - 4), "down") == 0) // this.name.Length - 3
|
||||
goDown = buttonStates[i].gameObject;
|
||||
}
|
||||
goUp_Img = goUp.GetComponent<Image>();
|
||||
goUp_SR = goUp.GetComponent<SpriteRenderer>();
|
||||
goDown_Img = goDown.GetComponent<Image>();
|
||||
goDown_SR = goDown.GetComponent<SpriteRenderer>();
|
||||
|
||||
if (goUp_Img != null) goUp_Img.enabled = !isChecked;
|
||||
if (goUp_SR != null) goUp_SR.enabled = !isChecked;
|
||||
if (goDown_Img != null) goDown_Img.enabled = isChecked;
|
||||
if (goDown_SR != null) goDown_SR.enabled = isChecked;
|
||||
isStarted = true;
|
||||
}
|
||||
|
||||
void OnMouseDown()
|
||||
{
|
||||
if (man.mode == "scedit" || man.mode == "play")
|
||||
return;
|
||||
OnCheck();
|
||||
}
|
||||
|
||||
|
||||
public void OnCheck()
|
||||
{
|
||||
if (goUp == null || goDown == null) Start();
|
||||
if (goUp == null || goDown == null) return;
|
||||
|
||||
try
|
||||
{
|
||||
isChecked = !isChecked;
|
||||
if (goUp_Img != null) goUp_Img.enabled = !isChecked;
|
||||
if (goUp_SR != null) goUp_SR.enabled = !isChecked;
|
||||
if (goDown_Img != null) goDown_Img.enabled = isChecked;
|
||||
if (goDown_SR != null) goDown_SR.enabled = isChecked;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Debug.LogError(e.Message);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void SetState(int st)
|
||||
{
|
||||
if (st == 0) isChecked = true; else isChecked = false;
|
||||
OnCheck();
|
||||
}
|
||||
}
|
||||
=======
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class ButtonCheckable : MonoBehaviour
|
||||
{
|
||||
Dictionary<string, GameObject> buttonStatesList = new Dictionary<string, GameObject>();
|
||||
|
||||
// int posCount;
|
||||
// int currentPos;
|
||||
GameObject goUp;
|
||||
GameObject goDown;
|
||||
public bool isChecked = false;
|
||||
public bool isStarted = false;
|
||||
Image goUp_Img=null, goDown_Img=null;
|
||||
SpriteRenderer goUp_SR = null, goDown_SR = null;
|
||||
Manager man;
|
||||
|
||||
void Start()
|
||||
{
|
||||
man = GameObject.Find("Manager").GetComponent<Manager>();
|
||||
// Debug.Log(go.name);
|
||||
Transform[] buttonStates = this.GetComponentsInChildren<Transform>();
|
||||
// Debug.Log(btnList.Length);
|
||||
// goUp = new GameObject();
|
||||
// goDown = new GameObject();
|
||||
for (int i = 0; i < buttonStates.Length; i++)
|
||||
{
|
||||
if (i == 0) continue;
|
||||
if (string.Compare(buttonStates[i].name.Substring(buttonStates[i].name.Length - 2), "up") == 0) // this.name.Length - 3
|
||||
goUp = buttonStates[i].gameObject;
|
||||
if (string.Compare(buttonStates[i].name.Substring(buttonStates[i].name.Length - 4), "down") == 0) // this.name.Length - 3
|
||||
goDown = buttonStates[i].gameObject;
|
||||
}
|
||||
goUp_Img = goUp.GetComponent<Image>();
|
||||
goUp_SR = goUp.GetComponent<SpriteRenderer>();
|
||||
goDown_Img = goDown.GetComponent<Image>();
|
||||
goDown_SR = goDown.GetComponent<SpriteRenderer>();
|
||||
|
||||
if (goUp_Img != null) goUp_Img.enabled = !isChecked;
|
||||
if (goUp_SR != null) goUp_SR.enabled = !isChecked;
|
||||
if (goDown_Img != null) goDown_Img.enabled = isChecked;
|
||||
if (goDown_SR != null) goDown_SR.enabled = isChecked;
|
||||
isStarted = true;
|
||||
}
|
||||
|
||||
void OnMouseDown()
|
||||
{
|
||||
if (man.mode == "scedit" || man.mode == "play")
|
||||
return;
|
||||
OnCheck();
|
||||
}
|
||||
|
||||
|
||||
public void OnCheck()
|
||||
{
|
||||
if (goUp == null || goDown == null) Start();
|
||||
if (goUp == null || goDown == null) return;
|
||||
|
||||
try
|
||||
{
|
||||
isChecked = !isChecked;
|
||||
if (goUp_Img != null) goUp_Img.enabled = !isChecked;
|
||||
if (goUp_SR != null) goUp_SR.enabled = !isChecked;
|
||||
if (goDown_Img != null) goDown_Img.enabled = isChecked;
|
||||
if (goDown_SR != null) goDown_SR.enabled = isChecked;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Debug.LogError(e.Message);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void SetState(int st)
|
||||
{
|
||||
if (st == 0) isChecked = true; else isChecked = false;
|
||||
OnCheck();
|
||||
}
|
||||
}
|
||||
>>>>>>> 3b1b9479a46e90d056b92897ea9f8422b25fc052
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: dbc28422848bda5459d5b1d421f29df7
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
59
Heli_with_panels/Assets/Scripts/Panel2D/ButtonCheckable3.cs
Normal file
59
Heli_with_panels/Assets/Scripts/Panel2D/ButtonCheckable3.cs
Normal file
@@ -0,0 +1,59 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
/* Работает на любое количество спрайтов, переключает по очереди */
|
||||
public class ButtonCheckable3 : MonoBehaviour
|
||||
{
|
||||
//Dictionary<string, GameObject> buttonStatesList3 = new Dictionary<string, GameObject>();
|
||||
List<GameObject> buttonStatesList3 = new List<GameObject>();
|
||||
int click = 0;
|
||||
Manager man;
|
||||
|
||||
void Start()
|
||||
{
|
||||
man = GameObject.Find("Manager").GetComponent<Manager>();
|
||||
Transform[] buttonStates = this.GetComponentsInChildren<Transform>();
|
||||
for (int i = 0; i < buttonStates.Length; i++)
|
||||
if (buttonStates[i].name != this.name)
|
||||
{
|
||||
buttonStates[i].gameObject.SetActive(false);
|
||||
buttonStatesList3.Add(buttonStates[i].gameObject);
|
||||
}
|
||||
|
||||
//EnableSprite(click);
|
||||
UnityObject curUO = man.objects.FindHandler(this.gameObject.name);
|
||||
curUO.SetObjectState(click);
|
||||
|
||||
//debug:
|
||||
/*if (this.name == "mfi3_Lamp5_1")
|
||||
Debug.Log("Lamp5_1 states = " + (buttonStates.Length + 1) + " active = " + this.gameObject.active + " activeInHierarchy = " + this.gameObject.activeInHierarchy);
|
||||
for (int i = 0; i < buttonStates.Length; i++)
|
||||
if (buttonStates[i].name != this.name)
|
||||
{
|
||||
if (this.name == "mfi3_Lamp5_1")
|
||||
Debug.Log(buttonStates[i].name + " active = " + buttonStates[i].gameObject.active + " activeInHierarchy = " + buttonStates[i].gameObject.activeInHierarchy);
|
||||
} */
|
||||
}
|
||||
|
||||
void OnMouseDown()
|
||||
{
|
||||
if (man.mode == "scedit" || man.mode == "play")
|
||||
return;
|
||||
click++;
|
||||
if (click > buttonStatesList3.Count - 1) click = 0;
|
||||
//Debug.Log("количество кликов + " + click);
|
||||
//EnableSprite(click);
|
||||
UnityObject curUO = man.objects.FindHandler(this.gameObject.name);
|
||||
curUO.SetObjectState(click);
|
||||
|
||||
}
|
||||
|
||||
public void EnableSprite(int n)
|
||||
{
|
||||
if (n >= buttonStatesList3.Count)
|
||||
return;
|
||||
buttonStatesList3.ForEach(_buttonStatesList3 => _buttonStatesList3.gameObject.SetActive(false));
|
||||
buttonStatesList3[n].gameObject.SetActive(true);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1a8fcc88003622547ac936dcfda3b30d
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
307
Heli_with_panels/Assets/Scripts/Panel2D/Connection.cs
Normal file
307
Heli_with_panels/Assets/Scripts/Panel2D/Connection.cs
Normal file
@@ -0,0 +1,307 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
|
||||
public class Connection : MonoBehaviour, IBeginDragHandler, IDragHandler, IEndDragHandler
|
||||
{
|
||||
public GameObject[] connects;
|
||||
[ContextMenuItem("Button", "OnButton")]
|
||||
[ContextMenuItem("ButtonCheckable", "OnButtonCheckable")]
|
||||
[ContextMenuItem("ButtonCheckable3", "OnButtonCheckable3")]
|
||||
[ContextMenuItem("Switch", "OnSwitch")]
|
||||
[ContextMenuItem("Handler", "OnHandler")]
|
||||
[ContextMenuItem("HideCollider", "OnHideCollider")]
|
||||
[ContextMenuItem("ScaleToScaleX", "OnScaleToScaleX")]
|
||||
public string typeThis;// = null;//"Button". "ButtonCheckable", "ButtonCheckable3", "Switch" (êðûøêà âûêëþ÷àåò òóìáëåðû), "Handler", "HideCollider", "ScaleToScaleX"(115), CoverStateToCoverState 0701 0702,
|
||||
void OnButton() => typeThis = "Button";
|
||||
void OnButtonCheckable() => typeThis = "ButtonCheckable";
|
||||
void OnButtonCheckable3() => typeThis = "ButtonCheckable3";
|
||||
void OnSwitch() => typeThis = "Switch";
|
||||
void OnHandler() => typeThis = "Handler";
|
||||
void OnHideCollider() => typeThis = "HideCollider";
|
||||
void OnScaleToScaleX() => typeThis = "ScaleToScaleX";
|
||||
[SerializeField] private int index=0;
|
||||
|
||||
private float d;//
|
||||
private DragCollider _drag;
|
||||
private Vector2 xy;
|
||||
private bool _delta = false;
|
||||
private PointerEventData data;
|
||||
Manager man;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
man = GameObject.Find("Manager").GetComponent<Manager>();
|
||||
xy = new Vector2(this.gameObject.transform.localPosition.x, this.gameObject.transform.localPosition.y);
|
||||
|
||||
for (int i = 0; i < connects.Length; i++)
|
||||
{
|
||||
switch (typeThis)
|
||||
{
|
||||
case "Handler":
|
||||
connects[i].gameObject.GetComponent<PolygonCollider2D>().enabled = !connects[i].gameObject.GetComponent<PolygonCollider2D>().enabled;
|
||||
break;
|
||||
case "ScaleToScaleX":
|
||||
_drag = connects[i].gameObject.transform.GetComponent<DragCollider>();
|
||||
ref readonly string typeDrag = ref _drag.typeDrag;
|
||||
if (typeDrag == "x")
|
||||
{
|
||||
d = connects[i].gameObject.transform.localPosition.x - xy.x;
|
||||
}
|
||||
else
|
||||
{
|
||||
d = connects[i].gameObject.transform.localPosition.y - xy.y;
|
||||
}
|
||||
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
private void OnMouseEnter()
|
||||
{
|
||||
for (int i = 0; i < connects.Length; i++)
|
||||
{
|
||||
switch (typeThis)
|
||||
{
|
||||
case "HideCollider":
|
||||
if (connects[i].gameObject.GetComponent<Collider2D>() != null)
|
||||
{
|
||||
connects[i].gameObject.GetComponent<Collider2D>().enabled = false;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
private void OnMouseExit()
|
||||
{
|
||||
for (int i = 0; i < connects.Length; i++)
|
||||
{
|
||||
switch (typeThis)
|
||||
{
|
||||
case "HideCollider":
|
||||
if (connects[i].gameObject.GetComponent<Collider2D>() != null)
|
||||
{
|
||||
connects[i].gameObject.GetComponent<Collider2D>().enabled = true;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
void OnMouseDown()
|
||||
{
|
||||
if(man == null) man = GameObject.Find("Manager").GetComponent<Manager>();
|
||||
if (man.mode == "scedit" || man.mode == "play")
|
||||
return;
|
||||
xy = new Vector2(this.gameObject.transform.localPosition.x, this.gameObject.transform.localPosition.y);
|
||||
for (int i = 0; i < connects.Length; i++)
|
||||
{
|
||||
switch (typeThis)
|
||||
{
|
||||
case "Button":
|
||||
connects[i].gameObject.GetComponent<myButton>().OnDown();
|
||||
break;
|
||||
case "ButtonCheckable":
|
||||
connects[i].gameObject.GetComponent<ButtonCheckable>().OnCheck();
|
||||
break;
|
||||
case "ButtonCheckable3":
|
||||
connects[i].gameObject.GetComponent<ButtonCheckable3>().EnableSprite(index);
|
||||
break;
|
||||
case "Switch":
|
||||
connects[i].gameObject.GetComponent<Switch>().setState(0);
|
||||
Transform[] btnList = connects[i].gameObject.GetComponentsInChildren<Transform>();
|
||||
string currentSw3Dname = connects[i].name.Substring(0, connects[i].name.Length) + "_3D";
|
||||
GameObject currentSw3D = GameObject.Find(currentSw3Dname);
|
||||
//Debug.Log($"currentSw3Dname {currentSw3Dname}");
|
||||
Switch3DRotate sw3Drotate = currentSw3D.GetComponent<Switch3DRotate>();
|
||||
sw3Drotate.RotateVertikalSwitch(2);
|
||||
break;
|
||||
case "Handler":
|
||||
connects[i].gameObject.GetComponent<PolygonCollider2D>().enabled=!connects[i].gameObject.GetComponent<PolygonCollider2D>().enabled;
|
||||
break;
|
||||
case "CoverStateToCoverState":
|
||||
//Debug.Log($"connects[i].gameObject.GetComponent<CoverState>() {connects[i].gameObject.GetComponent<CoverState>() != null}");
|
||||
connects[i].gameObject.GetComponent<CoverState>().switchOn();
|
||||
break;
|
||||
case "ScaleToScaleX":
|
||||
ref readonly string typeDrag = ref _drag.typeDrag;
|
||||
ref readonly bool _delta2 = ref _drag._delta;
|
||||
_delta = _delta2;
|
||||
|
||||
if (typeDrag == "x" && !_delta)
|
||||
{
|
||||
d = connects[i].gameObject.transform.localPosition.x - xy.x;
|
||||
}
|
||||
else if (typeDrag == "y" && !_delta)
|
||||
{
|
||||
d = connects[i].gameObject.transform.localPosition.y - xy.y;
|
||||
//Debug.Log($"d = {d}");
|
||||
}
|
||||
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
void OnMouseUp()
|
||||
{
|
||||
if (man.mode == "scedit" || man.mode == "play")
|
||||
return;
|
||||
for (int i = 0; i < connects.Length; i++)
|
||||
{
|
||||
switch (typeThis)
|
||||
{
|
||||
case "Button":
|
||||
connects[i].gameObject.GetComponent<myButton>().OnUp();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
public void OnBeginDrag(PointerEventData eventData)
|
||||
{
|
||||
if (man.mode == "scedit" || man.mode == "play")
|
||||
return;
|
||||
xy = new Vector2(this.gameObject.transform.localPosition.x, this.gameObject.transform.localPosition.y);
|
||||
|
||||
for (int i = 0; i < connects.Length; i++)
|
||||
{
|
||||
switch (typeThis)
|
||||
{
|
||||
case "ScaleToScaleX":
|
||||
ref readonly string typeDrag = ref _drag.typeDrag;
|
||||
ref readonly bool _delta2 = ref _drag._delta;
|
||||
_delta = _delta2;
|
||||
|
||||
if (typeDrag == "x" && !_delta)
|
||||
{
|
||||
d = connects[i].gameObject.transform.localPosition.x - xy.x;
|
||||
}
|
||||
else if (typeDrag == "y" && !_delta)
|
||||
{
|
||||
d = connects[i].gameObject.transform.localPosition.y - xy.y;
|
||||
}
|
||||
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public void Update()
|
||||
{
|
||||
if (man.mode == "scedit" || man.mode == "play")
|
||||
return;
|
||||
for (int i = 0; i < connects.Length; i++)
|
||||
{
|
||||
switch (typeThis)
|
||||
{
|
||||
case "ScaleToScaleX":
|
||||
if (connects[i].gameObject.transform.GetComponent<IndexH>() != null)
|
||||
{
|
||||
GameObject frame = connects[i].gameObject.transform.GetComponent<IndexH>().frame;
|
||||
if (frame.GetComponent<ScaleToText>() != null || frame.GetComponent<ScaleToText4>() != null)
|
||||
{
|
||||
bool point = (frame.GetComponent<ScaleToText>() != null) ? frame.GetComponent<ScaleToText>().point : frame.GetComponent<ScaleToText4>().point;
|
||||
bool isDrag = this.GetComponent<DragCollider>().isDrag;
|
||||
if (point || isDrag)
|
||||
{
|
||||
OnDrag(data);
|
||||
//Debug.Log($"point in connection = {point}");
|
||||
}
|
||||
else
|
||||
{
|
||||
OnBeginDrag(data);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
public void OnDrag(PointerEventData eventData)
|
||||
{
|
||||
if (man.mode == "scedit" || man.mode == "play")
|
||||
return;
|
||||
for (int i = 0; i < connects.Length; i++)
|
||||
{
|
||||
switch (typeThis)
|
||||
{
|
||||
case "ScaleToScaleX":
|
||||
ref readonly bool clamp = ref _drag.clamp;
|
||||
ref readonly string typeDrag = ref _drag.typeDrag;
|
||||
ref readonly float dragMin = ref _drag.dragMin;
|
||||
ref readonly float dragMax = ref _drag.dragMax;
|
||||
|
||||
/*GameObject frame = connects[i].gameObject.transform.GetComponent<IndexH>().frame;
|
||||
bool point = (frame.GetComponent<ScaleToText4>()!=null) ? frame.GetComponent<ScaleToText4>().point:false;*/
|
||||
//ref readonly Vector2 dd = ref _drag.dd;
|
||||
ref bool _delta2 = ref _drag._delta;
|
||||
|
||||
//Debug.Log($"OnDrag in connection = true");
|
||||
if (clamp && typeDrag == "x")
|
||||
{
|
||||
//Debug.Log($"clamp && typeDrag == x");
|
||||
if (this.gameObject.transform.localPosition.x + d >= dragMin && this.gameObject.transform.localPosition.x + d <= dragMax)
|
||||
{
|
||||
/*if(point) d = -2532;
|
||||
Debug.Log($" point = {point}");
|
||||
Debug.Log($" d = {d}");*/
|
||||
_delta = false;
|
||||
connects[i].gameObject.transform.localPosition = new Vector3(this.gameObject.transform.localPosition.x + d, connects[i].gameObject.transform.localPosition.y, connects[i].gameObject.transform.localPosition.z);
|
||||
//Debug.Log($" connects[i].gameObject.transform.localPosition = {connects[i].gameObject.transform.localPosition}");
|
||||
}
|
||||
else
|
||||
{
|
||||
_delta = true;
|
||||
}
|
||||
|
||||
}
|
||||
else if (clamp && typeDrag == "y")
|
||||
{
|
||||
if (this.gameObject.transform.localPosition.y + d >= dragMin && this.gameObject.transform.localPosition.y + d <= dragMax)
|
||||
{
|
||||
_delta = false;
|
||||
connects[i].gameObject.transform.localPosition = new Vector3(connects[i].gameObject.transform.localPosition.x, this.gameObject.transform.localPosition.y + d, connects[i].gameObject.transform.localPosition.z);
|
||||
}
|
||||
else
|
||||
{
|
||||
_delta = true;
|
||||
}
|
||||
|
||||
}
|
||||
_delta2 = _delta;
|
||||
xy = new Vector2(this.gameObject.transform.localPosition.x, this.gameObject.transform.localPosition.y);
|
||||
//connects[i].gameObject.transform.localPosition = new Vector3(this.gameObject.transform.localPosition.x + d, connects[i].gameObject.transform.localPosition.y, connects[i].gameObject.transform.localPosition.z);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void OnEndDrag(PointerEventData eventData)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
11
Heli_with_panels/Assets/Scripts/Panel2D/Connection.cs.meta
Normal file
11
Heli_with_panels/Assets/Scripts/Panel2D/Connection.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d5728f4aaf90d4346a89f56279343cc8
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
39
Heli_with_panels/Assets/Scripts/Panel2D/Cover.cs
Normal file
39
Heli_with_panels/Assets/Scripts/Panel2D/Cover.cs
Normal file
@@ -0,0 +1,39 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class Cover : MonoBehaviour
|
||||
{
|
||||
List<string> coverStatesListNames = new List<string>();
|
||||
//Dictionary<string, GameObject> switcheStatesList = new Dictionary<string, GameObject>();
|
||||
public Dictionary<string, CoverState> coverStatesList = new Dictionary<string, CoverState>();
|
||||
|
||||
// int posCount;
|
||||
// int currentPos;
|
||||
void Start()
|
||||
{
|
||||
// Debug.Log(go.name);
|
||||
Transform[] coverStates = this.GetComponentsInChildren<Transform>();
|
||||
// Debug.Log(btnList.Length);
|
||||
for (int i = 0; i < coverStates.Length; i++)
|
||||
{
|
||||
if (i == 0) continue;
|
||||
// Debug.Log(btnList[i].gameObject.name);
|
||||
coverStates[i].gameObject.AddComponent<CoverState>();
|
||||
coverStatesListNames.Add(coverStates[i].gameObject.name);
|
||||
coverStatesList.Add(coverStates[i].gameObject.name, coverStates[i].gameObject.GetComponent<CoverState>());
|
||||
}
|
||||
//coverStatesListNames.Sort();
|
||||
//setState(0);
|
||||
setState(0);
|
||||
}
|
||||
|
||||
public void setState(int state)
|
||||
{
|
||||
coverStatesList[coverStatesListNames[state]].switchOn();
|
||||
}
|
||||
public void setState(string swName)
|
||||
{
|
||||
coverStatesList[swName].switchOn();
|
||||
}
|
||||
}
|
||||
11
Heli_with_panels/Assets/Scripts/Panel2D/Cover.cs.meta
Normal file
11
Heli_with_panels/Assets/Scripts/Panel2D/Cover.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ce1306d71d9016241afe6729b45d63e7
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
44
Heli_with_panels/Assets/Scripts/Panel2D/Cover2.cs
Normal file
44
Heli_with_panels/Assets/Scripts/Panel2D/Cover2.cs
Normal file
@@ -0,0 +1,44 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class Cover2 : MonoBehaviour
|
||||
{
|
||||
List<GameObject> buttonStatesList3 = new List<GameObject>();
|
||||
Manager man;
|
||||
int click = 0;
|
||||
void Start()
|
||||
{
|
||||
man = GameObject.Find("Manager").GetComponent<Manager>();
|
||||
Transform[] buttonStates = this.GetComponentsInChildren<Transform>();
|
||||
for (int i = 0; i < buttonStates.Length; i++)
|
||||
{
|
||||
if ((!buttonStates[i].name.Equals(this.name)) && buttonStates[i].name.StartsWith(this.name))
|
||||
{
|
||||
buttonStates[i].gameObject.SetActive(false);
|
||||
buttonStatesList3.Add(buttonStates[i].gameObject);
|
||||
}
|
||||
|
||||
}
|
||||
EnableSprite(0);
|
||||
|
||||
}
|
||||
|
||||
void OnMouseUp()
|
||||
{
|
||||
if (man.mode == "scedit" || man.mode == "play")
|
||||
return;
|
||||
click++;
|
||||
if (click > buttonStatesList3.Count - 1) click = 0;
|
||||
//Debug.Log("êîëè÷åñòâî êëèêîâ + " + click);
|
||||
EnableSprite(click);
|
||||
|
||||
}
|
||||
|
||||
public void EnableSprite(int n)
|
||||
{
|
||||
buttonStatesList3.ForEach(_buttonStatesList3 => _buttonStatesList3.gameObject.SetActive(false));
|
||||
buttonStatesList3[n].gameObject.SetActive(true);
|
||||
}
|
||||
|
||||
}
|
||||
11
Heli_with_panels/Assets/Scripts/Panel2D/Cover2.cs.meta
Normal file
11
Heli_with_panels/Assets/Scripts/Panel2D/Cover2.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b8387cd22c69b81429e949f9a21922cf
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
138
Heli_with_panels/Assets/Scripts/Panel2D/CoverState.cs
Normal file
138
Heli_with_panels/Assets/Scripts/Panel2D/CoverState.cs
Normal file
@@ -0,0 +1,138 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class CoverState : MonoBehaviour
|
||||
{
|
||||
public Cover3DVrotate cw3DVrotate;
|
||||
public Cover3DHrotate cw3DHrotate;
|
||||
Manager man;
|
||||
|
||||
public void Start()
|
||||
{
|
||||
man = GameObject.Find("Manager").GetComponent<Manager>();
|
||||
}
|
||||
void OnMouseDown()
|
||||
{
|
||||
if (man.mode == "scedit" || man.mode == "play")
|
||||
return;
|
||||
switchOn();
|
||||
|
||||
//Switch3DVrotate sw3DVrotate = this.GetComponent<Switch3DVrotate>();
|
||||
|
||||
/* Transform[] btnList = this.transform.parent.gameObject.GetComponentsInChildren<Transform>();
|
||||
for (int i = 0; i < btnList.Length; i++)
|
||||
{
|
||||
if (i == 0) continue;
|
||||
if (btnList[i].gameObject.GetComponent<SpriteRenderer>() != null)
|
||||
{
|
||||
btnList[i].gameObject.GetComponent<SpriteRenderer>().enabled = true;
|
||||
btnList[i].gameObject.GetComponent<BoxCollider2D>().enabled = true;
|
||||
}
|
||||
if (btnList[i].gameObject.GetComponent<Image>() != null)
|
||||
{
|
||||
btnList[i].gameObject.GetComponent<Image>().enabled = true;
|
||||
btnList[i].gameObject.GetComponent<BoxCollider2D>().enabled = true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (this.gameObject.GetComponent<SpriteRenderer>() != null)
|
||||
{
|
||||
this.gameObject.GetComponent<SpriteRenderer>().enabled = false;
|
||||
this.gameObject.GetComponent<BoxCollider2D>().enabled = false;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
else
|
||||
if (this.gameObject.GetComponent<Image>() != null)
|
||||
{
|
||||
this.gameObject.GetComponent<Image>().enabled = false;
|
||||
this.gameObject.GetComponent<BoxCollider2D>().enabled = false;
|
||||
|
||||
}*/
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void switchOn()
|
||||
{
|
||||
Transform[] btnList = this.transform.parent.gameObject.GetComponentsInChildren<Transform>();
|
||||
for (int i = 1; i < btnList.Length; i++)
|
||||
{
|
||||
//if (i == 0) continue;
|
||||
|
||||
if (btnList[i].gameObject.GetComponent<SpriteRenderer>() != null)
|
||||
{
|
||||
btnList[i].gameObject.GetComponent<SpriteRenderer>().enabled = true;
|
||||
btnList[i].gameObject.GetComponent<BoxCollider2D>().enabled = true;
|
||||
}
|
||||
else
|
||||
if (btnList[i].gameObject.GetComponent<Image>() != null)
|
||||
{
|
||||
btnList[i].gameObject.GetComponent<Image>().enabled = true;
|
||||
btnList[i].gameObject.GetComponent<BoxCollider2D>().enabled = true;
|
||||
}
|
||||
|
||||
}
|
||||
//this.gameObject.GetComponent<Image>().enabled = true;
|
||||
if (this.gameObject.GetComponent<SpriteRenderer>() != null)
|
||||
{
|
||||
this.gameObject.GetComponent<SpriteRenderer>().enabled = false;
|
||||
this.gameObject.GetComponent<BoxCollider2D>().enabled = false;
|
||||
ConnectWith3d();
|
||||
ConnectWith3dh();
|
||||
}
|
||||
else
|
||||
if (this.gameObject.GetComponent<Image>() != null)
|
||||
{
|
||||
this.gameObject.GetComponent<Image>().enabled = false;
|
||||
this.gameObject.GetComponent<BoxCollider2D>().enabled = false;
|
||||
ConnectWith3d();
|
||||
ConnectWith3dh();
|
||||
}
|
||||
|
||||
if(man == null) man = GameObject.Find("Manager").GetComponent<Manager>();
|
||||
// частные случаи работы крышек, переключателей и др., не предусматриваемые механикой файла objects.xml - короче "костыли"
|
||||
if (this.transform.parent.gameObject.name == "Cover1_0502" && this.gameObject.name.EndsWith("_2"))
|
||||
man.objects.Find("Tumbler2_0502").SetObjectState(2);
|
||||
if (this.transform.parent.gameObject.name == "Cover2_0511" && this.gameObject.name.EndsWith("_2"))
|
||||
man.objects.Find("Tumbler2_0511").SetObjectState(0);
|
||||
|
||||
}
|
||||
|
||||
public void ConnectWith3d()
|
||||
{
|
||||
|
||||
string currentSw3Dname = this.transform.parent.name.Substring(0, transform.parent.name.Length) + "_3D";
|
||||
GameObject currentSw3D = GameObject.Find(currentSw3Dname);
|
||||
if (currentSw3D != null)
|
||||
{
|
||||
Cover3DVrotate cw3DVrotate = currentSw3D.GetComponent<Cover3DVrotate>();
|
||||
if (cw3DVrotate != null)
|
||||
cw3DVrotate.Rotate(int.Parse(this.name.Substring(this.name.Length - 1)));
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
public void ConnectWith3dh()
|
||||
{
|
||||
|
||||
string currentSw3DHname = this.transform.parent.name.Substring(0, transform.parent.name.Length) + "_3D";
|
||||
//Debug.Log(currentSw3DHname);
|
||||
GameObject currentSw3DH = GameObject.Find(currentSw3DHname);
|
||||
if (currentSw3DH != null)
|
||||
{
|
||||
Cover3DHrotate cw3DHrotate = currentSw3DH.GetComponent<Cover3DHrotate>();
|
||||
if (cw3DHrotate != null)
|
||||
cw3DHrotate.RotateH(int.Parse(this.name.Substring(this.name.Length - 1)));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
11
Heli_with_panels/Assets/Scripts/Panel2D/CoverState.cs.meta
Normal file
11
Heli_with_panels/Assets/Scripts/Panel2D/CoverState.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ce461297d7952f2459443070a25ec5a2
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
73
Heli_with_panels/Assets/Scripts/Panel2D/Drag.cs
Normal file
73
Heli_with_panels/Assets/Scripts/Panel2D/Drag.cs
Normal file
@@ -0,0 +1,73 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using UnityEngine.EventSystems;
|
||||
|
||||
public class Drag : MonoBehaviour, IBeginDragHandler, IDragHandler, IEndDragHandler
|
||||
{
|
||||
protected Vector3 mousePosition;
|
||||
protected Vector2 a; // Vector2 deltaPosition
|
||||
public string typeDrag = null;
|
||||
public float dragMin, dragMax;
|
||||
public bool clamp=false;
|
||||
|
||||
[HideInInspector] public Vector2 dd;//для передачи в connection
|
||||
[HideInInspector] public bool _delta = false;//для передачи в connection
|
||||
|
||||
private void Start()
|
||||
{
|
||||
dd = new Vector2(transform.localPosition.x, transform.localPosition.y);
|
||||
}
|
||||
public virtual void OnBeginDrag(PointerEventData data)
|
||||
{
|
||||
calculationBegin();
|
||||
}
|
||||
public virtual void OnDrag(PointerEventData data)
|
||||
{
|
||||
calculationDrag();
|
||||
|
||||
}
|
||||
|
||||
public void OnEndDrag(PointerEventData data)
|
||||
{
|
||||
dd = new Vector2(transform.localPosition.x, transform.localPosition.y);
|
||||
if (typeDrag == "x" && (dd.x == dragMin || dd.x == dragMax))
|
||||
{
|
||||
_delta = true;
|
||||
}
|
||||
else if (typeDrag == "y" && (dd.y == dragMin || dd.y == dragMax))
|
||||
{
|
||||
_delta = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
_delta = false;
|
||||
}
|
||||
}
|
||||
public void calculationBegin()
|
||||
{
|
||||
a = new Vector2(Input.mousePosition.x - transform.localPosition.x, Input.mousePosition.y - transform.localPosition.y);
|
||||
}
|
||||
public void calculationDrag()
|
||||
{
|
||||
mousePosition = Input.mousePosition;
|
||||
Vector2 q = new Vector2(mousePosition.x, mousePosition.y);
|
||||
Vector3 b = new Vector3(q.x - a.x, q.y - a.y, transform.localPosition.z);
|
||||
|
||||
if (typeDrag == "x")
|
||||
{
|
||||
b.x = (clamp) ? Mathf.Clamp(b.x, dragMin, dragMax) : b.x;
|
||||
transform.localPosition = new Vector3(b.x, transform.localPosition.y, transform.localPosition.z);
|
||||
}
|
||||
else if (typeDrag == "y")
|
||||
{
|
||||
b.y = (clamp) ? Mathf.Clamp(b.y, dragMin, dragMax) : b.y;
|
||||
transform.localPosition = new Vector3(transform.localPosition.x, b.y, transform.localPosition.z);
|
||||
}
|
||||
else
|
||||
{
|
||||
transform.localPosition = b;
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Heli_with_panels/Assets/Scripts/Panel2D/Drag.cs.meta
Normal file
11
Heli_with_panels/Assets/Scripts/Panel2D/Drag.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 65c1c1952aca7e641ab54adc14022f44
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
94
Heli_with_panels/Assets/Scripts/Panel2D/DragCollider.cs
Normal file
94
Heli_with_panels/Assets/Scripts/Panel2D/DragCollider.cs
Normal file
@@ -0,0 +1,94 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class DragCollider : MonoBehaviour
|
||||
{
|
||||
protected Vector3 mousePosition;
|
||||
protected Vector2 a; // Vector2 deltaPosition
|
||||
public string typeDrag = null;
|
||||
public float dragMin, dragMax;
|
||||
public bool clamp = false;
|
||||
|
||||
[HideInInspector] public Vector2 dd;//для передачи в connection
|
||||
[HideInInspector] public bool _delta = false;//для передачи в connection
|
||||
|
||||
[HideInInspector] public bool isDrag = false;
|
||||
Camera cam;//камера для канваса с панелями
|
||||
Manager man;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
dd = new Vector2(transform.localPosition.x, transform.localPosition.y);
|
||||
if (man == null) man = GameObject.Find("Manager").GetComponent<Manager>();
|
||||
cam = man.cam;
|
||||
}
|
||||
public void OnMouseDown()
|
||||
{
|
||||
calculationBegin();
|
||||
}
|
||||
public void OnMouseDrag()
|
||||
{
|
||||
calculationDrag();
|
||||
|
||||
}
|
||||
|
||||
public void OnMouseUp()
|
||||
{
|
||||
dd = new Vector2(transform.localPosition.x, transform.localPosition.y);
|
||||
if (typeDrag == "x" && (dd.x == dragMin || dd.x == dragMax))
|
||||
{
|
||||
_delta = true;
|
||||
}
|
||||
else if (typeDrag == "y" && (dd.y == dragMin || dd.y == dragMax))
|
||||
{
|
||||
_delta = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
_delta = false;
|
||||
}
|
||||
isDrag = false;
|
||||
}
|
||||
public void calculationBegin()
|
||||
{
|
||||
a = new Vector2(Input.mousePosition.x - transform.localPosition.x, Input.mousePosition.y - transform.localPosition.y);
|
||||
/*mousePosition = cam.ScreenToWorldPoint(Input.mousePosition);//mousePosition = Input.mousePosition;
|
||||
a = new Vector2(mousePosition.x - transform.localPosition.x, mousePosition.y - transform.localPosition.y);*/
|
||||
isDrag = true;
|
||||
}
|
||||
public void calculationDrag()
|
||||
{
|
||||
if (man.mode == "scedit" || man.mode == "play")
|
||||
return;
|
||||
/*mousePosition = cam.ScreenToWorldPoint(Input.mousePosition);*/
|
||||
mousePosition = Input.mousePosition;
|
||||
Vector2 q = new Vector2(mousePosition.x, mousePosition.y);
|
||||
Vector3 b = new Vector3(q.x - a.x, q.y - a.y, transform.localPosition.z);
|
||||
|
||||
if (typeDrag == "x")
|
||||
{
|
||||
b.x = (clamp) ? Mathf.Clamp(b.x, dragMin, dragMax) : b.x;
|
||||
transform.localPosition = new Vector3(b.x, transform.localPosition.y, transform.localPosition.z);
|
||||
}
|
||||
else if (typeDrag == "y")
|
||||
{
|
||||
b.y = (clamp) ? Mathf.Clamp(b.y, dragMin, dragMax) : b.y;
|
||||
transform.localPosition = new Vector3(transform.localPosition.x, b.y, transform.localPosition.z);
|
||||
}
|
||||
else
|
||||
{
|
||||
transform.localPosition = b;
|
||||
}
|
||||
}
|
||||
|
||||
public void SetState(int b)
|
||||
{
|
||||
b = (clamp) ? (int)Mathf.Clamp((float)b, dragMin, dragMax) : b;
|
||||
//b += (int)(dragMax - dragMin) / 2;
|
||||
if (typeDrag == "x")
|
||||
transform.localPosition = new Vector3(b, transform.localPosition.y, transform.localPosition.z);
|
||||
else if (typeDrag == "y")
|
||||
transform.localPosition = new Vector3(transform.localPosition.x, b, transform.localPosition.z);
|
||||
}
|
||||
}
|
||||
11
Heli_with_panels/Assets/Scripts/Panel2D/DragCollider.cs.meta
Normal file
11
Heli_with_panels/Assets/Scripts/Panel2D/DragCollider.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 231cfd8c832c9de4db7d791231ceda82
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
27
Heli_with_panels/Assets/Scripts/Panel2D/DragMask.cs
Normal file
27
Heli_with_panels/Assets/Scripts/Panel2D/DragMask.cs
Normal file
@@ -0,0 +1,27 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class DragMask : MonoBehaviour
|
||||
{
|
||||
|
||||
|
||||
private void OnMouseEnter()
|
||||
{
|
||||
|
||||
}
|
||||
public void OnMouseDown()
|
||||
{
|
||||
|
||||
}
|
||||
public void OnMouseDrag()
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void OnMouseUp()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
11
Heli_with_panels/Assets/Scripts/Panel2D/DragMask.cs.meta
Normal file
11
Heli_with_panels/Assets/Scripts/Panel2D/DragMask.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 65c9b7010d95cbd42879610e90285332
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
BIN
Heli_with_panels/Assets/Scripts/Panel2D/Handler.cs
Normal file
BIN
Heli_with_panels/Assets/Scripts/Panel2D/Handler.cs
Normal file
Binary file not shown.
11
Heli_with_panels/Assets/Scripts/Panel2D/Handler.cs.meta
Normal file
11
Heli_with_panels/Assets/Scripts/Panel2D/Handler.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5927e0332f09efe40a5e5919a5319e1b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
50
Heli_with_panels/Assets/Scripts/Panel2D/MyBtnCheck3.cs
Normal file
50
Heli_with_panels/Assets/Scripts/Panel2D/MyBtnCheck3.cs
Normal file
@@ -0,0 +1,50 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class MyBtnCheck3 : MonoBehaviour
|
||||
{
|
||||
List<GameObject> buttonStatesList3 = new List<GameObject>();
|
||||
int click = 1;
|
||||
Manager man;
|
||||
|
||||
void Start()
|
||||
{
|
||||
man = GameObject.Find("Manager").GetComponent<Manager>();
|
||||
Transform[] buttonStates = this.GetComponentsInChildren<Transform>();
|
||||
for (int i = 0; i < buttonStates.Length; i++)
|
||||
{
|
||||
if (buttonStates[i].name.Length > this.name.Length)
|
||||
{
|
||||
//Debug.Log(buttonStates[i] + " В массив ");
|
||||
buttonStates[i].gameObject.SetActive(false);
|
||||
buttonStatesList3.Add(buttonStates[i].gameObject);
|
||||
}
|
||||
|
||||
}
|
||||
EnableSprite(click);
|
||||
|
||||
}
|
||||
void OnMouseDown()
|
||||
{
|
||||
if (man.mode == "scedit" || man.mode == "play")
|
||||
return;
|
||||
EnableSprite(0);
|
||||
}
|
||||
void OnMouseUp()
|
||||
{
|
||||
if (man.mode == "scedit" || man.mode == "play")
|
||||
return;
|
||||
click++;
|
||||
if (click > buttonStatesList3.Count - 1) click = 1;
|
||||
//Debug.Log("количество кликов + " + click);
|
||||
EnableSprite(click);
|
||||
|
||||
}
|
||||
|
||||
public void EnableSprite(int n)
|
||||
{
|
||||
buttonStatesList3.ForEach(_buttonStatesList3 => _buttonStatesList3.gameObject.SetActive(false));
|
||||
buttonStatesList3[n].gameObject.SetActive(true);
|
||||
}
|
||||
}
|
||||
11
Heli_with_panels/Assets/Scripts/Panel2D/MyBtnCheck3.cs.meta
Normal file
11
Heli_with_panels/Assets/Scripts/Panel2D/MyBtnCheck3.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 353a6fbef5f528449b02e9bb1baea85b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
189
Heli_with_panels/Assets/Scripts/Panel2D/Panel2D.cs
Normal file
189
Heli_with_panels/Assets/Scripts/Panel2D/Panel2D.cs
Normal file
@@ -0,0 +1,189 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
|
||||
public class Panel2D : MonoBehaviour
|
||||
{
|
||||
|
||||
//public ScriptA m_someOtherScriptOnAnotherGameObject;
|
||||
// Start is called before the first frame update
|
||||
public Dictionary<string, GameObject> switchesList = new Dictionary<string, GameObject>(); // Обычные переключатели
|
||||
Dictionary<string, GameObject> switchesListHold = new Dictionary<string, GameObject>(); // Переключатели которые не фиксируются
|
||||
Dictionary<string, GameObject> buttonList = new Dictionary<string, GameObject>();
|
||||
Dictionary<string, GameObject> buttonCheckList = new Dictionary<string, GameObject>(); // Нажимно-отжимные, с тегом buttonscheck
|
||||
Dictionary<string, GameObject> buttonCheckList3 = new Dictionary<string, GameObject>(); // Переключатели и кнопки с любым количеством спрайтов,переключающиеся друг за другом
|
||||
Dictionary<string, GameObject> mybtnCheckList3 = new Dictionary<string, GameObject>(); // Переключатели и кнопки с нажатием (первый объект),с любым количеством спрайтов,переключающиеся друг за другом
|
||||
Dictionary<string, GameObject> coverList = new Dictionary<string, GameObject>(); // Крышки и колпачки
|
||||
Dictionary<string, GameObject> handlerList = new Dictionary<string, GameObject>(); // Крутилки
|
||||
Dictionary<string, GameObject> rotateAngleList = new Dictionary<string, GameObject>(); // Крутилки
|
||||
Manager man;
|
||||
Camera cam;//камера для канваса с панелями
|
||||
string layerName;
|
||||
Collider2D[] coll2d;
|
||||
public bool isStarted = false;
|
||||
|
||||
void Start()
|
||||
{
|
||||
if(!isStarted)
|
||||
StartCoroutine(Init());
|
||||
}
|
||||
public IEnumerator Init()
|
||||
{
|
||||
man = GameObject.Find("Manager").GetComponent<Manager>();
|
||||
cam = man.cam;
|
||||
layerName = LayerMask.LayerToName(gameObject.layer);
|
||||
coll2d = this.gameObject.GetComponentsInChildren<Collider2D>();
|
||||
UnityObject uObj = man.objects.Find(this.gameObject.name);
|
||||
while (!man.objects.isLoaded)
|
||||
yield return null;
|
||||
|
||||
// Debug.Log("Start 2D " + this.gameObject.name);
|
||||
|
||||
if (uObj == null)
|
||||
yield break;
|
||||
|
||||
List<UnityObject> switches = uObj.FindChildsWithTag("toggle");
|
||||
foreach (UnityObject sw in switches)
|
||||
{
|
||||
sw.gameObject.AddComponent<Switch>();
|
||||
switchesList.Add(sw.gameObject.name, sw.gameObject);
|
||||
//Debug.Log("Имена sw " + sw.name);
|
||||
}
|
||||
|
||||
List<UnityObject> switcheshold = uObj.FindChildsWithTag("togglehold");
|
||||
foreach (UnityObject swh in switcheshold)
|
||||
{
|
||||
//Debug.Log(swh);
|
||||
swh.gameObject.AddComponent<SwitchHold>();
|
||||
switchesListHold.Add(swh.gameObject.name, swh.gameObject);
|
||||
}
|
||||
List<UnityObject> buttons = uObj.FindChildsWithTag("buttons");
|
||||
foreach (UnityObject btn in buttons)
|
||||
{
|
||||
btn.gameObject.AddComponent<myButton>();
|
||||
buttonList.Add(btn.gameObject.name, btn.gameObject);
|
||||
//Debug.Log("Имена sw " + sw.name);
|
||||
}
|
||||
|
||||
List<UnityObject> buttonscheck = uObj.FindChildsWithTag("buttonscheck");
|
||||
foreach (UnityObject _buttonscheck in buttonscheck)
|
||||
{
|
||||
_buttonscheck.gameObject.AddComponent<ButtonCheckable>();
|
||||
buttonCheckList.Add(_buttonscheck.gameObject.name, _buttonscheck.gameObject);
|
||||
|
||||
if (!_buttonscheck.gameObject.activeInHierarchy && !_buttonscheck.gameObject.GetComponent<ButtonCheckable>().isStarted)
|
||||
{
|
||||
|
||||
string nm = _buttonscheck.gameObject.transform.parent.gameObject.name;
|
||||
GameObject parentGO = _buttonscheck.gameObject.transform.parent.parent.gameObject;
|
||||
if (nm == "view2_0801" || nm == "view2_0802" || nm == "view3_0801" || nm == "view3_0802" ||
|
||||
nm == "Handle3_0701" || nm == "Handle3_0702")
|
||||
{
|
||||
parentGO.SetActive(true);
|
||||
while (!_buttonscheck.gameObject.GetComponent<ButtonCheckable>().isStarted)
|
||||
yield return null;
|
||||
parentGO.SetActive(false);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
List<UnityObject> buttonscheck3 = uObj.FindChildsWithTag("buttonscheck3");
|
||||
foreach (UnityObject _buttonscheck3 in buttonscheck3)
|
||||
{
|
||||
_buttonscheck3.gameObject.AddComponent<ButtonCheckable3>();
|
||||
buttonCheckList3.Add(_buttonscheck3.gameObject.name, _buttonscheck3.gameObject);
|
||||
}
|
||||
|
||||
List<UnityObject> mybtnCheck = uObj.FindChildsWithTag("myBtnCheck");
|
||||
foreach (UnityObject _mybtnCheck in mybtnCheck)
|
||||
{
|
||||
_mybtnCheck.gameObject.AddComponent<MyBtnCheck3>();
|
||||
mybtnCheckList3.Add(_mybtnCheck.gameObject.name, _mybtnCheck.gameObject);
|
||||
}
|
||||
|
||||
List<UnityObject> cover = uObj.FindChildsWithTag("cover");
|
||||
foreach (UnityObject _cover in cover)
|
||||
{
|
||||
_cover.gameObject.AddComponent<Cover>();
|
||||
coverList.Add(_cover.gameObject.name, _cover.gameObject);
|
||||
}
|
||||
|
||||
List<UnityObject> handler = uObj.FindChildsWithTag("handles");
|
||||
foreach (UnityObject _handler in handler)
|
||||
{
|
||||
|
||||
if(_handler.gameObject.GetComponent<Handler>() == null)
|
||||
_handler.gameObject.AddComponent<Handler>();
|
||||
if (!_handler.gameObject.activeInHierarchy && !_handler.gameObject.GetComponent<Handler>().isStarted)
|
||||
{
|
||||
|
||||
string nm = _handler.gameObject.name;
|
||||
GameObject parentGO = _handler.gameObject.transform.parent.gameObject;
|
||||
if (nm == "view2_0801" || nm == "view2_0802" || nm == "view3_0801" || nm == "view3_0802" ||
|
||||
nm == "Handle3_0701" || nm == "Handle3_0702")
|
||||
{
|
||||
parentGO.SetActive(true);
|
||||
parentGO.SetActive(false);
|
||||
}
|
||||
}
|
||||
while (!_handler.gameObject.GetComponent<Handler>().isStarted)
|
||||
yield return null;
|
||||
|
||||
//if (_handler.gameObject.name == "Handle3_0701" || _handler.gameObject.name == "Handle3_0702")
|
||||
// Debug.Log("Init Panel2D: handler " + _handler.gameObject.name + " is started " + _handler.gameObject.GetComponent<Handler>().isStarted);
|
||||
|
||||
handlerList.Add(_handler.gameObject.name, _handler.gameObject);
|
||||
}
|
||||
List<UnityObject> rotateangle = uObj.FindChildsWithTag("rotateangle");
|
||||
foreach (UnityObject _rotateangle in rotateangle)
|
||||
{
|
||||
_rotateangle.gameObject.AddComponent<RotateAngle>();
|
||||
rotateAngleList.Add(_rotateangle.gameObject.name, _rotateangle.gameObject);
|
||||
}
|
||||
|
||||
// switchesList["Toggle1_0213"].GetComponent<Switch>().setState(0);
|
||||
//Debug.Log("End Start 2D " + this.gameObject.name);
|
||||
|
||||
isStarted = true;
|
||||
|
||||
/*for (int i = 0; i < man.objects.obj.Count; i++)
|
||||
{
|
||||
UnityObject uo = man.objects.obj[i];
|
||||
if (uo == null) continue;
|
||||
List<UnityObject> objs = uo.FindChildsWithTag("Untagged");
|
||||
foreach (UnityObject _handler in objs)
|
||||
if (_handler.gameObject.GetComponent<Handler>() != null)
|
||||
Debug.Log("Untagged handles " + _handler.gameObject.name);
|
||||
}*/
|
||||
}
|
||||
private void EnableCollider( bool isEnable)
|
||||
{
|
||||
for (int i = 0; i < coll2d.Length; i++)
|
||||
{
|
||||
coll2d[i].enabled = isEnable;
|
||||
}
|
||||
}
|
||||
public void setEnabled()
|
||||
{
|
||||
cam.cullingMask |= 1 << LayerMask.NameToLayer(layerName);
|
||||
this.gameObject.SetActive(true);
|
||||
if (layerName.StartsWith("MFI")) EnableCollider(true);
|
||||
}
|
||||
|
||||
public void setDisabled()
|
||||
{
|
||||
cam.cullingMask = 0;
|
||||
if (!layerName.StartsWith("MFI"))
|
||||
{
|
||||
|
||||
this.gameObject.SetActive(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
EnableCollider(false);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
11
Heli_with_panels/Assets/Scripts/Panel2D/Panel2D.cs.meta
Normal file
11
Heli_with_panels/Assets/Scripts/Panel2D/Panel2D.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9c209ec1c3824ab49808dd1be0fa0afd
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
95
Heli_with_panels/Assets/Scripts/Panel2D/RotateAngle.cs
Normal file
95
Heli_with_panels/Assets/Scripts/Panel2D/RotateAngle.cs
Normal file
@@ -0,0 +1,95 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using UnityEngine.EventSystems;
|
||||
using TMPro;
|
||||
|
||||
public class RotateAngle : MonoBehaviour
|
||||
{
|
||||
public float defaultAngle = 0; // угол устанавливаемый по дефолту. угол 0 по часам
|
||||
private List<GameObject> angles;
|
||||
private List<float> angleArray;
|
||||
float[] NewArrayAngle;
|
||||
public int count = -1, countAngle = 0;
|
||||
bool reverse = true;
|
||||
Manager man;
|
||||
|
||||
void Start()
|
||||
{
|
||||
man = GameObject.Find("Manager").GetComponent<Manager>();
|
||||
//transform.localRotation = Quaternion.Euler(0f, 0f, -defaultAngle);
|
||||
string n = gameObject.name;
|
||||
angles = new List<GameObject>();
|
||||
angleArray = new List<float>();
|
||||
foreach (CircleCollider2D gr in this.transform.parent.GetComponentsInChildren<CircleCollider2D>())
|
||||
{
|
||||
string s = gr.name;
|
||||
if ((!s.Equals(n)) && s.StartsWith(n))
|
||||
{
|
||||
count++;
|
||||
angles.Add(gr.gameObject);
|
||||
var at = Mathf.Atan2(gr.gameObject.transform.position.x - transform.position.x, gr.gameObject.transform.position.y - transform.position.y) * Mathf.Rad2Deg;
|
||||
angleArray.Add(at);
|
||||
gr.gameObject.AddComponent<AngleCollider>().countA = count;
|
||||
gr.gameObject.GetComponent<AngleCollider>().parObject = this.gameObject;
|
||||
|
||||
}
|
||||
}
|
||||
NewArrayAngle = angleArray.ToArray();
|
||||
OnCollider(0);
|
||||
|
||||
}
|
||||
public void OnCollider(int c)
|
||||
{
|
||||
if (!tryNewAngle(c)) return;
|
||||
transform.localRotation = Quaternion.Euler(0f, 0f, -NewArrayAngle[c]);
|
||||
countAngle=c;
|
||||
}
|
||||
|
||||
public void OnMouseDown()
|
||||
{
|
||||
if (man.mode == "scedit" || man.mode == "play")
|
||||
return;
|
||||
bool newReverse = reverse;
|
||||
int newcountAngle = countAngle;
|
||||
if (countAngle == count)
|
||||
{
|
||||
newReverse = true;
|
||||
}else if(countAngle == 0)
|
||||
{
|
||||
newReverse = false;
|
||||
}
|
||||
//reverse = (countAngle == count|| countAngle == 0) ? !reverse:reverse;
|
||||
newcountAngle = (!newReverse) ? countAngle+1 : countAngle - 1;
|
||||
|
||||
if (!tryNewAngle(newcountAngle))
|
||||
{
|
||||
newReverse = reverse;
|
||||
return;
|
||||
}
|
||||
|
||||
countAngle = newcountAngle; reverse = newReverse;
|
||||
OnCollider(countAngle);
|
||||
}
|
||||
|
||||
bool tryNewAngle(int c)
|
||||
{
|
||||
// частные случаи работы крышек, переключателей и др., не предусматриваемые механикой файла objects.xml - короче "костыли"
|
||||
if (this.gameObject.name == "Handle2_0511") // Panel0511
|
||||
{
|
||||
Handler H1 = man.objects.Find("Handle1_0511").gameObject.GetComponent<Handler>();
|
||||
if (c == 1 && H1.currentAngle <= 11 && H1.currentAngle > -18)
|
||||
return false;
|
||||
if (c == 2 && H1.currentAngle <= 11 && H1.currentAngle > -47)
|
||||
return false;
|
||||
switch(c) {
|
||||
case 0: H1.endDragMin = 11; break;
|
||||
case 1: H1.endDragMin = -18; break;
|
||||
case 2: H1.endDragMin = -47; break;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
11
Heli_with_panels/Assets/Scripts/Panel2D/RotateAngle.cs.meta
Normal file
11
Heli_with_panels/Assets/Scripts/Panel2D/RotateAngle.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 73e9252e05600f748a7bfcdc929475a0
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
97
Heli_with_panels/Assets/Scripts/Panel2D/Switch.cs
Normal file
97
Heli_with_panels/Assets/Scripts/Panel2D/Switch.cs
Normal file
@@ -0,0 +1,97 @@
|
||||
<<<<<<< HEAD
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class Switch : MonoBehaviour
|
||||
{
|
||||
List<string> switcheStatesListNames = new List<string>();
|
||||
//Dictionary<string, GameObject> switcheStatesList = new Dictionary<string, GameObject>();
|
||||
public Dictionary<string, SwitchState> switcheStatesList = new Dictionary<string, SwitchState>();
|
||||
bool isStarted = false;
|
||||
|
||||
// int posCount;
|
||||
// int currentPos;
|
||||
void Start()
|
||||
{
|
||||
if (isStarted) return;
|
||||
// Debug.Log(go.name);
|
||||
Transform[] switchStates = this.GetComponentsInChildren<Transform>();
|
||||
// Debug.Log(btnList.Length);
|
||||
for (int i = 0; i < switchStates.Length; i++)
|
||||
{
|
||||
if (i == 0) continue;
|
||||
// Debug.Log(btnList[i].gameObject.name);
|
||||
switchStates[i].gameObject.AddComponent<SwitchState>();
|
||||
switcheStatesListNames.Add(switchStates[i].gameObject.name);
|
||||
switcheStatesList.Add(switchStates[i].gameObject.name, switchStates[i].gameObject.GetComponent<SwitchState>());
|
||||
}
|
||||
switcheStatesListNames.Sort();
|
||||
if(switcheStatesListNames.Count>0)
|
||||
switcheStatesList[switcheStatesListNames[0]].switchOn();
|
||||
isStarted = true;
|
||||
//setState(1);
|
||||
}
|
||||
|
||||
public void setState(int state)
|
||||
{
|
||||
if (!isStarted) Start();
|
||||
if (state >= 0 && state < switcheStatesListNames.Count)
|
||||
switcheStatesList[switcheStatesListNames[state]].switchOn();
|
||||
else
|
||||
Debug.LogError("Ошибка установки состояния " + state + " объекта " + this.gameObject.name);
|
||||
}
|
||||
public void setState(string swName)
|
||||
{
|
||||
if (!isStarted) Start();
|
||||
switcheStatesList[swName].switchOn();
|
||||
}
|
||||
}
|
||||
=======
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class Switch : MonoBehaviour
|
||||
{
|
||||
List<string> switcheStatesListNames = new List<string>();
|
||||
//Dictionary<string, GameObject> switcheStatesList = new Dictionary<string, GameObject>();
|
||||
public Dictionary<string, SwitchState> switcheStatesList = new Dictionary<string, SwitchState>();
|
||||
bool isStarted = false;
|
||||
|
||||
// int posCount;
|
||||
// int currentPos;
|
||||
void Start()
|
||||
{
|
||||
if (isStarted) return;
|
||||
// Debug.Log(go.name);
|
||||
Transform[] switchStates = this.GetComponentsInChildren<Transform>();
|
||||
// Debug.Log(btnList.Length);
|
||||
for (int i = 0; i < switchStates.Length; i++)
|
||||
{
|
||||
if (i == 0) continue;
|
||||
// Debug.Log(btnList[i].gameObject.name);
|
||||
switchStates[i].gameObject.AddComponent<SwitchState>();
|
||||
switcheStatesListNames.Add(switchStates[i].gameObject.name);
|
||||
switcheStatesList.Add(switchStates[i].gameObject.name, switchStates[i].gameObject.GetComponent<SwitchState>());
|
||||
}
|
||||
switcheStatesListNames.Sort();
|
||||
if(switcheStatesListNames.Count>0)
|
||||
switcheStatesList[switcheStatesListNames[0]].switchOn();
|
||||
isStarted = true;
|
||||
//setState(1);
|
||||
}
|
||||
|
||||
public void setState(int state)
|
||||
{
|
||||
if (!isStarted) Start();
|
||||
if (state >= 0 && state < switcheStatesListNames.Count)
|
||||
switcheStatesList[switcheStatesListNames[state]].switchOn();
|
||||
else
|
||||
Debug.LogError("Ошибка установки состояния " + state + " объекта " + this.gameObject.name);
|
||||
}
|
||||
public void setState(string swName)
|
||||
{
|
||||
if (!isStarted) Start();
|
||||
switcheStatesList[swName].switchOn();
|
||||
}
|
||||
}
|
||||
>>>>>>> 3b1b9479a46e90d056b92897ea9f8422b25fc052
|
||||
11
Heli_with_panels/Assets/Scripts/Panel2D/Switch.cs.meta
Normal file
11
Heli_with_panels/Assets/Scripts/Panel2D/Switch.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1ea15b77f0adfa74fbcd95b872bbb96f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
63
Heli_with_panels/Assets/Scripts/Panel2D/SwitchHold.cs
Normal file
63
Heli_with_panels/Assets/Scripts/Panel2D/SwitchHold.cs
Normal file
@@ -0,0 +1,63 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
|
||||
public class SwitchHold : MonoBehaviour
|
||||
|
||||
{
|
||||
List<string> switcheHoldStatesListNames = new List<string>();
|
||||
//Dictionary<string, GameObject> switcheStatesList = new Dictionary<string, GameObject>();
|
||||
public Dictionary<string, SwitchHoldState> switcheHoldStatesList = new Dictionary<string, SwitchHoldState>();
|
||||
|
||||
// int posCount;
|
||||
// int currentPos;
|
||||
void Start()
|
||||
{
|
||||
// Debug.Log(go.name);
|
||||
Transform[] switchStates = this.GetComponentsInChildren<Transform>();
|
||||
// Debug.Log(btnList.Length);
|
||||
for (int i = 0; i < switchStates.Length; i++)
|
||||
{
|
||||
if (i == 0) continue;
|
||||
//Debug.Log(switchStates[i].gameObject.name + " switchStates");
|
||||
switchStates[i].gameObject.AddComponent<SwitchHoldState>();
|
||||
switcheHoldStatesListNames.Add(switchStates[i].gameObject.name);
|
||||
switcheHoldStatesList.Add(switchStates[i].gameObject.name, switchStates[i].gameObject.GetComponent<SwitchHoldState>());
|
||||
}
|
||||
switcheHoldStatesListNames.Sort();
|
||||
//Debug.Log(switcheHoldStatesListNames + " switchStates List");
|
||||
setState(2);
|
||||
|
||||
}
|
||||
|
||||
public void setState(int state)
|
||||
{
|
||||
switcheHoldStatesList[switcheHoldStatesListNames[state]].switchOn();
|
||||
}
|
||||
public void setState(string swName)
|
||||
{
|
||||
switcheHoldStatesList[swName].switchOn();
|
||||
}
|
||||
|
||||
|
||||
/* void OnMouseDown()
|
||||
{
|
||||
|
||||
Transform[] btnList = this.transform.parent.gameObject.GetComponentsInChildren<Transform>();
|
||||
for (int i = 0; i < btnList.Length; i++)
|
||||
{
|
||||
if (i == 0) continue;
|
||||
|
||||
btnList[i].gameObject.GetComponent<SpriteRenderer>().enabled = false;
|
||||
Debug.Log("btnList[i] + " + btnList[i]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Debug.Log(" + " + click);
|
||||
|
||||
click++;
|
||||
}*/
|
||||
|
||||
}
|
||||
11
Heli_with_panels/Assets/Scripts/Panel2D/SwitchHold.cs.meta
Normal file
11
Heli_with_panels/Assets/Scripts/Panel2D/SwitchHold.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9c4311345fc0f6e4da54c0c6a98e5413
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
86
Heli_with_panels/Assets/Scripts/Panel2D/SwitchHoldState.cs
Normal file
86
Heli_with_panels/Assets/Scripts/Panel2D/SwitchHoldState.cs
Normal file
@@ -0,0 +1,86 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class SwitchHoldState : MonoBehaviour
|
||||
{
|
||||
Manager man;
|
||||
|
||||
// public Switch3DRotate sw3Drotate;
|
||||
public Switch3DHRotate sw3DHrotate;
|
||||
void Start()
|
||||
{
|
||||
Transform[] btnList = this.transform.parent.gameObject.GetComponentsInChildren<Transform>();
|
||||
|
||||
for (int i = 1; i < btnList.Length; i++)
|
||||
{
|
||||
if (i == 1) continue;
|
||||
|
||||
btnList[i].gameObject.GetComponent<SpriteRenderer>().enabled = false;
|
||||
}
|
||||
man = GameObject.Find("Manager").GetComponent<Manager>();
|
||||
btnList[3].gameObject.GetComponent<SpriteRenderer>().enabled = true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void OnMouseDown()
|
||||
{
|
||||
if (man.mode == "scedit" || man.mode == "play")
|
||||
return;
|
||||
Transform[] btnList = this.transform.parent.gameObject.GetComponentsInChildren<Transform>();
|
||||
for (int i = 1; i < btnList.Length; i++)
|
||||
{
|
||||
//if (i == 1) continue;
|
||||
btnList[i].gameObject.GetComponent<SpriteRenderer>().enabled = false;
|
||||
}
|
||||
|
||||
this.gameObject.GetComponent<SpriteRenderer>().enabled = true;
|
||||
// btnList[1].gameObject.GetComponent<SpriteRenderer>().enabled = false;
|
||||
ConnectWith3DSwitchHorizontal();
|
||||
}
|
||||
|
||||
void OnMouseUp()
|
||||
{
|
||||
if (man.mode == "scedit" || man.mode == "play")
|
||||
return;
|
||||
Transform[] btnList = this.transform.parent.gameObject.GetComponentsInChildren<Transform>();
|
||||
for (int i = 1; i < btnList.Length; i++)
|
||||
{
|
||||
//if (i == 1) continue;
|
||||
btnList[i].gameObject.GetComponent<SpriteRenderer>().enabled = false;
|
||||
}
|
||||
btnList[3].gameObject.GetComponent<SpriteRenderer>().enabled = true;
|
||||
|
||||
|
||||
// Временный костыль возврата переключателя после отжатия, ситчаем что у всех таких выключателей возврат в середину
|
||||
string currentSw3DHname = this.name.Substring(0, this.name.Length - 1) + "3D";
|
||||
GameObject currentSw3DH = GameObject.Find(currentSw3DHname);
|
||||
Switch3DHRotate sw3DHrotate = currentSw3DH.GetComponent<Switch3DHRotate>();
|
||||
if (sw3DHrotate != null)
|
||||
//sw3DHrotate.RotateHorizontalSwitch(btnList.Length - 1, int.Parse(this.name.Substring(this.name.Length - 1)));
|
||||
sw3DHrotate.RotateHorizontalSwitch(2);
|
||||
|
||||
}
|
||||
|
||||
public void switchOn()
|
||||
{
|
||||
Transform[] btnList = this.transform.parent.gameObject.GetComponentsInChildren<Transform>();
|
||||
for (int i = 1; i < btnList.Length; i++)
|
||||
btnList[i].gameObject.GetComponent<SpriteRenderer>().enabled = false;
|
||||
this.gameObject.GetComponent<SpriteRenderer>().enabled = true;
|
||||
}
|
||||
|
||||
public void ConnectWith3DSwitchHorizontal()
|
||||
{
|
||||
Transform[] btnList = this.transform.parent.gameObject.GetComponentsInChildren<Transform>();
|
||||
string currentSw3DHname = this.name.Substring(0, this.name.Length - 1) + "3D";
|
||||
GameObject currentSw3DH = GameObject.Find(currentSw3DHname);
|
||||
Switch3DHRotate sw3DHrotate = currentSw3DH.GetComponent<Switch3DHRotate>();
|
||||
if (sw3DHrotate != null)
|
||||
//sw3DHrotate.RotateHorizontalSwitch(btnList.Length - 1, int.Parse(this.name.Substring(this.name.Length - 1)));
|
||||
sw3DHrotate.RotateHorizontalSwitch(int.Parse(this.name.Substring(this.name.Length - 1)) - 1);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: da9395e1f430aa141a05cff7871070d6
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
89
Heli_with_panels/Assets/Scripts/Panel2D/SwitchState.cs
Normal file
89
Heli_with_panels/Assets/Scripts/Panel2D/SwitchState.cs
Normal file
@@ -0,0 +1,89 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class SwitchState : MonoBehaviour
|
||||
{
|
||||
//public Switch3DRotate sw3Drotate;
|
||||
public Switch3DHRotate sw3DHrotate;
|
||||
Manager man;
|
||||
|
||||
void Start()
|
||||
{
|
||||
//sw3Drotate = FindObjectOfType<Switch3DRotate>();
|
||||
// Debug.Log(sw3Drotate + " объекты" );
|
||||
man = GameObject.Find("Manager").GetComponent<Manager>();
|
||||
}
|
||||
|
||||
void OnMouseDown()
|
||||
{
|
||||
if (man.mode == "scedit" || man.mode == "play")
|
||||
return;
|
||||
Transform[] btnList = this.transform.parent.gameObject.GetComponentsInChildren<Transform>();
|
||||
for (int i = 0; i < btnList.Length; i++)
|
||||
{
|
||||
if (i == 0) continue;
|
||||
if(btnList[i].gameObject.GetComponent<Image>()!=null)
|
||||
btnList[i].gameObject.GetComponent<Image>().enabled = false;
|
||||
else
|
||||
btnList[i].gameObject.GetComponent<SpriteRenderer>().enabled = false;
|
||||
}
|
||||
//this.gameObject.GetComponent<Image>().enabled = true;
|
||||
if (this.gameObject.GetComponent<Image>() != null)
|
||||
this.gameObject.GetComponent<Image>().enabled = true;
|
||||
else
|
||||
this.gameObject.GetComponent<SpriteRenderer>().enabled = true;
|
||||
//Debug.Log(int.Parse(this.name.Substring(this.name.Length - 1)) + " конец этого");
|
||||
|
||||
//if(sw3Drotate!=null) ConnectWith3DSwitchVertikal();
|
||||
//if (sw3DHrotate!=null) ConnectWith3DSwitchHorizontal();
|
||||
ConnectWith3DSwitchVertikal();
|
||||
ConnectWith3DSwitchHorizontal();
|
||||
|
||||
}
|
||||
/*Функция связывает вертикальные выключатели 2D и 3D */
|
||||
public void ConnectWith3DSwitchVertikal()
|
||||
{
|
||||
Transform[] btnList = this.transform.parent.gameObject.GetComponentsInChildren<Transform>();
|
||||
string currentSw3Dname = this.name.Substring(0, this.name.Length - 1) + "3D";
|
||||
GameObject currentSw3D = GameObject.Find(currentSw3Dname);
|
||||
Switch3DRotate sw3Drotate = currentSw3D.GetComponent<Switch3DRotate>();
|
||||
if (sw3Drotate != null)
|
||||
// sw3Drotate.RotateVertikalSwitch(btnList.Length - 1, int.Parse(this.name.Substring(this.name.Length - 1)));
|
||||
sw3Drotate.RotateVertikalSwitch(int.Parse(this.name.Substring(this.name.Length - 1))-1); // добавили в передаваемое значение -1. Спрайты имеют концовку 1,2,3, а numpos в редакторе начинается с нуля
|
||||
|
||||
|
||||
}
|
||||
/*Функция связывает горизонтальные выключатели 2D и 3D */
|
||||
public void ConnectWith3DSwitchHorizontal()
|
||||
{
|
||||
Transform[] btnList = this.transform.parent.gameObject.GetComponentsInChildren<Transform>();
|
||||
string currentSw3DHname = this.name.Substring(0, this.name.Length - 1) + "3D";
|
||||
GameObject currentSw3DH = GameObject.Find(currentSw3DHname);
|
||||
Switch3DHRotate sw3DHrotate = currentSw3DH.GetComponent<Switch3DHRotate>();
|
||||
if (sw3DHrotate != null)
|
||||
//sw3DHrotate.RotateHorizontalSwitch(btnList.Length - 1, int.Parse(this.name.Substring(this.name.Length - 1)));
|
||||
sw3DHrotate.RotateHorizontalSwitch(int.Parse(this.name.Substring(this.name.Length - 1)) - 1);
|
||||
}
|
||||
|
||||
public void switchOn()
|
||||
{
|
||||
Transform[] btnList = this.transform.parent.gameObject.GetComponentsInChildren<Transform>();
|
||||
for (int i = 0; i < btnList.Length; i++)
|
||||
{
|
||||
if (i == 0) continue;
|
||||
if (btnList[i].gameObject.GetComponent<Image>() != null)
|
||||
btnList[i].gameObject.GetComponent<Image>().enabled = false;
|
||||
else
|
||||
btnList[i].gameObject.GetComponent<SpriteRenderer>().enabled = false;
|
||||
}
|
||||
//this.gameObject.GetComponent<Image>().enabled = true;
|
||||
if (this.gameObject.GetComponent<Image>() != null)
|
||||
this.gameObject.GetComponent<Image>().enabled = true;
|
||||
else
|
||||
this.gameObject.GetComponent<SpriteRenderer>().enabled = true;
|
||||
//GetComponent<Switch3DRotate>().pos = btnList.Length;
|
||||
//GetComponent<Switch3DRotate>().numpos = int.Parse(this.name.Substring(this.name.Length - 1));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
11
Heli_with_panels/Assets/Scripts/Panel2D/SwitchState.cs.meta
Normal file
11
Heli_with_panels/Assets/Scripts/Panel2D/SwitchState.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 85d5b311fb0d04e45be05ab7ce5ac995
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
106
Heli_with_panels/Assets/Scripts/Panel2D/ToggleScript.cs
Normal file
106
Heli_with_panels/Assets/Scripts/Panel2D/ToggleScript.cs
Normal file
@@ -0,0 +1,106 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class ToggleScript : MonoBehaviour
|
||||
{
|
||||
public GameObject[] tog;
|
||||
int mouseY_;
|
||||
int curMouseY_;
|
||||
bool defTog;
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
OnTog0();
|
||||
|
||||
}
|
||||
public void OnClick()
|
||||
{
|
||||
if (tog.Length < 3)
|
||||
{
|
||||
OnTog2();
|
||||
}
|
||||
else
|
||||
{
|
||||
OnTog0();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
void OnTog0()
|
||||
{
|
||||
tog[0].SetActive(true);
|
||||
defTog = true;
|
||||
for (int i = 1; i < tog.Length; i++)
|
||||
{
|
||||
tog[i].SetActive(false);
|
||||
}
|
||||
}
|
||||
void OnTog2()
|
||||
{
|
||||
for (int i = 0; i < tog.Length; i++)
|
||||
{
|
||||
if (tog[i].activeSelf == true)
|
||||
{
|
||||
tog[i].SetActive(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
tog[i].SetActive(true);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
public void OnMouseDown()
|
||||
{
|
||||
mouseY_ = (int)Input.mousePosition.y;
|
||||
//Debug.Log($"mouseY {mouseY_}");
|
||||
}
|
||||
public void OnMouseUp()
|
||||
{
|
||||
curMouseY_ = (int)Input.mousePosition.y;
|
||||
if (curMouseY_ != mouseY_)
|
||||
{
|
||||
//Debug.Log($"curMouseY {curMouseY_}");
|
||||
int dMY = mouseY_ - curMouseY_;
|
||||
if (tog.Length < 3)
|
||||
{
|
||||
OnTog2();
|
||||
}
|
||||
else
|
||||
{
|
||||
if(defTog == true)
|
||||
{
|
||||
defTog = false;
|
||||
if (dMY < 0)
|
||||
{
|
||||
tog[0].SetActive(false);
|
||||
tog[1].SetActive(true);
|
||||
tog[2].SetActive(false);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
tog[0].SetActive(false);
|
||||
tog[1].SetActive(false);
|
||||
tog[2].SetActive(true);
|
||||
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
OnTog0();
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
11
Heli_with_panels/Assets/Scripts/Panel2D/ToggleScript.cs.meta
Normal file
11
Heli_with_panels/Assets/Scripts/Panel2D/ToggleScript.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 85951b9d667fdf044870056f527871fe
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
110
Heli_with_panels/Assets/Scripts/Panel2D/myButton.cs
Normal file
110
Heli_with_panels/Assets/Scripts/Panel2D/myButton.cs
Normal file
@@ -0,0 +1,110 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class myButton : MonoBehaviour
|
||||
{
|
||||
Dictionary<string, GameObject> buttonStatesList = new Dictionary<string, GameObject>();
|
||||
|
||||
// int posCount;
|
||||
// int currentPos;
|
||||
GameObject goUp;
|
||||
GameObject goDown;
|
||||
Manager man;
|
||||
Image goUp_Img = null, goDown_Img = null;
|
||||
SpriteRenderer goUp_SR = null, goDown_SR = null;
|
||||
|
||||
void Start()
|
||||
{
|
||||
man = GameObject.Find("Manager").GetComponent<Manager>();
|
||||
// Debug.Log(go.name);
|
||||
Transform[] buttonStates = this.GetComponentsInChildren<Transform>();
|
||||
// Debug.Log(btnList.Length);
|
||||
// goUp = new GameObject();
|
||||
// goDown = new GameObject();
|
||||
for (int i = 0; i < buttonStates.Length; i++)
|
||||
{
|
||||
if (i == 0) continue;
|
||||
if (string.Compare(buttonStates[i].name.Substring(buttonStates[i].name.Length - 2), "up") == 0) // this.name.Length - 3
|
||||
{
|
||||
goUp = buttonStates[i].gameObject;
|
||||
|
||||
}
|
||||
if (string.Compare(buttonStates[i].name.Substring(buttonStates[i].name.Length - 4), "down") == 0) // this.name.Length - 3
|
||||
{
|
||||
goDown = buttonStates[i].gameObject;
|
||||
|
||||
}
|
||||
}
|
||||
if (goUp == null || goDown == null)
|
||||
return;
|
||||
goUp_Img = goUp.GetComponent<Image>();
|
||||
goUp_SR = goUp.GetComponent<SpriteRenderer>();
|
||||
goDown_Img = goDown.GetComponent<Image>();
|
||||
goDown_SR = goDown.GetComponent<SpriteRenderer>();
|
||||
|
||||
if (goUp_Img != null && goDown_Img != null)
|
||||
{
|
||||
goUp_Img.enabled = true;
|
||||
goDown_Img.enabled = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
goUp_SR.enabled = true;
|
||||
goDown_SR.enabled = false;
|
||||
}
|
||||
}
|
||||
|
||||
public void OnMouseDown()
|
||||
{
|
||||
if (man.mode == "scedit" || man.mode == "play")
|
||||
return;
|
||||
OnDown();
|
||||
man.player.SetObjectState(man.objects.Find(this.gameObject.name), 1);
|
||||
}
|
||||
public void OnDown()
|
||||
{
|
||||
if (goUp == null || goDown == null)
|
||||
return;
|
||||
|
||||
if (goUp_Img != null && goDown_Img != null)
|
||||
{
|
||||
goUp_Img.enabled = false;
|
||||
goDown_Img.enabled = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
goDown_SR.enabled = true;
|
||||
goUp_SR.enabled = false;
|
||||
}
|
||||
}
|
||||
void OnMouseUp()
|
||||
{
|
||||
if (man.mode == "scedit" || man.mode == "play")
|
||||
return;
|
||||
OnUp();
|
||||
}
|
||||
public void OnUp()
|
||||
{
|
||||
if (goUp == null || goDown == null)
|
||||
return;
|
||||
try
|
||||
{
|
||||
if (goUp_Img != null && goDown_Img != null)
|
||||
{
|
||||
goUp_Img.enabled = true;
|
||||
goDown_Img.enabled = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
goUp_SR.enabled = true;
|
||||
goDown_SR.enabled = false;
|
||||
}
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
Debug.LogError(e.Message);
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Heli_with_panels/Assets/Scripts/Panel2D/myButton.cs.meta
Normal file
11
Heli_with_panels/Assets/Scripts/Panel2D/myButton.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 26f1aa70a7d15714faee773fab0fa971
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
36
Heli_with_panels/Assets/Scripts/Panel2D/pedals.cs
Normal file
36
Heli_with_panels/Assets/Scripts/Panel2D/pedals.cs
Normal file
@@ -0,0 +1,36 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class pedals : MonoBehaviour
|
||||
{
|
||||
private Vector3 mousePosition;
|
||||
public float moveSpeed = 1.2f;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void OnMouseDrag()
|
||||
{
|
||||
//mousePosition = Camera.main.ScreenToWorldPoint(Input.mousePosition);
|
||||
mousePosition = Camera.current.ScreenToWorldPoint(Input.mousePosition);
|
||||
|
||||
// вычисляем разницу между текущим положением и положением мыши
|
||||
|
||||
Vector3 difference = mousePosition - transform.position;
|
||||
difference.Normalize();
|
||||
// вычисляемый необходимый угол поворота
|
||||
float rotation_z = Mathf.Atan2(difference.y, difference.x) * Mathf.Rad2Deg;
|
||||
|
||||
// Применяем поворот вокруг оси Z
|
||||
if (rotation_z<45 && rotation_z>-45)
|
||||
{
|
||||
transform.localRotation = Quaternion.Euler(0f, 0f, rotation_z);
|
||||
|
||||
//int angle_int = Mathf.RoundToInt(rotation_z);
|
||||
|
||||
Debug.Log("угол"+ rotation_z);
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Heli_with_panels/Assets/Scripts/Panel2D/pedals.cs.meta
Normal file
11
Heli_with_panels/Assets/Scripts/Panel2D/pedals.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b0cc7128114335742bda5725b7601257
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user