ByNameModding / BNM-Android

Modding il2cpp games by classes, methods, field names on Android.
MIT License
176 stars 37 forks source link

BNM_NewStaticMethodInit problem #31

Closed ArifRios1st closed 3 months ago

ArifRios1st commented 3 months ago

i make new class something like this

struct PlayerData : public BNM::UnityEngine::MonoBehaviour {
   BNM_NewClassInit("NewClass", PlayerData, {
      return BNM::LoadClass(OBFUSCATES_BNM("UnityEngine"), 
         OBFUSCATES_BNM("MonoBehaviour"), 
         OBFUSCATES_BNM("UnityEngine.CoreModule"));
         }
      );

   static bool Move(BNM::Structures::Unity::Vector3 pos){
        //do something
        return true;
   }
   BNM_NewStaticMethodInit(BNM::GetType<bool>(), Move, 1, BNM::GetType<BNM::Structures::Unity::Vector3>());
}

in BNM_NewStaticMethodInit(BNM::GetType<bool>(), Move, 1, BNM::GetType<BNM::Structures::Unity::Vector3>()); i got error In template: cannot initialize return object of type 'void *' with an rvalue of type 'bool'

can you help me ? @BNM-Dev

BNM-Dev commented 3 months ago

This thing don't exists in BNM v2.0, so wait for update.

BNM-Dev commented 3 months ago

New API will look like this:

struct PlayerData : public BNM::UnityEngine::MonoBehaviour {
    BNM_CustomClass(PlayerData,
                    BNM::CompileTimeClassBuilder().Class(OBFUSCATE_BNM("NewClass")).Build(),
                    BNM::CompileTimeClassBuilder().Class(OBFUSCATE_BNM("MonoBehaviour"), OBFUSCATE_BNM("UnityEngine"), OBFUSCATE_BNM("UnityEngine.CoreModule")).Build(),
                    {}
    );

    static bool Move(BNM::Structures::Unity::Vector3 pos) {
        // Do something
        return true;
    }

    BNM_CustomMethod(Move, true, BNM::GetType<bool>(), "Move", BNM::GetType<BNM::Structures::Unity::Vector3>());
};
solomode0001 commented 3 months ago

New API will look like this:

struct PlayerData : public BNM::UnityEngine::MonoBehaviour {
    BNM_CustomClass(PlayerData,
                    BNM::CompileTimeClassBuilder().Class(OBFUSCATE_BNM("NewClass")).Build(),
                    BNM::CompileTimeClassBuilder().Class(OBFUSCATE_BNM("MonoBehaviour"), OBFUSCATE_BNM("UnityEngine"), OBFUSCATE_BNM("UnityEngine.CoreModule")).Build(),
                    {}
    );

    static bool Move(BNM::Structures::Unity::Vector3 pos) {
        // Do something
        return true;
    }

    BNM_CustomMethod(Move, true, BNM::GetType<bool>(), "Move", BNM::GetType<BNM::Structures::Unity::Vector3>());
};

I'm so excited for the update!

BNM-Dev commented 3 months ago

v2.0 alpha is out, so I closing this issue.