x


How to add color animations to spritemanager2 sprites

I am trying to add an color animation (alpha) to a spritemanager 2 packed sprite via unity animations. While there is the color attribute in the editor, this is not used during runtime (it is excluded). Right now I added a separate behavior that calls SetColor() on the sprite.

Is there a more elegant solution that lets me edit the curves in the animation editor, and have a preview and works during runtime ?

more ▼

asked Jun 13 '11 at 01:24 PM

Harald Scheirich gravatar image

Harald Scheirich
51 1 1 6

(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first

I don't know but it's add the your GameObject with Sprite Script.

using UnityEngine;

class FW_SM2ColorAni : MonoBehaviour
{
    Sprite m_Sprite;

    // Use this for initialization
    void Start ()
    {
        m_Sprite = gameObject.GetComponent<Sprite>();
    }

    void Update()
    {
        m_Sprite.SetColor(new Color(m_Sprite.color.r, m_Sprite.color.g, m_Sprite.color.b, m_Sprite.color.a));
    }
}
more ▼

answered Aug 19 '11 at 03:57 AM

freewill gravatar image

freewill
16

(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x57
x51

asked: Jun 13 '11 at 01:24 PM

Seen: 1027 times

Last Updated: Aug 19 '11 at 03:57 AM