FMOD Integration and removed Timeline package

Hello. I have some errors and missing libraries in FMOD Integrations scripts after removing the Timeline package.

Please handle the timeline package existing in the project.

Thanks for the feedback.

How would you suggest that we check for this?

Hi :wink:
You can use version defines https://forum.unity.com/threads/how-to-programmatically-detect-if-package-x-is-installed-compilation-failing.677491/

InputSystem asmdef

For example, the New Input System check XR module existing in project like this:

I haven’t been able to find a Unity define for Timeline specifically but I will make a task to look into this further.

Hello.
In another way, you can add your own define in project settings. This new define is added if you find the assembly name “Unity.Timeline”
I write a simple script (FMODStartup.cs) to check “Unity.Timeline” assembly in the project after compilation and add or remove custom UNITY_TIMELINE_EXIST define in project settings

[InitializeOnLoad]
public class FMODStartup {
    
    static FMODStartup()
    {
        Assembly[] playerAssemblies = CompilationPipeline.GetAssemblies(AssembliesType.Player);
        
        var timeLineAssemblyIndex = Array.FindIndex(playerAssemblies,
            assembly => assembly.name == "Unity.Timeline");
        
        if (timeLineAssemblyIndex >= 0)
        {
            PlayerSettings.SetScriptingDefineSymbolsForGroup(BuildTargetGroup.Standalone, "UNITY_TIMELINE_EXIST");
        }
        else
        {
            var definesString = PlayerSettings.GetScriptingDefineSymbolsForGroup ( EditorUserBuildSettings.selectedBuildTargetGroup );
            definesString.Replace("UNITY_TIMELINE_EXIST", "");
            PlayerSettings.SetScriptingDefineSymbolsForGroup(EditorUserBuildSettings.selectedBuildTargetGroup, definesString);
        }
    }
}

After that, I added a simple playable asset script with custom define “UNITY_TIMELINE_EXIST”

#if UNITY_TIMELINE_EXIST
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Playables;
using UnityEngine.Timeline;

public class TestTimeline : PlayableAsset, ITimelineClipAsset
{
    public override Playable CreatePlayable(PlayableGraph graph, GameObject owner)
    {
        return new Playable();
    }

    public ClipCaps clipCaps { get; }
}
#endif

And its work! We check to exist of timeline assembly and of/on scripts logic.


Also, you can use PackageManager API for search package and check installed status

using UnityEditor.PackageManager.Requests;
using UnityEditor.PackageManager;

[InitializeOnLoad]
public class FMODStartup
{
    private static SearchRequest _searchRequest;
    
    static FMODStartup()
    {
        _searchRequest = Client.Search("com.unity.timeline", true);
        EditorApplication.update += PackageSearchProgress;
        EditorApplication.LockReloadAssemblies();
    }

    private static void PackageSearchProgress()
    {
        if (_searchRequest.IsCompleted)
        {
            Debug.LogError($"+++++:{_searchRequest.Status}");
            EditorApplication.update -= PackageSearchProgress;
            EditorApplication.UnlockReloadAssemblies();
        }
    }
}