### Basic Google Test Setup Source: https://github.com/o3de/o3de.org/blob/development/content/blog/posts/google-test-matchers-part-1.md A minimal C++ example demonstrating the necessary includes and main function to run Google Tests. This serves as a starting point for writing tests. ```c++ #include #include TEST(AnExample, Test) { // .... } int main(int argc, char** argv) { ::testing::InitGoogleTest(&argc, argv); return RUN_ALL_TESTS(); } ``` -------------------------------- ### Client Configuration File Example Source: https://github.com/o3de/o3de.org/blob/development/content/docs/user-guide/networking/settings.md Use this configuration for a typical client setup. It connects to a host. ```cmd connect ``` -------------------------------- ### Example O3DE installation output Source: https://github.com/o3de/o3de.org/blob/development/content/docs/welcome-guide/setup/installing-linux.md An example of the output seen during O3DE installation, showing package list updates, dependency handling, and file unpacking. Note that versions and paths may vary. ```shell Reading package lists... Done Building dependency tree Reading state information... Done Note, selecting 'o3de' instead of '/usr/home//Downloads/o3de_2310_3.deb' The following packages were automatically installed and are no longer required: gir1.2-ibus-1.0 libasound2-dev libblkid-dev libdbus-1-dev libegl1-mesa-dev libgles2-mesa-dev libglib2.0-dev libglib2.0-dev-bin libibus-1.0-5 libibus-1.0-dev libice-dev libmount-dev libpcre16-3 libpcre2-16-0 libpcre2-32-0 libpcre2-dev libpcre2-posix2 libpcre3-dev libpcre32-3 libpcrecpp0v5 libpulse-dev libpulse-mainloop-glib0 libsdl2-2.0-0 libsdl2-dev libselinux1-dev libsepol1-dev libsm-dev libsndio-dev libsndio7.0 libudev-dev libwayland-bin libwayland-cursor0 libwayland-dev libwayland-egl1 libxcursor-dev libxcursor1 libxfixes-dev libxi-dev libxinerama-dev libxrandr-dev libxrender-dev x11proto-input-dev x11proto-randr-dev x11proto-xinerama-dev Use 'sudo apt autoremove' to remove them. The following NEW packages will be installed: o3de 0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded. After this operation, 17.9 GB of additional disk space will be used. Get:1 /usr/home//Downloads/o3de_2310_3.deb o3de amd64 2310_3 [5064 MB] Selecting previously unselected package o3de. (Reading database ... 48992 files and directories currently installed.) Preparing to unpack .../Linux/DEB/o3de_2310_3.deb ... Unpacking o3de (2310_3) ... Unpacking o3de (2310_3) over (2310_1) ... Setting up o3de (2310_3) ... ``` -------------------------------- ### Basic Styled Dock Widget Setup Source: https://github.com/o3de/o3de.org/blob/development/content/docs/tools-ui/component-library/uidev-styled-dock-component.md This C++ example demonstrates how to construct a main window, apply fancy docking, and add styled dock widgets to different areas of the window. It requires including AzQtComponents headers for DockMainWindow, FancyDocking, and StyledDockWidget. ```cpp #include #include #include // Construct a main window and apply fancy docking. auto mainWindow = new AzQtComponents::DockMainWindow(this); auto fancyDocking = new AzQtComponents::FancyDocking(mainWindow); // Add one AzQtComponents::StyledDockWidget per edge. auto leftDockWidget = new AzQtComponents::StyledDockWidget("Left Dock Widget", mainWindow); leftDockWidget->setObjectName(leftDockWidget->windowTitle()); leftDockWidget->setWidget(new QLabel("StyledDockWidget")); mainWindow->addDockWidget(Qt::LeftDockWidgetArea, leftDockWidget); auto topDockWidget = new AzQtComponents::StyledDockWidget("Top Dock Widget", mainWindow); topDockWidget->setObjectName(topDockWidget->windowTitle()); topDockWidget->setWidget(new QLabel("StyledDockWidget")); mainWindow->addDockWidget(Qt::TopDockWidgetArea, topDockWidget); auto rightDockWidget = new AzQtComponents::StyledDockWidget("Right Dock Widget", mainWindow); rightDockWidget->setObjectName(rightDockWidget->windowTitle()); rightDockWidget->setWidget(new QLabel("StyledDockWidget")); mainWindow->addDockWidget(Qt::RightDockWidgetArea, rightDockWidget); auto bottomDockWidget = new AzQtComponents::StyledDockWidget("Bottom Dock Widget", mainWindow); bottomDockWidget->setObjectName(bottomDockWidget->windowTitle()); bottomDockWidget->setWidget(new QLabel("StyledDockWidget")); mainWindow->addDockWidget(Qt::BottomDockWidgetArea, bottomDockWidget); QWidget* centralWidget = new QWidget; QVBoxLayout* vl = new QVBoxLayout(centralWidget); vl->addWidget(new QLabel("Central Widget")); mainWindow->setCentralWidget(centralWidget); ``` -------------------------------- ### Launch O3DE Project Manager Source: https://github.com/o3de/o3de.org/blob/development/content/docs/welcome-guide/setup/installing-linux.md Example command to launch the O3DE Project Manager from the shell after installation. The path includes the installation directory and version. ```shell /opt/O3DE/24.09/bin/Linux/profile/Default/o3de ``` -------------------------------- ### Create Install Build of Project Source: https://github.com/o3de/o3de.org/blob/development/content/docs/user-guide/build/distributable-engine.md Generates install binaries for the project in an 'install' subdirectory. Use this to create distributable assets. ```cmd cmake --build build\windows --config profile --target INSTALL ``` -------------------------------- ### Example Non-Monolithic Project Path Source: https://github.com/o3de/o3de.org/blob/development/content/docs/user-guide/packaging/windows-release-builds.md Example path for a non-monolithic project's Game Launcher executable. ```text C:\MyProject\install\bin\Windows\release\Default ``` -------------------------------- ### Example Usage of Asset Management Source: https://github.com/o3de/o3de.org/blob/development/content/docs/user-guide/editor/editor-automation.md This example demonstrates how to use the 'GetAssetIdByPath' and 'GetAssetPathById' functions to retrieve asset information. It shows how to get the Asset ID for a cube primitive and then use that ID to retrieve its relative path within the project. ```python import azlmbr.bus as bus import azlmbr.math emptyTypeId = azlmbr.math.Uuid() # get the cube asset ID bRegisterType = False cubeAssetId = azlmbr.asset.AssetCatalogRequestBus(bus.Broadcast, 'GetAssetIdByPath', 'objects/default/primitive_cube.cgf', emptyTypeId, bRegisterType) print ('cube asset ID validity is {}'.format(cubeAssetId.IsValid())) # get the cube path name (relative in project) cubePath = azlmbr.asset.AssetCatalogRequestBus(bus.Broadcast, 'GetAssetPathById', cubeAssetId) print ('cube asset path is {}'.format(cubePath)) ``` -------------------------------- ### Example Monolithic Project Path Source: https://github.com/o3de/o3de.org/blob/development/content/docs/user-guide/packaging/windows-release-builds.md Example path for a monolithic project's Game Launcher executable. ```text C:\MyProject\install\bin\Windows\release\Monolithic ``` -------------------------------- ### Build the INSTALL Target Source: https://github.com/o3de/o3de.org/blob/development/content/docs/user-guide/build/distributable-engine.md Build the 'INSTALL' target using CMake to generate the distributable binaries. The binaries are placed in a directory specified by CMAKE_INSTALL_PREFIX or an 'install' subdirectory by default. ```cmd cmake --build --preset windows-install --config profile ``` -------------------------------- ### Download, Build, and Install Google Test Source: https://github.com/o3de/o3de.org/blob/development/content/blog/posts/cmake-essentials-series-part-3.md Clone the Google Test repository, configure the build with a custom installation prefix, and then build and install the library. Use `-Dgtest_force_shared_crt=ON` on Windows to avoid link errors due to dynamic CRT linking. ```bash > git clone https://github.com/google/googletest.git #1 > cd googletest #2 > cmake -S . -B build -DCMAKE_INSTALL_PREFIX=../gtest-install -Dgtest_force_shared_crt=ON #3 > cmake --build build --target install #4 ``` -------------------------------- ### Get Event Start Time Source: https://github.com/o3de/o3de.org/blob/development/content/docs/user-guide/visualization/animation/character-editor/custom-events-parameters-motionevent-public-member-functions.md Retrieves the start time value of the event, indicating when it should be executed. ```cpp float GetStartTime () const ``` -------------------------------- ### Server configuration file example Source: https://github.com/o3de/o3de.org/blob/development/content/docs/user-guide/networking/multiplayer/running.md Defines commands to be executed by the ServerLauncher upon launch, including hosting and level loading. ```plaintext host LoadLevel ``` -------------------------------- ### GetStartTime Source: https://github.com/o3de/o3de.org/blob/development/content/docs/user-guide/visualization/animation/character-editor/custom-events-parameters-motionevent-public-member-functions.md Gets the start time value of this event, which is when the event should be executed. ```APIDOC ## GetStartTime Gets the start time value of this event, which is when the event should be executed. ### Syntax ``` float GetStartTime () const ``` ``` -------------------------------- ### Download Project Example Source: https://github.com/o3de/o3de.org/blob/development/content/docs/user-guide/project-config/cli-reference.md Example of downloading a custom project to a specified destination path. If --dest-path is omitted, the project downloads to the default location. ```cmd o3de.bat download --project-name "CustomProject" --dest-path "C:/projects" ``` -------------------------------- ### Create and Populate a Basic Context Menu in C++ Source: https://github.com/o3de/o3de.org/blob/development/content/docs/tools-ui/component-library/uidev-context-menu-component.md This C++ example demonstrates how to create a QMenu, add actions, separators, submenus, and checkable/disabled actions. Include the necessary Qt headers. ```cpp #include // Create the menu. QMenu* menu = new QMenu(parent); // Add some actions. menu->addAction(QStringLiteral("Load")); menu->addAction(QStringLiteral("Save")); // Add an action with a search icon. menu->addAction(QIcon(QStringLiteral(":/stylesheet/img/search.svg")), QStringLiteral("Search")); // Add a separator. menu->addSeparator(); // Add a submenu. auto submenu = menu->addMenu(QStringLiteral("Submenu")); // Add some checkable actions in the submenu. auto appleAction = submenu->addAction(QStringLiteral("Show Apples")); appleAction->setCheckable(true); appleAction->setChecked(true); auto orangeAction = submenu->addAction(QStringLiteral("Show Oranges")); orangeAction->setCheckable(true); auto pearAction = submenu->addAction(QStringLiteral("Show Pears")); pearAction->setCheckable(true); // Add an action that is disabled. auto disabledAction = menu->addAction(QStringLiteral("Disabled")); disabledAction->setEnabled(false); ``` -------------------------------- ### Full O3DE Editor Test Example: Enter Game Mode Source: https://github.com/o3de/o3de.org/blob/development/content/docs/user-guide/testing/parallel-pattern/_index.md A comprehensive example demonstrating how to write a test that enters game mode. It includes setup, execution, result reporting, and cleanup. ```python # Test Case Title : Check that entering into gamemode works # List of results that we want to check, this is not 100% necessary but its a good # practice to make it easier to debug tests. # Here we define a tuple of tests class Results(): enter_game_mode = ("Entered game mode", "Failed to enter game mode") def MyFeature_EnterGameModeWorks(): # A description of the test is always very helpful. # Description: This test checks that entering into gamemode works by openning an empty level # and entering into the gamemode. The is in gamemode state should be changed after doing it # Import report and test helper utilities from editor_python_test_tools.utils import Report from editor_python_test_tools.utils import TestHelper as helper # All exposed python bindings are in azlmbr import azlmbr.legacy.general as general # Required for automated tests helper.init_idle() # Open the level called "Base". # This level is an empty level where we can run automated tests to avoid creating one helper.open_level(level="Base") # Using the exposed Python API from editor in CryEditPy.py we can enter into gamemode this way general.enter_game_mode() # The script drives the execution of the test, to return the flow back to the editor, # we will tick it one time general.idle_wait_frames(1) # Now we can use the Report.result() to report the state of a result # if the second argument is false, it will mark this test as failed, however it will keep going. Report.result(Results.enter_game_mode, general.is_in_game_mode()) # Instead of using Report.result(), you can also use: # assert is_in_game_mode, "Didn't enter into gamemode" # However this would stop the test at this point and not report anything when it succeeds # The test will end at this point, is good practice to exit gamemode or reset any changed stated # *DO NOT* close the editor, the editor will close automatically and report the error code general.exit_game_mode() if __name__ == "__main__": # This utility starts up the test and sets up the state for knowing what test is currently being run from editor_python_test_tools.utils import Report Report.start_test(MyFeature_EnterGameModeWorks) ``` -------------------------------- ### Launch Resource Mapping Tool Example (O3DE Python) Source: https://github.com/o3de/o3de.org/blob/development/content/docs/user-guide/gems/reference/aws/aws-core/resource-mapping-tool.md An example of launching the resource mapping tool using the O3DE Python distribution, demonstrating the use of specific paths for binaries and build configuration. ```cmd python\python.cmd Gems\AWSCore\Code\Tools\ResourceMappingTool\resource_mapping_tool.py --binaries_path C:\MyProject\bin\profile\AWSCoreEditorQtBin ``` -------------------------------- ### Texture Atlas Comment Example Source: https://github.com/o3de/o3de.org/blob/development/content/docs/user-guide/interactivity/user-interface/canvases/texture-atlases/texture-atlases-creating.md Lines starting with // are treated as comments and ignored by the Asset Processor. ```plaintext // This is a comment that is ignored. ``` -------------------------------- ### Start Linux GameLift Server Locally Source: https://github.com/o3de/o3de.org/blob/development/content/docs/user-guide/gems/reference/aws/aws-gamelift/build-packaging-for-linux.md Use this command to start your Linux GameLift server locally after setting up GameLift Local. Ensure you replace placeholder paths with your actual installation folder and executable names. ```bash / --engine-path= --project-path= --project-cache-path=/assets -bg_ConnectToAssetProcessor=0 -rhi=null ``` -------------------------------- ### Registering and Using a System with AZ::Interface Source: https://github.com/o3de/o3de.org/blob/development/content/docs/user-guide/programming/messaging/az-interface.md Example demonstrating how to define an interface, register a system implementing that interface using AZ::Interface::Registrar, and then access the system's methods. Always check for a valid pointer before invoking methods. ```cpp class ISystem { public: virtual ~ISystem(); virtual void DoSomething() = 0; }; class System : public AZ::Interface::Registrar { public: void DoSomething() override; }; // In client code. // Check that the pointer is valid before use. if (ISystem* system = AZ::Interface::Get()) { system->DoSomething(); } ``` -------------------------------- ### Get registered Gem path Source: https://github.com/o3de/o3de.org/blob/development/content/docs/user-guide/project-config/cli-reference.md Retrieves the path of a Gem by its specified name. Use this to find the installation directory of a specific Gem. ```cmd o3de.bat get-registered --gem-name GEM_NAME ``` -------------------------------- ### Run client with config file Source: https://github.com/o3de/o3de.org/blob/development/content/docs/user-guide/networking/multiplayer/running.md Launches the ClientLauncher executable and executes commands from a specified configuration file on startup. ```batch MultiplayerSample.ClientLauncher.exe --console-command-file=launch_client.cfg ``` -------------------------------- ### Get registered engine path Source: https://github.com/o3de/o3de.org/blob/development/content/docs/user-guide/project-config/cli-reference.md Retrieves the path of an engine by its specified name. Use this to find the location of a particular engine installation. ```cmd o3de.bat get-registered --engine-name ENGINE_NAME ``` -------------------------------- ### Example Usage of EditorComponentAPIBus Source: https://github.com/o3de/o3de.org/blob/development/content/docs/user-guide/editor/editor-automation.md Demonstrates how to use the EditorComponentAPIBus to get, set, and list component properties. Ensure you have the necessary componentId and propertyPath defined. ```python import azlmbr.bus as bus # Get current value of the mesh asset property of the MeshComponentRenderNode propertyPath = "MeshComponentRenderNode|Mesh asset" valueOutcome = azlmbr.editor.EditorComponentAPIBus(bus.Broadcast, 'GetComponentProperty', componentId, propertyPath) if (valueOutcome.IsSuccess()): meshAssetId = valueOutcome.GetValue() print ('Old mesh asset is {}'.format(meshAssetId)) # Set the mesh asset outcome = None if (meshAssetId is not None): outcome = azlmbr.editor.EditorComponentAPIBus(bus.Broadcast, 'SetComponentProperty', componentId, propertyPath, meshAssetId) if(outcome.IsSuccess()): result = outcome.GetValue() print ('New mesh asset is {}'.format(result)) # Read the properties of this MeshComponentRenderNode propertyPaths = azlmbr.editor.EditorComponentAPIBus(bus.Broadcast, 'BuildComponentPropertyList', componentId) for path in propertyPaths: print ('ComponentId path has {}'.format(path)) ``` -------------------------------- ### Export Project Command Example (Windows) Source: https://github.com/o3de/o3de.org/blob/development/content/docs/user-guide/packaging/project-export/project-export-pc.md Demonstrates a full command-line invocation for exporting the O3DE MultiplayerSample project on Windows. This example includes common options for release builds, asset bundling, and file copying. ```bash # On Windows %O3DE_ENGINE_PATH%\scripts\o3de.bat export-project \ --export-script %O3DE_ENGINE_PATH%\scripts\o3de\ExportScripts\export_source_built_project.py \ --project-path %O3DE_PROJECT_PATH% -out %OUTPUT_PATH% \ --config release \ --archive-output zip -nounified \ --game-project-file-pattern-to-copy launch_client.cfg \ --server-project-file-pattern-to-copy launch_client.cfg \ --should-build-assets \ --log-level INFO \ --seedlist \path\to\o3de-multiplayersample\AssetBundling\SeedLists\BasePopcornFxSeedList.seed \ --seedlist %O3DE_PROJECT_PATH%\AssetBundling\SeedLists\GameSeedList.seed \ --seedlist %O3DE_PROJECT_PATH%\AssetBundling\SeedLists\VFXSeedList.seed ``` -------------------------------- ### Get Python Runtime Source: https://github.com/o3de/o3de.org/blob/development/content/docs/welcome-guide/setup/setup-from-github/building-linux.md Downloads the Python runtime required by the O3DE CLI script. Ensure CMake is installed and accessible in your system's PATH. ```shell # Run from the o3de engine root. python/get_python.sh ``` -------------------------------- ### Basic enable-gem Usage Source: https://github.com/o3de/o3de.org/blob/development/content/docs/user-guide/project-config/cli-reference.md A common usage example of the `enable-gem` command, specifying the Gem path and project path. ```cmd o3de.bat enable-gem -gp GEM_PATH -pp PROJECT_PATH ``` -------------------------------- ### Configure Legacy Asset Converter Settings Source: https://github.com/o3de/o3de.org/blob/development/content/docs/learning-guide/tutorials/lumberyard-to-o3de/converting-materials.md Edit the `settings.local.json` file to specify the paths for your O3DE installation. This is a one-time setup required for the tool to locate engine directories. ```json { "O3DE_DEV": "C:\\depot\\o3de-dev", "PATH_O3DE_3RDPARTY": "C:\\depot\\3rdParty", "PATH_O3DE_BIN": "C:\\depot\\o3de-dev\\build\\windows_vs2019\\bin\\profile", "DCCSI_LOG_PATH": "{your_path}\\user\\log\\DCCsi" } ``` -------------------------------- ### Example: Get Component Type Lists Source: https://github.com/o3de/o3de.org/blob/development/content/docs/user-guide/editor/editor-automation.md Demonstrates how to retrieve lists of game and level component type names, and how to find component type IDs and names using the EditorComponentAPIBus. ```python import azlmbr.bus as bus # Generate list of game component type names componentList = editor.EditorComponentAPIBus(bus.Broadcast, 'BuildComponentTypeNameListByEntityType', entity.EntityType().Game) # Generate list of level component type names componentList = editor.EditorComponentAPIBus(bus.Broadcast, 'BuildComponentTypeNameListByEntityType', entity.EntityType().Level) # Get component types for 'Mesh' and 'Comment' typeIdList = azlmbr.editor.EditorComponentAPIBus(bus.Broadcast, 'FindComponentTypeIds', ["Mesh", "Comment"]) # Get component type names from component type IDs typeNameList = azlmbr.editor.EditorComponentAPIBus(bus.Broadcast, 'FindComponentTypeNames', typeIdsList) ``` -------------------------------- ### Example windows_project.json Configuration Source: https://github.com/o3de/o3de.org/blob/development/content/docs/atom-guide/dev-guide/troubleshoot.md This JSON example demonstrates how to configure graphics API and validation mode for Windows platforms in the windows_project.json file. ```json { "Tags": [ "Windows" ], "windows_settings": { "graphics": { "graphicsAPI": "DX12", "validationMode": 0 } } } ``` -------------------------------- ### setup_launcher_layout_directory Source: https://github.com/o3de/o3de.org/blob/development/content/docs/user-guide/packaging/project-export/project-export-pc.md Setup the launcher layout directory for a path. ```APIDOC ## setup_launcher_layout_directory ### Description Setup the launcher layout directory for a path. ### Parameters This function does not explicitly list parameters in the provided documentation. ``` -------------------------------- ### AZSL Functions within SRGs Source: https://github.com/o3de/o3de.org/blob/development/content/docs/atom-guide/dev-guide/shaders/azsl/_index.md Define functions within Shader Resource Groups (SRGs) for use in vertex and fragment shaders. This example shows how to get world and normal matrices. ```cpp ShaderResourceGroup PerObject : BindingPerObject { row_major float3x4 m_modelToWorld; row_major float3x3 m_normalMatrix; float4x4 GetWorldMatrix() { float4x4 modelToWorld = float4x4( float4(1, 0, 0, 0), float4(0, 1, 0, 0), float4(0, 0, 1, 0), float4(0, 0, 0, 1)); modelToWorld[0] = m_modelToWorld[0]; modelToWorld[1] = m_modelToWorld[1]; modelToWorld[2] = m_modelToWorld[2]; return modelToWorld; } float3x3 GetNormalMatrix() { return m_normalMatrix; } } VertexOutput MainVS(VertexInput input) { const float4x4 worldMatrix = PerObject::GetWorldMatrix(); VertexOutput output; float3 worldPosition = mul(worldMatrix, float4(input.m_position,1)).xyz; output.m_position = mul(GetView_ViewProjectionMatrix(), float4(worldPosition, 1.0)); output.m_uv = input.m_uv; output.m_positionToCamera = GetView_WorldPosition() - worldPosition; output.m_normal = mul(PerObject::GetNormalMatrix(), input.m_normal); output.m_tangent = mul(PerObject::GetNormalMatrix(), input.m_tangent); return output; } ``` -------------------------------- ### Add Unit Attributes for Track View Properties Source: https://github.com/o3de/o3de.org/blob/development/content/docs/user-guide/programming/components/expose-animation.md Apply unit attributes to getter events in BehaviorContext reflection to guide Track View in how it should represent the property. For example, use PropertyUnits8BitColor for color properties. ```c++ ->Event("GetImaginaryTargetColor", &ImaginaryTargetComponentRequestBus::Events::GetImaginaryTargetColor) ->Attribute("Units", AZ::Edit::Attributes:: PropertyUnits8BitColor) ``` -------------------------------- ### Deferred Command Execution Example Source: https://github.com/o3de/o3de.org/blob/development/content/docs/user-guide/editor/console-cvars-commands.md This example demonstrates deferred command execution using a configuration file and command-line arguments. It shows how to load a map, wait for frames, take screenshots, wait for seconds, and then quit. ```plaintext --- autotest.cfg -- hud_startPaused = "0" wait_frames 100 screenshot autotestFrames wait_seconds 5.0 screenshot autotestTime -- console -- StarterGameLauncher.exe -devmode +map SinglePlayer +exec autotest +quit ``` -------------------------------- ### Configure Simulation Interfaces Settings Source: https://github.com/o3de/o3de.org/blob/development/content/docs/user-guide/interactivity/robotics/simulation-interfaces.md Example JSON configuration file for simulation interfaces, including state printing, starting state, and keyboard transitions. This file can be placed in your project's Registry directory. ```json { "SimulationInterfaces": { "PrintStateNameInGui": true, "StartInStoppedState": true, "KeyboardTransitions": { "StoppedToPlaying": "keyboard_key_alphanumeric_R", "PausedToPlaying": "keyboard_key_alphanumeric_R", "PlayingToPaused": "keyboard_key_alphanumeric_P" } }, "ROS2SimulationInterfaces": { "GetEntities": "custom_get_entities_service", "GetSimulatorFeatures": "" } } ``` -------------------------------- ### Run server with config file Source: https://github.com/o3de/o3de.org/blob/development/content/docs/user-guide/networking/multiplayer/running.md Launches the ServerLauncher executable and executes commands from a specified configuration file on startup. ```batch MultiplayerSample.ServerLauncher.exe --console-command-file=launch_server.cfg ``` -------------------------------- ### Install O3DE from a Local Snap Package Source: https://github.com/o3de/o3de.org/blob/development/content/docs/welcome-guide/setup/installing-linux.md Install O3DE using a downloaded Snap package file. Ensure you replace `.snap` with the actual filename of the downloaded package. ```shell snap install --classic --dangerous .snap ``` -------------------------------- ### Join a GameLift Session from Search Results Source: https://github.com/o3de/o3de.org/blob/development/content/docs/user-guide/gems/reference/aws/aws-gamelift/advanced-topics.md This Script Canvas example demonstrates how to join the first available game session from search results. It automatically starts after a successful session search and requires setting up the AWSGameLiftJoinSessionRequest. ```Script Canvas // This is a conceptual representation of Script Canvas nodes. // Actual implementation involves connecting nodes in the editor. // 1. Set up notification for search completion // Node: AWSGameLiftSessionAsyncRequestNotificationBus // Event: OnSearchSessionsAsyncComplete(SearchSessionsResponse) // 2. Get SessionConfigs array from response // Node: SessionConfigs(SearchSessionsResponse) // 3. Get the first SessionConfig // Node: Get First Element(SessionConfigs_Output) // 4. Set SessionId for join request // Node: SessionId(SessionConfig_Output) // 5. Create AWSGameLiftJoinSessionRequest variable // Variable: joinrequest (AWSGameLiftJoinSessionRequest) // 6. Set SessionId for join request // Node: SessionId(joinrequest, SessionId_Output_from_SessionConfig) // 7. Create Player ID // Node: CreatePlayerId() // 8. Set PlayerId for join request // Node: PlayerId(joinrequest, CreatePlayerId_Output) // 9. Join the session asynchronously // Node: JoinSessionAsync(joinrequest) ``` -------------------------------- ### Create a Basic Tree View with Branch Lines Source: https://github.com/o3de/o3de.org/blob/development/content/docs/tools-ui/component-library/uidev-tree-view-component.md Demonstrates how to create a QTreeView, set a custom model, and enable branch lines for a more visual hierarchy. Ensure you have a valid QAbstractItemModel implementation for MyModel. ```cpp #include #include // Create the tree view. auto treeView = new QTreeView(parent); // Set the model on the tree. treeView->setModel(new MyModel); // Set a BranchDelegate to support branch lines in your tree view. treeView->setItemDelegate(new AzQtComponents::BranchDelegate()); // Show the connecting branch lines. AzQtComponents::TreeView::setBranchLinesEnabled(treeView, true); ``` -------------------------------- ### C++ Example: Getting a Sound's Duration Source: https://github.com/o3de/o3de.org/blob/development/content/docs/user-guide/interactivity/audio/advanced-topics/sound-duration-runtime.md This C++ snippet demonstrates how to connect to the AudioTriggerNotificationBus and execute a trigger to receive sound duration information. It shows two methods: using the raw Audio Request and using an AudioProxy. ```cpp class MyClass : protected AudioTriggerNotificationBus::Handler { public: MyClass() { TAudioControlID triggerId = ...; AudioTriggerNotificationBus::Handler::BusConnect(TriggerNotificationIdType{ this }); // execute the m_triggerId ... if (auto audioSystem = AZ::Interface::Get(); audioSystem != nullptr) { // Example 1: via raw Audio Request Audio::ObjectRequest::ExecuteTrigger execTrigger; execTrigger.m_triggerId = triggerId; execTrigger.m_owner = this; audioSystem->PushRequest(AZStd::move(execTrigger)); // Example 2: via AudioProxy IAudioProxy* proxy = audioSystem->GetAudioProxy(); if (proxy) { // The second parameter is the "owner" override, which matches // what Id is connected to on the notification bus. proxy->Initialize("Example Sound", this); proxy->ExecuteTrigger(triggerId); proxy->Release(); } } } ~MyClass() { AudioTriggerNotificationBus::Handler::BusDisconnect(); } protected: void ReportDurationInfo( TAudioControlID triggerId, TAudioEventID eventId, float duration, float estimatedDuration) override { // ... } }; ``` -------------------------------- ### Create Component Example (Linux) Source: https://github.com/o3de/o3de.org/blob/development/content/docs/user-guide/programming/components/create-component.md Example of creating a component named 'MyTestComponent' in the 'MyGem' namespace on Linux. The template automatically appends 'Component' to the provided name. ```bash scripts/o3de.sh create-from-template -dp MyCode -dn MyTest -tn DefaultComponent -kr -r ${GemName} MyGem ``` -------------------------------- ### Shader Resource Group Register Allocation (With Spaces) Source: https://github.com/o3de/o3de.org/blob/development/content/docs/atom-guide/dev-guide/shaders/azsl/srg-semantics.md HLSL code demonstrating register allocation when using register spaces per SRG, influenced by FrequencyId. Each SRG gets its own space, with registers starting from 0 within each space. ```cpp /* Generated code from ShaderResourceGroup ObjectSrg */ Texture2D ObjectSrg_m_texture : register(t0, space1); RWTexture2D ObjectSrg_m_rwtexture : register(u1, space1); SamplerState ObjectSrg_m_sampler : register(s2, space1); struct ObjectSrg_SRGConstantsStruct { int ObjectSrg_m_objectCounter; }; ConstantBuffer<::ObjectSrg_SRGConstantsStruct> ObjectSrg_SRGConstantBuffer : register(b3, space1); /* Generated code from ShaderResourceGroup DrawSrg */ Texture2D DrawSrg_m_texture : register(t0, space0); RWTexture2D DrawSrg_m_rwtexture : register(u1, space0); SamplerState DrawSrg_m_sampler : register(s2, space0); struct DrawSrg_SRGConstantsStruct { int DrawSrg_m_drawCounter; }; ConstantBuffer<::DrawSrg_SRGConstantsStruct> DrawSrg_SRGConstantBuffer : register(b3, space0); ``` -------------------------------- ### Install O3DE from Specific Snap Channels Source: https://github.com/o3de/o3de.org/blob/development/content/docs/welcome-guide/setup/installing-linux.md Install O3DE from development or beta channels by specifying the channel name. Replace `` with the desired channel (e.g., `beta`, `edge`). ```shell snap install --classic -- o3de ``` -------------------------------- ### Implement Data Overlay Provider Example Source: https://github.com/o3de/o3de.org/blob/development/content/docs/user-guide/programming/components/reflection/serialization-context/_index.md Implement a data overlay provider by inheriting from DataOverlayProviderBus::Handler. This example shows how to fill overlay data based on tokens representing different data fields. ```cpp class DataOverlayProviderExample : public DataOverlayProviderBus::Handler { public: static DataOverlayProviderId GetProviderId() { return AZ_CRC("DataOverlayProviderExample", 0x60dafdbd); } static u32 GetIntToken() { return AZ_CRC("int_data", 0xd74868f3); } static u32 GetVectorToken() { return AZ_CRC("vector_data", 0x0aca20c0); } static u32 GetPointerToken() { return AZ_CRC("pointer_data", 0xa46a746e); } DataOverlayProviderExample() { m_ptrData.m_int = 5; m_ptrData.m_intVector.push_back(1); m_ptrData.m_ptr = nullptr; m_data.m_int = 3; m_data.m_intVector.push_back(10); m_data.m_intVector.push_back(20); m_data.m_intVector.push_back(30); m_data.m_ptr = &m_ptrData; } void FillOverlayData(DataOverlayTarget* dest, const DataOverlayToken& dataToken) override { if (*reinterpret_cast(dataToken.m_dataUri.data()) == GetIntToken()) { dest->SetData(m_data.m_int); } else if (*reinterpret_cast(dataToken.m_dataUri.data()) == GetVectorToken()) { dest->SetData(m_data.m_intVector); } else if (*reinterpret_cast(dataToken.m_dataUri.data()) == GetPointerToken()) { dest->SetData(*m_data.m_ptr); } } DataOverlayTestStruct m_data; DataOverlayTestStruct m_ptrData; }; ``` -------------------------------- ### Example of Batched, Parallel, and Shared Test Classes Source: https://github.com/o3de/o3de.org/blob/development/content/docs/user-guide/testing/parallel-pattern/_index.md Demonstrates how to define tests using `EditorBatchedTest`, `EditorParallelTest`, and `EditorSharedTest` by inheriting from these superclasses. This setup allows for running tests in batches within the same editor instance, in parallel across multiple instances, or as shared tests. ```python import pytest from ly_test_tools import LAUNCHERS from ly_test_tools.o3de.editor_test import EditorTestSuite, EditorBatchedTest, EditorParallelTest, EditorSharedTest @pytest.mark.SUITE_main @pytest.mark.parametrize("launcher_platform", ['windows_editor']) @pytest.mark.parametrize("project", ["AutomatedTesting"]) class TestAutomation(EditorTestSuite): # This test will be batched in the same editor class MyFeature_EnterGameModeWorks(EditorBatchedTest): from .tests import MyFeature_EnterGameModeWorks as test_module # This test will be batched along with the previous one in the same editor class MyFeature_DeletionWorks(EditorBatchedTest): from .tests import MyFeature_DeletionWorks as test_module # The following two tests will be run in individual editor instances at the same time. class MyFeature_ParallelTest1(EditorParallelTest): from .tests import MyFeature_ParallelTest1 as test_module class MyFeature_ParallelTest2(EditorParallelTest): from .tests import MyFeature_ParallelTest2 as test_module # This test will be launched along with other shared tests in a parallel fashion, # but may run in the same editor as other tests in any order. # MyFeature_FeatureToggleWorks(EditorSharedTest): from .tests import MyFeature_FeatureToggleWorks as test_module ``` -------------------------------- ### Create Component Example (Windows) Source: https://github.com/o3de/o3de.org/blob/development/content/docs/user-guide/programming/components/create-component.md Example of creating a component named 'MyTestComponent' in the 'MyGem' namespace on Windows. The template automatically appends 'Component' to the provided name. ```cmd scripts\o3de.bat create-from-template -dp MyCode -dn MyTest -tn DefaultComponent -kr -r ${GemName} MyGem ```