KLingo Project Documentation 1.0.0
Unreal Engine 5.6 C++ Project Documentation
로딩중...
검색중...
일치하는것 없음
UListActorComponent.cpp
이 파일의 문서화 페이지로 가기
1
5// Copyright (c) 2025 Doppleddiggong. All rights reserved. Unauthorized copying, modification, or distribution of this file, via any medium is strictly prohibited. Proprietary and confidential.
6
7
9
10#if WITH_EDITOR
11#include "Editor.h"
12#include "Engine/Selection.h"
13#include "ScopedTransaction.h"
14#include "Algo/Unique.h"
15#endif
16
17#if WITH_EDITOR
19int32 UListActorComponent::GatherSelectedItem(TArray<AActor*>& Out) const
20{
21 Out.Reset();
22 if (!GEditor)
23 return 0;
24
25 TArray<AActor*> Selected;
26 GEditor->GetSelectedActors()->GetSelectedObjects<AActor>(Selected);
27
28 for (AActor* A : Selected)
29 {
30 if (!IsValid(A))
31 continue;
32
33 if (ClassFilter && !A->IsA(ClassFilter))
34 continue;
35 Out.Add(A);
36 }
37
38 // 일관성: 이름 정렬 + 중복 제거
39 Out.Sort([](const AActor& L, const AActor& R){
40 return L.GetFName().LexicalLess(R.GetFName());
41 });
42
43 Out.SetNum(Algo::Unique(Out));
44
45 return Out.Num();
46}
47
49void UListActorComponent::AssignInternal(const bool bAppend)
50{
51 TArray<AActor*> Picked;
52 const int32 Count = GatherSelectedItem(Picked);
53 if (Count <= 0)
54 return;
55
56 const FScopedTransaction Tx(NSLOCTEXT("ListActorManager", "AssignFromSelection", "Assign Items From Selection"));
57 Modify();
58
59 if (!bAppend)
60 {
61 ArrayActors.Reset();
62 }
63
64 for (AActor* A : Picked)
65 {
66 if (!IsValid(A))
67 continue;
68
69 ArrayActors.AddUnique(A);
70 }
71
72 if (UPackage* Pkg = GetOutermost())
73 {
74 Pkg->SetDirtyFlag(true);
75 }
76}
77#endif // WITH_EDITOR
78
80void UListActorComponent::AssignItemReplace()
81{
82#if WITH_EDITOR
83 AssignInternal(false);
84#endif
85}
86
88void UListActorComponent::AssignItemAppend()
89{
90#if WITH_EDITOR
91 AssignInternal(true);
92#endif
93}
94
95
97void UListActorComponent::SortByNameAsc()
98{
99#if WITH_EDITOR
100 const FScopedTransaction Tx(
101 NSLOCTEXT("ListActorManager", "SortByNameAsc", "Sort ArrayActors by Name Asc")
102 );
103 Modify();
104
105 ArrayActors.Sort([](const AActor& L, const AActor& R) {
106 return L.GetActorLabel() < R.GetActorLabel();
107 });
108
109 if (UPackage* Pkg = GetOutermost())
110 {
111 Pkg->SetDirtyFlag(true);
112 }
113#endif
114}
115
117void UListActorComponent::SortByNameDesc()
118{
119#if WITH_EDITOR
120 const FScopedTransaction Tx(
121 NSLOCTEXT("ListActorManager", "SortByNameDesc", "Sort ArrayActors by Name Desc")
122 );
123 Modify();
124
125 ArrayActors.Sort([](const AActor& L, const AActor& R) {
126 return L.GetActorLabel() > R.GetActorLabel();
127 });
128
129 if (UPackage* Pkg = GetOutermost())
130 {
131 Pkg->SetDirtyFlag(true);
132 }
133#endif
134}
UListActorComponent 클래스를 선언합니다.