2D Toolkit Forum
2D Toolkit => Support => Topic started by: Phantom on October 17, 2012, 12:11:30 pm
-
Hi.
I have sprite with "Red square". Need it animate changing transparent. How do it?
I probe change Color.A property but no effect.
Thanks.
-
if you're using the built in Unity animation system, it can't animate properties, just variables.
Attach a script like this:
using UnityEngine;
using System.Collections;
[ExecuteInEditMode]
public class tk2dAnimationAdapter : MonoBehaviour {
public Color color = Color.white;
tk2dBaseSprite sprite = null;
// Use this for initialization
void Start() {
sprite = GetComponent<tk2dBaseSprite>();
if (sprite != null)
{
sprite.color = color;
}
}
// Update is called once per frame
void Update () {
if (sprite != null && sprite.color != color)
{
sprite.color = color;
}
}
}
And animate the color property on this instead for it to work as expected.
-
Thank you. It work.