I’ve tried a million things and can’t seem to get the simple effect of making my sprites glow. I followed a tutorial to make a a glowing shader but it turned out it would only work on 3D objects. I found a script to put on the camera that makes everything glow from unity’s built in assets, but can’t make it only effect a specific object. Does anyone know how to either make a shader meant for 3D work on sprites, make the camera glow effect script effect only specific objects, or have any other ideas on how I can achieve a glowing effect on a sprite?? I’m looking for an effect similar to that in games like geometry wars or Ori and the Blind Forest where objects glow.
If you’re curious, I need it so I can make certain body-parts of enemies glow to indicate to the player which parts are that enemy’s weak points. Actually, if anyone has a better idea than making them glow I’d be open to suggestions Because this glow thing is starting to be more trouble than it’s worth. I tried particle effects but can’t figure out how to make them spawn based on the shape of an object (only in squares or spheres).
I changed firestoke code into this and it’s working for me perfectly, and as an absolute amateur I have to say that I am very grateful for the main Shader code and of course firestoke script. I think if you try and work on the code a bit, you can personalize it to fit your needs. here is the code:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class ShineMaterialScript : MonoBehaviour
{
public float width;
public float duration;
public float m_Delay;
//delay is the time between each shine;
void Start ()
{
Material mat = Resources.Load("Materials/Environment/Shiny", typeof(Material)) as Material;
// either you have to have this exact address in your resource folder or change it to where ever
// you saved your shiny material, remember that the "Shiny" last bit here is just an example I used for
// the material name, you have to use the name which you have given your material with shiny shader on it.
// Take note that you have to add a "Resourse" folder in your assets folder in order for the script to work.
Renderer renderer = gameObject.GetComponent<Renderer>();
if (renderer != null)
{
renderer.material = mat;
}
else
{
Image img = gameObject.GetComponent<Image>();
if (img != null)
{
img.material = mat;
}
else
{
Debug.LogWarning("Cannot get the Renderer or Image component!");
}
}
mat.SetFloat("_ShineWith", width);
StopAllCoroutines();
StartCoroutine(shineRoutine(mat, duration, m_Delay));
}
static IEnumerator shineRoutine(Material mat, float duration, float m_Delay)
{
if (mat != null)
{
float location = 0f;
float interval = 0.04f;
float offsetVal = interval / duration;
while (true)
{
yield return new WaitForSeconds(interval);
mat.SetFloat("_ShineLocation", location);
location += offsetVal;
if (location > 1f)
{
yield return new WaitForSeconds(m_Delay);
location = 0f;
}
}
}
else
{
Debug.LogWarning("There is no Material parameter!");
}
}
}