Hello Guest

Author Topic: Sprite transparet.  (Read 3506 times)

Phantom

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 6
    • View Profile
Sprite transparet.
« 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.


unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Sprite transparet.
« Reply #1 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.

Phantom

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 6
    • View Profile
Re: Sprite transparet.
« Reply #2 on: October 18, 2012, 09:08:22 am »
Thank you. It work.