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().interactionLayers; } IEnumerator SnapToSocketReset() { while (gameObject.transform.position != SocketAttach.position) { yield return null; } EndPos.GetComponent().interactionLayers = InitInteractionLayers; EndPos.GetComponent().enabled = true; //EndPos.GetComponent().ResetPos(); RopeRenderer.enabled = true; WireCapRenderer.enabled = true; } public void SwitchToRope(InteractionLayerMask SocketMask, Transform v_SocketAttach) { gameObject.GetComponent().interactionLayers = SocketMask; SocketAttach = v_SocketAttach; StartCoroutine(SnapToSocketReset()); } }