NGUI: Set OnFinished Callback Causes Compile Error


I am getting a compiler error when I try to specify my own custom on finished method. The OnFinished method will execute when a NGUI::TweenScale has completed?

The compile error is:

Operator +=' cannot be applied to operands of type System.Collections.Generic.List’ and `method group’

Why is this happening and how can I fix it? Note I’ve posted on the NGUI forums but no responses after 1.5 days.

using UnityEngine;
using System.Collections;

public class CircularMenu : MonoBehaviour {

    private void OnEnable() {
        GetComponent<TweenScale>().onFinished += onScaleFinished;  // Compile error: Operator `+=' cannot be applied to operands of type `System.Collections.Generic.List<EventDelegate>' and `method group'
    private void OnDisable() {
        GetComponent<TweenScale>().onFinished -= onScaleFinished;
    private void onScaleFinished(GameObject go) {


Because onFinished has a type of List (see NGUI docs). That collection doesn’t have a defined += operator.

You may instead want to call AddOnFinished:


If you want to also call RemoveOnFinished, you may need to read up on constructing an EventDelegate, which NGUI uses internally to create a sort of serializable callback reference.

My thought is that there’s probably an easier way to manage this. Don’t forget that you can write your own custom component that manages some of this internally.