The equivalent F# code is the following:
member this.Fade() =
seq {
for f in 1.0 .. -0.1 .. 0.0 do
let c = renderer.material.color
c.alpha <- f
renderer.material.color <- c
yield ()
} :> IEnumerable
Note that unlike in C#, you have to yield some value, so we're using unit (()
). The seq
expression will have the type seq<unit>
, which is an alias for IEnumerable<Unit>
. To make it conform to the type Unity is expecting, we just need to upcast it by using :> IEnumerable