// Must hook before the drone is actually scaled, to move the parent trigger to the root entity. // This is done to prevent issues where the player observes the entity they are parented to resize. private void OnDroneScaleBegin(Drone drone, BaseEntity rootEntity, float scale, float previousScale) { if (previousScale == 1) { var platform = drone.GetComponent <DronePlatformComponent>(); if (platform == null) { return; } // Move parent trigger to root entity. UnityEngine.Object.DestroyImmediate(platform); DronePlatformComponent.AddToRootEntity(drone, rootEntity, scale); return; } if (scale == 1) { var platform = rootEntity.GetComponent <DronePlatformComponent>(); if (platform == null) { return; } // Move parent trigger to drone. UnityEngine.Object.DestroyImmediate(platform); drone.Invoke(() => DronePlatformComponent.AddToDrone(drone, scale), 0); return; } rootEntity.GetOrAddComponent <DronePlatformComponent>().SetScale(scale); }