Quantcast
Channel: Questions in topic: "il2cpp"
Viewing all articles
Browse latest Browse all 598

il2cpp generics and overloads

$
0
0
My issue is that I have a fairly automated decoding of google protocol buffers that I need to convert at the end of the chain. It all works well in Mac/Windows but fails in iOS due to (I think) il2cpp The code looks like this: public static class PotConverter { public static void Convert(float a, int b) { Debug.Log("called the typed convert"); } } public class Porto { T a; M b; public Porto(T _a, M _b) { a = _a; b = _b; } public void doThat() { PotConverter.Convert((dynamic)a, (dynamic)b); } } public class lala : MonoBehaviour { Porto a = new Porto(1.0f,2); void OnEnable () { a.doThat(); } I do need **dynamic** as generics loose track of types in this situation (generic class calling an overloaded function set). In iOS, seemingly, **dynamic** is not supported. Is there a way around it? how can it be implemented in a decent way for il2cpp platforms? Right now I am doing a horror for iOS, which of course is error prone, doesn't scale, etc, etc: public static void Convert(U a, V b) { if (a.GetType()== typeof( float)) { Debug.Log("first we float manhattan"); if(b.GetType() == typeof(int)) { Debug.Log("then we float berlin"); Convert(Get(a), Get(b)); } } else Debug.Log("no conversion available");} Can it be done better? thanks!

Viewing all articles
Browse latest Browse all 598

Trending Articles



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