我是虚幻的新手。我是一个研究项目的一部分,我正在努力更好地学习引擎,但是有一些东西让我卡了很长一段时间。我GetGrids
在 .h 文件中声明了一个私有函数。我试图在 .cpp 文件中调用它,但控件从未进入该函数。我在那个根本没有命中的函数中设置了一个断点。我尝试重新启动 Visual Studio,重建解决方案,但似乎没有任何效果。
#include "RoboRev_Win.h"
#include "MapsManager.h"
AMapsManager::AMapsManager(const FObjectInitializer& ObjectInitializer)
:Super(ObjectInitializer)
{
m_row = MAP_SIZE;
m_column = MAP_SIZE;
m_startPoint = FVector(0, 0, 90);
m_IsMapCreated = false;
PrimaryActorTick.bStartWithTickEnabled = true;
}
void AMapsManager::Tick(float DeltaSeconds)
{
Super::Tick(DeltaSeconds);
if (!m_IsMapCreated)
CreateMap();
}
AGrid* AMapsManager::GetGridWithID(int _ID)
{
for (int i = 1; i <= GRID_SIZE*GRID_SIZE; i++)
{
AGrid *_Grid = m_Grids[i];
if (_Grid->ID == _ID)
{
return _Grid;
}
}
return NULL;
}
void AMapsManager::GetGrids()
{
int a, b, c;
a = 1;
b = 2;
c = 3;
int sum;
sum = a + b + c;
printf("");
printf("");
}
void AMapsManager::CreateMap()
{
UWorld* const _World = GetWorld();
if (_World)
{
m_IsMapCreated = true;
FActorSpawnParameters _Parameters;
_Parameters.Owner = this;
_Parameters.Instigator = Instigator;
FVector _SpawnPosition;
FRotator _Rotator(0, 0, 0);
_SpawnPosition = FVector(0, 0, 0);
originalX = _SpawnPosition.X - ((MAP_SIZE / 2)*GRID_SIZE);
_SpawnPosition.X = originalX;
_SpawnPosition.Y = originalX;
_CurrentID = 1;
for (int i = 1; i <= m_row; i++)
{
for (int j = 1; j <= m_column; j++)
{
AGrid *_Grid = static_cast<AGrid *>(_World->SpawnActor(m_GridPawn, &_SpawnPosition, &_Rotator, _Parameters));
_Grid->ID = _CurrentID;
m_Grids.push_back(_Grid);
_SpawnPosition.X += GRID_SIZE;
_CurrentID++;
}
_SpawnPosition.Y += GRID_SIZE;
_SpawnPosition.X = originalX;
}
}
int _MapIDs[] = { 1, 2, 3, 4, 5, 10, 15, 20, 25 };
int k = 9;
for (int l = 0; l < k; l++)
{
//AGrid *_Grid = GetGridWithID(_MapIDs[l]);
//_Grid->ChangeMaterial();
this->GetGrids();
}
}
不要介意函数在做什么。它只是一个测试功能。
这是 .h 文件中的声明
private:
void GetGrids();
请帮忙!