Hello.
I’ve been using this script to cast dynamic shadows with sprites for a while now.
However, with one of the new updates, it has become outdated, and needs something to be fixed.
using UnityEngine;
using System.Collections;
public class SpriteShadows : MonoBehaviour {
// Use this for initialization
void Start () {
Renderer renderer = GetComponent <Renderer>();
if (renderer == null)
Debug.Log ("Renderer is empty");
GetComponent<Renderer>().shadowCastingMode =
UnityEngine.Rendering.ShadowCastingMode.On;
GetComponent <Renderer>().receiveShadows = true;
}
// Update is called once per frame
void Update () {
}
}
When I go to test, I get the error message “GetGfxDevice() should only be called from the main thread”
Followed by a crash.
Can anyone point me in the right direction to fix this and get the script up to date?