private void Start()
        {
#if UNITY_EDITOR
            if (Material == null)
            {
                Material = (Material)UnityEditor.AssetDatabase.LoadAssetAtPath(
                    "Assets/Light2D/Materials/DualColor.mat", typeof(Material));
            }
#endif

            if (!Application.isPlaying)
            {
                return;
            }

            GameObject obstacleObj = new GameObject(gameObject.name + " Light Obstacle");

            obstacleObj.transform.parent        = gameObject.transform;
            obstacleObj.transform.localPosition = Vector3.zero;
            obstacleObj.transform.localRotation = Quaternion.identity;
            obstacleObj.transform.localScale    = Vector3.one * LightObstacleScale;
            if (LightingSystem.Instance != null)
            {
                obstacleObj.layer = LightingSystem.Instance.LightObstaclesLayer;
            }

            if (GetComponent <SpriteRenderer>() != null || GetComponent <CustomSprite>() != null)
            {
                LightObstacleSprite obstacleSprite = obstacleObj.AddComponent <LightObstacleSprite>();
                obstacleSprite.Color         = MultiplicativeColor;
                obstacleSprite.AdditiveColor = AdditiveColor;
                obstacleSprite.Material      = Material;
            }
            else
            {
                LightObstacleMesh obstacleMesh = obstacleObj.AddComponent <LightObstacleMesh>();
                obstacleMesh.MultiplicativeColor = MultiplicativeColor;
                obstacleMesh.AdditiveColor       = AdditiveColor;
                obstacleMesh.Material            = Material;
            }

            Destroy(this);
        }
    private void Update()
    {
        if (obstacleSprite == null)
        {
            obstacleSprite = GetComponentInChildren <Light2D.LightObstacleSprite>();
            if (obstacleSprite == null)
            {
                Debug.LogError("No Light Obstacle Sprite found");
                DestroyImmediate(this);
                return;
            }
        }
        float height = -transform.position.z;

        obstacleSprite.Color.a = heightToAlpha.Evaluate(height) / 255f;

        float scale = heightToScale.Evaluate(height);

        obstacleSprite.transform.localScale = new Vector3(scale, scale, scale);
    }