mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-24 12:54:40 +01:00
Merge pull request #216 from BigRoy/enhancement/fusion_launch_with_menu
Fusion: Add Launch Hook to start "AYON menu" on Fusion start
This commit is contained in:
commit
3457dc7e44
3 changed files with 46 additions and 1 deletions
|
|
@ -0,0 +1,36 @@
|
|||
import os
|
||||
from ayon_core.lib import PreLaunchHook
|
||||
from ayon_core.hosts.fusion import FUSION_HOST_DIR
|
||||
|
||||
|
||||
class FusionLaunchMenuHook(PreLaunchHook):
|
||||
"""Launch AYON menu on start of Fusion"""
|
||||
app_groups = ["fusion"]
|
||||
order = 9
|
||||
|
||||
def execute(self):
|
||||
# Prelaunch hook is optional
|
||||
settings = self.data["project_settings"][self.host_name]
|
||||
if not settings["hooks"]["FusionLaunchMenuHook"]["enabled"]:
|
||||
return
|
||||
|
||||
variant = self.application.name
|
||||
if variant.isnumeric():
|
||||
version = int(variant)
|
||||
if version < 18:
|
||||
print("Skipping launch of OpenPype menu on Fusion start "
|
||||
"because Fusion version below 18.0 does not support "
|
||||
"/execute argument on launch. "
|
||||
f"Version detected: {version}")
|
||||
return
|
||||
else:
|
||||
print(f"Application variant is not numeric: {variant}. "
|
||||
"Validation for Fusion version 18+ for /execute "
|
||||
"prelaunch argument skipped.")
|
||||
|
||||
path = os.path.join(FUSION_HOST_DIR,
|
||||
"deploy",
|
||||
"MenuScripts",
|
||||
"launch_menu.py").replace("\\", "/")
|
||||
script = f"fusion:RunScript('{path}')"
|
||||
self.launch_context.launch_args.extend(["/execute", script])
|
||||
|
|
@ -75,6 +75,12 @@ class HooksModel(BaseSettingsModel):
|
|||
default_factory=HookOptionalModel,
|
||||
title="Install PySide2"
|
||||
)
|
||||
FusionLaunchMenuHook: HookOptionalModel = SettingsField(
|
||||
default_factory=HookOptionalModel,
|
||||
title="Launch AYON Menu on Fusion Start",
|
||||
description="Launch the AYON menu on Fusion application startup. "
|
||||
"This is only supported for Fusion 18+"
|
||||
)
|
||||
|
||||
|
||||
class CreateSaverModel(CreateSaverPluginModel):
|
||||
|
|
@ -143,6 +149,9 @@ DEFAULT_VALUES = {
|
|||
"hooks": {
|
||||
"InstallPySideToFusion": {
|
||||
"enabled": True
|
||||
},
|
||||
"FusionLaunchMenuHook": {
|
||||
"enabled": False
|
||||
}
|
||||
},
|
||||
"create": {
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
__version__ = "0.1.4"
|
||||
__version__ = "0.1.5"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue