目录:第九艺术-目录
好久没写了,先简单写一个
不知道有没有人和我一样,相比 Sequence 还是更喜欢 Matinee 多一点,最主要的原因还是相比 Sequence 的笨重,封装的那么严实,还是更喜欢的 Matinee 的轻便,逻辑简单明确,当然,还是因为这样改起来好改,比如在 Matinee 里加一些回调,可以把很多不想运行时Tick里才执行的东西放到这里,在编辑器里直接就能看,诸如此类,对于我们这种没啥做过场动画的需求的项目,改改Matinee来做一些事,实在简单轻便
Matinee 丢掉了,我很怀念它,所以就把他找回来了,现在官方只是把 外部的接口 删掉了,不知道之后会不会把 MatineeActor 整个删掉,理论上为了兼容旧项目,应该不会再删掉,不过这也是理论,如果删掉了,我就再找回来,哈哈
下面直接贴需要修改的部分(修改部分会注释包起来)了,因为逻辑很简单,就是几个界面上的接口,也不需要解释太多了
ToolBar 上的 接口
LevelEditorActions.h
添加 UICommandInfo 声明
TSharedPtr< FUICommandInfo > WorldProperties;
TSharedPtr< FUICommandInfo > OpenContentBrowser;
TSharedPtr< FUICommandInfo > OpenMarketplace;
//BEGIN
TSharedPtr< FUICommandInfo > AddMatinee;
//END
TSharedPtr< FUICommandInfo > ToggleVR;
添加 方法回调
static void OnAddVolume( UClass* VolumeClass );
//BEGIN
static void OnAddMatinee();
//END
LevelEditor.cpp
在 FLevelEditorModule::BindGlobalLevelEditorCommands 里面添加action映射
ActionList.MapAction(
Commands.AddMatinee,
FExecuteAction::CreateStatic(&FLevelEditorActionCallbacks::OnAddMatinee)
);
LevelEditorActions.cpp
在 FLevelEditorCommands::RegisterCommands 里
UI_COMMAND(AddMatinee, "Add Matinee [Legacy]", "Creates a new matinee actor to edit", EUserInterfaceActionType::Button, FInputChord());
上面声明的方法 OnAddMatinee 的实现
void FLevelEditorActionCallbacks::OnAddMatinee()
{
// Warn the user prior to creating our actor
if (GEditor->ShouldOpenMatinee(NULL))
{
// Spawn a matinee actor at the origin, and either move infront of the camera or focus camera on it (depending on the viewport) and open for edit
UActorFactory* ActorFactory = GEditor->FindActorFactoryForActorClass(AMatineeActor::StaticClass());
check(ActorFactory);
AMatineeActor* MatineeActor = CastChecked<AMatineeActor>(FLevelEditorActionCallbacks::AddActor(ActorFactory, FAssetData(), &FTransform::Identity));
if (GCurrentLevelEditingViewportClient->IsPerspective())
{
GEditor->MoveActorInFrontOfCamera(*MatineeActor, GCurrentLevelEditingViewportClient->GetViewLocation(), GCurrentLevelEditingViewportClient->GetViewRotation().Vector());
}
else
{
GEditor->MoveViewportCamerasToActor(*MatineeActor, false);
}
GEditor->OpenMatinee(MatineeActor, false);
}
}
LevelEditorToolBar.cpp
最后就是toolbar上的调用了,首先打开默认允许 MatineeActor
static TAutoConsoleVariable<int32> CVarAllowMatineeActors(
TEXT("Matinee.AllowMatineeActors"),
1,/*0,*/
TEXT("Toggles whether matinee actors should appear in the cinematics menu so that they can be edited."));
然后 在 FLevelEditorToolBar::RegisterCinematicsMenu() 的时候,加入 Matinee 的Entry,这个位置可以改,我放这里,是为了少改动一些代码,能分开一些最好,所以加入的位置已经不是之前版本的位置
UToolMenu* Menu = UToolMenus::Get()->RegisterMenu("LevelEditor.LevelEditorToolBar.Cinematics");
Menu->bShouldCloseWindowAfterMenuSelection = true;
//BEGIN
{
FToolMenuSection& Section = Menu->AddSection("LevelEditorNewMatinee", LOCTEXT("MatineeMenuCombo_NewHeading", "New"));
Section.AddMenuEntry(FLevelEditorCommands::Get().AddMatinee, TAttribute<FText>(), TAttribute<FText>(), FSlateIcon(FEditorStyle::GetStyleSetName(), "ClassIcon.MatineeActor"));
}
//END
Menu->AddSection("LevelEditorNewCinematics", LOCTEXT("CinematicsMenuCombo_NewHeading", "New"));
这个方法下面的代码就是就是 cast 然后编辑 MatineeActor,在初始官方提交的版本这里编辑也不能编辑了,后面应该是因为兼容性,又改回来了
到这里,就可以从 MenuToolBar上添加和打开 Matinee 了
Detail界面的接口
下面是 选中 MatineeActor 后,在Detail 界面的 Edit 按钮
先把4.23或者之前的引擎版本的 MatineeActorDetails.h 和 MatineeActorDetails.cpp 直接拷贝过来,然后直接注册就行
DetailCustomizations.cpp
FDetailCustomizationsModule::RegisterObjectCustomizations
RegisterCustomClassLayout("MatineeActor", FOnGetDetailCustomizationInstance::CreateStatic(&FMatineeActorDetails::MakeInstance));
然后就可以看到这个按钮了