Added check for editor camera.

This commit is contained in:
maverickdgg 2022-11-22 20:54:16 +08:00
parent a57145b510
commit 142f025692
4 changed files with 101 additions and 2 deletions

View File

@ -1,4 +1,4 @@
Start in Fullscreen: false
Starting Scene ID: 94283040
Starting Scene ID: 94246101
Window Size: {x: 1920, y: 1080}
Window Title: SHADE Engine

View File

@ -0,0 +1,79 @@
- EID: 0
Name: Canvas
IsActive: true
NumberOfChildren: 1
Components:
Canvas Component:
Canvas Width: 10
Canvas Height: 10
IsActive: true
Scripts: ~
- EID: 6
Name: Default
IsActive: true
NumberOfChildren: 0
Components:
Transform Component:
Translate: {x: 0, y: 0, z: 0}
Rotate: {x: 0, y: 0, z: 0}
Scale: {x: 1, y: 1, z: 1}
IsActive: true
Renderable Component:
Mesh: 141771688
Material: 129340704
IsActive: true
Scripts: ~
- EID: 1
Name: Camera
IsActive: true
NumberOfChildren: 0
Components:
Camera Component:
Position: {x: 0, y: 3, z: 8}
Pitch: 0
Yaw: 0
Roll: 0
Width: 1920
Height: 1080
Near: 0.00999999978
Far: 10000
Perspective: true
IsActive: true
Light Component:
Position: {x: 0, y: 0, z: 0}
Type: Directional
Direction: {x: 1.79999995, y: 0, z: 1}
Color: {x: 0.951541841, y: 0.921719015, z: 0.553319454, w: 1}
Layer: 4294967295
Strength: 0
IsActive: true
Scripts: ~
- EID: 7
Name: BigBoi
IsActive: true
NumberOfChildren: 0
Components:
Transform Component:
Translate: {x: 0, y: -16.8647861, z: -14.039052}
Rotate: {x: -0, y: 0, z: -0}
Scale: {x: 28.1434975, y: 28.1434975, z: 28.1434975}
IsActive: true
Renderable Component:
Mesh: 149697411
Material: 126974645
IsActive: true
Scripts: ~
- EID: 8
Name: AmbientLight
IsActive: true
NumberOfChildren: 0
Components:
Light Component:
Position: {x: 0, y: 0, z: 0}
Type: Ambient
Direction: {x: 0, y: 0, z: 1}
Color: {x: 1, y: 1, z: 1, w: 1}
Layer: 4294967295
Strength: 0.25
IsActive: true
Scripts: ~

View File

@ -0,0 +1,3 @@
Name: UI Test
ID: 96139961
Type: 5

View File

@ -7,6 +7,7 @@
#include "Camera/SHCameraSystem.h"
#include "Editor/EditorWindow/SHEditorWindowManager.h"
#include "Editor/EditorWindow/ViewportWindow/SHEditorViewport.h"
#include "Editor/SHEditor.h"
#include "Resource/SHResourceManager.h"
#include "Input/SHInputManager.h"
@ -118,12 +119,28 @@ namespace SHADE
void SHUISystem::UpdateCanvasComponent(SHCanvasComponent& comp) noexcept
{
auto cameraSystem = SHSystemManager::GetSystem<SHCameraSystem>();
#ifdef SHEDITOR
auto editor = SHSystemManager::GetSystem<SHEditor>();
if (editor->editorState != SHEditor::State::PLAY)
{
comp.canvasMatrix = SHMatrix::Identity;
comp.canvasMatrix(0, 0) = cameraSystem->GetEditorCamera()->GetWidth() * 0.5f / (comp.GetCanvasWidth() * 0.5f);
comp.canvasMatrix(1, 1) = cameraSystem->GetEditorCamera()->GetHeight() * 0.5f / (comp.GetCanvasHeight() * 0.5f);
}
else
{
comp.canvasMatrix = SHMatrix::Identity;
comp.canvasMatrix(0, 0) = cameraSystem->GetDirector(0)->GetWidth() * 0.5f / (comp.GetCanvasWidth() * 0.5f);
comp.canvasMatrix(1, 1) = cameraSystem->GetDirector(0)->GetHeight() * 0.5f / (comp.GetCanvasHeight() * 0.5f);
}
#else
comp.canvasMatrix = SHMatrix::Identity;
comp.canvasMatrix(0, 0) = cameraSystem->GetDirector(0)->GetWidth() * 0.5f / (comp.GetCanvasWidth() * 0.5f );
comp.canvasMatrix(1, 1) = cameraSystem->GetDirector(0)->GetHeight() * 0.5f / (comp.GetCanvasHeight() * 0.5f );
#endif
}
void SHUISystem::UpdateCanvasMatrixRoutine::Execute(double dt) noexcept
{
SHUISystem* system = (SHUISystem*)GetSystem();