Notice
Recent Posts
250x250
«   2025/03   »
1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31
관리 메뉴

일상 코딩

[Unreal Engine] Unreal Engine 5 / Visual Studio C++ 개발 환경 설정 언리얼 엔진 5 개발 환경 설정 세팅 본문

Unreal Engine/C++ 환경설정

[Unreal Engine] Unreal Engine 5 / Visual Studio C++ 개발 환경 설정 언리얼 엔진 5 개발 환경 설정 세팅

polarcompass 2023. 8. 21. 01:39
728x90
출처

https://www.inflearn.com/course/lecture?courseSlug=%EC%9D%B4%EB%93%9D%EC%9A%B0-%EC%96%B8%EB%A6%AC%EC%96%BC-%ED%94%84%EB%A1%9C%EA%B7%B8%EB%9E%98%EB%B0%8D-part-1&unitId=152769&tab=curriculum

 

학습 페이지

 

www.inflearn.com

https://dev.epicgames.com/community/learning/tutorials/XjvJ/unreal-engine-ue-5-1-visual-studio-2022-installation-guide

 

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

5.1.1 버전
디버깅 편집기호 체크

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

'Community' 다운로드

https://visualstudio.microsoft.com/thank-you-downloading-visual-studio/?sku=Community&channel=Release&version=VS2022&source=VSLandingPage&cid=2030&workload=dotnet-dotnetwebcloud&passive=false#dotnet

 

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 환경 설정

Edit  -> Editor Preference
"Region & Language" -> English 선택
설치를 진행한 정확한 visual studio 버전을 지정해준다.
'Live Coding' 활성화
Plugins 설정
'Visual Studio Integration Tool' 활성화

Visual Studio 환경 설정

영어로 설정

Visual Studio 재시작 한다.

언리얼 에디터로 Visual Studio 재시작
"Development Editor" 부분 길이 늘리기
"Development Editor" 부분 길이 늘리기

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

VisualCommander_333.vsix
0.68MB

 

Visual Studio Theme Pack
VSCode에 쓰이는 'Dark+'테마 적용

https://marketplace.visualstudio.com/items?itemName=idex.vsthemepack

VisualStudioThemePack.vsix
0.17MB

 

VCmd 버튼 생성됨

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

Visual Studio 2019 이상은 다 저 파일을 지정해준다.
import로 위의 파일을 지정한다.
Extensions로 매크로 지정
매크로 지정

";" 세미콜론 입력시 변수가 지워지는 문제가 있어서 "AfterKeyPress" 함수 부분을 수정했다.

아래 코드 블럭 코드를 복사 후 'Code:' 안에 복붙 해준다.

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 기능 켜기

Alt+Enter 구현부 작성시 Peek Document 기능 켰을 때

Windows 언어 utf-8 적용
1. 코드에 한글이 들어갈 경우 compile / build 시에 에러가 날 수 있기에
.h / .cpp 파일 저장시 encoding을 utf-8로 적용해야 한다.
또는
2. 시스템 언어 encoding을 utf-8로 변경하고 재시작 한다.
경로
시간 및 언어
-> 언어 및 지역 -> 기본 언어 설정 -국가 또는 지역 -> 유니코드를 지원하지 않는 프로그램용 언어

 

728x90