您最多选择25个主题
主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
33 行
844 B
33 行
844 B
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
public class ContactPosition : MonoBehaviour
|
|
{
|
|
private Material m_TargetMaterial;
|
|
private int m_PropertyHash;
|
|
|
|
public GameObject m_TargetObject;
|
|
|
|
// Start is called before the first frame update
|
|
void Start()
|
|
{
|
|
m_PropertyHash = Shader.PropertyToID("_ContactPosition");
|
|
m_TargetMaterial = m_TargetObject.GetComponent<Renderer>().sharedMaterial;
|
|
}
|
|
|
|
// Update is called once per frame
|
|
void Update()
|
|
{
|
|
m_TargetMaterial.SetVector(m_PropertyHash, transform.position);
|
|
|
|
//if(Input.GetKey(KeyCode.A))
|
|
//{
|
|
// m_TargetMaterial.SetFloat("_IsInContact", 1.0f);
|
|
//}
|
|
//else
|
|
//{
|
|
// m_TargetMaterial.SetFloat("_IsInContact", 0);
|
|
//}
|
|
}
|
|
}
|