So I have a script that I want to execute in edit mode. The script works fine inside of play mode. I’m triggering a unity event in the update loop of execute in edit mode, but no event is being raised it seems. Is this expected behavior?
[ExecuteInEditMode]
public class CardManager : UIBehaviour
{
/// <summary>
/// Triggered when the loot item has changed.
/// </summary>
[SerializeField]
private LootItemDataEvent _onLootItemAssigned = null;
private void Update()
{
// If the previous item does not match the current then we've switch items and should trigger the event
if (_lootItem == _previousLootItem)
{
return;
}
Debug.Log("Switch!");
_previousLootItem = _lootItem;
_onLootItemAssigned.Invoke(_lootItem);
}
}
So there is clearly more to the code that I posted above, but this gives the quickest example of what I’m seeing. The “LootItemDataEvent” is just a custom unity event, I’ll paste the code below in case there is an issue there.
namespace Meta.Event
{
using System;
using Loot;
using UnityEngine.Events;
/// <summary>
/// Allows a unity event to send loot item data with it.
/// </summary>
/// <seealso cref="UnityEngine.Events.UnityEvent{LootItemData}" />
[Serializable]
public class LootItemDataEvent : UnityEvent<LootItemData>
{ }
}
Thanks in advance!