From fb7e4f92ef4e6e38819ff871cbe2f260b5bcd162 Mon Sep 17 00:00:00 2001 From: Areloch Date: Wed, 25 May 2016 22:16:24 -0500 Subject: [PATCH] Adds in a GameObjects folder that lists all available game objects to the Scripted objects tab in the creator panel in the editor. --- .../worldEditor/scripts/editors/creator.ed.cs | 46 +++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/Templates/Full/game/tools/worldEditor/scripts/editors/creator.ed.cs b/Templates/Full/game/tools/worldEditor/scripts/editors/creator.ed.cs index a6507cbaf..1712097ea 100644 --- a/Templates/Full/game/tools/worldEditor/scripts/editors/creator.ed.cs +++ b/Templates/Full/game/tools/worldEditor/scripts/editors/creator.ed.cs @@ -304,6 +304,36 @@ function EWCreatorWindow::navigate( %this, %address ) %this.addShapeIcon( %obj ); } } + + //Add a separate folder for Game Objects + if(isClass("Entity")) + { + if(%address $= "") + { + %this.addFolderIcon("GameObjects"); + } + else + { + //find all GameObjectAssets + %assetQuery = new AssetQuery(); + if(!AssetDatabase.findAssetType(%assetQuery, "GameObjectAsset")) + return 0; //if we didn't find ANY, just exit + + %count = %assetQuery.getCount(); + + for(%i=0; %i < %count; %i++) + { + %assetId = %assetQuery.getAsset(%i); + + %gameObjectAsset = AssetDatabase.acquireAsset(%assetId); + + if(isFile(%gameObjectAsset.TAMLFilePath)) + { + %this.addGameObjectIcon( %gameObjectAsset.gameObjectName ); + } + } + } + } } if ( %this.tab $= "Meshes" ) @@ -734,6 +764,22 @@ function EWCreatorWindow::addPrefabIcon( %this, %fullPath ) %this.contentCtrl.addGuiControl( %ctrl ); } +function EWCreatorWindow::addGameObjectIcon( %this, %gameObjectName ) +{ + %ctrl = %this.createIcon(); + + %ctrl.altCommand = "spawnGameObject( \"" @ %gameObjectName @ "\", true );"; + %ctrl.iconBitmap = EditorIconRegistry::findIconByClassName( "Prefab" ); + %ctrl.text = %gameObjectName; + %ctrl.class = "CreatorGameObjectIconBtn"; + %ctrl.tooltip = "Spawn the " @ %gameObjectName @ " GameObject"; + + %ctrl.buttonType = "radioButton"; + %ctrl.groupNum = "-1"; + + %this.contentCtrl.addGuiControl( %ctrl ); +} + function CreatorPopupMenu::onSelect( %this, %id, %text ) { %split = strreplace( %text, "/", " " );