using DG.Tweening; using System.Collections; using System.Collections.Generic; using UnityEngine; /// /// ÂÝË¿µ¶ /// public class Screwdriver : MonoBehaviour { /// /// ÂÝË¿µ¶×ø±ê /// public Transform ScrewdriverTrans; /// /// ÓÒ±ßÂÝË¿ /// public Transform ScrewR; /// /// ×ó±ßÂÝË¿ /// public Transform ScrewL; public InteractiveObjects[] interactiveObjects; // Start is called before the first frame update void Start() { } // Update is called once per frame void Update() { if (Input.GetMouseButtonDown(0)) {//Camera.transform.forward Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); RaycastHit hit; bool raycast = Physics.Raycast(ray, out hit); if (raycast) { if (hit.collider.gameObject.name == "¸Ç_¹Ì¶¨ÂÝË¿_Rup") { StartCoroutine(Rscrew()); Debug.Log(hit.collider.gameObject.name); } if (hit.collider.gameObject.name == "¹Ì¶¨ÂÝË¿_Ldown") { StartCoroutine(Lscrew()); Debug.Log(hit.collider.gameObject.name); } } } } /// /// ÓÒ±ßÂÝË¿ /// /// IEnumerator Rscrew() { ScrewdriverTrans.transform.DOLocalRotate(new Vector3(-19.741f, -113.296f, 90),1f); yield return new WaitForSeconds(1.5f); ScrewdriverTrans.transform.DOLocalMove(new Vector3(3.2373f, 1.8549f, -1.244f), 1f); yield return new WaitForSeconds(1); ScrewdriverTrans.transform.DOLocalRotate(new Vector3(-19.741f, -113.296f, -104.747f), 1f); yield return new WaitForSeconds(1.5f); ScrewdriverTrans.transform.DOLocalMove(new Vector3(3.191f, 1.831f, -1.158f), 1f); yield return new WaitForSeconds(2f); ScrewR.transform.DOLocalMove(new Vector3(0.1316f, 0.036f, 0.0034f), 1.5f); yield return new WaitForSeconds(3f); Destroy(ScrewR); } /// /// ×ó±ßÂÝË¿ /// /// IEnumerator Lscrew() { ScrewdriverTrans.transform.DOLocalRotate(new Vector3(-19.741f, -113.296f, 90), 1f); yield return new WaitForSeconds(1.5f); ScrewdriverTrans.transform.DOLocalRotate(new Vector3(-19.741f, -113.296f, -104.747f), 1f); yield return new WaitForSeconds(1.5f); ScrewdriverTrans.transform.DOLocalMove(new Vector3(3.2373f, 1.8284f, -1.3885f), 1f); yield return new WaitForSeconds(1.5f); ScrewL.transform.DOLocalMove(new Vector3(-0.07357633f, -0.01137948f, -0.0366f), 1f); } //private void OnMouseEnter() //{ // for (int i= 0; i < interactiveObjects.Length; i++) // { // interactiveObjects[i].enabled = true; // } //} //private void OnMouseExit() //{ // for (int i = 0; i < interactiveObjects.Length; i++) // { // interactiveObjects[i].enabled = false; // } //} }