浏览代码

Fixing send messages while disabling OnMessageEvents (working on copies of call arrays)

/main
Thomas ICHÉ 5 年前
当前提交
54a9e19f
共有 2 个文件被更改,包括 8 次插入3 次删除
  1. 1
      CHANGELOG.md
  2. 10
      Runtime/Managers/Messager/Messager.cs

1
CHANGELOG.md


- **Delayed Logic** now has a mode that allows you to have a random delay within a range.
- **Audio Play Clip Action** now allows you to randomize volume and pitch within a range of values every time you play the clip.
- Messager now send messages through a copy of its source listeners array instead of the actual enumerator. This prevents from modifying the call array at the same frame if a OnMessageEvent becomes disabled during execution.
#### Fixed

10
Runtime/Managers/Messager/Messager.cs


{
try
{
foreach (var message in m_RegisteredMessages[eventName])
// Get a copy of registered messages to iterate on. This prevents issues while deregistering message recievers while iterating.
var messages = m_RegisteredMessages[eventName];
foreach (var message in messages)
message.Invoke(instigator);
if(message != null)
message.Invoke(instigator);
}
}
catch (Exception e)

}
else
{
Debug.Log("[MessageManager] could not find any listeners for event : " + eventName);
if(GameplayIngredientsSettings.currentSettings.verboseCalls)
Debug.Log("[MessageManager] could not find any listeners for event : " + eventName);
}
}
}
正在加载...
取消
保存