Hello Guest

Author Topic: Animating Sptire Alpha with Unity3D Animation Editor  (Read 5356 times)

undream

  • Newbie
  • *
  • Posts: 5
    • View Profile
Animating Sptire Alpha with Unity3D Animation Editor
« on: August 13, 2013, 01:48:50 pm »
Hello.
I'm trying to animate the sprite alpha using the built-in animation editor of unity 3D. I've edited the "color.a" property under "Tk 2d sliced sprite (script)" but it was not updating the alpha.
Then I've found a script, tk2d animation adapter, by googleing about the problem. Here is the script.

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;
}
}
}

When I attach this script to my objects, everything works fine. However, when I preview the animation using te animation editor wondow, since it "commits" every change, the animation editor records new keyframes to tk2d sliced sprite's color.a property.

I'm looking for a smooth solution to update the alpha via animation editor.

Thank you.

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Animating Sptire Alpha with Unity3D Animation Editor
« Reply #1 on: August 13, 2013, 03:17:47 pm »
I posted a variant in the other thread. Try it and see if it works better for you?

Basically, this is just working around the fundemental issue with the unity animation editor that it doesn't animate properties properly :(