using DG.Tweening; using System.Collections; using System.Collections.Generic; using UnityEngine; /// /// 绝缘胶带 /// public class AdhesiveTape : MonoBehaviour { /// /// 绝缘胶带 /// public GameObject TapeOBJ; /// /// 电线前段胶带 /// public Material TapeMar; // Start is called before the first frame update void Start() { TapeMar.SetFloat("_step_p1", 0); TapeMar.SetFloat("_step_p2", 0); TapeMar.SetFloat("_step_p3", 0); TapeMar.SetFloat("_step_p4", 0); TapeMar.SetFloat("_step_p5", 0); TapeMar.SetFloat("_step_p6", 0); //TapeMar.SetFloat("_step_p1", 1); } // 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 == "pCylinder170") { StartCoroutine(tape()); } } } } IEnumerator tape() { TapeOBJ.gameObject.transform.DOLocalMove(new Vector3(3.1215f, 2.1383f, -1.3484f),1f); yield return new WaitForSeconds(1f); TapeMar.SetFloat("_step_p1", 1); yield return new WaitForSeconds(1f); TapeMar.SetFloat("_step_p2", 1); yield return new WaitForSeconds(1f); TapeMar.SetFloat("_step_p3", 1); yield return new WaitForSeconds(1f); TapeMar.SetFloat("_step_p4", 1); yield return new WaitForSeconds(1f); TapeMar.SetFloat("_step_p5", 1); yield return new WaitForSeconds(1f); TapeMar.SetFloat("_step_p6", 1); } }