47 lines
1.1 KiB
C#
47 lines
1.1 KiB
C#
|
using System.Collections;
|
||
|
using System.Collections.Generic;
|
||
|
using UnityEngine;
|
||
|
|
||
|
public class reciveShadow : MonoBehaviour
|
||
|
{
|
||
|
public bool refreshEverySecond = true;
|
||
|
public Environment environment;
|
||
|
public sbyte shadowStrength = 5;
|
||
|
public Material inShadow;
|
||
|
public Material noShadow;
|
||
|
|
||
|
void Start()
|
||
|
{
|
||
|
/*if (environment.shadowStrength(transform.position) > shadowStrength)
|
||
|
{
|
||
|
gameObject.GetComponent<Renderer>().material = inShadow;
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
gameObject.GetComponent<Renderer>().material = noShadow;
|
||
|
}*/
|
||
|
}
|
||
|
int frame = 0;
|
||
|
|
||
|
// Update is called once per frame
|
||
|
void Update()
|
||
|
{
|
||
|
if(frame == 2)
|
||
|
{
|
||
|
|
||
|
}
|
||
|
if(refreshEverySecond&&frame%60==0&&frame>60)
|
||
|
{
|
||
|
if (environment.shadowStrength(transform.position) > shadowStrength)
|
||
|
{
|
||
|
gameObject.GetComponent<Renderer>().material = inShadow;
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
gameObject.GetComponent<Renderer>().material = noShadow;
|
||
|
}
|
||
|
}
|
||
|
frame++;
|
||
|
}
|
||
|
}
|