Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Question help with Marker message script?

Discussion in 'Timeline' started by metaphysician, Jul 29, 2023.

  1. metaphysician

    metaphysician

    Joined:
    May 29, 2012
    Posts:
    186
    hey folks, i went through the long thread on Signals and i totally agree the system was designed poorly, in that no parameters can be passed through Signals. so i decided to search for a customized Marker that would basically act as something similar to an AnimationEvent. i found this project from someone at Unity on Github here: https://github.com/Unity-Technologies/Timeline-MessageMarker

    unfortunately the main MessageReceiver script results in compilation errors in building for Android. it fails on this block it seems:

    Code (CSharp):
    1. public void OnNotify(Playable origin, INotification notification, object context)
    2.     {
    3.         //An INotificationReceiver will receive all the triggered notifications. We need to
    4.         //have a filter to use only the notifications that we can process.
    5.         var message = notification as Message;
    6.         if (message == null)
    7.             return;
    8.         var methodToCall = message.method;
    9.         var argument = ArgumentForMessage(message, origin.GetGraph().GetResolver());
    10.      
    11.      
    12.         if (EditorApplication.isPlaying)
    13.             SendMessage(methodToCall, argument);
    14.     }
    the issue is with EditorApplication.isPlaying, and i think maybe it needs a compilation flag or platform define so that it will be ignored in the build, or that it will use something else for Android. this is on a Quest headset but i don't think that matters in this case. any assistance or advice would be much appreciated! also open to using any other package providing similar functionality. thanks!
     
  2. tsukimi

    tsukimi

    Joined:
    Dec 10, 2014
    Posts:
    50
    Just wrap with the if statement with #if editor.
    Code (CSharp):
    1. #if UNITY_EDITOR
    2.         if (EditorApplication.isPlaying)
    3. #endif
    4.        SendMessage(methodToCall, argument);
    5.  
    reason: EditorApplication only exists in editor, so you will get error when building. Also, in build
    isPlaying 
    is always true, so it's fine to always call it.
     
    metaphysician likes this.
  3. metaphysician

    metaphysician

    Joined:
    May 29, 2012
    Posts:
    186
    that's the ticket! thanks very much. code compiles now. appreciated - thanks!
     
    tsukimi likes this.