It shows how to use classes management.
#include <BNM/UserSettings/GlobalSettings.hpp>
#include <BNM/ClassesManagement.hpp>
#include <BNM/BasicMonoStructures.hpp>
#include <BNM/UnityStructures.hpp>
#include <BNM/Field.hpp>
#include "BNM/ComplexMonoStructures.hpp"
#ifdef BNM_CLASSES_MANAGEMENT
BNM::CompileTimeClassBuilder(BNM_OBFUSCATE_TMP(
"UnityEngine"), BNM_OBFUSCATE_TMP(
"MonoBehaviour"), BNM_OBFUSCATE_TMP(
"UnityEngine.CoreModule")).Build(),
{},
);
void Constructor() {
*this = BNM_ExampleObject();
}
int Value{};
uintptr_t veryImportantValue{0x424E4D};
void Start() {
BNM_LOG_INFO("BNM_ExampleObject::Start! Верен ли veryImportantValue (Is veryImportantValue true): %d", veryImportantValue == 0x424E4D);
}
void *GetReferenceValue(int id, bool *isValid) {
*isValid = false;
BNM_LOG_INFO("BNM_ExampleObject::GetReferenceValue(%d)!", id);
return nullptr;
}
BNM::CompileTimeClassBuilder(BNM_OBFUSCATE_TMP("UnityEngine"), BNM_OBFUSCATE_TMP("IExposedPropertyTable")).Build(),
};
struct Delegates :
BNM::MulticastDelegate<int> *justDelegateDef;
BNM::UnityEngine::UnityAction<int, int> *JustUnityAction;
BNM::Structures::Mono::Action<int, int> *JustAction;
BNM::UnityEngine::UnityEvent<int, int> *JustEvent;
void *logClass;
BNM_CustomClass(Delegates, BNM::CompileTimeClassBuilder(
nullptr, BNM_OBFUSCATE_TMP(
"Delegates")).Build(), {}, {});
void Start() {
BNM_LOG_DEBUG("justDelegateDef: %p", justDelegateDef);
BNM_LOG_DEBUG("JustUnityAction: %p", JustUnityAction);
BNM_LOG_DEBUG("JustAction: %p", JustAction);
BNM_LOG_DEBUG("JustEvent: %p", JustEvent);
if (justDelegateDef) justDelegateDef->
Invoke(10, 60);
if (JustUnityAction) JustUnityAction->Invoke(70, 9);
if (JustAction) JustAction->
Invoke(30, 42);
if (JustEvent) JustEvent->
Invoke(7, 234);
}
};
void OnLoaded_Example_05() {
Class BNM_ExampleObjectClass = BNM_ExampleObject::BNMCustomClass.myClass;
}
#endif
#define BNM_CustomMethod(_method_, _isStatic_, _type_, _name_,...)
Define info about C++ method for il2cpp.
Definition ClassesManagement.hpp:309
#define BNM_CustomClass(_class_, _targetType_, _baseType_, _owner_,...)
Define info of C++ class for il2cpp.
Definition ClassesManagement.hpp:250
#define BNM_CustomMethodMarkAsInvokeHook(_method_)
Mark method to prefer InvokeHook.
Definition ClassesManagement.hpp:330
#define BNM_CallCustomMethodOrigin(_method_,...)
Call method origin, if it exists.
Definition ClassesManagement.hpp:358
#define BNM_CustomMethodSkipTypeMatch(_method_)
Skip method parameters type matching.
Definition ClassesManagement.hpp:348
#define BNM_CustomField(_field_, _type_, _name_)
Define info about C++ field for il2cpp.
Definition ClassesManagement.hpp:280
constexpr DefaultTypeRef Get()
Method that helps to get il2cpp class type from C++ and BNM types.
Definition Defaults.hpp:132
Namespace that holds some basic and the most commonly used C# classes.
Definition BasicMonoStructures.hpp:70
Namespace that holds Unity math and helper structs.
Definition Defaults.hpp:14
Main BNM namespace.
Definition BasicMonoStructures.hpp:16
Class for working with il2cpp classes.
Definition Class.hpp:29
Struct for building CompileTimeClass.
Definition Class.hpp:639
CompileTimeClass Build()
Build CompileTimeClass.
Definition Class.hpp:715
Ret Invoke(Parameters ...parameters)
Invoke delegate.
Definition Delegates.hpp:140
UnityEngine.MonoBehaviour implementation.
Definition UnityStructures.hpp:72
void Invoke(Parameters ...parameters) const
Invoke event.
Definition UnityStructures.hpp:215