Skip to content

pjc0247/uver

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 

Repository files navigation

uver

Code transformation for Unity/C#

Monkey Patching

The example below demonstrates how to Monkey Patch existing method.

class CrazyMathPatch : Interceptor {
    public override bool IsTransformable(MethodData method)
        // parameters(0, 0) is not important because they never be evaluated.
        => Match(method, () => Mathf.Max(0, 0)); 

    public float Max(float a, float b) {
        return Environment.TickCount % 2 == 1 ?
            a : b;
    }
}

Aspect Oriented Programming

class ProfileSampleAspect : Aspect {
  public override string attributeName => "TestAttribute";
  
  public override object Call(params object[] args) {
     Profiler.BeginSample("SAMPLE");
      var ret = CallOrigin(args);
     Profiler.EndSample();
     
     return ret;
  }
}

About

Code transformation for Unity/C#

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages