// Fill out your copyright notice in the Description page of Project Settings. #include "EleriAssetCategory.h" #include "AssetToolsModule.h" #include "IAssetTools.h" #include "Internationalization/Text.h" #include "Modules/ModuleManager.h" #define LOCTEXT_NAMESPACE "EleriAssetCategory" namespace EleriAssetCategory { const FAssetCategoryPath& Get() { // A function-local static rather than a namespace-scope global: LOCTEXT has to run once the // localization system is up, which this module's static initialisers cannot count on. static const FAssetCategoryPath Category(LOCTEXT("Category", "Eleri")); return Category; } uint32 GetLegacyCategoryBit() { // The new Content Browser places a factory by the category path of the asset definition behind the // class it supports. The older one still files the Add menu by an EAssetTypeCategories bitmask, and // a bit for a category of our own only exists once someone has registered it. Doing that here, once // and lazily, is what keeps the two paths pointing at the same entry instead of at two nearly // identical ones. static const uint32 Bit = []() { IAssetTools& AssetTools = FModuleManager::LoadModuleChecked(TEXT("AssetTools")).Get(); // The key the engine groups by is the source string of the path's first entry rather than the // localized one, so an editor running in another language still lands in the same category. const FAssetCategoryPath& Category = Get(); return (uint32)AssetTools.RegisterAdvancedAssetCategory( FName(*FTextInspector::GetSourceString(Category.GetCategoryText())), Category.GetCategoryText()); }(); return Bit; } } #undef LOCTEXT_NAMESPACE