class in Unity.Scripting.LifecycleManagement
/
Inherits from:Unity.Scripting.LifecycleManagement.LifecycleAttributeBase
Marks a static method as a callback to be invoked before code is unloaded during a code reload.
Methods marked with this attribute are called before assemblies are unloaded during a code reload. This is the counterpart to OnCodeLoadedAttribute.
Use this callback to:
This is a method attribute that can only be applied to static methods with no parameters and return type void.
Additional resources: OnCodeLoadedAttribute, OnCodeDeinitializingAttribute
using Unity.Scripting.LifecycleManagement; using UnityEngine; using System; using System.Runtime.InteropServices;
public static partial class NativeAudioPlugin { private static IntPtr s_PluginHandle;
[DllImport("AudioPlugin")] private static extern IntPtr AudioPlugin_Initialize();
[DllImport("AudioPlugin")] private static extern void AudioPlugin_Shutdown(IntPtr handle);
[OnCodeLoaded] static void Initialize() { s_PluginHandle = AudioPlugin_Initialize(); }
[OnCodeUnloading] static void Shutdown() { if (s_PluginHandle != IntPtr.Zero) { AudioPlugin_Shutdown(s_PluginHandle); s_PluginHandle = IntPtr.Zero; } } }