Giter Site home page Giter Site logo

Comments (25)

rdeioris avatar rdeioris commented on August 24, 2024

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.

sinokgr avatar sinokgr commented on August 24, 2024

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.

rdeioris avatar rdeioris commented on August 24, 2024

sorry, missed a check, i will push the fix in few minutes

from unrealenginepython.

rdeioris avatar rdeioris commented on August 24, 2024

should be fixed now, pull and rebuild :)

from unrealenginepython.

sinokgr avatar sinokgr commented on August 24, 2024

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.

rdeioris avatar rdeioris commented on August 24, 2024

ue_site.py in Scripts is automatically imported on startup. You have to call ue.add_menu_extension() there

from unrealenginepython.

sinokgr avatar sinokgr commented on August 24, 2024

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.

rdeioris avatar rdeioris commented on August 24, 2024

Window -> at the end they are appended. Check python logs for eventual errors

from unrealenginepython.

sinokgr avatar sinokgr commented on August 24, 2024

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.
image
image
I went to debug mode, and it opened the file PyCharacter.cpp in line 13
image

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
image

from unrealenginepython.

rdeioris avatar rdeioris commented on August 24, 2024

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.

sinokgr avatar sinokgr commented on August 24, 2024

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.

rdeioris avatar rdeioris commented on August 24, 2024

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.

sinokgr avatar sinokgr commented on August 24, 2024

ok, I'll try that and I'll let you know.
Thanks!

from unrealenginepython.

sinokgr avatar sinokgr commented on August 24, 2024

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.

rdeioris avatar rdeioris commented on August 24, 2024

Yes it is almost ready, just a couple of tests

from unrealenginepython.

rdeioris avatar rdeioris commented on August 24, 2024

@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.

sinokgr avatar sinokgr commented on August 24, 2024

Awesome! Worked like charm! Many thanks for that @rdeioris. :)
Now the only thing remaining from my point of view is issue30.

from unrealenginepython.

sinokgr avatar sinokgr commented on August 24, 2024

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.

rdeioris avatar rdeioris commented on August 24, 2024

Hi, if i remember correctly main menus can only be created in ue_site.py

from unrealenginepython.

sinokgr avatar sinokgr commented on August 24, 2024

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.

LarsGroh avatar LarsGroh commented on August 24, 2024

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.

rdeioris avatar rdeioris commented on August 24, 2024

Hi, the extender api has been changed some month ago:

https://github.com/20tab/UnrealEnginePython/blob/master/examples/extenders_example.py

from unrealenginepython.

yuchen-sketch avatar yuchen-sketch commented on August 24, 2024

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.

rdeioris avatar rdeioris commented on August 24, 2024

@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.

yuchen-sketch avatar yuchen-sketch commented on August 24, 2024

@rdeioris
Got it. Thanks!

from unrealenginepython.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.