Skip to content

Commit c686eb1

Browse files
author
David
committed
Added new versions of some examples to work in 4.25.
May NOT be a complete set of changes required as just tested these examples.
1 parent 1ce237e commit c686eb1

File tree

3 files changed

+126
-0
lines changed

3 files changed

+126
-0
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import unreal_engine as ue
2+
from unreal_engine.classes import Blueprint, K2Node_DynamicCast, Actor, Object
3+
from unreal_engine.structs import EdGraphPinType
4+
from unreal_engine.enums import EEdGraphPinDirection
5+
6+
bp_foo = ue.load_object(Blueprint, '/Game/Foo.Foo')
7+
bp_bar = ue.load_object(Blueprint, '/Game/Bar.Bar')
8+
9+
graph = ue.blueprint_add_function(bp_foo, 'FooCaster')
10+
func = graph.Nodes[0]
11+
12+
cast_node = K2Node_DynamicCast(Outer=graph)
13+
cast_node.TargetType = bp_bar.GeneratedClass
14+
15+
pin_type = EdGraphPinType(PinCategory = 'object', PinSubCategoryObject=Actor)
16+
pin = func.node_create_pin(EEdGraphPinDirection.EGPD_Input, pin_type, 'Arg001')
17+
18+
19+
graph.graph_add_node(cast_node, 600, 0)
20+
21+
cast_node.node_find_pin('Object').category = 'object'
22+
cast_node.node_find_pin('Object').sub_category = Object
23+
24+
pin.make_link_to(cast_node.node_find_pin('Object'))
25+
func.node_find_pin('then').make_link_to(cast_node.node_find_pin('execute'))
26+
27+
ue.compile_blueprint(bp_foo)

examples/custom_settings_425.py

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
import unreal_engine as ue
2+
3+
from unreal_engine.classes import Object
4+
#from unreal_engine.classes import StrProperty, IntProperty
5+
from unreal_engine.properties import StrProperty, IntProperty
6+
from unreal_engine import CLASS_CONFIG, CLASS_DEFAULT_CONFIG, CPF_CONFIG
7+
8+
def config(arg):
9+
config_name = None
10+
def wrapper(u_class):
11+
cflags = u_class.class_get_flags()
12+
u_class.class_set_flags(cflags|CLASS_CONFIG)
13+
if config_name:
14+
u_class.class_set_config_name(config_name)
15+
return u_class
16+
if isinstance(arg, str):
17+
config_name = arg
18+
return wrapper
19+
return wrapper(arg)
20+
21+
def default_config(u_class):
22+
cflags = u_class.class_get_flags()
23+
u_class.class_set_flags(cflags|CLASS_DEFAULT_CONFIG)
24+
return u_class
25+
26+
@config('DumbConfig')
27+
@default_config
28+
class FooSettings(Object):
29+
30+
HelloWorld = StrProperty
31+
32+
FooWorld = [IntProperty]
33+
34+
def __init__(self):
35+
self.add_property_flags('HelloWorld', CPF_CONFIG)
36+
self.get_fproperty('HelloWorld').set_metadata('Category', 'CategoryTest001')
37+
self.HelloWorld = 'Hello World 001'
38+
39+
self.add_property_flags('FooWorld', CPF_CONFIG)
40+
self.get_fproperty('FooWorld').set_metadata('Category', 'CategoryTest002')
41+
self.FooWorld = [17, 22, 30]
42+
43+
44+
ue.register_settings('Project', 'FooBar', 'General', 'General DisplayName', 'General Description', ue.get_mutable_default(FooSettings))

examples/graphs_creator_425.py

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
import unreal_engine as ue
2+
from unreal_engine.classes import K2Node_InputKey, K2Node_SpawnActorFromClass, Actor, Character, KismetMathLibrary
3+
from unreal_engine.structs import Key
4+
5+
# create a new blueprint
6+
new_blueprint = ue.create_blueprint(Actor, '/Game/StrangeBlueprint')
7+
8+
# add a member float variable
9+
ue.blueprint_add_member_variable(new_blueprint, 'Speed', 'float')
10+
11+
# get a reference to the first graph page
12+
uber_page = new_blueprint.UberGraphPages[0]
13+
14+
# get good coordinates for a new node
15+
x, y = uber_page.graph_get_good_place_for_new_node()
16+
# add the Speed variable to the graph
17+
uber_page.graph_add_node_variable_get('Speed', None, x, y)
18+
19+
x, y = uber_page.graph_get_good_place_for_new_node()
20+
# add a custom event to the graph
21+
hello_world = uber_page.graph_add_node_custom_event('Hello World', x, y)
22+
23+
# get a reference to the 'then' pin
24+
hello_world_then = hello_world.node_find_pin('then')
25+
26+
x, y = uber_page.graph_get_good_place_for_new_node()
27+
# add a 'Spawn Actor From Class' node
28+
spawn_actor_node = uber_page.graph_add_node(K2Node_SpawnActorFromClass, x, y)
29+
30+
# set its Class pin
31+
pin_class = spawn_actor_node.node_find_pin('Class')
32+
pin_class.default_object = Character
33+
34+
# get a reference to its 'exec' pin
35+
spawn_actor_node_exec = spawn_actor_node.node_find_pin('execute')
36+
37+
# link the hello world event to the spawn actor node
38+
hello_world_then.make_link_to(spawn_actor_node_exec)
39+
40+
x, y = uber_page.graph_get_good_place_for_new_node()
41+
# create a 'make transform' node
42+
make_transform = uber_page.graph_add_node_call_function(KismetMathLibrary.MakeTransform, x, y)
43+
44+
# link the return value of 'make transform' to the 'SpawnTransform' pin of the spawn actor node
45+
make_transform.node_find_pin('ReturnValue').make_link_to(spawn_actor_node.node_find_pin('SpawnTransform'))
46+
47+
input_key = K2Node_InputKey(Outer=uber_page)
48+
input_key.InputKey = Key(KeyName='SpaceBar')
49+
input_key_node = uber_page.graph_add_node(input_key, 400, 400)
50+
51+
# compile the blueprint
52+
ue.compile_blueprint(new_blueprint)
53+
54+
# save it
55+
ue.editor_save_all()

0 commit comments

Comments
 (0)