- Home /
What is var.Select()?
Im following a shading tutorial http://three-eyed-games.com/2019/03/18/gpu-path-tracing-in-unity-part-3/ and it uses something like this
var indices = mesh.GetIndices(0); _indices.AddRange(indices.Select(index => index + firstVertex));
And unity has a problem at "indices.Select()" Because int[].Select "does not exist"
How do i make that not happen?
Answer by Bunny83 · May 17 at 01:36 PM
Select is a standard extension method that comes with the Linq extension. You have to add using System.Linq;
to the top of your script in order to use them. This looks like an oversight to me that they didn't include it in the code snippets. Though on the other hand when it comes to plain C# certain things has to be assumed as basic knowledge. So you can not always start at the very bottom.
The Select method return a new collection (IEnumerable) which applies the provided selection callback to each element. So the new collection will go through all the indices and add "firstVertex" as an offset to the index.
Your answer
Follow this Question
Related Questions
error CS0019: Operator `-' cannot be applied to operands of type `System.DateTime' and `string' 1 Answer
Changing a GUI String to read as a INT 2 Answers
Change weapons / gameObject / Int with one button / key 1 Answer
using char to extract integer numbers from a list - [UnityScript] 1 Answer
IndexOutOfRangeException help on debug 3 Answers