Ejemplo n.º 1
0
	private void DrawGizmos() {
	
		if (isActiveAndEnabled == false) {
			return;
		}

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

		if (Lighting2D.ProjectSettings.editorView.drawGizmosBounds == EditorGizmosBounds.Rectangle) {
			for(int i = 0; i < cameraSettings.Length; i++) {
				CameraSettings cameraSetting = cameraSettings[i];

				Camera camera = cameraSetting.GetCamera();

				if (camera != null) {
					Rect cameraRect = CameraTransform.GetWorldRect(camera);

					GizmosHelper.DrawRect(transform.position, cameraRect);
				}
			}
		}

		for(int i = 0; i < Scriptable.LightSprite2D.List.Count; i++) {
			Scriptable.LightSprite2D light = Scriptable.LightSprite2D.List[i];

			Rect rect = light.lightSpriteShape.GetWorldRect();

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

			GizmosHelper.DrawPolygon(light.lightSpriteShape.GetSpriteWorldPolygon(), transform.position);

			Gizmos.color = new Color(0, 1f, 1f);
			GizmosHelper.DrawRect(transform.position, rect);
		}
	}
Ejemplo n.º 2
0
            public static void Draw(Camera camera, LightTilemapRoom2D id, Material material)
            {
                Vector2 cameraPosition = -camera.transform.position;

                float cameraRadius = CameraTransform.GetRadius(camera);

                LightTilemapCollider.Base tilemapCollider = id.GetCurrentTilemap();

                material.mainTexture = null;

                Texture2D currentTexture = null;

                GL.Begin(GL.QUADS);

                int count = tilemapCollider.chunkManager.GetTiles(CameraTransform.GetWorldRect(camera));

                for (int i = 0; i < count; i++)
                {
                    LightTile tile = tilemapCollider.chunkManager.display[i];
                    if (tile.GetOriginalSprite() == null)
                    {
                        continue;
                    }

                    Vector2 tilePosition = tile.GetWorldPosition(tilemapCollider);

                    tilePosition += cameraPosition;

                    if (tile.NotInRange(tilePosition, cameraRadius))
                    {
                        continue;
                    }

                    spriteRenderer.sprite = tile.GetOriginalSprite();

                    if (spriteRenderer.sprite.texture == null)
                    {
                        continue;
                    }

                    if (currentTexture != spriteRenderer.sprite.texture)
                    {
                        currentTexture       = spriteRenderer.sprite.texture;
                        material.mainTexture = currentTexture;

                        material.SetPass(0);
                    }

                    Universal.Sprite.FullRect.Simple.DrawPass(tile.spriteMeshObject, spriteRenderer, tilePosition, tile.worldScale, tile.worldRotation);
                }

                GL.End();

                material.mainTexture = null;
            }
Ejemplo n.º 3
0
    public bool InCamera(Camera camera)
    {
        Rect cameraRect = CameraTransform.GetWorldRect(camera);

        if (cameraRect.Overlaps(lightSpriteShape.GetWorldRect()))
        {
            return(true);
        }

        return(false);
    }
Ejemplo n.º 4
0
        public static void DrawTiles(Camera camera, LightTilemapRoom2D id, Material material)
        {
            Vector2 cameraPosition = -camera.transform.position;

            float cameraRadius = CameraTransform.GetRadius(camera);

            if (id.superTilemapEditor.tilemap == null)
            {
                return;
            }

            if (id.superTilemapEditor.tilemap.Tileset != null)
            {
                material.mainTexture = id.superTilemapEditor.tilemap.Tileset.AtlasTexture;
            }

            material.color = id.color;

            LightTilemapCollider.Base tilemapCollider = id.GetCurrentTilemap();

            material.SetPass(0);
            GL.Begin(GL.QUADS);

            int count = id.superTilemapEditor.chunkManager.GetTiles(CameraTransform.GetWorldRect(camera));

            for (int i = 0; i < count; i++)
            {
                LightingTile tile = id.superTilemapEditor.chunkManager.display[i];

                Vector2 tilePosition = tile.GetWorldPosition(tilemapCollider);

                tilePosition += cameraPosition;

                if (tile.NotInRange(tilePosition, cameraRadius))
                {
                    continue;
                }

                Vector2 scale = tile.worldScale * 0.5f * tile.scale;

                Rendering.Universal.Texture.DrawPassSTE(tilePosition, scale, tile.uv, tile.worldRotation, 0);
            }

            GL.End();

            material.mainTexture = null;
            material.color       = Color.white;
        }
Ejemplo n.º 5
0
        private static MeshObject GetMeshPixelPerfect(Light2D light)
        {
            if (pixelPerfectMeshObject == null)
            {
                Camera camera = Camera.main;

                Rect rect = CameraTransform.GetWorldRect(camera);

                CalculatePoints();

                CalculateOffsets(rect.height * 1.1f / light.size);

                pixelPerfectMeshObject = GenerateMesh();
            }

            return(pixelPerfectMeshObject);
        }