// Use this for initialization void Start() { spriteAnimation = GetComponent<SpriteAnimation>(); spriteRenderer = GetComponent<SpriteRenderer>(); updateHandler = PreUpdateHandler; //register a function to handler the animation evaluate spriteAnimation.AddComponentUpdateHandler( SpriteAnimationComponentUpdateType.PreUpdateComponent, updateHandler); }
void Start() { spriteRenderer = GetComponent<SpriteRenderer>(); spriteAnimation = GetComponent<SpriteAnimation>(); //register a animation update handler to change the color. //Because if do not change the color in handler, the color will overwrite by animation update in current implemention. spriteAnimation.AddComponentUpdateHandler( SpriteAnimationComponentUpdateType.PreUpdateComponent, OnUpdateAnimation); //register a hanlder to the event delegate handler, use delegate to handle event will cost less the SendMessage on mobile GetComponent<CollisionComponent>().OnComponentMouseOver += OnComponentMouseOverHandle; }