M
M
MrAfitol2021-09-30 20:29:23
C++ / C#
MrAfitol, 2021-09-30 20:29:23

Distinct() does not work in the game, what should I do?

In the unity emulator, this function removes duplicates, and when assembling in the game, he does not want to remove

public Dropdown dd;
    Resolution[] res;
    

    void Start()
    {
        Resolution [] resolution = Screen.resolutions;
        res = resolution.Distinct().ToArray();

        string[] strRes = new string[res.Length];
        for (int i = 0; i < res.Length; i++)
        {
            strRes[i] = res[i].width.ToString() + "x" + res[i].height.ToString();
        }
        dd.AddOptions(strRes.ToList());
    }


Screenshot from the emulator:
6155f37e468c9261303347.png

From the game:
6155f3b90f0cf944996589.png

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
mletov, 2021-09-30
@mletov

Try to do something like this (only instead of ResolutionName the correct property name)

Screen.resolutions.Select(x => x.ResolutionName).Distinct();

Maybe your other item properties are different, and therefore does not work correctly.
Well, check it out:
https://www.codeproject.com/Questions/748930/Disti...
https://stackoverflow.com/questions/1365748/distin...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question