[Visual Assist Extension] Has anyone in the community (or Epic) written any VA snippets? Paste em!

You can define a ‘VA snippet’ in Visual Assist (VAX) for Visual Studio, and use them like refactoring macros, I suppose you could say. I’m just curious if anyone here or at Epic has written any that they found useful - for quick refactoring without destroying UE macros, use with Slate, etc.

Let’s see what we’ve got :slight_smile:

Great idea! I would like to see them also ; )

Heres a couple of my own:

Basic stuff for UObject and AActor class creation:


#pragma once

#include "$FILE_BASE$.generated.h"

UCLASS()
class U$FILE_BASE$ : public UObject
{
	GENERATED_BODY()
};


#pragma once

#include "$FILE_BASE$.generated.h"

UCLASS()
class A$FILE_BASE$ : public AActor
{
	GENERATED_BODY()
};

Slate:

Widget from file



#pragma once

#include "SlateBasics.h"

class $FILE_BASE$ : public SCompoundWidget
{
public:
	SLATE_BEGIN_ARGS($FILE_BASE$)
	{}
	SLATE_END_ARGS()
	
	void Construct(const FArguments& InArgs)
	{
		$end$
	}
};

New widget


class $Class_name$ : public SCompoundWidget
{
public:
	SLATE_BEGIN_ARGS($Class_name$)
	{}
	SLATE_END_ARGS()
	
	void Construct(const FArguments& InArgs)
	{
		$end$
	}
};

SlateCheckBox


(SCheckBox)
.IsFocusable(false)
.IsChecked(this, &$ClassName$::Get$Var_name$CheckState)
.OnCheckStateChanged(this, &$ClassName$::On$Var_name$CheckStateChanged)

ECheckBoxState Get$Var_name$CheckState() const
{ 
	return b$Var_name$ ? ECheckBoxState::Checked : ECheckBoxState::Unchecked; 
}

void On$Var_name$CheckStateChanged(ECheckBoxState InType)
{
	b$Var_name$ = InType == ECheckBoxState::Checked;
}$end$

FReply


FReply $Event_name$()
{
	$end$
	return FReply::Handled();
}

STreeView (can be easily modified for List/tile View widgets)


SAssignNew(TreeView, STreeView<$Item_Class_Name$>)
.OnSelectionChanged(this, &$ClassName$::OnTreeSelectionChanged)
.OnGenerateRow(this, &$ClassName$::GenerateTreeRow)
.TreeItemsSource(&ListSource)
.OnGetChildren(this, &$ClassName$::OnGetChildrenForTree)

/** OnSelection changed. */
void OnTreeSelectionChanged($Item_Class_Name$ InItem, ESelectInfo::Type SelectInfo);

/** Generate list(tree) row. */
TSharedRef<ITableRow> GenerateTreeRow($Item_Class_Name$ InItem, const TSharedRef<STableViewBase>& OwnerTable);

/** Given a data item populate the OutChildren array with the item's children. */
void OnGetChildrenForTree($Item_Class_Name$ InItem, TArray< $Item_Class_Name$ >& OutChildren);

/** TreeView widget */
TSharedPtr<STreeView<$Item_Class_Name$>> TreeView;

/** Items list displayed by widget. */
TArray<$Item_Class_Name$> ListSource;

I also have some really basic stuff like Horizontal, Vertical boxes, borders etc that looks like that:


(SVerticalBox)
+SVerticalBox::Slot()

	$end$
]

And last but not least, I’ve edited “Document Method” snippet to match Epic’s format. (In VA Snippet editor from ‘Type’ dropdown choose refactoring and “Document Method” and paste this code)



/**
 * $end$
 * @param $MethodArgName$
 * @return $SymbolType$
*/

Cheers!

1 Like

@szyszek: Sorry I never got back to you about these! They’re awesome, thanks!