Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

problem with calling typed method with arguments #61

Open
merlin1277 opened this issue Mar 6, 2020 · 2 comments
Open

problem with calling typed method with arguments #61

merlin1277 opened this issue Mar 6, 2020 · 2 comments
Labels

Comments

@merlin1277
Copy link

merlin1277 commented Mar 6, 2020

Hello,

Generate bindings breaks when trying to generate the binding for a "method<>(args)", it works well with "method<>()".

{
				"Name": "UnityEngine.Object",
				"Methods": [
					{
						"Name": "Instantiate",
						"ParamTypes": [
							"UnityEngine.Object"
						],
                        "GenericParams": [
                            {
                                "Types": [
								 "UnityEngine.Component"
                                   
                                ]
                            },
                            {
                                "Types": [
                                    "UnityEngine.GameObject"
                                ]
                            },
                            {
                                "Types": [
                                    "UnityEngine.MeshRenderer"
                                ]
                            },
                            {
                                "Types": [
                                    "UnityEngine.ParticleSystem"
                                ]
                            },
                            {
                                "Types": [
                                    "UnityEngine.Light"
                                ]
                            },
                            {
                                "Types": [
                                    "UnityEngine.AudioSource"
                                ]
                            },
                            {
                                "Types": [
                                    "UnityEngine.TextMesh"
                                ]
                            }
                        ]
					}
				]
			}

it doesnt find a matching method . the c# method is public static T Instantiate<>(T original) where T : Object; , on the UnityEngine.Object type;

Thank you for helping ,

Regards,

Merlin

@jacksondunstan
Copy link
Owner

It looks like the code generator isn't finding the method because it's generic so it's types are T instead of Object. I'd happily accept a PR with a fix.

@majorika
Copy link
Contributor

majorika commented Feb 13, 2021

simple workaround :
Set ParamTypes to ["UnityEngine.T"],
however UnityEngine.T does not seem appropriate.

I found a new problem with Instantiate. ex)

GameObject a = GameObject::CreatePrimitive(PrimitiveType::Sphere);
a.AddComponent<MyGame::BaseBallScript>();
GameObject b = UnityEngine::Object::Instantiate<UnityEngine::GameObject>(a);

b instantiated with a BaseBallScript, but b's BaseBallScript.transform.GetInstanceID() will be return a's InstanceID.
a will move 2x faster, b doesn't move.

root cause :
a's CppHandle value also copied to b's when using Instantiate method. It's ok while calling base constructor, but between base constructor to Awake, CppHandle value overwritten to original's.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants