羅馬繞道
羅馬繞道
CC#
Created by 羅馬繞道 on 8/24/2023 in #help
❔ Compiler cannot infer lambda return type
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using TMPro;
using Cysharp.Threading.Tasks;

public class Title : MonoBehaviour
{
void Start() {
StartCoroutine(ShowTitles());
}

IEnumerator ShowTitles() {
string[] words = {"The", "White", "Christmas", "welcomes", "you!"};
foreach (var pack in words.Select((word) => {
var obj = GameObject.Find(word);
var render = obj.GetComponent<MeshRenderer>();
Material mat = render.materials[0];

var colour = mat.GetColor("_Color");
float H, S, V;
Color.RGBToHSV(colour, out H, out S, out V);
mat.SetColor("_Color", Color.HSVToRGB(H, S, 1));

return new {mat, H, S, V};
})) {
int x = 10;
for (int i=0; i < x; i++) {
yield return new WaitForSeconds(0.1f);

pack.mat.SetColor("_Color", Color.HSVToRGB(pack.H, pack.S, pack.V / (float)x));
}
}
}
}
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using TMPro;
using Cysharp.Threading.Tasks;

public class Title : MonoBehaviour
{
void Start() {
StartCoroutine(ShowTitles());
}

IEnumerator ShowTitles() {
string[] words = {"The", "White", "Christmas", "welcomes", "you!"};
foreach (var pack in words.Select((word) => {
var obj = GameObject.Find(word);
var render = obj.GetComponent<MeshRenderer>();
Material mat = render.materials[0];

var colour = mat.GetColor("_Color");
float H, S, V;
Color.RGBToHSV(colour, out H, out S, out V);
mat.SetColor("_Color", Color.HSVToRGB(H, S, 1));

return new {mat, H, S, V};
})) {
int x = 10;
for (int i=0; i < x; i++) {
yield return new WaitForSeconds(0.1f);

pack.mat.SetColor("_Color", Color.HSVToRGB(pack.H, pack.S, pack.V / (float)x));
}
}
}
}
\Avatar\Title.cs(25,20): error CS1662: Cannot convert lambda expression to intended delegate type because some of the return types in the block are not implicitly convertible to the delegate return type
\Avatar\Title.cs(25,20): error CS1662: Cannot convert lambda expression to intended delegate type because some of the return types in the block are not implicitly convertible to the delegate return type
7 replies