Skip to content

Commit 2f4bf95

Browse files
author
Roberto De Ioris
committed
2 parents e6b0abf + 2345796 commit 2f4bf95

2 files changed

Lines changed: 75 additions & 11 deletions

File tree

‎README.md‎

Lines changed: 58 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,22 @@ If you want to package your project (it is required only if you need to have a p
6363

6464
If you want to package without python, just remember to change the UnrealEnginePython.uplugin to have this line: https://github.com/20tab/UnrealEnginePython/blob/master/UnrealEnginePython.uplugin#L20 set as "Editor" instead of "Runtime"
6565

66+
# Binaries installation on MaxOSX
67+
68+
Check in the releases page (https://github.com/20tab/UnrealEnginePython/releases) if there is a binary version that matches your configuration (otherwise open an issue asking us for it [please specify the python version too]) and download it.
69+
70+
Binary releases for MacOSX expects an official python installation (the packages you get from python.org).
71+
72+
Create (if it does not already exist) a Plugins directory in your project root directory (at the same level of Content/ and the .uproject file) and unzip the plugin into it. If your project is named FooBar you will end with FooBar/Plugins/UnrealEnginePython.
73+
74+
Open your project and go to the Edit/Plugins menu. Go to the bottom and under "Project/Scripting Languages" enable UnrealEnginePython.
75+
76+
Restart your project and you should see the PythonConsole under the "Window/Developer Tools" menu
77+
78+
Binary releases are mainly useful for editor scripting, if you want to package your project for distribution and you need the python runtime, you need a source release (see below).
79+
80+
If instead, you want to package your project without python, just remember to change the UnrealEnginePython.uplugin to have this line: https://github.com/20tab/UnrealEnginePython/blob/master/UnrealEnginePython.uplugin#L20 set as "Editor" instead of "Runtime"
81+
6682
# Installation from sources on MacOSX
6783

6884
* install the latest official python distribution from python.org (the installation will end in the "/Library/Frameworks/Python.framework/Versions/X.Y" directory).
@@ -872,7 +888,7 @@ class Ball:
872888

873889
Now we create (at runtime !!!) a whole new PyActor:
874890

875-
```py
891+
```python
876892
class SuperHero:
877893
def begin_play(self):
878894
# spawn a new PyActor
@@ -890,6 +906,47 @@ class SuperHero:
890906
pass
891907
```
892908

909+
Spawning Notes
910+
--------------
911+
912+
Remember that only Actors can be spawned in a world, and that even the editor is a valid world:
913+
914+
```python
915+
import unreal_engine as ue
916+
from unreal_engine.classes import Actor, Character
917+
from unreal_engine import FVector, FRotator
918+
919+
world = ue.get_editor_world()
920+
actor000 = world.actor_spawn(Actor, FVector(0, 0, 0), FRotator(0, 0, 0))
921+
character000 = world.actor_spawn(Character, FVector(100, 100, 100), FRotator(0, 0, 0))
922+
```
923+
924+
Remember that the Blueprint asset is not a valid actor by itself, you need to get the class generated by the blueprint:
925+
926+
```python
927+
import unreal_engine as ue
928+
from unreal_engine.classes import Blueprint
929+
from unreal_engine import FVector, FRotator
930+
931+
world = ue.get_editor_world()
932+
933+
blueprint = ue.load_object(Blueprint, '/Game/TestBall.TestBall')
934+
actor000 = world.actor_spawn(blueprint.GeneratedClass, FVector(0, 0, 0), FRotator(0, 0, 0))
935+
```
936+
937+
otherwise you can directly reference the BlueprintGeneratedClass
938+
939+
```python
940+
import unreal_engine as ue
941+
from unreal_engine.classes import BlueprintGeneratedClass
942+
from unreal_engine import FVector, FRotator
943+
944+
world = ue.get_editor_world()
945+
946+
blueprint_actor = ue.load_object(BlueprintGeneratedClass, '/Game/TestBall.TestBall_C')
947+
actor000 = world.actor_spawn(blueprint_actor, FVector(0, 0, 0), FRotator(0, 0, 0))
948+
```
949+
893950
Integration with PyQT
894951
---------------------
895952

‎docs/PythonConsole.md‎

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ This is a plugin module giving you a shell for running python commands. It is th
77

88
In this screenshot you can see how to get access to the editor world, and how to add actors to it.
99

10-
The console is still in early stage of development (it is really raw, do not expected a good user experience)
10+
The console supports history
1111

1212
Running python scripts
1313
----------------------
@@ -25,10 +25,12 @@ ue.exec('yourscript.py')
2525

2626
python scripts are searched from the /Content/Scripts directory
2727

28-
Editor scripting
29-
----------------
28+
Note: on python2 ue.exec is not a valid function, you need to use ue.py_exec
3029

31-
The following functions allows access to editor internals:
30+
Editor scripting example
31+
------------------------
32+
33+
This is an example of editor scripting from the python console
3234

3335
```py
3436
# get access to the editor world
@@ -47,8 +49,8 @@ unreal_engine.editor_select_actor(an_actor)
4749
new_asset = unreal_engine.import_asset(filename, package[, factory_class])
4850
```
4951

50-
Asset importing
51-
---------------
52+
Asset importing example
53+
-----------------------
5254

5355
The following code shows how to import an asset from python (an image as a texture):
5456

@@ -86,17 +88,17 @@ factory_obj.set_property('bRGBToEmissive', True)
8688
new_object = ue.import_asset('C:/Users/Tester/Desktop/logo.png', '/Game/FooBar/20tab', factory_obj)
8789
```
8890

89-
Reimporting
90-
-----------
91+
Reimporting example
92+
-------------------
9193

9294
You can reimport an object with the asset_reimport() method:
9395

9496
```py
9597
uobject.asset_reimport([ask_for_new_file, show_notification, filename])
9698
```
9799

98-
Assets listing
99-
--------------
100+
Assets listing example
101+
----------------------
100102

101103
```py
102104
# get the assets under the specified path
@@ -169,3 +171,8 @@ ret = ue.message_dialog_open(ue.APP_MSG_TYPE_YES_NO, "Do you want to shot ?")
169171
if ret == ue.APP_RETURN_TYPE_YES:
170172
ue.log('You choose "YES"')
171173
```
174+
175+
Multiline mode
176+
--------------
177+
178+
If a statement ends with ':' the python console will assume an 'incomplete' commands and will wait for the next line NOT starting with a space to issue the instructions. This mode allows you to enter functions, classes, cycles in the console.

0 commit comments

Comments
 (0)