2D Toolkit Forum

2D Toolkit => Support => Topic started by: Phantom on October 17, 2012, 12:11:30 pm

Title: Sprite transparet.
Post 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.

Title: Re: Sprite transparet.
Post by: unikronsoftware on October 17, 2012, 06:50:08 pm
if you're using the built in Unity animation system, it can't animate properties, just variables.
Attach a script like this:

Code: [Select]
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.
Title: Re: Sprite transparet.
Post by: Phantom on October 18, 2012, 09:08:22 am
Thank you. It work.