Search Unity

iTween oncomplete callback is not working

Discussion in 'Scripting' started by SweetBro, Apr 17, 2015.

  1. SweetBro

    SweetBro

    Joined:
    Jan 14, 2013
    Posts:
    69
    I'm too tired at this point, so maybe I'm missing something extremely obvious, but my oncomplete callback isn't functioning and since no errors are being raised I have no idea why and can't debug it myself. The onupdate call functions perfectly fine. Relevant code:

    Code (CSharp):
    1.     public void ActivateWindup(float time)
    2.     {
    3.         if (GetComponent<iTween>() != null) Destroy(GetComponent<iTween>());
    4.         Hashtable hash = new Hashtable {
    5.             {"from", 0},
    6.             {"to", maxSize},
    7.             {"time", time},
    8.             {"oncomplete", "WindupCallback"},
    9.             {"onupdate", "UpdateVal"}
    10.         };
    11.         iTween.ValueTo(gameObject, hash);
    12.     }
    13.  
    14.     void WindupCallback()
    15.     {
    16.         Debug.Log("Windup Finished");
    17.         associatedEidolon.ActivateAbility(associatedEidolon.battleArenaAt.GetCombatantListWithoutBattler(associatedEidolon));
    18.     }
    The class that contains the previous code inherits ProgressBar which has:

    Code (CSharp):
    1.     public void UpdateVal(float val){
    2.         if(val <= maxSize){
    3.         curVal = val;
    4.         percentDone = ((val/maxSize) * 100);
    5.         }
    6.         else{
    7.         curVal = maxSize;
    8.         percentDone = 100;
    9.         }
    10.     }
    No moving the callback into the parent method did not help. No adding an "oncompletetarget": gameObject did not help, nor did I expect it too since the iTween script and the callback method is on the same object. No making it public did not help. No renaming it did not help.
     
  2. SweetBro

    SweetBro

    Joined:
    Jan 14, 2013
    Posts:
    69
    I am unfathomably retarded.

    After about an hour of digging through iTween's source code searching for when my "oncomplete" stops being tracked, I realized that I the event handler was still calling the old method. On the bright-side I found a bug that would have caused a massive performance hit that I likely wouldn't have found otherwise and would not have noticed until much later.