Assets\CharacterTest\Scripts\Misc\SceneInitializationSystem.cs(45,37): error SGSG0002: No reference to SystemState was found for function with SystemAPI.GetComponent access, add ref SystemState ...
as method parameter. This will be used for updating handles and completing dependencies.
[BurstCompile]
public void OnUpdate(ref SystemBase system)
{
if (SystemAPI.HasSingleton<SceneInitialization>())
{
ref SceneInitialization initlizer = ref SystemAPI.GetSingletonRW<SceneInitialization>().ValueRW;
Cursor.lockState = CursorLockMode.Locked;
Cursor.visible = false;
var playerEntity = system.EntityManager.Instantiate(initlizer.playerEntity);
var characterEntity = system.EntityManager.Instantiate(initlizer.charaterPrefabEntity);
LocalTransform localT = SystemAPI.GetComponent<LocalTransform>(initlizer.characterSpawnPointEntity);
SystemAPI.SetComponent(characterEntity, LocalTransform.FromPositionRotation(localT.Position, localT.Rotation));
var cameraEntity = system.EntityManager.Instantiate(initlizer.orbitCameraEntity);
system.EntityManager.SetComponentData(cameraEntity, new MainEntityCamera());
PlatformerPlayer player = SystemAPI.GetComponent<PlatformerPlayer>(playerEntity);
player.ControlledCharacter = characterEntity;
player.ControlledCamera = characterEntity;
SystemAPI.SetComponent(playerEntity, player);
system.EntityManager.DestroyEntity(SystemAPI.GetSingletonEntity<SceneInitialization>());
}
}
The error actually points to this line:
LocalTransform localT = SystemAPI.GetComponent(initlizer.characterSpawnPointEntity);
I can’t see any connection between the error and the code, and I can’t clear the error. What could be the reason for this?