vault backup: 2024-10-12 17:19:45
This commit is contained in:
@@ -0,0 +1,69 @@
|
||||
# ConversionRoot
|
||||
|
||||
- **功能描述:** 在场景编辑器里允许Actor在自身以及子类之间做转换
|
||||
- **引擎模块:** Scene
|
||||
- **元数据类型:** bool
|
||||
- **作用机制:** 在Meta中增加[IsConversionRoot](../../../../Meta/Blueprint/IsConversionRoot.md)
|
||||
- **常用程度:★**
|
||||
|
||||
一般是用在Actor上,在Actor转换的时候用来限制转换的级别。比如ASkeletalMeshActor,AStaticMeshActor等。
|
||||
|
||||
常常ComponentWrapperClass一起出现。
|
||||
|
||||
根据代码来说,meta中的IsConversionRoot会限制只传达到这一层,不继续往根上查找。
|
||||
|
||||
只有配有ConversionRoot的Actor才会允许Convert Actor,否则是禁用的。
|
||||
|
||||
## 示例代码:
|
||||
|
||||
```cpp
|
||||
//(BlueprintType = true, IncludePath = Class/Trait/MyClass_ConversionRoot.h, IsBlueprintBase = true, IsConversionRoot = true, ModuleRelativePath = Class/Trait/MyClass_ConversionRoot.h)
|
||||
UCLASS(Blueprintable,BlueprintType, ConversionRoot)
|
||||
class INSIDER_API AMyActor_ConversionRoot :public AActor
|
||||
{
|
||||
GENERATED_BODY()
|
||||
};
|
||||
|
||||
```
|
||||
|
||||
## 示例效果:
|
||||
|
||||
在蓝图中创建其子类BP_ConversionRoot_Child1和BP_ConversionRoot_Child2。然后把BP_ConversionRoot_Child1拖放进场景里创建个Actor,也创建个普通的蓝图Actor作为对比。
|
||||
|
||||

|
||||
|
||||
在关卡中选择Child1,会允许ConvertActor,在ConverstionRoot的自身以及所有子类之间做转换。
|
||||
|
||||

|
||||
|
||||
如果是普通的Actor,因为没有定义ConversionRoot,则不能做转换。
|
||||
|
||||

|
||||
|
||||
## 原理:
|
||||
|
||||
在关卡中的Actor选择:关卡中选择一个Actor,然后DetailsPanel里会显示ConverActor属性栏,可以选择另外一个Actor来进行改变。
|
||||
TSharedRef<SWidget> FActorDetails::MakeConvertMenu( const FSelectedActorInfo& SelectedActorInfo )
|
||||
这个函数就是用来创建Select Type的Combo Button的菜单的。内部会调用CreateClassPickerConvertActorFilter:
|
||||
|
||||
```cpp
|
||||
UClass* FActorDetails::GetConversionRoot( UClass* InCurrentClass ) const
|
||||
{
|
||||
UClass* ParentClass = InCurrentClass;
|
||||
|
||||
while(ParentClass)
|
||||
{
|
||||
if( ParentClass->GetBoolMetaData(FName(TEXT("IsConversionRoot"))) )
|
||||
{
|
||||
break;
|
||||
}
|
||||
ParentClass = ParentClass->GetSuperClass();
|
||||
}
|
||||
|
||||
return ParentClass;
|
||||
}
|
||||
|
||||
void FActorDetails::CreateClassPickerConvertActorFilter(const TWeakObjectPtr<AActor> ConvertActor, class FClassViewerInitializationOptions* ClassPickerOptions)
|
||||
Filter->AllowedChildOfRelationship.Add(RootConversionClass);//限定这个基类以下的其他子类
|
||||
|
||||
```
|
Binary file not shown.
After Width: | Height: | Size: 26 KiB |
Binary file not shown.
After Width: | Height: | Size: 4.2 KiB |
Binary file not shown.
After Width: | Height: | Size: 196 KiB |
@@ -0,0 +1,65 @@
|
||||
# NotPlaceable
|
||||
|
||||
- **功能描述:** 标明该Actor不可被放置在关卡里
|
||||
- **引擎模块:** Behavior
|
||||
- **元数据类型:** bool
|
||||
- **作用机制:** 在ClassFlags中添加[CLASS_NotPlaceable](../../../../Flags/EClassFlags/CLASS_NotPlaceable.md)
|
||||
- **关联项:** Placeable (Placeable.md)
|
||||
- **常用程度:★★★**
|
||||
|
||||
标明该Actor不可被放置在关卡里,没法拖放到场景里。使继承自基类的Placeable说明符无效。会在ClassFlagss里标记上CLASS_NotPlaceable,这个标记是可以继承的,意味着其所有的子类默认都不可放置。例如AWorldSettings其实就是一个notplaceable的Actor。
|
||||
|
||||
但是注意该类依然可以通过SpawnActor动态生成到关卡中。
|
||||
|
||||
NotPlaceable的类是不出现在PlaceMode的类选择里去的。
|
||||
|
||||
## 示例代码:
|
||||
|
||||
```cpp
|
||||
UCLASS(Blueprintable,BlueprintType, NotPlaceable)
|
||||
class INSIDER_API AMyActor_NotPlaceable :public AActor
|
||||
{
|
||||
GENERATED_BODY()
|
||||
};
|
||||
```
|
||||
|
||||
## 示例效果:
|
||||
|
||||
拖动到场景里会发现不能创建Actor。
|
||||
|
||||

|
||||
|
||||
## 原理:
|
||||
|
||||
如果直接是C++类AMyActor_NotPlaceable ,是可以直接从ContentBrowser拖到场景里去的。看源码可知,只有BP继承下来的子类才有受到这个限制。
|
||||
|
||||
```cpp
|
||||
TArray<AActor*> FLevelEditorViewportClient::TryPlacingActorFromObject( ULevel* InLevel, UObject* ObjToUse, bool bSelectActors, EObjectFlags ObjectFlags, UActorFactory* FactoryToUse, const FName Name, const FViewportCursorLocation* Cursor )
|
||||
{
|
||||
|
||||
bool bPlace = true;
|
||||
if (ObjectClass->IsChildOf(UBlueprint::StaticClass()))
|
||||
{
|
||||
UBlueprint* BlueprintObj = StaticCast<UBlueprint*>(ObjToUse);
|
||||
bPlace = BlueprintObj->GeneratedClass != NULL;
|
||||
if(bPlace)
|
||||
{
|
||||
check(BlueprintObj->ParentClass == BlueprintObj->GeneratedClass->GetSuperClass());
|
||||
if (BlueprintObj->GeneratedClass->HasAnyClassFlags(CLASS_NotPlaceable | CLASS_Abstract))
|
||||
{
|
||||
bPlace = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (bPlace)
|
||||
{
|
||||
PlacedActor = FActorFactoryAssetProxy::AddActorForAsset( ObjToUse, bSelectActors, ObjectFlags, FactoryToUse, Name );
|
||||
if ( PlacedActor != NULL )
|
||||
{
|
||||
PlacedActors.Add(PlacedActor);
|
||||
PlacedActor->PostEditMove(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
Binary file not shown.
After Width: | Height: | Size: 155 KiB |
@@ -0,0 +1,33 @@
|
||||
# Placeable
|
||||
|
||||
- **功能描述:** 标明该Actor可以放置在关卡里。
|
||||
- **引擎模块:** Scene
|
||||
- **元数据类型:** bool
|
||||
- **作用机制:** 在ClassFlags中移除[CLASS_NotPlaceable](../../../../Flags/EClassFlags/CLASS_NotPlaceable.md)
|
||||
- **关联项:** [NotPlaceable](../NotPlaceable/NotPlaceable.md)
|
||||
- **常用程度:★★★**
|
||||
|
||||
标明该Actor可以放置在关卡里。
|
||||
|
||||
默认情况下是placeable的,因此源码里目前没有用到Placeable的地方。
|
||||
|
||||
子类可使用NotPlaceable说明符覆盖此标志,正如AInfo之类的上面自己设置NotPlaceable。
|
||||
|
||||
指示可在编辑器中创建此类,而且可将此类放置到关卡、UI场景或蓝图(取决于类类型)中。此标志会传播到所有子类;
|
||||
|
||||
placeable没法清除父类的notplaceable标记。
|
||||
|
||||
## 示例代码:
|
||||
|
||||
```cpp
|
||||
UCLASS(Blueprintable, BlueprintType,placeable)
|
||||
class INSIDER_API AMyActor_Placeable :public AMyActor_NotPlaceable
|
||||
{
|
||||
GENERATED_BODY()
|
||||
};
|
||||
error : The 'placeable' specifier cannot override a 'nonplaceable' base class. Classes are assumed to be placeable by default. Consider whether using the 'abstract' specifier on the base class would work.
|
||||
```
|
||||
|
||||
## 示例效果:
|
||||
|
||||

|
Binary file not shown.
After Width: | Height: | Size: 125 KiB |
Reference in New Issue
Block a user