Quantcast
Channel: Answers by "Peter G"
Viewing all articles
Browse latest Browse all 90

Answer by Peter G

$
0
0
The problem is that a mutual conversion exists. To quote the [MSDN page][1] on your error.> In a conditional statement, you must be able to convert the types on either side of the : operator. Also, there cannot be mutual conversion routines; you only need one conversion. There cannot be mutual conversions. Since each one can be implicitly cast into the other, the compiler doesn't know which one to choose. In your case, you'd think that the compiler could infer the correct conversion based on the type that you are assigning the value to, but you can't assume that will work every time because this is also valid (using type inference I mean. You'll still get the error) : var d_ray_color = do_fire ? Character.ray_color : Color.white; Now does the compiler convert the `Character.ray_color` to a `Color` or does it convert `Color.white` to a `Color32`? That's why there's an issue. Fortunately it's an easy fix. Just specify which type you want by casting one to the other. Color d_ray_color = do_fire ? (Color)Character.ray_color : Color.white; [1]: http://msdn.microsoft.com/en-us/library/1yaky37f(v=vs.90).aspx

Viewing all articles
Browse latest Browse all 90

Trending Articles



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