Comments (25)
add_menu_extension() has been added:
import unreal_engine as ue
def menu_callback_for_script():
ue.exec('yourscript.py')
ue.add_menu_extension('Run My Funny Script', menu_callback_for_script)
add_menu_extension is useful only on ue_site.py. (you can call it multiple time to register multiple menu entries)
from unrealenginepython.
I've created a new project, ran the installion process of the new repository and the project built successfully. When I'm tried to open the project though, it crashed after the splash screen. Here is the report:
Access violation - code c0000005 (first/second chance not available)
UE4Editor_UnrealEnginePython!FPythonSlateCommands::RegisterCommands() [c:\users\sinokgr\documents\unreal projects\python_4_12_5\plugins\unrealenginepython\source\unrealenginepython\private\uepyslate.cpp:15]
UE4Editor_UnrealEnginePython!TCommands::Register() [c:\program files (x86)\epic games\4.12\engine\source\runtime\slate\public\framework\commands\commands.h:53]
UE4Editor_UnrealEnginePython!FUnrealEnginePythonModule::StartupModule() [c:\users\sinokgr\documents\unreal projects\python_4_12_5\plugins\unrealenginepython\source\unrealenginepython\private\unrealenginepython.cpp:86]
UE4Editor_Core
UE4Editor_Core
UE4Editor_UnrealEnginePython!FModuleManager::LoadModuleChecked() [c:\program files (x86)\epic games\4.12\engine\source\runtime\core\public\modules\modulemanager.h:281]
UE4Editor_UnrealEnginePython!APyActor::APyActor() [c:\users\sinokgr\documents\unreal projects\python_4_12_5\plugins\unrealenginepython\source\unrealenginepython\public\pyactor.cpp:13]
UE4Editor_CoreUObject
UE4Editor_CoreUObject
UE4Editor_CoreUObject
UE4Editor_CoreUObject
UE4Editor_Core
UE4Editor_Core
UE4Editor_Projects
UE4Editor_Projects
UE4Editor
UE4Editor
UE4Editor
UE4Editor
UE4Editor
UE4Editor
kernel32
ntdll
from unrealenginepython.
sorry, missed a check, i will push the fix in few minutes
from unrealenginepython.
should be fixed now, pull and rebuild :)
from unrealenginepython.
Thanks @rdeioris, it opens fine now. Sorry if this is stupid question, but what do you mean by "add_menu_extension is useful only on ue_site.py". I was searching a file named ue_site.py to add my menus, couldn't find any so I then tried to create a new ue_site.py and add it to Scripts folders and import it. That didn't work either so I assume I'm doing something wrong.
from unrealenginepython.
ue_site.py in Scripts is automatically imported on startup. You have to call ue.add_menu_extension() there
from unrealenginepython.
In the folder Scripts, I created a file named "ue_site.py", copy-pasted your code in there and started the project but I can't find the menu 'Run My Funny Script' anywhere. Where is it supposed to appear? Top menu? RC menu?
from unrealenginepython.
Window -> at the end they are appended. Check python logs for eventual errors
from unrealenginepython.
You're correct, I found an error and it was in this line
ue.exec('yourscript.py')
I changed it to
ue.exec_('yourscript.py')
and now the project is crashing before even start. In order to simplify stuff, I changed it to
ue.log('Begin Play on Hero class')
but it still crashes.
I went to debug mode, and it opened the file PyCharacter.cpp in line 13
Last thing. Except from just appending sub-menus to the Window menu, will there be an option to create new menus in top bar with submenus??
[edit]
something like that
from unrealenginepython.
Can you paste/upload the whol ue_sitepy ? Is it python2 or 3 ? Is it possible you have built the plugin with threading support ?
from unrealenginepython.
that's the current script
import unreal_engine as ue
def menu_callback_for_script():
ue.log('Log test')
ue.add_menu_extension('Run My Funny Script', menu_callback_for_script)
I use python 2.7 and I've build the plugin with threading support because I need to use PySide and in your email you told me that this is how you add support (at least one of the two ways to be accurate)
from unrealenginepython.
For now try removing threading support. If i remember correctly you are using the custom loop for qt, and this does not require threading
from unrealenginepython.
ok, I'll try that and I'll let you know.
Thanks!
from unrealenginepython.
Yei! It works! Many thanks @rdeioris! :D
You haven't answered me about the Menus-Submenus though. Can you add this option like Unity for example?
from unrealenginepython.
Yes it is almost ready, just a couple of tests
from unrealenginepython.
@sinokgr You can now pass a third argument to add_menu_extension, with the name of the new menu bar:
ue.add_menu_extension('Foobar', callable, 'NewMenu')
from unrealenginepython.
Awesome! Worked like charm! Many thanks for that @rdeioris. :)
Now the only thing remaining from my point of view is issue30.
from unrealenginepython.
Hi there,
I tried to create a menu today, with no main menu and nothing happens.
Console reports Registered python extender command "Test", but nothing appears.
ue.add_menu_extension('Test', test)
if I change that to the following it works as expected
ue.add_menu_extension('Test', test, 'Top')
Any ideas why?
Thanks
from unrealenginepython.
Hi, if i remember correctly main menus can only be created in ue_site.py
from unrealenginepython.
yep, this is where this code exists. The second snippet works fine. The only issue is that currently I can only create submenus, so I can have something like "menu bar item>tool". Initially you could do just "tool". Third variable is optional but without it, it doesn't add the menu.
from unrealenginepython.
This one does not work on my side:
ue.add_menu_extension('Test', test, 'Top')
I placed it within ue_site.py No other main menu is being created.
This one worked:
ue.add_menu_extension('Test', test)
An item is being created under "Window"
Bu I noticed that if erase the command from ue_site the menu item is still being created.
This is something I would not expect for a clean startup process.
from unrealenginepython.
Hi, the extender api has been changed some month ago:
https://github.com/20tab/UnrealEnginePython/blob/master/examples/extenders_example.py
from unrealenginepython.
Hi, @rdeioris
I am also trying to add buttons to unreal.
Any way that the buttons can be loaded automatically when create a new project rather than closing the project and pasting the scripts folder and reopening it?
from unrealenginepython.
@yuchen-sketch please open new issues for new requests :) btw you can put the Scripts/ directory in the Plugin Content directory (instead of the project dir). it will be added to the pythonpath automatically. So when the user enables the python plugin the ue_site.py script can be executed automatically
from unrealenginepython.
@rdeioris
Got it. Thanks!
from unrealenginepython.
Related Issues (20)
- upgrade python console to IPython or other alternatives?
- Error with module h5py
- 4.26.2 Python 3.7 Crash When call bind_event in uep HOT 2
- How to add force to pyactor HOT 1
- keyboard input HOT 2
- Where are the python modules? HOT 1
- Build Failed: Cannot open include file 'UEPyModule.h'
- seems not work at 4.27?
- How can I redirect a python class so that the engine can recognize him?(请问如何重定向一个python类,然后引擎能够识别他?)
- Spawn a pyactor in begin_play doesn't works fine.
- First demo in docs/Http_API.md cause the editor crashed in 4.27.2
- Great content! It might be possible to create an updated version (ue5) HOT 1
- How to call Python automation code from a UI button? HOT 4
- How do I get text from a UEditableTextBox?
- How to run a simple python function, with inputs & outputs, from blueprints? HOT 5
- I am using multithreading to Spawn a Blueprint Actor and Unreal Engine is crashing suddenly when the spawn function gets called.
- consider archiving the repo in github
- how can I change my python env in my own source(python3.8),rather then the give source(python3.6 in UnrealEnginePython/)
- a
- Issues about the HouseKeeper
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from unrealenginepython.