Moved UIRoutines call order. Call FinalizeChanges. Fixed UI Button Events. #359

Merged
maverickdgg merged 8 commits from SP3-20-UI-System into main 2023-02-23 14:00:51 +08:00
4 changed files with 28 additions and 2 deletions
Showing only changes of commit 7292f11cdb - Show all commits

View File

@ -28,6 +28,18 @@ namespace SHADE
: Component(entity)
{}
void UIElement::ClearStaticEventData()
{
if (onClickEventMap != nullptr)
onClickEventMap->Clear();
if (onReleasedEventMap != nullptr)
onReleasedEventMap->Clear();
if (onHoverEnterEventMap != nullptr)
onHoverEnterEventMap->Clear();
if (onHoverExitEventMap != nullptr)
onHoverExitEventMap->Clear();
}
/*---------------------------------------------------------------------------------*/
/* Properties */
/*---------------------------------------------------------------------------------*/

View File

@ -73,6 +73,15 @@ namespace SHADE
CallbackEvent^ get();
}
internal:
/*-----------------------------------------------------------------------------*/
/* Static Clear Functions */
/*-----------------------------------------------------------------------------*/
/// <summary>
/// Disposes static event data which may contains data from SHADE_Scripting.
/// </summary>
static void ClearStaticEventData();
private:
/*-----------------------------------------------------------------------------*/
/* Event Handling Functions */
@ -108,6 +117,7 @@ namespace SHADE
/*-----------------------------------------------------------------------------*/
/* Static Data Members */
/*-----------------------------------------------------------------------------*/
// As these hold references to code in SHADE_Scripting, we must remember to dispose of them when changing scenes
static System::Collections::Generic::Dictionary<Entity, CallbackEvent^>^ onClickEventMap;
static System::Collections::Generic::Dictionary<Entity, CallbackEvent^>^ onReleasedEventMap;
static System::Collections::Generic::Dictionary<Entity, CallbackEvent^>^ onHoverEnterEventMap;

View File

@ -21,6 +21,7 @@ of DigiPen Institute of Technology is prohibited.
#include "Utility/Convert.hxx"
#include "Utility/Debug.hxx"
#include "Scripts/ScriptStore.hxx"
#include "Components/UIElement.hxx"
namespace SHADE
{
@ -43,6 +44,9 @@ namespace SHADE
oss << "[EngineInterface] Unloading " << Convert::ToNative(ManagedLibraryName) << ".dll";
ScriptStore::Exit();
// Unload static data of components that have access to the assembly
UIElement::ClearStaticEventData();
// Unload the script
scriptContext->Unload();
scriptContext = nullptr;