Add support for PrefabObject tracks and automated animation instancing with UsePrefabObjects enabled
This commit is contained in:
@@ -49,6 +49,7 @@ public:
|
||||
None = 0,
|
||||
Mute = 1,
|
||||
Loop = 2,
|
||||
PrefabObject = 4,
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
@@ -473,3 +474,5 @@ protected:
|
||||
void unload(bool isReloading) override;
|
||||
AssetChunksFlag getChunksToPreload() const override;
|
||||
};
|
||||
|
||||
DECLARE_ENUM_OPERATORS(SceneAnimation::Track::Flags);
|
||||
|
||||
@@ -1124,6 +1124,7 @@ void SceneAnimationPlayer::Serialize(SerializeStream& stream, const void* otherO
|
||||
SERIALIZE(RandomStartTime);
|
||||
SERIALIZE(RestoreStateOnStop);
|
||||
SERIALIZE(UpdateMode);
|
||||
SERIALIZE(UsePrefabObjects);
|
||||
}
|
||||
|
||||
void SceneAnimationPlayer::Deserialize(DeserializeStream& stream, ISerializeModifier* modifier)
|
||||
@@ -1140,6 +1141,30 @@ void SceneAnimationPlayer::Deserialize(DeserializeStream& stream, ISerializeModi
|
||||
DESERIALIZE(RandomStartTime);
|
||||
DESERIALIZE(RestoreStateOnStop);
|
||||
DESERIALIZE(UpdateMode);
|
||||
DESERIALIZE(UsePrefabObjects);
|
||||
|
||||
if (UsePrefabObjects && Animation && !Animation->WaitForLoaded())
|
||||
{
|
||||
// When loading from prefab automatically map objects from prefab instance into animation tracks with object references
|
||||
for (auto& track : Animation->Tracks)
|
||||
{
|
||||
if (track.Disabled || !(track.Flag & SceneAnimation::Track::Flags::PrefabObject))
|
||||
continue;
|
||||
switch (track.Type)
|
||||
{
|
||||
case SceneAnimation::Track::Types::Actor:
|
||||
case SceneAnimation::Track::Types::Script:
|
||||
case SceneAnimation::Track::Types::CameraCut:
|
||||
{
|
||||
const auto trackData = track.GetData<SceneAnimation::ObjectTrack::Data>();
|
||||
Guid id;
|
||||
if (modifier->IdsMapping.TryGet(trackData->ID, id))
|
||||
_objectsMapping[trackData->ID] = id;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void SceneAnimationPlayer::Collect(RenderContext& renderContext)
|
||||
|
||||
@@ -128,6 +128,12 @@ public:
|
||||
API_FIELD(Attributes="EditorDisplay(\"Scene Animation\"), EditorOrder(80), DefaultValue(UpdateModes.EveryUpdate)")
|
||||
UpdateModes UpdateMode = UpdateModes::EveryUpdate;
|
||||
|
||||
/// <summary>
|
||||
/// Determines whether the scene animation should automatically map prefab objects from scene animation into prefab instances. Useful for reusable animations to automatically link prefab objects.
|
||||
/// </summary>
|
||||
API_FIELD(Attributes="EditorDisplay(\"Scene Animation\"), EditorOrder(100)")
|
||||
bool UsePrefabObjects = false;
|
||||
|
||||
public:
|
||||
|
||||
/// <summary>
|
||||
|
||||
Reference in New Issue
Block a user