Commit Graph

256 Commits

Author SHA1 Message Date
Jamie Dale
7dab7f26af Ensure start-up scripts run when using Python in commandlet mode
#rb none

[CL 10796194 by Jamie Dale in Main branch]
2019-12-18 10:36:58 -05:00
Jamie Dale
964231997f Defer the OnPythonInitialized notification until after start-up scripts have run
This delegate was previously useless as it would run when the PythonScriptPlugin module was loaded, which meant that no-one could bind to it

#rb none

[CL 10795922 by Jamie Dale in Main branch]
2019-12-18 10:30:26 -05:00
Jamie Dale
93b10e9d9c Python FProperty fixes
- Fixed Python container wrappers leaking transient property instances.
   - PyUtil::TPropOnScope will manage an optionally owned property instance, deleting it if required when it goes out-of-scope.
 - Fixed Python container wrappers crashing during GC due to calling FReferenceCollector::AddReferencedObjects passing a FProperty-based type.
 - Fixed Python delegate wrappers crashing when called with arguments due to checking Children rather than ChildProperties.

#rb Robert.Manuszewski
#rnx

[CL 10791312 by Jamie Dale in Main branch]
2019-12-18 08:41:22 -05:00
Robert Manuszewski
7b6f840f7f Copying //UE4/Dev-Core @ 10708550 to Dev-Main (//UE4/Dev-Main)
#rb none

[CL 10708666 by Robert Manuszewski in Main branch]
2019-12-13 11:07:03 -05:00
Jamie Dale
c59d31c72d Emit RuntimeError in Python for Blueprint execution errors
This previously used the generic Exception type

#fyi Andrew.Rodham
#rb none

[CL 10497227 by Jamie Dale in Dev-Editor branch]
2019-12-03 11:48:43 -05:00
Jamie Dale
daa908ed5a Fix CIS static analysis warning (unreachable code)
#rb none
#rnx

[CL 10479149 by Jamie Dale in Dev-Editor branch]
2019-11-28 17:16:47 -05:00
Jamie Dale
6ed3c75acf Improved Python error reporting for invalid ScriptName and ScriptMethod values
Bad values here can cause the unreal.py file to fail to parse, so we now validate that user-defined values are valid for Python when generating the glue and report an error for any that are invalid.

This also re-adds the type prefixes to any class, struct, or enum types that would start with a number without their prefix. Once again, this is needed to avoid invalid symbol names in the unreal.py file.

#jira UE-85176
#rb none

[CL 10479002 by Jamie Dale in Dev-Editor branch]
2019-11-28 15:42:26 -05:00
Jamie Dale
6676737341 Fixed some issues that caused the unreal.py stub file to have syntax errors
We require this file to be error free in order to generate the Python API docs

#jira UE-85176
#rb Conan.Reis
#rnx

[CL 10478756 by Jamie Dale in Dev-Editor branch]
2019-11-28 12:09:25 -05:00
jamie dale
26c86de3f2 Fixed some issues that caused the unreal.py stub file to have syntax errors
We require this file to be error free in order to generate the Python API docs

#jira UE-85176
[FYI] Robb.Surridge
#rb Conan.Reis
#lockdown Cristina.Riveron
#rnx

#ROBOMERGE-SOURCE: CL 10476637 in //UE4/Release-4.24/...
#ROBOMERGE-BOT: RELEASE (Release-4.24 -> Main) (v595-10452236)

[CL 10476638 by jamie dale in Main branch]
2019-11-27 17:12:25 -05:00
Jamie Dale
d8cba515b4 Disable register warnings for C code included into C++17
#jira UE-85039
#rb Ben.Marsh
#rnx

[CL 10461373 by Jamie Dale in Dev-Editor branch]
2019-11-26 16:41:45 -05:00
Jamie Dale
47d89a1e16 Added a Blueprint node for calling Python with args
This allows people to create a Blueprint node that can define a blob of literal Python script, along with wildcard inputs and outputs to be used by the script itself.

The node takes care of marshalling data in and out of the Python script, and allows people to invoke custom Python from Blueprints without relying on Python generated BPFL types.

#jira UE-84932
#rb Dan.OConnor

[CL 10421545 by Jamie Dale in Dev-Editor branch]
2019-11-25 14:20:28 -05:00
Jamie Dale
b266566090 Clean-up native module references when shutting down Python
#rb Rex.Hill

[CL 10355258 by Jamie Dale in Dev-Editor branch]
2019-11-21 14:55:43 -05:00
Jamie Dale
da52d61658 PySlate now checks that FSlateApplication is available rather than crashing
#rb Rex.Hill

[CL 10349283 by Jamie Dale in Dev-Editor branch]
2019-11-21 14:10:27 -05:00
Jamie Dale
6d5ffe9fa3 Implemented set_editor_properties for Python wrapped structs
This will attempt to notify the nearest object in the Python owner context stack, and is otherwise identical to the implementation for wrapped objects (see 10265342).

#rb Lauren.Barnes
#rnx

[CL 10343893 by Jamie Dale in Dev-Editor branch]
2019-11-21 13:32:25 -05:00
Jamie Dale
fa47fcdea1 Added a way to force a change notify when using SetEditorProperty in Python or Editor Utilities, even if the value is unchanged
This may be needed if you've edited data on an instance indirectly (eg, modifying an array reference on the object), and need to force a change notification to update some dependent data.

In Python, this can be done by passing unreal.PropertyAccessChangeNotifyMode.ALWAYS as the notify_mode argument to set_editor_property.
In Editor Utilities, there is a new advanced pin available for setting the "Change Notify Mode".
In both cases the default method is to notify only when the value actually changes.

This change also significantly simplifies UK2Node_GetEditorProperty and UK2Node_SetEditorProperty by having them derive from UK2Node_CallFunction, rather than being a proxy node that expands to a UK2Node_CallFunction node.

#jira UE-80285
#rb Lauren.Barnes

[CL 10337069 by Jamie Dale in Dev-Editor branch]
2019-11-21 12:12:05 -05:00
Jamie Dale
f1f4f7fcb0 Generate UserDefinedEnum wrappers on-demand if marshalled via Python
This avoids the caller needing to have called unreal.get_blueprint_generated_types(...) for the type before trying to access it.

#rb Lauren.Barnes

[CL 10319031 by Jamie Dale in Dev-Editor branch]
2019-11-20 10:01:08 -05:00
Jamie Dale
29fa4b658e Fixed Python memory leak
#rb none
#rnx

[CL 10267523 by Jamie Dale in Dev-Editor branch]
2019-11-15 16:31:57 -05:00
Jamie Dale
8b807289c3 CIS fix
#rb none
#rnx

[CL 10266585 by Jamie Dale in Dev-Editor branch]
2019-11-15 15:40:51 -05:00
Jamie Dale
de4f7490d3 CIS fix
#rb none
#rnx

[CL 10266516 by Jamie Dale in Dev-Editor branch]
2019-11-15 15:37:02 -05:00
Jamie Dale
e96c641170 Added set_editor_properties to let you set multiple properties which only emit a single pre/post change notification
hism_comp.set_editor_properties({
    'cast_shadow': False,
    'instance_start_cull_distance': 12,
    'instance_end_cull_distance': 23,
    })

#rb Lauren.Barnes

[CL 10265342 by Jamie Dale in Dev-Editor branch]
2019-11-15 14:39:19 -05:00
Jamie Dale
046a164ece Exposed UserDefinedEnum types to Python
This is the first phase of allowing Blueprint types to be generated for Python, which must be accessed via unreal.get_blueprint_generated_types(...) as asset names are not guaranteed to be unique, so they're not added to the unreal module.

Once a type has been generated for Python, it will be updated if the underlying asset is changed. Should the asset be deleted then the Python type will be reset to clean state and become mostly unusable.

This change also ensures that the Unreal type pointers referenced by the Python meta-data are ARO'd correctly. This will cause a warning if you try and delete an asset with a type used by Python.

 MyEnum = unreal.get_blueprint_generated_types('/Game/MyEnum') # This can also accept multiple arguments or a list, and will return a tuple of types
 print(MyEnum.MY_ENTRY)

#jira UE-81862, UE-81859
#rb Lauren.Barnes

[CL 10227467 by Jamie Dale in Dev-Editor branch]
2019-11-14 16:52:43 -05:00
Chris Gagnon
d1973355bc Merge Dev-Tools-Stagng tp Dev-Editor
#rb none

[CL 9961726 by Chris Gagnon in Dev-Editor branch]
2019-11-01 17:39:56 -04:00
marc audy
c9c4908ac1 Merging CL# 9893571 as it should not have been deadended
#rb
#rnx


#ROBOMERGE-SOURCE: CL 9900920
#ROBOMERGE-BOT: (v558-9892490)

[CL 9900943 by marc audy in Main branch]
2019-10-31 11:25:06 -04:00
Jamie Dale
5904862070 Added PropertyAccessUtil to contain the common logic of getting and setting properties in a way that emits change notifications
The existing Python code has been ported to use this, and this can also be used by Blueprints (or other C++ setting properties) to allow property changes that emit change notifications.

#jira UE-77388
#rb Chris.Gagnon

[CL 9706346 by Jamie Dale in Dev-Editor branch]
2019-10-18 18:51:40 -04:00
Chris Gagnon
5b7e66b1fb Merging //UE4/Dev-Main to Dev-Editor (//UE4/Dev-Editor) to CL 9544902 for stream reparenting.
#rb none

[CL 9671142 by Chris Gagnon in Dev-Editor branch]
2019-10-17 19:44:57 -04:00