Bug Fixes

script and actors not having connect transform in on awake and in on start

join auto anchor having wrong anchor because was including scale

fixed selection do to changes to transform accessibility ?
This commit is contained in:
NoriteSC
2023-08-25 14:50:56 +02:00
parent 50c85aec6d
commit 6ab2e540a3
9 changed files with 42 additions and 45 deletions

View File

@@ -1229,14 +1229,14 @@ bool Prefab::SyncChangesInternal(PrefabInstancesData& prefabInstancesData)
{
ScopeLock lock(Locker);
_isCreatingDefaultInstance = true;
_defaultInstance = PrefabManager::SpawnPrefab(this, nullptr, &ObjectsCache, true);
_defaultInstance = PrefabManager::SpawnPrefab(this,Transform::Identity, nullptr, &ObjectsCache, true);
_isCreatingDefaultInstance = false;
}
// Instantiate prefab instance from prefab (default spawning logic)
// Note: it will get any added or removed objects from the nested prefabs
// TODO: try to optimize by using recreated default instance to ApplyAllInternal (will need special path there if apply is done with default instance to unlink it instead of destroying)
const auto targetActor = PrefabManager::SpawnPrefab(this, nullptr, nullptr, true);
const auto targetActor = PrefabManager::SpawnPrefab(this, Transform::Identity, nullptr, nullptr, true);
if (targetActor == nullptr)
{
LOG(Warning, "Failed to instantiate default prefab instance from changes synchronization.");

View File

@@ -76,7 +76,7 @@ Actor* Prefab::GetDefaultInstance()
_isCreatingDefaultInstance = true;
// Instantiate objects from prefab (default spawning logic)
_defaultInstance = PrefabManager::SpawnPrefab(this, nullptr, &ObjectsCache);
_defaultInstance = PrefabManager::SpawnPrefab(this, Transform::Identity, nullptr, &ObjectsCache);
_isCreatingDefaultInstance = false;
return _defaultInstance;

View File

@@ -39,42 +39,37 @@ PrefabManagerService PrefabManagerServiceInstance;
Actor* PrefabManager::SpawnPrefab(Prefab* prefab)
{
Actor* parent = Level::Scenes.Count() != 0 ? Level::Scenes.Get()[0] : nullptr;
return SpawnPrefab(prefab, parent, nullptr);
return SpawnPrefab(prefab,Transform::Identity, parent, nullptr);
}
Actor* PrefabManager::SpawnPrefab(Prefab* prefab, const Vector3& position)
{
auto instance = SpawnPrefab(prefab);
if (instance)
instance->SetPosition(position);
return instance;
Actor* parent = Level::Scenes.Count() != 0 ? Level::Scenes.Get()[0] : nullptr;
return SpawnPrefab(prefab, Transform(position), parent, nullptr);
}
Actor* PrefabManager::SpawnPrefab(Prefab* prefab, const Vector3& position, const Quaternion& rotation)
{
auto instance = SpawnPrefab(prefab);
if (instance)
instance->SetTransform(Transform(position, rotation, instance->GetScale()));
return instance;
Actor* parent = Level::Scenes.Count() != 0 ? Level::Scenes.Get()[0] : nullptr;
return SpawnPrefab(prefab, Transform(position, rotation), parent, nullptr);
}
Actor* PrefabManager::SpawnPrefab(Prefab* prefab, const Vector3& position, const Quaternion& rotation, const Vector3& scale)
{
auto instance = SpawnPrefab(prefab);
if (instance)
instance->SetTransform(Transform(position, rotation, scale));
return instance;
Actor* parent = Level::Scenes.Count() != 0 ? Level::Scenes.Get()[0] : nullptr;
return SpawnPrefab(prefab, Transform(position, rotation, scale), parent, nullptr);
}
Actor* PrefabManager::SpawnPrefab(Prefab* prefab, const Transform& transform)
{
auto instance = SpawnPrefab(prefab);
if (instance)
instance->SetTransform(transform);
return instance;
Actor* parent = Level::Scenes.Count() != 0 ? Level::Scenes.Get()[0] : nullptr;
return SpawnPrefab(prefab, transform, parent, nullptr);
}
Actor* PrefabManager::SpawnPrefab(Prefab* prefab, Actor* parent, Dictionary<Guid, const void*>* objectsCache, bool withSynchronization)
Actor* PrefabManager::SpawnPrefab(Prefab* prefab, Actor* parent)
{
return SpawnPrefab(prefab, Transform::Identity, parent, nullptr);
}
Actor* PrefabManager::SpawnPrefab(Prefab* prefab,const Transform& transform, Actor* parent, Dictionary<Guid, const void*>* objectsCache, bool withSynchronization)
{
PROFILE_CPU_NAMED("Prefab.Spawn");
if (prefab == nullptr)
@@ -183,6 +178,10 @@ Actor* PrefabManager::SpawnPrefab(Prefab* prefab, Actor* parent, Dictionary<Guid
if (parent)
parent->Children.Add(root);
//move root to right location
if (transform != Transform::Identity)
root->SetTransform(transform);
// Link actors hierarchy
for (int32 i = 0; i < sceneObjects->Count(); i++)
{

View File

@@ -70,20 +70,18 @@ API_CLASS(Static) class FLAXENGINE_API PrefabManager
/// <param name="prefab">The prefab asset.</param>
/// <param name="parent">The parent actor to add spawned object instance. Can be null to just deserialize contents of the prefab.</param>
/// <returns>The created actor (root) or null if failed.</returns>
API_FUNCTION() static Actor* SpawnPrefab(Prefab* prefab, Actor* parent)
{
return SpawnPrefab(prefab, parent, nullptr);
}
API_FUNCTION() static Actor* SpawnPrefab(Prefab* prefab, Actor* parent);
/// <summary>
/// Spawns the instance of the prefab objects. If parent actor is specified then created actors are fully initialized (OnLoad event and BeginPlay is called if parent actor is already during gameplay).
/// </summary>
/// <param name="prefab">The prefab asset.</param>
/// <param name="transform">prefab instance transform.</param>
/// <param name="parent">The parent actor to add spawned object instance. Can be null to just deserialize contents of the prefab.</param>
/// <param name="objectsCache">The options output objects cache that can be filled with prefab object id mapping to deserialized object (actor or script).</param>
/// <param name="withSynchronization">True if perform prefab changes synchronization for the spawned objects. It will check if need to add new objects due to nested prefab modifications.</param>
/// <returns>The created actor (root) or null if failed.</returns>
static Actor* SpawnPrefab(Prefab* prefab, Actor* parent, Dictionary<Guid, const void*, HeapAllocation>* objectsCache, bool withSynchronization = false);
static Actor* SpawnPrefab(Prefab* prefab, const Transform& transform, Actor* parent, Dictionary<Guid, const void*, HeapAllocation>* objectsCache, bool withSynchronization = false);
#if USE_EDITOR