From 15d5aafadba1e4078b754169143ca51b8c0c89fc Mon Sep 17 00:00:00 2001 From: AzaezelX Date: Mon, 14 Nov 2022 21:30:13 -0600 Subject: [PATCH] add MeshRoadEditorGui::onRoadCreation callback use it, and the RoadEditorGui::onRoadCreation one to assign default road matrials on initial creation --- .../source/environment/editors/guiMeshRoadEditorCtrl.cpp | 4 ++++ .../game/tools/meshRoadEditor/meshRoadEditorGui.tscript | 7 +++++++ .../BaseGame/game/tools/roadEditor/roadEditorGui.tscript | 1 + 3 files changed, 12 insertions(+) diff --git a/Engine/source/environment/editors/guiMeshRoadEditorCtrl.cpp b/Engine/source/environment/editors/guiMeshRoadEditorCtrl.cpp index 69963cec5..671c39e96 100644 --- a/Engine/source/environment/editors/guiMeshRoadEditorCtrl.cpp +++ b/Engine/source/environment/editors/guiMeshRoadEditorCtrl.cpp @@ -677,6 +677,10 @@ void GuiMeshRoadEditorCtrl::on3DMouseDown(const Gui3DMouseEvent & event) // Submit it. undoMan->addAction( action ); + //send a callback to script after were done here if one exists + if (isMethod("onRoadCreation")) + Con::executef(this, "onRoadCreation"); + return; } else if ( mMode == mAddNodeMode ) diff --git a/Templates/BaseGame/game/tools/meshRoadEditor/meshRoadEditorGui.tscript b/Templates/BaseGame/game/tools/meshRoadEditor/meshRoadEditorGui.tscript index c1ef1c9c5..b29185746 100644 --- a/Templates/BaseGame/game/tools/meshRoadEditor/meshRoadEditorGui.tscript +++ b/Templates/BaseGame/game/tools/meshRoadEditor/meshRoadEditorGui.tscript @@ -84,6 +84,13 @@ function MeshRoadEditorGui::onRoadSelected( %this, %road ) } } +function MeshRoadEditorGui::onRoadCreation( %this ) +{ + %this.road.TopMaterialAsset = "Core_GameObjects:DefaultDecalRoadMaterial"; + %this.road.SideMaterialAsset = "Core_GameObjects:DefaultRoadMaterialOther"; + %this.road.BottomMaterialAsset = "Core_GameObjects:DefaultRoadMaterialOther"; +} + function MeshRoadEditorGui::onNodeSelected( %this, %nodeIdx ) { if ( %nodeIdx == -1 ) diff --git a/Templates/BaseGame/game/tools/roadEditor/roadEditorGui.tscript b/Templates/BaseGame/game/tools/roadEditor/roadEditorGui.tscript index 351491167..f24f1a229 100644 --- a/Templates/BaseGame/game/tools/roadEditor/roadEditorGui.tscript +++ b/Templates/BaseGame/game/tools/roadEditor/roadEditorGui.tscript @@ -79,6 +79,7 @@ function RoadEditorGui::onEscapePressed( %this ) //just in case we need it later function RoadEditorGui::onRoadCreation( %this ) { + %this.road.MaterialAsset = "Core_GameObjects:DefaultDecalRoadMaterial"; } function RoadEditorGui::onRoadSelected( %this, %road )