mirror of
https://gitea.msk.dinamika-avia.ru/Constanta-Design/MI-38.git
synced 2026-01-24 02:45:39 +03:00
04.07.2022
This commit is contained in:
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:
|
||||
Reference in New Issue
Block a user