urho icon indicating copy to clipboard operation
urho copied to clipboard

No GetVar( ) method for Urho.Node class

Open laheller opened this issue 6 years ago • 6 comments

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?

laheller avatar Jun 29 '18 20:06 laheller

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

OmidID avatar Jul 02 '18 07:07 OmidID

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"

laheller avatar Jul 04 '18 12:07 laheller

@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.

OmidID avatar Jul 06 '18 07:07 OmidID

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

laheller avatar Jul 06 '18 08:07 laheller

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

OmidID avatar Jul 06 '18 10:07 OmidID

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

dgzornoza avatar Jan 23 '19 21:01 dgzornoza