- Home /
Animated Button Collider
Hello Everyone,
I am currently trying to make an animated button when it is in a still state.(non mouse over or clicked). I created a animation in after effects and brought it into unity where I have successfully been able to create a script that plays the animation, and it is interaction with mouse overs.
My problem stems from the built in ability to detect when the mouse is over the button, the collider picks up a square around the object and doesn't ignore the blank areas (alpha). I have come across this problem before and managed to get rid of it with a script with a "eventAlphaThreshold". The issue that I have is that this doesn't work with the "eventAlphaThreshold". So my main question that I am asking is how can I make the alpha/transparent part of my button non-interactive while still keeping my animation playing.
Collider looks like this (square is collider, circle is button (is filled in game)) :
using UnityEngine; using System.Collections; using UnityEngine.UI;
public class Animtion : MonoBehaviour {
public Image wheretoputit;
public Sprite[] images;
int fps = 10;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
int index = (int)((Time.time * fps) % images.Length);
images[index].eventAlphaThreshold = 0.5f; // doesnt work ( `UnityEngine.Sprite' does not contain a definition for `eventAlphaThreshold' )
wheretoputit.sprite = images [index];
}
}