Доделал настройку скорости, добавил иконки на катушки с материалом
This commit is contained in:
1 parent
a3cccd5530
commit
080f5fce79
11 files changed
+17530
-10964
No files matched your search
@@ -0,0 +1,65 @@
|
||||
using UnityEngine;
|
||||
using TMPro;
|
||||
|
||||
[RequireComponent(typeof(TMP_Text))]
|
||||
public class CircularText : MonoBehaviour
|
||||
{
|
||||
public float radius = 150f;
|
||||
[Range(10, 360)] public float totalAngle = 180f; // Угол дуги в градусах
|
||||
public bool isBottomHalf = false; // Если true, текст будет выгнут вниз
|
||||
|
||||
private TMP_Text tmpText;
|
||||
private Vector3[] originalVertices;
|
||||
|
||||
void LateUpdate()
|
||||
{
|
||||
if (tmpText == null) tmpText = GetComponent<TMP_Text>();
|
||||
tmpText.ForceMeshUpdate();
|
||||
if (tmpText.textInfo.characterCount == 0) return;
|
||||
|
||||
TMP_MeshInfo meshInfo = tmpText.textInfo.meshInfo[0];
|
||||
Vector3[] vertices = meshInfo.vertices;
|
||||
|
||||
if (originalVertices == null || originalVertices.Length != vertices.Length)
|
||||
originalVertices = (Vector3[])vertices.Clone();
|
||||
|
||||
float minX = tmpText.rectTransform.rect.xMin;
|
||||
float width = tmpText.rectTransform.rect.width;
|
||||
if (width == 0) return;
|
||||
|
||||
// Рассчитываем начальный и конечный углы
|
||||
float startAngle = (180f + totalAngle / 2f) * (isBottomHalf ? -1 : 1);
|
||||
float endAngle = (180f - totalAngle / 2f) * (isBottomHalf ? -1 : 1);
|
||||
|
||||
for (int i = 0; i < tmpText.textInfo.characterCount; i++)
|
||||
{
|
||||
TMP_CharacterInfo charInfo = tmpText.textInfo.characterInfo[i];
|
||||
if (!charInfo.isVisible) continue;
|
||||
|
||||
int vIndex = charInfo.vertexIndex;
|
||||
float charCenterX = (originalVertices[vIndex + 0].x + originalVertices[vIndex + 2].x) / 2f;
|
||||
float charCenterY = (originalVertices[vIndex + 0].y + originalVertices[vIndex + 1].y) / 2f;
|
||||
|
||||
float t = Mathf.Clamp01((charCenterX - minX) / width);
|
||||
float angle = Mathf.Lerp(startAngle, endAngle, t);
|
||||
float rad = angle * Mathf.Deg2Rad;
|
||||
|
||||
// 1. Находим точку на окружности
|
||||
Vector3 circlePos = new Vector3(Mathf.Cos(rad) * radius, Mathf.Sin(rad) * radius);
|
||||
|
||||
// 2. Поворачиваем саму букву так, чтобы её "низ" смотрел в центр
|
||||
Quaternion rot = Quaternion.Euler(0, 0, angle - 90f);
|
||||
|
||||
// 3. Применяем позицию и поворот к вершинам
|
||||
for (int j = 0; j < 4; j++)
|
||||
{
|
||||
Vector3 originalPos = originalVertices[vIndex + j];
|
||||
Vector3 relativePos = originalPos - new Vector3(charCenterX, charCenterY);
|
||||
vertices[vIndex + j] = circlePos + rot * relativePos;
|
||||
}
|
||||
}
|
||||
|
||||
meshInfo.mesh.vertices = vertices;
|
||||
tmpText.UpdateGeometry(meshInfo.mesh, 0);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 008175fdcf47cde4daadce6abf412f63
|
||||
@@ -3,6 +3,7 @@ using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Events;
|
||||
using System.Linq;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class MachineCoordinatesMovementScript : MonoBehaviour
|
||||
{
|
||||
@@ -26,12 +27,15 @@ public class MachineCoordinatesMovementScript : MonoBehaviour
|
||||
Vector3 CurrentCords;
|
||||
|
||||
[SerializeField]
|
||||
float CartXMaxSpeed = 1f;
|
||||
float CartXSpeed = 0.1f;
|
||||
|
||||
[SerializeField]
|
||||
float CartYMaxSpeed = 1f;
|
||||
float CartYSpeed = 0.1f;
|
||||
|
||||
[SerializeField]
|
||||
float CartZMaxSpeed = 1f;
|
||||
float CartZSpeed = 0.1f;
|
||||
|
||||
[SerializeField]
|
||||
@@ -112,10 +116,8 @@ public class MachineCoordinatesMovementScript : MonoBehaviour
|
||||
StartWork(PalmTreeProg);
|
||||
}
|
||||
|
||||
|
||||
setActiveActionButtons();
|
||||
|
||||
|
||||
if (RestartFlag == true)
|
||||
{
|
||||
if (MoveTo(Vector3.zero))
|
||||
@@ -160,6 +162,16 @@ public class MachineCoordinatesMovementScript : MonoBehaviour
|
||||
}
|
||||
}
|
||||
|
||||
public void setSpeedHor(Slider slider)
|
||||
{
|
||||
CartXSpeed = CartXMaxSpeed * (slider.value / 100);
|
||||
CartZSpeed = CartZMaxSpeed * (slider.value / 100);
|
||||
}
|
||||
public void setSpeedVert(Slider slider)
|
||||
{
|
||||
CartYSpeed = CartYMaxSpeed * (slider.value / 100);
|
||||
}
|
||||
|
||||
void setActiveActionButtons()
|
||||
{
|
||||
List<string> buttonsToActivate = new List<string>();
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class SliderNumToTextScript : MonoBehaviour
|
||||
{
|
||||
TextMeshProUGUI textMesh;
|
||||
// Start is called once before the first execution of Update after the MonoBehaviour is created
|
||||
void Start()
|
||||
{
|
||||
textMesh = GetComponent<TextMeshProUGUI>();
|
||||
}
|
||||
|
||||
public void OnValueChanged(Slider slider) {
|
||||
textMesh.text = slider.value + " %";
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4bf6b48ec0922f94bab583ac11141646
|
||||
Reference in new issue
Block a user