ShanxiKnowledgeBase/SXElectricityInformationAcq.../Assets/taoruiqi/AdhesiveTape.cs

96 lines
2.4 KiB
C#

using DG.Tweening;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
/// <summary>
/// 없鍍스던
/// </summary>
public class AdhesiveTape : MonoBehaviour
{
/// <summary>
/// 없鍍스던
/// </summary>
public GameObject TapeOBJ;
/// <summary>
/// 든窟품뙈스던
/// </summary>
public Material TapeMar;
/// <summary>
/// 든窟툭旒
/// </summary>
public BoxCollider TapeMarCol;
// Start is called before the first frame update
void Start()
{
Init();
}
void Init()
{
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());
}
}
}
}
/// <summary>
/// 든窟끌스던
/// </summary>
/// <returns></returns>
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);
yield return new WaitForSeconds(1f);
StartCoroutine(TapeBack());
}
/// <summary>
/// 스던럿쀼땡뺌
/// </summary>
/// <returns></returns>
IEnumerator TapeBack()
{
TapeOBJ.transform.DOLocalMove(new Vector3(3.179443f, 1.790938f, -1.107346f),1f);
TapeMarCol.enabled = false;
yield return new WaitForSeconds(1f);
}
}