Visual Studio Snippets
Visual Studio Snippets could be very useful, thatÔÇÖs why IÔÇÖve created a public repository with a few examples. Snippets are generated with doxygen style comments. How to add snippet ? First of a...
Visual Studio Snippets could be very useful, thatÔÇÖs why IÔÇÖve created a public repository with a few examples. Snippets are generated with doxygen style comments.
How to add snippet ?
First of all you have to clone GitHub repository. Then you have two choices:
- Method one. Paste .snippet files into: "C:\Users\\Documents\Visual Studio 2013\Code Snippets\Visual C++\My Code Snippets". Then restart VS.
- Method two. Open Visual Studio, navigate to TOOLS -> Code Snippets Manager -> Import (This allows an Add folder option for easier management)
[4.6 Branch and above] Epic seems to have started initial integration with Branch 4.6 and above. Look on GitHub under "\Engine\extras\VisualStudioSnippets" and follow the Readme file.
How to use snippets ?
Import them and just start typing ue4
After selecting snippet from the list, hit TAB.
To navigate between highlited fields you can use TAB and SHIFT + TAB. After you enter all names, hit ENTER.
Snippets
- ue4classa ÔÇô Blueprintable class that derives from an AActor. Parameters are: comment, class name and base class name.
/**
* Comment
*/
UCLASS(BlueprintType, Blueprintable)
class AFoo : public AFooBase
{
GENERATED_UCLASS_BODY()
public:
protected:
private:
};
- ue4classu ÔÇô Blueprintable class that derives from an UObject. Parameters are: comment, class name, base class name.
/**
* Comment
*/
UCLASS(BlueprintType, Blueprintable)
class UFoo : public UFooBase
{
GENERATED_UCLASS_BODY()
public:
protected:
private:
};
- ue4enum ÔÇô Simple enum. Parameters are: comment, enum name, first member name and itÔÇÖs comment.
/**
* Comment
*/
UENUM()
enum EMyEnum
{
Name, /**> Comment */
};
- ue4enumdisplay ÔÇô Enum that can be used with blueprints. Parameters are: comment, enum name, first member name, itÔÇÖs display name and comment.
/**
* Comment
*/
UENUM()
namespace EMyEnum
{
enum Type
{
Name UMETA(DisplayName = "DisplayName"), /**> Comment */
};
}
- ue4event ÔÇô This function can be used as an event in blueprint. Parameters are: comment (parameters and return value), UI category, virtual and const modifiers, return type, function name and arguments.
/**
* Comment
* @param Comment
* @return Comment
*/
UFUNCTION(BlueprintImplementableEvent, Category = "MyProject")
virtual void OnFunctionName(args) const;
- ue4func ÔÇô This function is available for blueprint logic. Parameters are: comment (parameters and return value), UI category, virtual and const modifiers, function name and arguments.
/**
* Comment
* @param Comment
* @return Comment
*/
UFUNCTION(BlueprintCallable, Category = "MyProject")
virtual void FunctionName(args) const;
- ue4interface ÔÇô Simple ue4 interface. Parmameters are: comment and name.
/**
* Comment
*/
UINTERFACE()
class UFoo : public UInterface
{
GENERATED_UINTERFACE_BODY()
};
class IFoo
{
GENERATED_IINTERFACE_BODY()
};
- ue4log ÔÇô Simplest log line. Parameters are category, verbosity and message.
UE_LOG(MyProject, Error, TEXT("Log message"));
- ue4logdeclare ÔÇô Declaration of log category. Place this in main header of your project to allow logging. Parameters are: category, default verbosity and compile time verbosity.
DECLARE_LOG_CATEGORY_EXTERN(MyProject, Log, All);
- ue4logdefine ÔÇô Definition of log category. Place this in main code file. Parameter is category name.
DEFINE_LOG_CATEGORY(MyProject);
- ue4logfloat ÔÇô Log line that can be used to print float value. Parameters are: category, verbosity and variable name.
UE_LOG(MyProject, Error, TEXT("The value of 'variable' is: %f"), variable);
- ue4logint ÔÇô This log line can be used to log an integer value. Parameters are: category, verbosity and variable name.
UE_LOG(MyProject, Error, TEXT("The value of 'variable' is: %i"), variable);
- ue4loguobj ÔÇô This log line is designed to log from inside of the objects. By default, square brackets contains a name of an object that writes the log. Parameters are: category, verbosity, message and name of a pointer to the object.
UE_LOG(MyProject, Error, TEXT("[%s] Log message"), *(this->GetName()));
- ue4prop ÔÇô This read/write property is available everywhere (blueprint, instance and archetype details). Parameters are: comment, category, type and name.
/**
* Comment
*/
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "MyProject")
Type Name;
- ue4struct ÔÇô Simple structure. Parameters are: comment and name.
/**
* Comment
*/
USTRUCT()
struct FFoo
{
GENERATED_USTRUCT_BODY()
};
- ue4mark ÔÇô This comment can be used to mark changes made to engine classes. Parameters are: Company symbol, task/ticket number, name and surname of a developer and short description of modification.
/* BEGIN ACME (ACME-938) */
// Name Surname - Comment
virtual void Tick(float DeltaTime);
/* END ACME */
Author: