Сделал изменение цвета завершённых пунктов и текущего
This commit is contained in:
1 parent
b167fc448f
commit
9e7457b818
20 files changed
+11178
-10685
No files matched your search
@@ -1,7 +1,9 @@
|
||||
using Palmmedia.ReportGenerator.Core;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Events;
|
||||
using UnityEngine.Rendering;
|
||||
|
||||
public class MachineCoordinatesMovementScript : MonoBehaviour
|
||||
@@ -71,7 +73,11 @@ public class MachineCoordinatesMovementScript : MonoBehaviour
|
||||
static public List<Vector3> CurrentProgram { get; private set; }
|
||||
static public List<Vector3> ComponentsHoldersCords { get; private set; }
|
||||
|
||||
[Serializable]
|
||||
public class MachineStepEvent : UnityEvent<int> { }
|
||||
|
||||
[Tooltip("Event called when step updated")]
|
||||
public static MachineStepEvent OnStep = new MachineStepEvent();
|
||||
|
||||
// Ãðàíèöû ïî êîîðäèíàòàì: (0.435, 0.02, 0.4125)
|
||||
|
||||
@@ -133,6 +139,7 @@ public class MachineCoordinatesMovementScript : MonoBehaviour
|
||||
else
|
||||
{
|
||||
CurrentStep++;
|
||||
OnStep?.Invoke(CurrentStep);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -153,6 +160,7 @@ public class MachineCoordinatesMovementScript : MonoBehaviour
|
||||
Restart = true;
|
||||
CurrentProgram = new(program);
|
||||
CurrentStep = 0;
|
||||
OnStep?.Invoke(CurrentStep);
|
||||
}
|
||||
|
||||
public void MaterialInserted(int index)
|
||||
@@ -264,6 +272,7 @@ public class MachineCoordinatesMovementScript : MonoBehaviour
|
||||
}
|
||||
else
|
||||
{
|
||||
//Vector3.MoveTowards()
|
||||
XAxis.localPosition = new(cords.x, XAxis.localPosition.y, XAxis.localPosition.z);
|
||||
YAxis.localPosition = new(YAxis.localPosition.x, cords.y, YAxis.localPosition.z);
|
||||
ZAxis.localPosition = new(ZAxis.localPosition.x, ZAxis.localPosition.y, cords.z);
|
||||
|
||||
@@ -1,13 +1,17 @@
|
||||
using System.Collections.Generic;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class PositionListElement : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private List<string> propertyTitle = new List<string>();
|
||||
[SerializeField] private List<TextMeshProUGUI> propertyTextObject = new List<TextMeshProUGUI>();
|
||||
|
||||
public Color HighlightedColor;
|
||||
public Color StepCompletedColor; //= new(0xB8, 0xD3, 0xFF, 64);
|
||||
public Color CurrentStepColor; //= new(0xB8, 0xD3, 0xFF, 128);
|
||||
|
||||
//public Color colorr;
|
||||
|
||||
// Runtime dictionary (not serialized)
|
||||
public Dictionary<string, TextMeshProUGUI> propertiesDatabase { get; private set; }
|
||||
@@ -31,6 +35,11 @@ public class PositionListElement : MonoBehaviour
|
||||
propertiesDatabase[propertyName].text = value;
|
||||
}
|
||||
|
||||
public void SetStatusColor(Color color)
|
||||
{
|
||||
gameObject.GetComponent<Image>().color = color;
|
||||
}
|
||||
|
||||
// Start is called once before the first execution of Update after the MonoBehaviour is created
|
||||
void Start()
|
||||
{
|
||||
|
||||
@@ -9,17 +9,16 @@ public class PositionListScript : MonoBehaviour
|
||||
{
|
||||
[SerializeField]
|
||||
PositionListElement _positionListElementTemplate;
|
||||
|
||||
|
||||
[SerializeField]
|
||||
List<PositionListElement> _positionsList = new();
|
||||
|
||||
|
||||
|
||||
|
||||
// Start is called once before the first execution of Update after the MonoBehaviour is created
|
||||
void Start()
|
||||
{
|
||||
StartCoroutine(waitForMachineInit());
|
||||
MachineCoordinatesMovementScript.OnStep.AddListener(OnStepUpdate);
|
||||
}
|
||||
|
||||
private IEnumerator waitForMachineInit()
|
||||
@@ -32,50 +31,50 @@ public class PositionListScript : MonoBehaviour
|
||||
{
|
||||
PositionListElement newElement;
|
||||
|
||||
for (int i = 1; i < MachineCoordinatesMovementScript.CurrentProgram.Count; i+=2)
|
||||
for (int i = 1; i < MachineCoordinatesMovementScript.CurrentProgram.Count; i += 2)
|
||||
{
|
||||
newElement = createNewElementObject(-1f * (i - 1) * _positionListElementTemplate.GetComponent<RectTransform>().rect.height/2);
|
||||
newElement = createNewElementObject(-1f * (i - 1) * _positionListElementTemplate.GetComponent<RectTransform>().rect.height / 2);
|
||||
|
||||
_positionsList.Add(newElement);
|
||||
|
||||
newElement.SetProperty("No", _positionsList.Count.ToString());
|
||||
|
||||
int smdComponentIndex = MachineCoordinatesMovementScript.ComponentsHoldersCords.IndexOf(
|
||||
MachineCoordinatesMovementScript.CurrentProgram[i-1]);
|
||||
MachineCoordinatesMovementScript.CurrentProgram[i - 1]);
|
||||
newElement.SetProperty("Type", smdComponentIndex.ToString());
|
||||
|
||||
switch (smdComponentIndex)
|
||||
{
|
||||
case 0:
|
||||
newElement.SetProperty("Name", "R6");
|
||||
newElement.SetProperty("Name", "R6");
|
||||
break;
|
||||
|
||||
case 1:
|
||||
newElement.SetProperty("Name", "C2");
|
||||
break;
|
||||
case 1:
|
||||
newElement.SetProperty("Name", "C2");
|
||||
break;
|
||||
|
||||
case 2:
|
||||
newElement.SetProperty("Name", "C1");
|
||||
break;
|
||||
case 2:
|
||||
newElement.SetProperty("Name", "C1");
|
||||
break;
|
||||
|
||||
case 3:
|
||||
newElement.SetProperty("Name", "LED3");
|
||||
break;
|
||||
case 3:
|
||||
newElement.SetProperty("Name", "LED3");
|
||||
break;
|
||||
|
||||
default:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
newElement.SetProperty("X", MachineCoordinatesMovementScript.CurrentProgram[i].x.ToString());
|
||||
newElement.SetProperty("Y", MachineCoordinatesMovementScript.CurrentProgram[i].y.ToString());
|
||||
newElement.SetProperty("Z", MachineCoordinatesMovementScript.CurrentProgram[i].z.ToString());
|
||||
newElement.SetProperty("A", "1");
|
||||
newElement.SetProperty("Val", "1");
|
||||
newElement.SetProperty("X", MachineCoordinatesMovementScript.CurrentProgram[i].x.ToString());
|
||||
newElement.SetProperty("Y", MachineCoordinatesMovementScript.CurrentProgram[i].y.ToString());
|
||||
newElement.SetProperty("Z", MachineCoordinatesMovementScript.CurrentProgram[i].z.ToString());
|
||||
newElement.SetProperty("A", "1");
|
||||
newElement.SetProperty("Val", "1");
|
||||
newElement.SetProperty("Feeder", "B");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private PositionListElement createNewElementObject(float y_pos)
|
||||
private PositionListElement createNewElementObject(float y_pos)
|
||||
{
|
||||
GameObject newObject = Instantiate(_positionListElementTemplate.gameObject, _positionListElementTemplate.transform.parent);
|
||||
newObject.GetComponent<RectTransform>().localPosition = new(0, y_pos, 0);
|
||||
@@ -84,16 +83,30 @@ public class PositionListScript : MonoBehaviour
|
||||
return newObject.GetComponent<PositionListElement>();
|
||||
}
|
||||
|
||||
private void OnStepUpdate(int step)
|
||||
{
|
||||
if (step % 2 == 0)
|
||||
{
|
||||
PositionListElement currentElement = _positionsList[step / 2];
|
||||
|
||||
currentElement.SetProperty("State", "Work");
|
||||
|
||||
currentElement.SetStatusColor(currentElement.CurrentStepColor);
|
||||
|
||||
if (step == 0) return;
|
||||
|
||||
PositionListElement prevElement = _positionsList[(step / 2) - 1];
|
||||
|
||||
prevElement.SetProperty("State", "Ok");
|
||||
|
||||
prevElement.SetStatusColor(prevElement.StepCompletedColor);
|
||||
}
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
if (MachineCoordinatesMovementScript.CurrentStep == 0) return;
|
||||
//if (MachineCoordinatesMovementScript.CurrentStep == 0) return;
|
||||
//{ _positionsList[MachineCoordinatesMovementScript.CurrentStep]}
|
||||
|
||||
if (MachineCoordinatesMovementScript.CurrentStep % 2 == 0)
|
||||
{
|
||||
PositionListElement currentElement = _positionsList[MachineCoordinatesMovementScript.CurrentStep-1];
|
||||
currentElement.GetComponent<Image>().color = currentElement.HighlightedColor;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user