Added shader outline to quarry

This commit is contained in:
journaliciouz
2025-12-11 22:36:08 +01:00
parent e98d10b2db
commit b9cf96367a
23 changed files with 6819 additions and 1563 deletions

View File

@@ -6,12 +6,13 @@ using Core.Lifecycle;
public class GlowOutline : ManagedBehaviour
{
private SpriteRenderer parentSprite;
private Color outlineColor;
private Transform[] childrenTransforms;
private SpriteRenderer[] childrenSprites;
private List<GlowOutlineData> outlineColors;
public SpriteRenderer itemSprite;
public float thiccness;
public GlowOutlineData.InteractionType interactionType;
@@ -40,19 +41,12 @@ public class GlowOutline : ManagedBehaviour
if (data.interaction == interactionType)
{
outlineColor = data.outlineColour;
Debug.Log(outlineColor);
}
}
// Find the spriterenderer in parent gameobject, but ignore our own spriterenderer
foreach (SpriteRenderer sprite in GetComponentsInParent<SpriteRenderer>())
{
if (sprite != this.GetComponent<SpriteRenderer>())
{
parentSprite = sprite;
}
}
// Set the scale and sprite of each child. Skip first child because that's the outline object.
childrenTransforms[1].localPosition = new Vector3(1, 0, 0) * thiccness;
@@ -62,8 +56,8 @@ public class GlowOutline : ManagedBehaviour
foreach (SpriteRenderer childSprite in childrenSprites)
{
childSprite.sprite = parentSprite.sprite;
childSprite.material.color = outlineColor;
childSprite.sprite = itemSprite.sprite;
childSprite.sharedMaterial.color = outlineColor;
}
}