xamarin / urho

Code to integrate with the Urho3D engine
Other
462 stars 122 forks source link

No GetVar( ) method for Urho.Node class #338

Open laheller opened 6 years ago

laheller commented 6 years ago

The Urho.Node.SetVar(key,value) method looks a bit useless, since there is no Urho.Node.GetVar(key) method. Or at least the last available nuget package version (1.8.93) of UrhoSharp does not provide GetVar method for Urho.Node class. Maybe I am wrong but what is then then the purpose of method SetVariable while we cannot get the value of variable?

OmidID commented 6 years ago

It's looks generator missing method. I'll take a looks.

laheller commented 6 years ago

Quick workaround for GetVar overload which returns a string:

internal class MyNode : Node {
    [DllImport("mono-urho", CallingConvention = CallingConvention.Cdecl)]
    private static extern string Node_GetVar11(IntPtr handle, int key);

    public MyNode(Context c) : base(c) { }

    public string GetVar(StringHash key) {
        return Node_GetVar11(base.Handle, key.Code);
    }
}

Usage:

var key = new StringHash("MyLabel");
var nn = new MyNode(app.Context);
nn.SetVar(key, "MyValue");
Console.WriteLine( nn.GetVar(key) ); // shoud display the string "MyValue"
OmidID commented 6 years ago

@laheller That should be generate because the method you used Node_GetVar11 was changed to Node_GetVar_11 https://github.com/xamarin/urho/blob/master/Bindings/Portable/Generated/binding.cpp#L6576

So on next version your app will be crash.

laheller commented 6 years ago

@OmidID the above is just a workaround for current v1.8.93 version.

OmidID commented 6 years ago

@laheller Yes i understand. that method you used it's generated. so that why it's should be fix by generator.

dgzornoza commented 5 years ago

thanks @OmidID, in v1.9.67 function name is 'Node_GetVar_11'