-
(UE4) 언리얼 엔진 Navigation System ConfigUnrealEngine 2020. 3. 10. 22:55
네비게이션 시스템을 이용한 Config 수정
1234567891011121314151617181920212223242526272829303132333435UWorld *world = GEditor->GetEditorWorldContext().World();UNavigationSystemV1* NavSystem = UNavigationSystemV1::GetCurrent(world);TArray<FNavDataConfig> supportedAgents;supportedAgents = NavSystem->GetSupportedAgents();bool isOverlap = false;for (FNavDataConfig sa : supportedAgents){UE_LOG(LogTemp, Display, TEXT("NavSystem :: %s"), *sa.Name.ToString());if (sa.Name.Compare(FName(TEXT("HumanStudioAuto"))) == 0){isOverlap = true;break;}}if (!isOverlap){FNavDataConfig HumanAgent(26.0f, 144.0f);HumanAgent.Name = FName(TEXT("HumanStudioAuto"));supportedAgents.Add(HumanAgent);NavSystem->OverrideSupportedAgents(supportedAgents);NavSystem->SaveConfig();NavSystem->SaveConfig(16384Ui64, *(FPaths::ProjectConfigDir().Append("DefaultEngine.ini")));}ANavMeshBoundsVolume *nmbv = NULL;nmbv = Cast<ANavMeshBoundsVolume>(AddActorFromClass(ANavMeshBoundsVolume::StaticClass()));NavSystem->OnNavigationBoundsAdded(nmbv);cs GConfig 객체를 이용
12345678910111213141516GConfig->GetString(TEXT("/Script/NavigationSystem.NavigationSystemV1"),TEXT("SupportedAgents"),aaa,GEngineIni);GConfig->SetString(TEXT("/Script/NavigationSystem.NavigationSystemV1"),TEXT("SupportedAgents"),TEXT("(Name=\"HumanStudio2\",Color=(B=0,G=255,R=140,A=164),DefaultQueryExtent=(X=50.000000,Y=50.000000,Z=250.000000),NavigationDataClassName=/Script/NavigationSystem.RecastNavMesh,AgentRadius=35.000000,AgentHeight=144.000000,AgentStepHeight=-1.000000,NavWalkingSearchHeightScale=0.500000,PreferredNavData=None,bCanCrouch=False,bCanJump=False,bCanWalk=True,bCanSwim=False,bCanFly=False)"),GEngineIni);GConfig->Flush(false, GEngineIni);cs INI File Matching
1234567891011121314151617181920212223FConfigFile* ConfigFile = nullptr;// Look for the first matching INI file entryfor (TMap<FString, FConfigFile>::TIterator It(*GConfig); It; ++It){if (It.Key().EndsWith(TEXT("DefaultEngine.ini"))){ConfigFile = &It.Value();break;}}check(ConfigFile != nullptr);FConfigSection* Section = ConfigFile->Find(TEXT("/Script/NavigationSystem.NavigationSystemV1"));if (Section != nullptr){TArray<FConfigValue> List;Section->MultiFind(TEXT("SupportedAgents"), List);for (auto& value : List){UE_LOG(LogClass, Display, TEXT("TEST: %s"), *value.GetValue());}}cs