article

AndresGenvid avatar image
AndresGenvid posted

01. Unreal C++ Class Setup Guide   

Unreal Class Setup Guide

This guide was written as a quick reference step by step guide for the first setup of genvid classes. For class descriptions or more in depth information on each step please check the documentation at https://www.genvidtech.com/

C++ Class Creation

  1. In the Unreal Project - go to create a new C++ class.

  2. Search for “Genvid” in all classes. Note the following Genvid classes: GenvidSessionManager, GenvidSession, GenvidVideo, GenvidAudio, GenvidStreams, GenvidEvents, and GenvidCommands.

    • Open GenvidVideo and set the stream name to be “Video”

    • Open GenvidAudio and set the stream name to be “Audio. Set the Audio Format to be S16LE

  3. Create a C++ class for each one.

  4. Create a C++ class for your PlayerController and GameMode


Blueprint Class Creation and Setup

  1. Create a blueprint for each C++ class created above

  2. Open your blueprint GenvidSessionManager. Set your blueprint GenvidSession in the property “Session Class”

  3. Open your GenvidSession blueprint. Set your blueprint GenvidAudio and GenvidVideo in the properties “Audio Stream Class” and “Video Stream Class”.

  4. Open your PlayerController blueprint. Add the blueprint GenvidEvents, GenvidStreams, and GenvidCommands as components

  5. Open your GameMode blueprint. Set your PlayerController as the default player controller class property

  6. Open project settings - set your new game mode as the default


Example GenvidSession Blueprint


Example PlayerController component list


GenvidSessionManager Instance Creation

  1. The GenvidSessionManager needs to persist at all times. One way to make sure this is the case is to have the GameInstance manage it.

  2. Create a GameInstance C++ class. Create a blueprint for that class.

  3. Set the blueprint as the default game instance class in project settings.

  4. Open the GameInstance C++ header class and add the following functions and properties:

    • Override the Init() function.

    • Override the Shutdown() function.

    • Create a TSubclassOf<{your genvid session manager class}> property named “GenvidSessionManagerClass”

      • Add a UPROPERTY tag to it to allow editing of the default value in editor

      • BlueprintReadOnly and EditDefaultsOnly is enough for our purposes

    • Create a pointer to {your genvid session manager class} property named “GenvidSessionManager”

      • Add a UPROPERTY tag to it

  5. Open the GameInstance C++ cpp class

    • In the Init Function add the following code:=

  6. Super::Init();
    GenvidSessionManager = Cast<UMyGenvidSessionManager>(UMyGenvidSessionManager::CreateSessionManager(this, GenvidSesssionManagerClass));
    GenvidSessionManager->Initialize();
    • We create the session manager, cast and set it, then initialize it

    • GetVersion is a function can that can be used to confirm it is up and running and the correct version

    • GenvidSessionManager and GenvidSessionManagerClass refer to the properties created above

    • UMyGenvidSessionManager refers to your Genvid Session Manger C++ class

    • In the Shutdown function add the following code:

  7. GenvidSessionManager->Terminate();
    Super::Shutdown();
    • We terminate the session

    • In your game instance blueprint set the GenvidSessionManagerClass property to your session manager blueprint



unreal engineunreal
10 |600

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

Article

Contributors

AndresGenvid contributed to this article