Skip to content

How can I create a new instance of a Ray struct? #336

Discussion options

You must be logged in to vote

I managed to do this, but i am myself still a little bit confused about how the unbox work maybe @vfsfitvnm will have a good explanation for all of us

import 'frida-il2cpp-bridge';

const log = console.log.bind(console);

function Vector3(x = 0, y = 0, z = 0) {
  const Vector3 = Il2Cpp.domain.assembly('UnityEngine.CoreModule').image.class('UnityEngine.Vector3');
  const vector3 = Vector3.alloc();
  vector3.method('.ctor', 3).invoke(x, y, z);
  return vector3;
}

function Ray(origin = Vector3(), direction = Vector3(0, 0, 1)) {
  const Ray = Il2Cpp.domain.assembly('UnityEngine.CoreModule').image.class('UnityEngine.Ray');
  const ray = Ray.alloc();
  ray.method('.ctor', 2).invoke(origin.unbox()

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by Patrick-van-Halm
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants