Reworked Socket + EndPos reset
This commit is contained in:
1 parent
085d330a87
commit
430f676e49
151 files changed
+18194
-18446
No files matched your search
@@ -0,0 +1,55 @@
|
||||
using System.Collections;
|
||||
using UnityEngine;
|
||||
using UnityEngine.XR.Interaction.Toolkit;
|
||||
using UnityEngine.XR.Interaction.Toolkit.Interactables;
|
||||
|
||||
public class BabinaScript : MonoBehaviour
|
||||
{
|
||||
|
||||
[SerializeField]
|
||||
MeshRenderer RopeRenderer;
|
||||
|
||||
[SerializeField]
|
||||
MeshRenderer WireCapRenderer;
|
||||
|
||||
[SerializeField]
|
||||
GameObject EndPos;
|
||||
|
||||
InteractionLayerMask InitInteractionLayers;
|
||||
|
||||
bool SyncingWithSocket = false;
|
||||
|
||||
Transform SocketAttach;
|
||||
|
||||
|
||||
// Start is called once before the first execution of Update after the MonoBehaviour is created
|
||||
void Start()
|
||||
{
|
||||
InitInteractionLayers = gameObject.GetComponent<XRGrabInteractable>().interactionLayers;
|
||||
}
|
||||
|
||||
IEnumerator SnapToSocketReset()
|
||||
{
|
||||
while (gameObject.transform.position != SocketAttach.position)
|
||||
{
|
||||
yield return null;
|
||||
}
|
||||
EndPos.GetComponent<XRGrabInteractable>().interactionLayers = InitInteractionLayers;
|
||||
|
||||
EndPos.GetComponent<Collider>().enabled = true;
|
||||
|
||||
//EndPos.GetComponent<MaterialRopeDetachAction>().ResetPos();
|
||||
RopeRenderer.enabled = true;
|
||||
WireCapRenderer.enabled = true;
|
||||
}
|
||||
|
||||
public void SwitchToRope(InteractionLayerMask SocketMask, Transform v_SocketAttach)
|
||||
{
|
||||
gameObject.GetComponent<XRGrabInteractable>().interactionLayers = SocketMask;
|
||||
|
||||
SocketAttach = v_SocketAttach;
|
||||
|
||||
StartCoroutine(SnapToSocketReset());
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 920b801be046242459608049f5646557
|
||||
@@ -0,0 +1,26 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using UnityEngine.XR.Interaction.Toolkit;
|
||||
using UnityEngine.XR.Interaction.Toolkit.Interactables;
|
||||
|
||||
public class BoardScript : MonoBehaviour
|
||||
{
|
||||
// Start is called once before the first execution of Update after the MonoBehaviour is created
|
||||
|
||||
private int mask;
|
||||
void Start()
|
||||
{
|
||||
mask = InteractionLayerMask.GetMask("Default", "Board");
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void ComponentsPlaced()
|
||||
{
|
||||
gameObject.GetComponent<XRGrabInteractable>().interactionLayers = mask;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: adae81e6dbf2d4449bb7388cc214afc3
|
||||
@@ -0,0 +1,27 @@
|
||||
using UnityEngine;
|
||||
|
||||
public class Components_Install_Trigger : MonoBehaviour
|
||||
{
|
||||
// Start is called once before the first execution of Update after the MonoBehaviour is created
|
||||
void Start()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private void OnTriggerEnter(Collider other)
|
||||
{
|
||||
//Debug.Log("Touched: " + other.gameObject.name);
|
||||
if (other.gameObject.tag == "SMD_Plate_component")
|
||||
{
|
||||
other.gameObject.GetComponent<MeshRenderer>().enabled = true;
|
||||
//Debug.Log("Activated: " + other.gameObject.name);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d8e99c34380f2844b8472acbb5d3aa7e
|
||||
@@ -0,0 +1,81 @@
|
||||
using UnityEngine;
|
||||
|
||||
public class CookerScript : MonoBehaviour
|
||||
{
|
||||
[SerializeField]
|
||||
Transform OvenDoor;
|
||||
|
||||
[SerializeField]
|
||||
float MoveSpeed;
|
||||
|
||||
Vector3 OvenDoorInitialPos;
|
||||
|
||||
Vector3 OvenDoorTargetPos;
|
||||
|
||||
bool DoorMoving = false;
|
||||
|
||||
bool forward = true;
|
||||
|
||||
// Start is called once before the first execution of Update after the MonoBehaviour is created
|
||||
void Start()
|
||||
{
|
||||
OvenDoorInitialPos = OvenDoor.localPosition;
|
||||
OvenDoorTargetPos = new(OvenDoorInitialPos.x, OvenDoorInitialPos.y, OvenDoorInitialPos.z - 0.21f);
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
if (DoorMoving)
|
||||
{
|
||||
|
||||
float MoveDistance;
|
||||
|
||||
if (forward) {
|
||||
MoveDistance = OvenDoorTargetPos.z - OvenDoor.localPosition.z;
|
||||
}
|
||||
else {
|
||||
MoveDistance = OvenDoorInitialPos.z - OvenDoor.localPosition.z;
|
||||
}
|
||||
|
||||
|
||||
float MoveStep = MoveSpeed * Time.deltaTime;
|
||||
float MoveAmount = Mathf.Min(MoveStep, Mathf.Abs(MoveDistance));
|
||||
|
||||
//Debug.Log(MoveAmount);
|
||||
|
||||
if (forward) {
|
||||
//OvenDoor.transform.Translate(0, 0, -MoveAmount);
|
||||
OvenDoor.transform.localPosition = new(OvenDoor.transform.localPosition.x, OvenDoor.transform.localPosition.y, OvenDoor.transform.localPosition.z - MoveAmount);
|
||||
|
||||
if (MoveAmount != MoveStep)
|
||||
{
|
||||
OvenDoor.transform.localPosition = OvenDoorTargetPos;
|
||||
DoorMoving = false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//OvenDoor.transform.Translate(0, 0, MoveAmount);
|
||||
OvenDoor.transform.localPosition = new(OvenDoor.transform.localPosition.x, OvenDoor.transform.localPosition.y, OvenDoor.transform.localPosition.z + MoveAmount);
|
||||
if (MoveAmount != MoveStep)
|
||||
{
|
||||
OvenDoor.transform.localPosition = OvenDoorInitialPos;
|
||||
DoorMoving = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public void DoorMove()
|
||||
{
|
||||
DoorMoving = true;
|
||||
if (OvenDoor.localPosition == OvenDoorInitialPos)
|
||||
{
|
||||
forward = true;
|
||||
}
|
||||
else { forward = false; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d5ade6aab0a5b4e4e8015070f33ef6e6
|
||||
@@ -0,0 +1,276 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Rendering;
|
||||
|
||||
public class MachineCoordinatesMovementScript : MonoBehaviour
|
||||
{
|
||||
|
||||
[SerializeField]
|
||||
[Tooltip("XAxis Transform")]
|
||||
Transform XAxis;
|
||||
|
||||
[SerializeField]
|
||||
[Tooltip("YAxis Transform")]
|
||||
Transform YAxis;
|
||||
|
||||
[SerializeField]
|
||||
[Tooltip("ZAxis Transform")]
|
||||
Transform ZAxis;
|
||||
|
||||
[SerializeField]
|
||||
Vector3 CurrentCords;
|
||||
|
||||
[SerializeField]
|
||||
float CartXSpeed = 0.1f;
|
||||
|
||||
[SerializeField]
|
||||
float CartYSpeed = 0.1f;
|
||||
|
||||
[SerializeField]
|
||||
float CartZSpeed = 0.1f;
|
||||
|
||||
[SerializeField]
|
||||
int MaterialsToInsert = 0;
|
||||
|
||||
[SerializeField]
|
||||
bool TestProgramStart;
|
||||
|
||||
[SerializeField]
|
||||
bool DebugStart = false;
|
||||
|
||||
[SerializeField]
|
||||
bool Restart = false;
|
||||
|
||||
// Ôëàã ðàáîòû, ïî íåìó ïðîâåðÿåòñÿ, âûïîëíÿåòñÿ ëè ñåé÷àñ êàêàÿ-ëèáî ïðîãðàììà
|
||||
bool WorkInProgress = false;
|
||||
|
||||
[SerializeField]
|
||||
List<bool> InsertedMaterials;
|
||||
|
||||
[SerializeField]
|
||||
List<bool> InsertedReels;
|
||||
|
||||
bool ReadyToWork = false;
|
||||
|
||||
bool ReelsReady = false;
|
||||
|
||||
// Íîìåð îáúåêòà â CurrentProgram, ê êîòîðîìó äâèãàòüñÿ
|
||||
int CurrentStep = 0;
|
||||
|
||||
List<Vector3> CurrentProgram;
|
||||
|
||||
// Ãðàíèöû ïî êîîðäèíàòàì: (0.435, 0.02, 0.4125)
|
||||
|
||||
[SerializeField]
|
||||
GameObject Board;
|
||||
|
||||
void Start()
|
||||
{
|
||||
//DiagonalMoveDbg = false;
|
||||
for (int i = 0; i < MaterialsToInsert; i++)
|
||||
{
|
||||
InsertedMaterials.Add(false);
|
||||
InsertedReels.Add(false);
|
||||
}
|
||||
}
|
||||
void FixedUpdate()
|
||||
{
|
||||
CurrentCords = new(XAxis.localPosition.x, YAxis.localPosition.y, ZAxis.localPosition.z);
|
||||
|
||||
if (DebugStart)
|
||||
{
|
||||
DebugStart = false;
|
||||
StartWork(PalmTreeProg);
|
||||
}
|
||||
|
||||
if (TestProgramStart == true)
|
||||
{
|
||||
TestProgramStart = false;
|
||||
|
||||
if (ReadyToWork)
|
||||
{
|
||||
StartWork(PalmTreeProg);
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.Log(InsertedMaterials);
|
||||
}
|
||||
}
|
||||
|
||||
if (Restart == true)
|
||||
{
|
||||
if (MoveTo(Vector3.zero))
|
||||
{
|
||||
Restart = false;
|
||||
}
|
||||
}
|
||||
else if (WorkInProgress == true)
|
||||
{
|
||||
if(CurrentStep <= CurrentProgram.Count - 1)
|
||||
{
|
||||
if (MoveTo(CurrentProgram[CurrentStep]))
|
||||
{
|
||||
if(YAxis.localPosition.y > 0) {
|
||||
CurrentProgram[CurrentStep] = new(CurrentProgram[CurrentStep].x, 0, CurrentProgram[CurrentStep].z);
|
||||
}
|
||||
else
|
||||
{
|
||||
CurrentStep++;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
WorkInProgress = false;
|
||||
Restart = true;
|
||||
Board.GetComponent<BoardScript>().ComponentsPlaced();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Ôóíêöèÿ íà÷àëà ðàáîòû, ïðèíèìàåò ïðîãðàììó äëÿ ðàáîòû
|
||||
public void StartWork(List<Vector3> program)
|
||||
{
|
||||
WorkInProgress = true;
|
||||
Restart = true;
|
||||
CurrentProgram = new(program);
|
||||
CurrentStep = 0;
|
||||
}
|
||||
|
||||
public void MaterialInserted(int index)
|
||||
{
|
||||
InsertedMaterials[index] = true;
|
||||
|
||||
foreach (bool mat in InsertedMaterials) {
|
||||
if (!mat) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if(ReelsReady){
|
||||
ReadyToWork = true;
|
||||
}
|
||||
}
|
||||
|
||||
public void ReelInserted(int index)
|
||||
{
|
||||
InsertedReels[index] = true;
|
||||
|
||||
foreach (bool reel in InsertedReels) {
|
||||
if (!reel) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
ReelsReady = true;
|
||||
}
|
||||
|
||||
public void MaterialRemoved(int index)
|
||||
{
|
||||
InsertedMaterials[index] = false;
|
||||
|
||||
ReadyToWork = false;
|
||||
}
|
||||
|
||||
public void ReelRemoved(int index)
|
||||
{
|
||||
InsertedReels[index] = false;
|
||||
|
||||
ReelsReady = false;
|
||||
}
|
||||
|
||||
|
||||
// Âîçâðàùàåò true, êîãäà íàõîäèòñÿ â êîîðäèíàòå, êîòîðóþ ñîîáùèëè
|
||||
bool MoveTo(Vector3 cords)
|
||||
{
|
||||
float XMoveDistance = cords.x - XAxis.localPosition.x;
|
||||
float YMoveDistance = cords.y - YAxis.localPosition.y;
|
||||
float ZMoveDistance = cords.z - ZAxis.localPosition.z;
|
||||
|
||||
if (Mathf.Abs(XMoveDistance) < 0.0001f)
|
||||
{
|
||||
XMoveDistance = 0;
|
||||
}
|
||||
if (Mathf.Abs(YMoveDistance) < 0.0001f)
|
||||
{
|
||||
YMoveDistance = 0;
|
||||
}
|
||||
if (Mathf.Abs(ZMoveDistance) < 0.0001f)
|
||||
{
|
||||
ZMoveDistance = 0;
|
||||
}
|
||||
|
||||
if (Mathf.Abs(XMoveDistance) > 0 || Mathf.Abs(ZMoveDistance) > 0)
|
||||
{
|
||||
float XStep = CartXSpeed * Time.deltaTime;
|
||||
float XMoveAmount = Mathf.Min(XStep, Mathf.Abs(XMoveDistance));
|
||||
|
||||
float ZStep = CartZSpeed * Time.deltaTime;
|
||||
float ZMoveAmount = Mathf.Min(ZStep, Mathf.Abs(ZMoveDistance));
|
||||
|
||||
|
||||
if (XMoveDistance > 0)
|
||||
{
|
||||
XAxis.Translate(XMoveAmount, 0, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
XAxis.Translate(-XMoveAmount, 0, 0);
|
||||
}
|
||||
|
||||
if (ZMoveDistance > 0)
|
||||
{
|
||||
ZAxis.Translate(0, 0, ZMoveAmount);
|
||||
}
|
||||
else
|
||||
{
|
||||
ZAxis.Translate(0, 0, -ZMoveAmount);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
else if (Mathf.Abs(YMoveDistance) > 0)
|
||||
{
|
||||
float YStep = CartYSpeed * Time.deltaTime;
|
||||
float YMoveAmount = Mathf.Min(YStep, Mathf.Abs(YMoveDistance));
|
||||
|
||||
if (YMoveDistance > 0)
|
||||
{
|
||||
YAxis.Translate(0, -YMoveAmount, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
YAxis.Translate(0, YMoveAmount, 0);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
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);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// Ãðàíèöû ïî êîîðäèíàòàì: (0.435, 0.02, 0.4125)
|
||||
[SerializeField]
|
||||
List<Vector3> testProgr;
|
||||
|
||||
[SerializeField]
|
||||
List<Vector3> PalmTreeProg;
|
||||
|
||||
public void StartWorkFromButton()
|
||||
{
|
||||
if (!WorkInProgress)
|
||||
{
|
||||
TestProgramStart = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e34482080efdef44ba4531f880c48107
|
||||
@@ -0,0 +1,49 @@
|
||||
using GogoGaga.OptimizedRopesAndCables;
|
||||
using System.Collections;
|
||||
using UnityEngine;
|
||||
using UnityEngine.XR.Interaction.Toolkit.Interactables;
|
||||
|
||||
public class MaterialRopeDetachAction : MonoBehaviour
|
||||
{
|
||||
[SerializeField]
|
||||
Vector3 InitialCords;
|
||||
[SerializeField]
|
||||
Quaternion InitialRotation;
|
||||
|
||||
bool resetAsked = false;
|
||||
|
||||
XRGrabInteractable grabComponent;
|
||||
|
||||
// Start is called once before the first execution of Update after the MonoBehaviour is created
|
||||
void Start()
|
||||
{
|
||||
grabComponent = gameObject.GetComponent<XRGrabInteractable>();
|
||||
InitialCords = transform.localPosition;
|
||||
InitialRotation = gameObject.transform.rotation;
|
||||
StartCoroutine(ResetPosTimed());
|
||||
//Rope = gameObject.GetComponentInChildren<Rope>();
|
||||
}
|
||||
|
||||
IEnumerator ResetPosTimed()
|
||||
{
|
||||
yield return new WaitForFixedUpdate();
|
||||
|
||||
if (!grabComponent.isSelected)
|
||||
{
|
||||
transform.localPosition = InitialCords;
|
||||
transform.rotation = InitialRotation;
|
||||
}
|
||||
StartCoroutine(ResetPosTimed());
|
||||
}
|
||||
|
||||
public void ResetPos()
|
||||
{
|
||||
transform.localPosition = InitialCords;
|
||||
transform.rotation = InitialRotation;
|
||||
//Rope.RecalculateRope();
|
||||
// gameObject.GetComponent<XRGrabInteractable>().interactionManager.
|
||||
//Invoke("InvokedReset", 0.1f);
|
||||
//resetAsked = true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 44d83f6815c184a4b9cf2344b7d13795
|
||||
@@ -0,0 +1,30 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.XR.Interaction.Toolkit.Interactors;
|
||||
|
||||
public class MaterialSocketChecker : MonoBehaviour
|
||||
{
|
||||
// Start is called once before the first execution of Update after the MonoBehaviour is created
|
||||
void Start()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void test(XRSocketInteractor interactor) {
|
||||
Debug.Log(interactor.interactablesHovered[0].transform.gameObject.name + " " + (interactor.interactablesHovered[0].transform.gameObject.name == "1").ToString());
|
||||
if (
|
||||
interactor.interactablesHovered[0].transform.gameObject.name == "1")
|
||||
{
|
||||
interactor.socketActive = true;
|
||||
}
|
||||
else {
|
||||
interactor.interactionManager.SelectExit(interactor, interactor.interactablesSelected[0]);
|
||||
interactor.socketActive = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8c67a9e214b042047bc5004a3876b469
|
||||
@@ -0,0 +1,232 @@
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class MovingBelt : MonoBehaviour
|
||||
{
|
||||
// Start is called once before the first execution of Update after the MonoBehaviour is created
|
||||
|
||||
[SerializeField]
|
||||
Transform AxisTransform;
|
||||
|
||||
float MonitoredAxisCord;
|
||||
|
||||
[SerializeField]
|
||||
bool reversed = false;
|
||||
|
||||
enum UsedAxis
|
||||
{
|
||||
X,
|
||||
Y,
|
||||
Z,
|
||||
}
|
||||
|
||||
[SerializeField]
|
||||
[Tooltip("Determines which axis will be monitored.")]
|
||||
UsedAxis m_UsedAxis = UsedAxis.Z;
|
||||
UsedAxis usedAxis
|
||||
{
|
||||
get => m_UsedAxis;
|
||||
set => m_UsedAxis = value;
|
||||
}
|
||||
|
||||
[SerializeField]
|
||||
Transform MovingPartTransform;
|
||||
|
||||
[SerializeField]
|
||||
Transform StaticPartTransform;
|
||||
|
||||
[SerializeField]
|
||||
Transform RadiusTransform;
|
||||
|
||||
[SerializeField]
|
||||
List<Transform> MovingPartSegments;
|
||||
|
||||
[SerializeField]
|
||||
List<Transform> StaticPartSegments;
|
||||
|
||||
[SerializeField]
|
||||
float SegmentSize;
|
||||
|
||||
Transform CurrentMoveExtra;
|
||||
Transform CurrentMoveLastPart;
|
||||
|
||||
float CurrentExtraStartCord;
|
||||
|
||||
[SerializeField]
|
||||
float MoveDelta;
|
||||
|
||||
GameObject extraSection;
|
||||
|
||||
|
||||
|
||||
|
||||
void Start()
|
||||
{
|
||||
//gameObject.transform.SetParent(transform);
|
||||
|
||||
// Îòëè÷èå â íàõîæäåíèè äîïîëíèòåëüíîé ñåêöèè: reversed == false - ñåêöèÿ â moving ÷àñòè è íàîáîðîò
|
||||
switch (reversed) {
|
||||
case false:
|
||||
extraSection = Instantiate(MovingPartSegments[MovingPartSegments.Count - 1].gameObject, MovingPartTransform);
|
||||
|
||||
MovingPartSegments.Add(extraSection.transform);
|
||||
|
||||
CurrentMoveExtra = MovingPartSegments[MovingPartSegments.Count - 1];
|
||||
CurrentMoveLastPart = StaticPartSegments[StaticPartSegments.Count - 1];
|
||||
break;
|
||||
|
||||
case true:
|
||||
extraSection = Instantiate(StaticPartSegments[StaticPartSegments.Count - 1].gameObject, StaticPartTransform);
|
||||
|
||||
StaticPartSegments.Add(extraSection.transform);
|
||||
|
||||
CurrentMoveExtra = StaticPartSegments[StaticPartSegments.Count - 1];
|
||||
CurrentMoveLastPart = MovingPartSegments[MovingPartSegments.Count - 1];
|
||||
break;
|
||||
}
|
||||
|
||||
CurrentExtraStartCord = CurrentMoveExtra.localPosition.z;
|
||||
//UpperPartSegments[0].transform.SetParent(UpperPartTransform);
|
||||
//Debug.Log(usedAxis + " " + (usedAxis == UsedAxis.X).ToString() + " " + (usedAxis == UsedAxis.Z).ToString() + " ");
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Update is called once per frame
|
||||
void FixedUpdate()
|
||||
{
|
||||
|
||||
switch (usedAxis)
|
||||
{
|
||||
case UsedAxis.X:
|
||||
MonitoredAxisCord = AxisTransform.localPosition.x;
|
||||
break;
|
||||
case UsedAxis.Y:
|
||||
MonitoredAxisCord = AxisTransform.localPosition.y;
|
||||
break;
|
||||
case UsedAxis.Z:
|
||||
MonitoredAxisCord = AxisTransform.localPosition.z;
|
||||
break;
|
||||
}
|
||||
|
||||
//Debug.Log(MoveDelta);
|
||||
|
||||
FollowAxis(reversed);
|
||||
|
||||
|
||||
|
||||
if (MoveDelta >= 1)
|
||||
{
|
||||
MoveForward(reversed);
|
||||
|
||||
}
|
||||
else if (MoveDelta < 0)
|
||||
{
|
||||
MoveBackward(reversed);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void MoveForward(bool reversed)
|
||||
{
|
||||
if (!reversed)
|
||||
{
|
||||
//Debug.Log("1" + CurrentMoveUpper.name + " " + CurrentMoveLower.name + " " + CurrentMoveUpper.localPosition.z + " " + CurrentMoveUpperStartCord);
|
||||
CurrentMoveLastPart.SetParent(MovingPartTransform);
|
||||
CurrentMoveLastPart.localPosition = CurrentMoveExtra.localPosition;
|
||||
|
||||
MovingPartSegments.Add(CurrentMoveLastPart);
|
||||
CurrentMoveLastPart.rotation = Quaternion.Euler(CurrentMoveLastPart.rotation.eulerAngles.x, CurrentMoveLastPart.rotation.eulerAngles.y + 180f, CurrentMoveLastPart.rotation.eulerAngles.z);
|
||||
|
||||
StaticPartSegments.RemoveAt(StaticPartSegments.Count - 1);
|
||||
|
||||
CurrentMoveExtra = CurrentMoveLastPart;
|
||||
CurrentExtraStartCord = CurrentMoveExtra.localPosition.z;
|
||||
|
||||
//Debug.Log("2" + CurrentMoveUpper.name + " " + CurrentMoveLower.name + " " + CurrentMoveUpper.localPosition.z + " " + CurrentMoveUpperStartCord);
|
||||
|
||||
CurrentMoveLastPart = StaticPartSegments[StaticPartSegments.Count - 1];
|
||||
}
|
||||
else {
|
||||
|
||||
CurrentMoveLastPart.SetParent(StaticPartTransform);
|
||||
CurrentMoveLastPart.localPosition = CurrentMoveExtra.localPosition;
|
||||
|
||||
StaticPartSegments.Add(CurrentMoveLastPart);
|
||||
|
||||
CurrentMoveLastPart.rotation = Quaternion.Euler(CurrentMoveLastPart.rotation.eulerAngles.x, CurrentMoveLastPart.rotation.eulerAngles.y + 180f, CurrentMoveLastPart.rotation.eulerAngles.z);
|
||||
|
||||
MovingPartSegments.RemoveAt(MovingPartSegments.Count - 1);
|
||||
|
||||
CurrentMoveExtra = CurrentMoveLastPart;
|
||||
CurrentExtraStartCord = CurrentMoveExtra.localPosition.z;
|
||||
|
||||
CurrentMoveLastPart = MovingPartSegments[MovingPartSegments.Count - 1];
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void MoveBackward(bool reversed) {
|
||||
|
||||
if (!reversed)
|
||||
{
|
||||
|
||||
//Debug.Log("1" + CurrentMoveUpper.name + " " + CurrentMoveLower.name + " " + CurrentMoveUpper.localPosition.z + " " + CurrentMoveUpperStartCord);
|
||||
CurrentMoveExtra.SetParent(StaticPartTransform);
|
||||
CurrentMoveExtra.localPosition = CurrentMoveLastPart.localPosition;
|
||||
|
||||
StaticPartSegments.Add(CurrentMoveExtra);
|
||||
|
||||
CurrentMoveExtra.rotation = Quaternion.Euler(CurrentMoveExtra.rotation.eulerAngles.x, CurrentMoveExtra.rotation.eulerAngles.y + 180f, CurrentMoveExtra.rotation.eulerAngles.z);
|
||||
|
||||
MovingPartSegments.RemoveAt(MovingPartSegments.Count - 1);
|
||||
|
||||
CurrentMoveLastPart = CurrentMoveExtra;
|
||||
CurrentMoveExtra = MovingPartSegments[MovingPartSegments.Count - 1];
|
||||
|
||||
CurrentExtraStartCord = MovingPartSegments[MovingPartSegments.Count - 2].localPosition.z;
|
||||
//Debug.Log("2" + CurrentMoveUpper.name + " " + CurrentMoveLower.name + " " + CurrentMoveUpper.localPosition.z + " " + CurrentMoveUpperStartCord);
|
||||
}
|
||||
else
|
||||
{
|
||||
CurrentMoveExtra.SetParent(MovingPartTransform);
|
||||
CurrentMoveExtra.localPosition = CurrentMoveLastPart.localPosition;
|
||||
|
||||
MovingPartSegments.Add(CurrentMoveExtra);
|
||||
CurrentMoveExtra.rotation = Quaternion.Euler(CurrentMoveExtra.rotation.eulerAngles.x, CurrentMoveExtra.rotation.eulerAngles.y + 180f, CurrentMoveExtra.rotation.eulerAngles.z);
|
||||
StaticPartSegments.RemoveAt(StaticPartSegments.Count - 1);
|
||||
|
||||
CurrentMoveLastPart = CurrentMoveExtra;
|
||||
|
||||
CurrentMoveExtra = StaticPartSegments[StaticPartSegments.Count - 1];
|
||||
|
||||
CurrentExtraStartCord = StaticPartSegments[StaticPartSegments.Count - 2].localPosition.z;
|
||||
}
|
||||
}
|
||||
|
||||
void FollowAxis(bool reversed)
|
||||
{
|
||||
switch (reversed) {
|
||||
case false:
|
||||
CurrentMoveExtra.localPosition = new(0, 0, MonitoredAxisCord / 2); // z = 0.5 z
|
||||
RadiusTransform.localPosition = new(0, 0, MonitoredAxisCord / 2); // z = 0.5 z
|
||||
MovingPartTransform.localPosition = new(0, 0, MonitoredAxisCord / 2); // z = 0.5 z
|
||||
|
||||
MoveDelta = (CurrentMoveExtra.localPosition.z - CurrentExtraStartCord) / SegmentSize;
|
||||
|
||||
break;
|
||||
|
||||
case true:
|
||||
CurrentMoveExtra.localPosition = new(0, 0, -MonitoredAxisCord / 2); // -z = 0.5 z
|
||||
RadiusTransform.localPosition = new(0, 0, -MonitoredAxisCord / 2); // -z = 0.5 z
|
||||
MovingPartTransform.localPosition = new(0, 0, -MonitoredAxisCord); // -z = z
|
||||
|
||||
MoveDelta = - (CurrentMoveExtra.localPosition.z - CurrentExtraStartCord) / SegmentSize;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
CurrentMoveLastPart.localPosition = new(0, 0, MonitoredAxisCord / 2); // +z = 0.5 z
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: df3c23911e4586b4a995e7edd2121093
|
||||
@@ -0,0 +1,52 @@
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class PlateProgramCreator : MonoBehaviour
|
||||
{
|
||||
[SerializeField]
|
||||
List<Vector3> Program;
|
||||
|
||||
[SerializeField]
|
||||
List<GameObject> ComponentsToInstallParents;
|
||||
|
||||
[SerializeField]
|
||||
List<Vector3> ComponentsHoldersCords;
|
||||
|
||||
[SerializeField]
|
||||
Transform StartCord;
|
||||
|
||||
[SerializeField]
|
||||
bool start;
|
||||
|
||||
|
||||
// Start is called once before the first execution of Update after the MonoBehaviour is created
|
||||
void Start()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
if (start) {
|
||||
for (int i = 0; i < ComponentsToInstallParents.Count; i++) {
|
||||
foreach (var ChildTransform in ComponentsToInstallParents[i].GetComponentsInChildren<Renderer>())
|
||||
{
|
||||
if (ChildTransform.gameObject == ComponentsToInstallParents[i]) continue;
|
||||
Vector3 RelativeCords = ChildTransform.bounds.center - StartCord.position;
|
||||
//Debug.Log(StartCord.position.ToString() + "_-_" + ChildTransform.position.ToString() + ChildTransform.gameObject.name);
|
||||
//break;
|
||||
|
||||
RelativeCords = new(Mathf.Abs(RelativeCords.x), Mathf.Abs(RelativeCords.y), Mathf.Abs(RelativeCords.z));
|
||||
|
||||
Program.Add(ComponentsHoldersCords[i]);
|
||||
Program.Add(RelativeCords);
|
||||
}
|
||||
}
|
||||
|
||||
start = false;
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 935b4f2bebce4854aabde031ec90ab42
|
||||
@@ -0,0 +1,42 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.XR.Interaction.Toolkit;
|
||||
using UnityEngine.XR.Interaction.Toolkit.Interactables;
|
||||
using UnityEngine.XR.Interaction.Toolkit.Interactors;
|
||||
|
||||
[RequireComponent(typeof(XRSocketInteractor))]
|
||||
public class FilteredSocketReel : MonoBehaviour
|
||||
{
|
||||
//[SerializeField] private string allowedTag = "SocketCompatible";
|
||||
|
||||
[SerializeField] private MachineCoordinatesMovementScript MachineController;
|
||||
|
||||
private int SocketTagNumber;
|
||||
|
||||
private XRSocketInteractor socketInteractor;
|
||||
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
socketInteractor = GetComponent<XRSocketInteractor>();
|
||||
SocketTagNumber = int.Parse(this.gameObject.tag.Split("Material")[1]) - 1;
|
||||
socketInteractor.selectEntered.AddListener(OnObjectPlaced);
|
||||
socketInteractor.selectExited.AddListener(OnObjectRemoved);
|
||||
}
|
||||
|
||||
private void OnDestroy()
|
||||
{
|
||||
socketInteractor.selectEntered.RemoveListener(OnObjectPlaced);
|
||||
socketInteractor.selectExited.RemoveListener(OnObjectRemoved);
|
||||
}
|
||||
|
||||
private void OnObjectPlaced(SelectEnterEventArgs args)
|
||||
{
|
||||
MachineController.ReelInserted(SocketTagNumber);
|
||||
args.interactableObject.transform.GetComponent<BabinaScript>().SwitchToRope(socketInteractor.interactionLayers, socketInteractor.attachTransform);
|
||||
}
|
||||
|
||||
private void OnObjectRemoved(SelectExitEventArgs args)
|
||||
{
|
||||
MachineController.ReelRemoved(SocketTagNumber);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a3522924c0cb6304f9f913e6bd38df29
|
||||
@@ -0,0 +1,78 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.XR.Interaction.Toolkit;
|
||||
using UnityEngine.XR.Interaction.Toolkit.Interactors;
|
||||
|
||||
[RequireComponent(typeof(XRSocketInteractor))]
|
||||
public class FilteredSocket : MonoBehaviour
|
||||
{
|
||||
//[SerializeField] private string allowedTag = "SocketCompatible";
|
||||
|
||||
[SerializeField] private Transform SocketVisual;
|
||||
|
||||
[SerializeField] private MeshRenderer SocketToHolderRope;
|
||||
|
||||
[SerializeField] private MachineCoordinatesMovementScript MachineController;
|
||||
|
||||
[SerializeField] private float SocketVisualRotationAngle = 5f;
|
||||
|
||||
private Vector3 InitialRotation;
|
||||
|
||||
private int SocketTagNumber;
|
||||
|
||||
private XRSocketInteractor socketInteractor;
|
||||
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
socketInteractor = GetComponent<XRSocketInteractor>();
|
||||
socketInteractor.selectEntered.AddListener(OnObjectPlaced);
|
||||
socketInteractor.selectExited.AddListener(OnObjectRemoved);
|
||||
SocketToHolderRope.enabled = false;
|
||||
|
||||
SocketTagNumber = int.Parse(this.gameObject.tag.Split("Material")[1]) - 1;
|
||||
|
||||
|
||||
InitialRotation = SocketVisual.localEulerAngles;
|
||||
}
|
||||
|
||||
private void OnDestroy()
|
||||
{
|
||||
socketInteractor.selectEntered.RemoveListener(OnObjectPlaced);
|
||||
socketInteractor.selectExited.RemoveListener(OnObjectRemoved);
|
||||
}
|
||||
|
||||
private void OnObjectPlaced(SelectEnterEventArgs args)
|
||||
{
|
||||
// Åñëè ó îáúåêòà íå òîò òåã, îòìåíÿåì åãî ðàçìåùåíèå
|
||||
if (!args.interactableObject.transform.CompareTag(this.gameObject.tag))
|
||||
{
|
||||
//Debug.Log(socketInteractor.name + " " + args.interactableObject.transform.gameObject.name);
|
||||
socketInteractor.interactionManager.SelectExit(socketInteractor, args.interactableObject);
|
||||
MachineController.MaterialRemoved(SocketTagNumber);
|
||||
}
|
||||
else {
|
||||
//gameObject.
|
||||
//SocketVisual.Rotate(SocketVisualRotationAngle, 0, 0, Space.Self);
|
||||
SocketVisual.localRotation = Quaternion.Euler(InitialRotation.x - SocketVisualRotationAngle, InitialRotation.y, InitialRotation.z);
|
||||
SocketToHolderRope.enabled = true;
|
||||
|
||||
MachineController.MaterialInserted(SocketTagNumber);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private void OnObjectRemoved(SelectExitEventArgs args)
|
||||
{
|
||||
// Ìîæíî äîáàâèòü ëîãèêó ïðè èçâëå÷åíèè îáúåêòà
|
||||
|
||||
/*if (!args.interactableObject.isSelected)
|
||||
{
|
||||
args.interactableObject.transform.gameObject.GetComponent<MaterialRopeDetachAction>().ResetCheck();
|
||||
}*/
|
||||
//args.interactableObject.transform.gameObject.GetComponent<MaterialRopeDetachAction>().reset();
|
||||
SocketVisual.localRotation = Quaternion.Euler(InitialRotation.x, InitialRotation.y, InitialRotation.z);
|
||||
MachineController.MaterialRemoved(SocketTagNumber);
|
||||
SocketToHolderRope.enabled = false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3bd5943c6e9961a4ba4afb0b16b71acb
|
||||
Reference in new issue
Block a user