Skip to content

Commit 5a2ffa8

Browse files
committed
- add example of accessAndModifyComponents of selected actor[s]
1 parent 34c629c commit 5a2ffa8

File tree

2 files changed

+71
-0
lines changed

2 files changed

+71
-0
lines changed
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# _
2+
# (_)
3+
# _ __ ___ __ _ _ __ ___ ___ _ __ _ ___ _ __ ___
4+
# | '_ ` _ \ / _` | '_ ` _ \ / _ \| '_ \| |/ _ \ '_ ` _ \
5+
# | | | | | | (_| | | | | | | (_) | | | | | __/ | | | | |
6+
# |_| |_| |_|\__,_|_| |_| |_|\___/|_| |_|_|\___|_| |_| |_|
7+
# www.mamoniem.com
8+
# www.ue4u.xyz
9+
#Copyright 2021 Muhammad A.Moniem (@_mamoniem). All Rights Reserved.
10+
#
11+
12+
#notice that this version affects only components that are (not) inherited. This is possibly due to unreal bug!
13+
#inherited components usually have a blue icon, where none-inherited have gray icon
14+
15+
import unreal
16+
17+
@unreal.uclass()
18+
class MyEditorUtility(unreal.GlobalEditorUtilityBase):
19+
pass
20+
21+
selectedActors = MyEditorUtility().get_selection_set()
22+
23+
for actor in selectedActors:
24+
unreal.log(actor.get_name())
25+
unreal.log("*************************************************")
26+
27+
SMCompts = actor.root_component.get_children_components(True)
28+
comptsCount = len(SMCompts)
29+
print("Found [%d] components attached to the root"%(comptsCount))
30+
for SMCompt in SMCompts:
31+
print ("Checking compontnt [%s] which is [%s] if StaticMeshComponent"%(SMCompt.get_name(), SMCompt.get_class().get_name()))
32+
if (SMCompt.get_class().get_name() == "StaticMeshComponent"):
33+
print(">>TRUE")
34+
SMComptT = SMCompt.relative_location
35+
print(SMComptT)
36+
SMCompt.set_relative_location(unreal.Vector(0.0, 0.0, 0.0), False, True)
37+
print(SMComptT)
38+
else:
39+
print(">>FALSE")
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# _
2+
# (_)
3+
# _ __ ___ __ _ _ __ ___ ___ _ __ _ ___ _ __ ___
4+
# | '_ ` _ \ / _` | '_ ` _ \ / _ \| '_ \| |/ _ \ '_ ` _ \
5+
# | | | | | | (_| | | | | | | (_) | | | | | __/ | | | | |
6+
# |_| |_| |_|\__,_|_| |_| |_|\___/|_| |_|_|\___|_| |_| |_|
7+
# www.mamoniem.com
8+
# www.ue4u.xyz
9+
#Copyright 2021 Muhammad A.Moniem (@_mamoniem). All Rights Reserved.
10+
#
11+
12+
#notice that this version works with both type of blueprint/actor components inherited & none-inherited.
13+
#inherited components usually have a blue icon, where none-inherited have gray icon
14+
15+
import unreal
16+
17+
@unreal.uclass()
18+
class MyEditorUtility(unreal.GlobalEditorUtilityBase):
19+
pass
20+
21+
selectedActors = MyEditorUtility().get_selection_set()
22+
23+
for actor in selectedActors:
24+
unreal.log(actor.get_name())
25+
unreal.log("****************************************************")
26+
27+
SMCompts = actor.get_components_by_class(unreal.StaticMeshComponent)
28+
for SMCompt in SMCompts:
29+
SMComptT = SMCompt.get_editor_property("relative_location")
30+
print(SMComptT)
31+
SMCompt.set_editor_property("relative_location", unreal.Vector(0.0, 0.0, 0.0))
32+
print(SMComptT)

0 commit comments

Comments
 (0)