Fixed Button texture swapping. Fixed Button scripts on scene change. Added buttons to scenes. Added SHEDITOR define for Managed #341

Merged
maverickdgg merged 17 commits from SP3-20-UI-System into main 2023-02-04 00:32:29 +08:00
5 changed files with 49 additions and 13 deletions
Showing only changes of commit 3cd1778d08 - Show all commits

View File

@ -36,6 +36,9 @@
Mesh: 141771688 Mesh: 141771688
Material: 123313564 Material: 123313564
IsActive: true IsActive: true
UI Component:
Canvas ID: 1
IsActive: true
Scripts: ~ Scripts: ~
- EID: 5 - EID: 5
Name: Main Menu Button Name: Main Menu Button
@ -56,6 +59,9 @@
Hovered Texture: 55999018 Hovered Texture: 55999018
Clicked Texture: 66382894 Clicked Texture: 66382894
IsActive: true IsActive: true
UI Component:
Canvas ID: 1
IsActive: true
Scripts: Scripts:
- Type: ChangeSceneButton - Type: ChangeSceneButton
Enabled: true Enabled: true
@ -79,6 +85,9 @@
Hovered Texture: 65045286 Hovered Texture: 65045286
Clicked Texture: 58607560 Clicked Texture: 58607560
IsActive: true IsActive: true
UI Component:
Canvas ID: 1
IsActive: true
Scripts: Scripts:
- Type: QuitButton - Type: QuitButton
Enabled: true Enabled: true

View File

@ -22,6 +22,9 @@
Mesh: 141771688 Mesh: 141771688
Material: 121834459 Material: 121834459
IsActive: true IsActive: true
UI Component:
Canvas ID: 0
IsActive: true
Scripts: ~ Scripts: ~
- EID: 5 - EID: 5
Name: Start Game Button Name: Start Game Button
@ -42,6 +45,9 @@
Hovered Texture: 62235279 Hovered Texture: 62235279
Clicked Texture: 64722619 Clicked Texture: 64722619
IsActive: true IsActive: true
UI Component:
Canvas ID: 0
IsActive: true
Scripts: Scripts:
- Type: ChangeSceneButton - Type: ChangeSceneButton
Enabled: true Enabled: true
@ -65,6 +71,9 @@
Hovered Texture: 65045286 Hovered Texture: 65045286
Clicked Texture: 58607560 Clicked Texture: 58607560
IsActive: true IsActive: true
UI Component:
Canvas ID: 0
IsActive: true
Scripts: Scripts:
- Type: QuitButton - Type: QuitButton
Enabled: true Enabled: true

View File

@ -9,17 +9,22 @@ public class ChangeSceneButton : Script
protected override void start() protected override void start()
{ {
UIElement ui = GetComponent<UIElement>(); UIElement ui = GetComponent<UIElement>();
if (ui != null)
{
ui.OnClick.RegisterAction(() => ui.OnClick.RegisterAction(() =>
{ {
if(sceneID != 0) if (sceneID != 0)
{ {
Audio.PlaySFXOnce2D("event:/UI/success"); Audio.PlaySFXOnce2D("event:/UI/success");
SceneManager.ChangeScene(sceneID); SceneManager.ChangeScene(sceneID);
Audio.StopAllSounds(); Audio.StopAllSounds();
} }
}); });
}
else
{
Debug.LogError("Failed to register button action for ChangeSceneButton.");
}
} }
protected override void update() protected override void update()
{ {

View File

@ -6,12 +6,22 @@ public class QuitButton : Script
protected override void start() protected override void start()
{ {
UIElement ui = GetComponent<UIElement>(); UIElement ui = GetComponent<UIElement>();
if (ui != null)
{
ui.OnClick.RegisterAction(() =>
{
ui.OnClick.RegisterAction(() => ui.OnClick.RegisterAction(() =>
{ {
Audio.StopAllSounds(); Audio.StopAllSounds();
Application.Quit(); Application.Quit();
}); });
});
}
else
{
Debug.LogError("Failed to register button action for QuitButton.");
}
} }
protected override void update() protected override void update()

View File

@ -205,6 +205,7 @@ namespace SHADE
AddComponentToComponentNode<SHTextRenderableComponent>(components, eid); AddComponentToComponentNode<SHTextRenderableComponent>(components, eid);
AddComponentToComponentNode<SHAnimatorComponent>(components, eid); AddComponentToComponentNode<SHAnimatorComponent>(components, eid);
AddComponentToComponentNode<SHUIComponent>(components, eid);
node[ComponentsNode] = components; node[ComponentsNode] = components;
@ -263,6 +264,7 @@ namespace SHADE
AddComponentID<SHToggleButtonComponent>(componentIDList, componentsNode); AddComponentID<SHToggleButtonComponent>(componentIDList, componentsNode);
AddComponentID<SHTextRenderableComponent>(componentIDList, componentsNode); AddComponentID<SHTextRenderableComponent>(componentIDList, componentsNode);
AddComponentID<SHAnimatorComponent>(componentIDList, componentsNode); AddComponentID<SHAnimatorComponent>(componentIDList, componentsNode);
AddComponentID<SHUIComponent>(componentIDList, componentsNode);
return componentIDList; return componentIDList;
} }
@ -347,5 +349,6 @@ namespace SHADE
SHSerializationHelper::InitializeComponentFromNode<SHTextRenderableComponent>(componentsNode, eid); SHSerializationHelper::InitializeComponentFromNode<SHTextRenderableComponent>(componentsNode, eid);
SHSerializationHelper::InitializeComponentFromNode<SHLightComponent>(componentsNode, eid); SHSerializationHelper::InitializeComponentFromNode<SHLightComponent>(componentsNode, eid);
SHSerializationHelper::InitializeComponentFromNode<SHAnimatorComponent>(componentsNode, eid); SHSerializationHelper::InitializeComponentFromNode<SHAnimatorComponent>(componentsNode, eid);
SHSerializationHelper::InitializeComponentFromNode<SHUIComponent>(componentsNode, eid);
} }
} }