diff --git a/Source/Engine/Scripting/ManagedCLR/MClass.cpp b/Source/Engine/Scripting/ManagedCLR/MClass.cpp index 90e1c0d9f..53fe1b358 100644 --- a/Source/Engine/Scripting/ManagedCLR/MClass.cpp +++ b/Source/Engine/Scripting/ManagedCLR/MClass.cpp @@ -373,7 +373,7 @@ MObject* MClass::CreateInstance(void** params, uint32 numParams) #endif } -bool MClass::HasAttribute(MClass* monoClass) +bool MClass::HasAttribute(const MClass* monoClass) const { #if USE_MONO MonoCustomAttrInfo* attrInfo = GET_CUSTOM_ATTR(); @@ -383,7 +383,7 @@ bool MClass::HasAttribute(MClass* monoClass) #endif } -bool MClass::HasAttribute() +bool MClass::HasAttribute() const { #if USE_MONO MonoCustomAttrInfo* attrInfo = GET_CUSTOM_ATTR(); @@ -393,7 +393,7 @@ bool MClass::HasAttribute() #endif } -MObject* MClass::GetAttribute(MClass* monoClass) +MObject* MClass::GetAttribute(const MClass* monoClass) const { #if USE_MONO MonoCustomAttrInfo* attrInfo = GET_CUSTOM_ATTR(); diff --git a/Source/Engine/Scripting/ManagedCLR/MClass.h b/Source/Engine/Scripting/ManagedCLR/MClass.h index d6da7f707..f75c6dce4 100644 --- a/Source/Engine/Scripting/ManagedCLR/MClass.h +++ b/Source/Engine/Scripting/ManagedCLR/MClass.h @@ -14,7 +14,7 @@ private: #if USE_MONO MonoClass* _monoClass; - void* _attrInfo = nullptr; + mutable void* _attrInfo = nullptr; #endif const MAssembly* _assembly; @@ -271,20 +271,20 @@ public: /// /// The attribute class to check. /// True if has attribute of that class type, otherwise false. - bool HasAttribute(MClass* monoClass); + bool HasAttribute(const MClass* monoClass) const; /// /// Checks if class has an attribute of any type. /// /// True if has any custom attribute, otherwise false. - bool HasAttribute(); + bool HasAttribute() const; /// /// Returns an instance of an attribute of the specified type. Returns null if the class doesn't have such an attribute. /// /// The attribute class to take. /// The attribute object. - MObject* GetAttribute(MClass* monoClass); + MObject* GetAttribute(const MClass* monoClass) const; /// /// Returns an instance of all attributes connected with given class. Returns null if the class doesn't have any attributes. diff --git a/Source/Engine/Scripting/Object.cs b/Source/Engine/Scripting/Object.cs index f35f3fffd..cc4b7e6e5 100644 --- a/Source/Engine/Scripting/Object.cs +++ b/Source/Engine/Scripting/Object.cs @@ -151,6 +151,17 @@ namespace FlaxEngine return Internal_TryFindObject(ref id, typeof(T)) as T; } + /// + /// Tries to find the object by the given identifier. Searches only registered scene objects. + /// + /// Unique ID of the object. + /// Type of the object. + /// Found object or null if missing. + public static Object TryFind(ref Guid id, Type type) + { + return Internal_TryFindObject(ref id, type); + } + /// /// Destroys the specified object and clears the reference variable. /// The object obj will be destroyed now or after the time specified in seconds from now. diff --git a/Source/Tools/Flax.Build/Bindings/BindingsGenerator.CSharp.cs b/Source/Tools/Flax.Build/Bindings/BindingsGenerator.CSharp.cs index 1f907606b..549e55d2d 100644 --- a/Source/Tools/Flax.Build/Bindings/BindingsGenerator.CSharp.cs +++ b/Source/Tools/Flax.Build/Bindings/BindingsGenerator.CSharp.cs @@ -16,6 +16,8 @@ namespace Flax.Build.Bindings private static readonly HashSet CSharpUsedNamespaces = new HashSet(); private static readonly List CSharpUsedNamespacesSorted = new List(); + public static event Action GenerateCSharpTypeInternals; + internal static readonly Dictionary CSharpNativeToManagedBasicTypes = new Dictionary() { // Language types @@ -1098,6 +1100,8 @@ namespace Flax.Build.Bindings } } + GenerateCSharpTypeInternals?.Invoke(buildData, classInfo, contents, indent); + // Nested types foreach (var apiTypeInfo in classInfo.Children) { @@ -1276,6 +1280,8 @@ namespace Flax.Build.Bindings contents.Append(indent).AppendLine("}"); } + GenerateCSharpTypeInternals?.Invoke(buildData, structureInfo, contents, indent); + // Nested types foreach (var apiTypeInfo in structureInfo.Children) { @@ -1417,6 +1423,8 @@ namespace Flax.Build.Bindings contents.Append(");").AppendLine(); } + GenerateCSharpTypeInternals?.Invoke(buildData, interfaceInfo, contents, indent); + // End indent = indent.Substring(0, indent.Length - 4); contents.AppendLine(indent + "}"); diff --git a/Source/Tools/Flax.Build/Build/DotNet/Builder.DotNet.cs b/Source/Tools/Flax.Build/Build/DotNet/Builder.DotNet.cs index bee75928c..47402131d 100644 --- a/Source/Tools/Flax.Build/Build/DotNet/Builder.DotNet.cs +++ b/Source/Tools/Flax.Build/Build/DotNet/Builder.DotNet.cs @@ -11,6 +11,8 @@ namespace Flax.Build { static partial class Builder { + public static event Action> BuildDotNetAssembly; + private static void BuildTargetDotNet(RulesAssembly rules, TaskGraph graph, Target target, Platform platform, TargetConfiguration configuration) { // Check if use custom project file @@ -142,7 +144,7 @@ namespace Flax.Build } } - private static void BuildDotNet(TaskGraph graph, BuildData buildData, NativeCpp.BuildOptions buildOptions, string name, List sourceFiles, HashSet fileReferences = null) + private static void BuildDotNet(TaskGraph graph, BuildData buildData, NativeCpp.BuildOptions buildOptions, string name, List sourceFiles, HashSet fileReferences = null, IGrouping binaryModule = null) { // Setup build options var buildPlatform = Platform.BuildTargetPlatform; @@ -250,6 +252,8 @@ namespace Flax.Build task.CommandArguments = $"/noconfig /shared @\"{responseFile}\""; } + BuildDotNetAssembly?.Invoke(graph, buildData, buildOptions, task, binaryModule); + // Copy referenced assemblies foreach (var srcFile in buildOptions.ScriptingAPI.FileReferences) { @@ -336,7 +340,7 @@ namespace Flax.Build } // Build assembly - BuildDotNet(graph, buildData, buildOptions, binaryModuleName + ".CSharp", sourceFiles, fileReferences); + BuildDotNet(graph, buildData, buildOptions, binaryModuleName + ".CSharp", sourceFiles, fileReferences, binaryModule); } } }