ABOUT ME

-

Today
-
Yesterday
-
Total
-
  • (UE4) 언리얼 엔진 Navigation System Config
    UnrealEngine 2020. 3. 10. 22:55

    네비게이션 시스템을 이용한 Config 수정

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    UWorld *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 객체를 이용

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    GConfig->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

     

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    FConfigFile* ConfigFile = nullptr;
    // Look for the first matching INI file entry
    for (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

    댓글

Designed by Tistory.