Skip to content

Commit

Permalink
.NET: Fix non-static fields not getting proxied
Browse files Browse the repository at this point in the history
  • Loading branch information
praydog committed May 13, 2024
1 parent 695c1de commit 2f3673f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
2 changes: 1 addition & 1 deletion csharp-api/REFrameworkNET/Proxy.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ public ref class Proxy : public Reflection::DispatchProxy, public IProxy, public
bool isValueType = !IsManaged() && GetTypeDefinition()->IsValueType();

if (methodAttribute->FieldFacade == REFrameworkNET::FieldFacadeType::Getter) {
return field->GetDataBoxed(iobject->GetAddress(), isValueType);
return field->GetDataBoxed(targetMethod->ReturnType, iobject->GetAddress(), isValueType);
}

field->SetDataBoxed(iobject->GetAddress(), args[0], isValueType);
Expand Down
18 changes: 14 additions & 4 deletions csharp-api/test/Test/Test.cs
Original file line number Diff line number Diff line change
Expand Up @@ -117,13 +117,14 @@ public static void Entry() {
//var range = via.RangeI.REFType.CreateInstance(0).As<via.RangeI>();
var range = REFrameworkNET.ValueType.New<via.RangeI>();
var testVec = REFrameworkNET.ValueType.New<via.vec3>();
System.Console.WriteLine("Test vec x before: " + testVec.x);

System.Console.WriteLine("Test vec before: " + testVec.x + " " + testVec.y + " " + testVec.z);

testVec.x = 1.0f;
testVec.y = 2.0f;
testVec.z = 3.0f;
System.Console.WriteLine("Test vec x after: " + testVec.x);
System.Console.WriteLine("Test vec y after: " + testVec.y);
System.Console.WriteLine("Test vec z after: " + testVec.z);

System.Console.WriteLine("Test vec after: " + testVec.x + " " + testVec.y + " " + testVec.z);

var axisXStatic = via.vec3.AxisX;
var axisYStatic = via.vec3.AxisY;
Expand All @@ -142,6 +143,15 @@ public static void Entry() {
var mesh = (meshes.get_Item(i) as IObject).As<via.render.Mesh>();
mesh.set_DrawRaytracing(true);
}

var characterManager = API.GetManagedSingletonT<app.CharacterManager>();
if (characterManager.ManualPlayer != null) {
var playergo = characterManager.ManualPlayer.get_GameObject();
var transform = playergo.get_Transform();
var position = transform.get_Position();

REFrameworkNET.API.LogInfo("Player position: " + position.x + " " + position.y + " " + position.z);
}
}

public static void TryEnableFrameGeneration() {
Expand Down

0 comments on commit 2f3673f

Please sign in to comment.