Author Topic: Compile Error When Setting Custom onFinished()  (Read 3379 times)

gretty

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 13
    • View Profile
Compile Error When Setting Custom onFinished()
« on: July 16, 2014, 02:06:45 AM »
Hello

Why cant I specify my own custom on finished method that will execute when a TweenScale has completed? I am getting the compile error:

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

Heres my simple code:
  1. using UnityEngine;
  2. using System.Collections;
  3.  
  4. public class CircularMenu : MonoBehaviour {
  5.  
  6.         private void OnEnable() {
  7.                
  8.                 GetComponent<TweenScale>().onFinished += onScaleFinished;  // Compile error: Operator `+=' cannot be applied to operands of type `System.Collections.Generic.List<EventDelegate>' and `method group'
  9.         }
  10.        
  11.         private void OnDisable() {
  12.                
  13.                 GetComponent<TweenScale>().onFinished -= onScaleFinished;
  14.         }
  15.        
  16.         private void onScaleFinished(GameObject go) {
  17.  
  18.         }
  19. }
  20.  

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Compile Error When Setting Custom onFinished()
« Reply #1 on: July 17, 2014, 01:45:56 AM »
EventDelegate.Add(GetComponent<TweenScale>().onFinished, onScaleFinished);