일상 코딩
[Unreal Engine] Unreal Engine 5 / Visual Studio C++ 개발 환경 설정 언리얼 엔진 5 개발 환경 설정 세팅 본문
[Unreal Engine] Unreal Engine 5 / Visual Studio C++ 개발 환경 설정 언리얼 엔진 5 개발 환경 설정 세팅
polarcompass 2023. 8. 21. 01:39출처
학습 페이지
www.inflearn.com
UE 5.1 & Visual Studio 2022 installation guide | Community tutorial
Integrating Visual Studio 2022 with Unreal Engine 5.1 can trip up some beginners since previous UE 4 C++ tutorials don't use live coding . The informati...
dev.epicgames.com
버전 테이블
제품명 | 버전 |
Unreal Engine 5 | 5.1.1 |
Visual Studio | 2022 |
Epic Launcher 설치
https://store.epicgames.com/en-US/download
Visual Studio 설치
https://visualstudio.microsoft.com/downloads/
Download Visual Studio Tools - Install Free for Windows, Mac, Linux
Download Visual Studio IDE or VS Code for free. Try out Visual Studio Professional or Enterprise editions on Windows, Mac.
visualstudio.microsoft.com
Thank you for downloading Visual Studio - Visual Studio
Visual Studio is a powerful IDE for Python language through its built-in Python Development and Data Science workloads. Python is a popular, easy to learn, free to use programming language with many free libraries. In Visual Studio, use Python to build
visualstudio.microsoft.com
무조건 언어는 영어로 한다.
Unreal Editor 환경 설정
Visual Studio 환경 설정
Visual Studio 재시작 한다.
Visual Studio 추가 개발 환경 설정
https://vlasovstudio.com/visual-commander/
Visual Commander - Modern alternative to Visual Studio macros
Visual Commander The freemium Visual Commander extension lets you automate repetitive tasks in Visual Studio 2022/2019/2017 and SSMS 17/2016. You can reuse existing Visual Studio macros from previous versions of the IDE and create new commands and extensio
vlasovstudio.com
https://vlasovstudio.com/visual-commander/VisualCommander_333.vsix
Visual Studio Theme Pack
VSCode에 쓰이는 'Dark+'테마 적용
https://marketplace.visualstudio.com/items?itemName=idex.vsthemepack
https://github.com/hackalyze/ue4-vs-extensions
GitHub - hackalyze/ue4-vs-extensions: Useful UE4 Visual Studio extensions.
Useful UE4 Visual Studio extensions. Contribute to hackalyze/ue4-vs-extensions development by creating an account on GitHub.
github.com
";" 세미콜론 입력시 변수가 지워지는 문제가 있어서 "AfterKeyPress" 함수 부분을 수정했다.
using EnvDTE;
using EnvDTE80;
using Microsoft.VisualStudio;
using System;
using System.Text.RegularExpressions;
using System.Windows.Forms;
public class E : VisualCommanderExt.IExtension
{
private EnvDTE80.DTE2 _DTE;
private EnvDTE80.TextDocumentKeyPressEvents _textDocumentKeyPressEvents;
private static readonly string MACRO_REGEX = @"^(?<leading_whitespace>[\s]*)(UPROPERTY|UFUNCTION|GENERATED_(USTRUCT_|UCLASS_|(U|I)INTERFACE_)?BODY)\(.*";
private static readonly string TEXT_WITH_WS_REGEX = @"(?<leading_whitespace>[\s]*)\S+";
private CommandEvents _pasteEvent;
private string _beforeText;
private int _numSelectedLines;
public void SetSite(DTE2 DTE, Microsoft.VisualStudio.Shell.Package package) {
_DTE = DTE;
EnvDTE80.Events2 events2 = (EnvDTE80.Events2)DTE.Events;
_textDocumentKeyPressEvents = events2.get_TextDocumentKeyPressEvents(null);
_textDocumentKeyPressEvents.AfterKeyPress += AfterKeyPress;
var pasteGuid = typeof(VSConstants.VSStd97CmdID).GUID.ToString("B");
var pasteID = (int)VSConstants.VSStd97CmdID.Paste;
_pasteEvent = _DTE.Events.CommandEvents[pasteGuid, pasteID];
_pasteEvent.BeforeExecute += BeforePaste;
_pasteEvent.AfterExecute += AfterPaste;
}
public void Close() {
_textDocumentKeyPressEvents.AfterKeyPress -= AfterKeyPress;
_pasteEvent.AfterExecute -= AfterPaste;
_pasteEvent.BeforeExecute -= BeforePaste;
}
private string GetActiveDocumentText() {
TextDocument doc = (TextDocument)(_DTE.ActiveDocument.Object("TextDocument"));
var editPoint = doc.StartPoint.CreateEditPoint();
return editPoint.GetText(doc.EndPoint);
}
private void BeforePaste(string Guid, int ID, Object CustomIn, Object CustomOut, ref bool CancelDefault) {
_beforeText = GetActiveDocumentText();
TextSelection sel = (TextSelection)_DTE.ActiveDocument.Selection;
_numSelectedLines = sel.Text.Split(new string[] { Environment.NewLine }, StringSplitOptions.None).Length;
}
private void AfterPaste(string Guid, int ID, Object CustomIn, Object CustomOut) {
string afterText = GetActiveDocumentText();
string[] beforeLines = _beforeText.Split(new string[] { Environment.NewLine }, StringSplitOptions.None);
string[] afterLines = afterText.Split(new string[] { Environment.NewLine }, StringSplitOptions.None);
int pasteLength = (afterLines.Length - beforeLines.Length) + _numSelectedLines;
TextSelection sel = (TextSelection)_DTE.ActiveDocument.Selection;
var editPoint = sel.ActivePoint.CreateEditPoint();
bool underMacro = false;
string lastWhiteSpace = "";
bool openedUndoContext = false;
int startPasteLine = sel.ActivePoint.Line - pasteLength;
int macroLineNum = startPasteLine + 1;
// Search up the document from the start of our paste until we find a line with text on it
// so we can then determine if this line contains a macro we care about
while (--macroLineNum >= 1) {
string macroLine = editPoint.GetLines(macroLineNum, macroLineNum + 1);
if (!Regex.IsMatch(macroLine, @"\S+")) {
continue;
}
var macroMatch = Regex.Match(macroLine, MACRO_REGEX);
if (macroMatch.Success) {
underMacro = true;
lastWhiteSpace = macroMatch.Groups["leading_whitespace"].ToString();
}
break;
}
if (!_DTE.UndoContext.IsOpen) {
openedUndoContext = true;
// Open the UndoContext so all of our changes can be undone with a single undo
_DTE.UndoContext.Open("FixUE4MacroIndents", false);
}
try {
for (int onLine = startPasteLine; onLine < afterLines.Length; onLine++) {
var line = afterLines[onLine];
// We only need to potentially fix the newly pasted lines
if (onLine >= startPasteLine + pasteLength) {
sel.GotoLine(onLine, false);
sel.MoveToPoint(editPoint);
break;
}
if (underMacro) {
var varMatch = Regex.Match(line, TEXT_WITH_WS_REGEX);
if (varMatch.Success && varMatch.Groups["leading_whitespace"].ToString() != lastWhiteSpace) {
sel.GotoLine(onLine + 1, false);
sel.DeleteWhitespace(EnvDTE.vsWhitespaceOptions.vsWhitespaceOptionsHorizontal);
sel.Insert(lastWhiteSpace);
underMacro = false;
// This line has been modified, so change it for the MACRO_REGEX matching below
line = lastWhiteSpace + line.Trim();
}
}
// Its important to check if the current line is a macro
// even if we just fixed the spacing of the current line
var macroMatch = Regex.Match(line, MACRO_REGEX);
if (macroMatch.Success) {
underMacro = true;
lastWhiteSpace = macroMatch.Groups["leading_whitespace"].ToString();
} else if (Regex.Match(line, @"\S+").Success) {
underMacro = false;
}
}
} finally {
if (openedUndoContext) {
_DTE.UndoContext.Close();
}
}
}
private void AfterKeyPress(string key, TextSelection sel, bool completion) {
// Only semicolons or carriage returns should cause an indentation that need to be fixed
if (key != ";" && key != "\r") {
return;
}
// Make sure we're using smart indent
EnvDTE.Properties textEditorC = _DTE.get_Properties("TextEditor", "C/C++");
if ((int)textEditorC.Item("IndentStyle").Value != 2) {
return;
}
if (key == ";") {
// Make sure we're auto-formatting on semicolons
//EnvDTE.Properties textEditorCSpecific = _DTE.get_Properties("TextEditor", "C/C++ Specific");
//if (!(bool)textEditorCSpecific.Item("AutoFormatOnSemicolon").Value) {
// return;
//}
return;
}
var doc = _DTE.ActiveDocument;
var editPoint = sel.ActivePoint.CreateEditPoint();
string macroLine = null;
var macroLineNum = sel.ActivePoint.Line;
// Search up the document from our current line until we find a line with text on it
// so we can then determine if this line contains a macro we care about
var found = false;
while (--macroLineNum >= 1) {
macroLine = editPoint.GetLines(macroLineNum, macroLineNum + 1);
if (!Regex.IsMatch(macroLine, @"\S+")) {
continue;
}
found = true;
break;
}
if (!found) {
return;
}
var macroMatch = Regex.Match(macroLine, MACRO_REGEX);
if (macroMatch.Success) {
// Goto and select our current line, can't do this in a single GotoLine call for some reason
sel.GotoLine(sel.ActivePoint.Line, false);
// sel.SelectLine();
if (Regex.IsMatch(sel.Text, @"\S+")) {
// If the line below the macro has text, undo the indent it just did
// doc.Undo();
} else {
// If the line below the macro is empty, add matching whitespace to the beginning of this line to match it up with the macro
sel.MoveToPoint(editPoint);
sel.DeleteWhitespace(EnvDTE.vsWhitespaceOptions.vsWhitespaceOptionsHorizontal);
sel.Insert(macroMatch.Groups["leading_whitespace"].ToString());
}
}
}
}
Visual Studio C++ 코드 Refactoring 기능 켜기
Windows 언어 utf-8 적용
1. 코드에 한글이 들어갈 경우 compile / build 시에 에러가 날 수 있기에
.h / .cpp 파일 저장시 encoding을 utf-8로 적용해야 한다.
또는
2. 시스템 언어 encoding을 utf-8로 변경하고 재시작 한다.
경로
시간 및 언어 -> 언어 및 지역 -> 기본 언어 설정 -국가 또는 지역 -> 유니코드를 지원하지 않는 프로그램용 언어