Forum rules - please read before posting.

How do I use the Highlight component? (URP2D renderer)

I don't want to use other Unity plug-ins, that would increase the risk. :s

Comments

  • edited February 2022

    The Highlight component's build-in brightening effect works by affecting the "_Color" property of the Material it's set to affect.

    If your Material doesn't have this property - whether because your Render Pipeline is changed or its Shader doesn't rely on it - it will not have a default effect.

    An integration for the URP-supported Easy Performant Outline exists on the wiki here. However, if you want to stay away from other assets (though I'd say this one is safe) you'll have to rely on a custom shader and script to modify it.

    This'll involve using Unity's Shader Graph to create a custom sprite shader, which also features a "Highlight" float property that will affect the sprite's brightness. How exactly you do this will be up to you, as it'll be down to the exact effect you want.

    Once you have this set up, and you can manually test this by controlling the effect with the Material's "Highlight" property in its Inspector, you can rely on this custom script to sync it with AC's Highlight component:

    using UnityEngine;
    using AC;
    
    public class CustomHighlight : MonoBehaviour
    {
    
        public string highlightProperty = "Highlight";
        public Renderer _renderer;
        public Highlight highlight;
    
        private void Update ()
        {
            float hightlightAmount = highlight.GetHighlightIntensity ();
            _renderer.material.SetFloat (highlightProperty, hightlightAmount);
        }
    
    }
    
  • edited February 2022

    I didn't use this script. I just added the "color" property to Shader graph.Highlight to work!

  • True, that'd do it too!

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.