56 lines
1.4 KiB
C#
56 lines
1.4 KiB
C#
using UnityEngine;
|
|
/// <summary>
|
|
/// 设置伪装网
|
|
/// </summary>
|
|
public class SetThreshold : MonoBehaviour
|
|
{
|
|
public static SetThreshold instance;
|
|
private Renderer mat;
|
|
private float current;
|
|
public OneValueSyncObject target;
|
|
private float speed = 0.02f;
|
|
private void Awake()
|
|
{
|
|
instance = this;
|
|
mat = GetComponent<Renderer>();
|
|
current = target.myint = 0;
|
|
SetSmoothness(current);
|
|
}
|
|
// Start is called before the first frame update
|
|
void Start()
|
|
{
|
|
|
|
}
|
|
private void SetSmoothness(float f)
|
|
{
|
|
//SetPosition();
|
|
mat.material.SetColor("_Color", new Vector4(1, 1, 1, f));
|
|
}
|
|
|
|
private void SetPosition()
|
|
{
|
|
mat.material.SetVector("_StartPoint", transform.position);
|
|
}
|
|
// Update is called once per frame
|
|
void Update()
|
|
{
|
|
if (current != target.myint)
|
|
{
|
|
current = Mathf.Lerp(current, target.myint, speed);
|
|
SetSmoothness(current);
|
|
}
|
|
}
|
|
public void InstallWeiZhaungWang()
|
|
{
|
|
target.myint = 1;
|
|
target.SendSync();
|
|
if (target.action_apprisedetail != null) target.action_apprisedetail.Invoke();
|
|
}
|
|
public void DismantleWeiZhuangWang()
|
|
{
|
|
target.myint = 0;
|
|
target.SendSync();
|
|
if (target.action_apprisedetail != null) target.action_apprisedetail.Invoke();
|
|
}
|
|
}
|