İçeriğe geç
Ara

C++ Developer API

Yerel Developer API’yi yalnızca Editor’da çalışan bir C++ eklentisinden veya aracından kullanın. Kullanan editor modülünün bağımlılıklarına Locus modülünü ekleyin; edinim için Locus.h, istekler ve sonuçlar için Developer/LocusDeveloperApi.h başlığını dahil edin.

GetLocusDeveloperApi(), etkin FLocusDeveloperApi nesnesini; başlatılmış Locus Editor ömrünün dışında ise nullptr döndürür.

  • Edinme ve gönderme işlemlerini Game Thread’de yapın.
  • API işaretçisini subsystem veya modül kapanışı boyunca saklamayın.
  • Her tamamlama Game Thread’de tam olarak bir kez çalışır.
  • Kabul edilen iş, Locus’un mevcut yürütücüsünün sonraki bir tick’inde tamamlanır.
  • Kabul hatası, gönderim dönmeden önce satır içinde tamamlanabilir.
  • Callback’e ait durumu göndermeden önce hazırlayın.
  • İptal iş birliğine dayalıdır. Kuyruktaki işi önleyebilir ancak depo çalışmasını kesemez veya kaydedilmiş bir değişikliği geriye dönük olarak iptal edemez.
  • Engelleyici beklemeler, uyku, Game Thread pompalama veya Future.Get() eklemeyin.

Döndürülen FLocusDeveloperRequestHandle, istek kimliğini ve thread-safe, iş birliğine dayalı Cancel() işlevini sunar.

#include "Locus.h"
#include "Developer/LocusDeveloperApi.h"
void CreateCombatDocument()
{
FLocusDeveloperApi* Locus = GetLocusDeveloperApi();
if (Locus == nullptr)
{
return;
}
FLocusDeveloperCreateDocumentRequest Request;
Request.Path = TEXT("Design/Combat.md");
Request.Markdown = TEXT("# Combat\n");
Request.PresentationRoot =
ELocusDeveloperDocumentPresentationRoot::LocusDocuments;
FLocusDeveloperRequestHandle Handle = Locus->CreateDocument(
MoveTemp(Request),
[](TLocusDeveloperResult<FLocusDeveloperDocumentSnapshot> Result)
{
if (!Result.IsSuccess())
{
UE_LOG(LogTemp, Error, TEXT("Locus: %s"), *Result.Error.Message);
return;
}
const FLocusDeveloperDocumentSnapshot& Document = Result.Value.GetValue();
UE_LOG(LogTemp, Display, TEXT("Created %s"),
*Document.Identity.RelativePath);
});
// Retain Handle only if this tool needs to offer cancellation.
}

Girdi yolu seçili sunum köküne göredir. Döndürülen kimlik ise ProjectDocuments köküne göre tanımlanır.

Revizyon işlemeyi gizlemeyin. Okuma sonucundaki revizyonu değişiklik ön koşulu olarak kullanın:

FLocusDeveloperGetDocumentRequest GetRequest;
GetRequest.Identity.RelativePath = TEXT("Design/Combat.md");
Locus->GetDocument(
MoveTemp(GetRequest),
[Locus](TLocusDeveloperResult<FLocusDeveloperDocumentSnapshot> GetResult)
{
if (!GetResult.IsSuccess())
{
return;
}
const FLocusDeveloperDocumentSnapshot& Current = GetResult.Value.GetValue();
FLocusDeveloperUpdateDocumentRequest UpdateRequest;
UpdateRequest.Identity = Current.Identity;
UpdateRequest.ExpectedRevision = Current.Revision;
UpdateRequest.Markdown = Current.Markdown + TEXT("\n## Abilities\n");
Locus->UpdateDocument(
MoveTemp(UpdateRequest),
[](TLocusDeveloperResult<FLocusDeveloperDocumentSnapshot> Result)
{
if (Result.Error.Code ==
ELocusDeveloperErrorCode::StaleRevision)
{
// Reread before reconsidering the mutation.
}
});
});
FLocusDeveloperCreateNoteRequest Request;
Request.Scope = ELocusDeveloperScope::Private;
Request.Title = TEXT("Local investigation");
Request.Body = TEXT("Not shared with the project repository.");
Request.Tags = {TEXT("investigation")};
FLocusDeveloperRequestHandle Handle = Locus->CreateNote(
MoveTemp(Request),
[](TLocusDeveloperResult<FLocusDeveloperNoteSnapshot> Result)
{
if (Result.IsSuccess())
{
const FLocusDeveloperNoteIdentifier Identity =
Result.Value->Identity; // GUID + Private scope
}
});

Kapsam filtreleri de aynı ölçüde açıktır. All, Özel içeriği kapsar; bir araç Özel içeriği dahil etmemeliyse Shared isteyin.

FLocusDeveloperCreatePinRequest Request;
Request.Scope = ELocusDeveloperScope::Shared;
Request.WorldAssetPath = TEXT("/Game/Maps/Main.Main");
Request.WorldLabel = TEXT("Main");
Request.Location = FVector(120.0, 40.0, 180.0);
Request.Title = TEXT("Check encounter cover");
Request.PinType = ELocusDeveloperPinType::Issue;
FLocusDeveloperRequestHandle Handle = Locus->CreatePin(
MoveTemp(Request),
[](TLocusDeveloperResult<FLocusDeveloperPinSnapshot> Result)
{
if (!Result.IsSuccess())
{
UE_LOG(LogTemp, Warning, TEXT("Pin create failed: %s"),
LexToString(Result.Error.Code));
}
});

Pin oluşturmak, desteklenen, kayıtlı ve projeye ait bir dünya gerektirir. Meta veri güncellemeleri konumu, dünyayı, çapayı, görünümü ve kapsamı korur.

İşlem matrisi, kimlik sözleşmesi, hata sınıflandırması, revizyonlar ve işlem durumu için Developer API genel bakışına bakın.