Quantcast
Channel: Questions in topic: "dll"
Viewing all articles
Browse latest Browse all 706

How to assign a function to UnityEvent without the use of lambdas?

$
0
0
I have a piece of C# code which I am to convert into `C++/CLI` for the purpose of connecting `C#` with `C++`. Here's the code:-

using UnityEngine; using UnityEngine.Events; public class A { public void Func1(int index) { } public void Func2() { } } public class B : MonoBehaviour { UnityEvent event; private void Start() { A aClass = new A(); event.AddListener(() => A.Func1(index)); // This event needs to be without lambdas event.AddListener(A.Func2); } }

Since I am going to convert this code to `C++/CLI`, I won't be able to use lambdas as they are not allowed. I also need to pass the specific index that is to be determined by `Start()`, so I cannot access the index from other functions too.

EDIT: I can't use local functions too but since they are not allowed in `C++/CLI`.

Viewing all articles
Browse latest Browse all 706

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>