diff --git a/Source/Engine/Debug/DebugCommands.cpp b/Source/Engine/Debug/DebugCommands.cpp index f4cfa1d86..baf4eb024 100644 --- a/Source/Engine/Debug/DebugCommands.cpp +++ b/Source/Engine/Debug/DebugCommands.cpp @@ -265,8 +265,23 @@ namespace if (auto* managedModule = dynamic_cast(module)) { const MClass* attribute = ((NativeBinaryModule*)GetBinaryModuleFlaxEngine())->Assembly->GetClass("FlaxEngine.DebugCommand"); + const MMethod* getInfo = attribute->GetMethod("GetInfoInternal", 1); ASSERT_LOW_LAYER(attribute); const auto& classes = managedModule->Assembly->GetClasses(); +#define FILTER(type) \ + if (useClass && type->GetVisibility() != MVisibility::Public) \ + continue; \ + MObject* attr = type->GetAttribute(attribute); \ + if (!useClass && !attr) \ + continue; \ + if (attr) \ + { \ + bool hide = false; \ + void* params[1] = { &hide }; \ + getInfo->Invoke(attr, params, nullptr); \ + if (hide) \ + continue; \ + } for (const auto& e : classes) { MClass* mclass = e.Value; @@ -292,10 +307,7 @@ namespace name.StartsWith("add_") || name.StartsWith("remove_")) continue; - if (!useClass && !method->HasAttribute(attribute)) - continue; - if (useClass && method->GetVisibility() != MVisibility::Public) - continue; + FILTER(method); auto& commandData = Commands.AddOne(); BuildName(commandData, mclass, method->GetName()); @@ -309,10 +321,7 @@ namespace { if (!field->IsStatic()) continue; - if (!useClass && !field->HasAttribute(attribute)) - continue; - if (useClass && field->GetVisibility() != MVisibility::Public) - continue; + FILTER(field); auto& commandData = Commands.AddOne(); BuildName(commandData, mclass, field->GetName()); @@ -326,10 +335,7 @@ namespace { if (!property->IsStatic()) continue; - if (!useClass && !property->HasAttribute(attribute)) - continue; - if (useClass && property->GetVisibility() != MVisibility::Public) - continue; + FILTER(property); auto& commandData = Commands.AddOne(); BuildName(commandData, mclass, property->GetName()); @@ -338,6 +344,7 @@ namespace commandData.MethodSet = property->GetSetMethod(); } } +#undef FILTER } else #endif diff --git a/Source/Engine/Debug/DebugCommands.cs b/Source/Engine/Debug/DebugCommands.cs index ed17d01dc..72ae1d4e1 100644 --- a/Source/Engine/Debug/DebugCommands.cs +++ b/Source/Engine/Debug/DebugCommands.cs @@ -22,6 +22,15 @@ namespace FlaxEngine [AttributeUsage(AttributeTargets.Class | AttributeTargets.Method | AttributeTargets.Field | AttributeTargets.Property)] public sealed class DebugCommand : Attribute { + /// + /// Hides the entry from the Debug Commands. Can be used to exclude specific members from class marked as debug commands contains as a whole. + /// + public bool Hide; + + internal void GetInfoInternal(out bool hide) + { + hide = Hide; + } } partial class DebugCommands diff --git a/Source/Engine/Engine/Screen.h b/Source/Engine/Engine/Screen.h index f8203ac3d..41eb45f3f 100644 --- a/Source/Engine/Engine/Screen.h +++ b/Source/Engine/Engine/Screen.h @@ -40,14 +40,14 @@ DECLARE_SCRIPTING_TYPE_NO_SPAWN(Screen); /// /// The screen-space position. /// The game viewport position. - API_FUNCTION() static Float2 ScreenToGameViewport(const Float2& screenPos); + API_FUNCTION(Attributes="DebugCommand(Hide=true)") static Float2 ScreenToGameViewport(const Float2& screenPos); /// /// Converts the game viewport position to the screen-space position. /// /// The game viewport position. /// The screen-space position. - API_FUNCTION() static Float2 GameViewportToScreen(const Float2& viewportPos); + API_FUNCTION(Attributes="DebugCommand(Hide=true)") static Float2 GameViewportToScreen(const Float2& viewportPos); /// /// Sets the window size (in screen-space, includes DPI scale). diff --git a/Source/Engine/Networking/NetworkManager.h b/Source/Engine/Networking/NetworkManager.h index 467ae2333..f6916fc47 100644 --- a/Source/Engine/Networking/NetworkManager.h +++ b/Source/Engine/Networking/NetworkManager.h @@ -151,14 +151,14 @@ public: /// /// Network connection identifier. /// Found client or null. - API_FUNCTION() static NetworkClient* GetClient(API_PARAM(Ref) const NetworkConnection& connection); + API_FUNCTION(Attributes="DebugCommand(Hide=true)") static NetworkClient* GetClient(API_PARAM(Ref) const NetworkConnection& connection); /// /// Gets the network client with a given identifier. Returns null if failed to find it. /// /// Network client identifier (synchronized on all peers). /// Found client or null. - API_FUNCTION() static NetworkClient* GetClient(uint32 clientId); + API_FUNCTION(Attributes="DebugCommand(Hide=true)") static NetworkClient* GetClient(uint32 clientId); public: ///