Exemplo n.º 1
0
        public static void Mask(Light2D light, LightCollider2D id, LayerSetting layerSetting)
        {
            if (id.InLight(light) == false)
            {
                return;
            }

            int shapeCount = id.shapes.Count;

            for (int i = 0; i < shapeCount; i++)
            {
                LightColliderShape shape = id.shapes[i];

                List <MeshObject> meshObjects = shape.GetMeshes();

                if (meshObjects == null)
                {
                    return;
                }

                Vector2 position = shape.transform2D.position - light.transform2D.position;

                Vector2 pivotPosition = shape.GetPivotPoint() - light.transform2D.position;
                GL.Color(LayerSettingColor.Get(pivotPosition, layerSetting, id.maskEffect, id.maskTranslucency));

                GLExtended.DrawMeshPass(meshObjects, position, shape.transform.lossyScale, shape.transform2D.rotation);
            }
        }
Exemplo n.º 2
0
    private void DrawGizmos()
    {
        if (isActiveAndEnabled == false)
        {
            return;
        }

        Gizmos.color = new Color(1f, 0.5f, 0.25f);

        if (mainShape.shadowType != LightCollider2D.ShadowType.None)
        {
            foreach (LightColliderShape shape in shapes)
            {
                List <Polygon2> polygons = shape.GetPolygonsWorld();

                GizmosHelper.DrawPolygons(polygons, transform.position);
            }
        }

        switch (Lighting2D.ProjectSettings.editorView.drawGizmosBounds)
        {
        case EditorGizmosBounds.Rectangle:

            if (maskEffect == MaskEffect.Isometric)
            {
                Gizmos.color = Color.green;
                GizmosHelper.DrawIsoRect(transform.position, mainShape.GetIsoWorldRect());
            }
            else
            {
                Gizmos.color = new Color(0, 1f, 1f);
                GizmosHelper.DrawRect(transform.position, mainShape.GetWorldRect());
            }

            break;
        }

        Vector2?pivotPoint = mainShape.GetPivotPoint();

        if (pivotPoint != null)
        {
            Vector3 pos = transform.position;
            pos.x = pivotPoint.Value.x;
            pos.y = pivotPoint.Value.y;

            Gizmos.DrawIcon(pos, "circle_v2", true);
        }
    }