1
votes

Can someone help me

PlayerSettings.SetGraphicsAPIs (BuildTarget.Android, TargetGlesGraphics.OpenGLES_2_0);

gives me this compile error :

Assets/_Developer/JEONG/Editor/BuildEditor.cs(776,18): error CS1502: The best overloaded method match for `UnityEditor.PlayerSettings.SetGraphicsAPIs(UnityEditor.Buil‌​dTarget, UnityEngine.Rendering.GraphicsDeviceType[])' has some invalid arguments

I don't know why but i follow the documentation in Unity

2
You don't know why what ? Can you please copy the full error message into your question ? - Pac0
@Pac0 Assets/_Developer/JEONG/Editor/BuildEditor.cs(776,18): error CS1502: The best overloaded method match for `UnityEditor.PlayerSettings.SetGraphicsAPIs(UnityEditor.BuildTarget, UnityEngine.Rendering.GraphicsDeviceType[])' has some invalid arguments - NoobProgrammer
The error tells you clearly that the second parameter needs to be an array, not a single value, so you should change TargetGlesGraphics.OpenGLES_2_0 to new[]{TargetGlesGraphics.OpenGLES_2_0} - UnholySheep
@UnholySheep so its something like this PlayerSettings.SetGraphicsAPIs (BuildTarget.Android, new[]{TargetGlesGraphics.OpenGLES_2_0}); it doesnt work - NoobProgrammer
Right, you are actually using the wrong enum type here as well - it needs to be GraphicsDeviceType.OpenGLES2 instead of TargetGlesGraphics.OpenGLES_2_0 (and in the array form as per my previous comment) - UnholySheep

2 Answers

1
votes

You should call it like that :

PlayerSettings.SetGraphicsAPIs (BuildTarget.Android, new [] { GraphicsDeviceType.OpenGLES3 });

As per the error message, the function is expecting an array of GraphicsDeviceType. Since you want only one device type, you still have to provide an array where there is one element.

Also, the value is GraphicsDeviceType.OpenGLES3 (full name with namespace : UnityEngine.Rendering.GraphicsDeviceType.OpenGLES3 ), and not TargetGlesGraphics.Whatever .

You can see in error message that it expects a value as an array of GraphicsDeviceType, so I searched the unity doc to find this :

https://docs.unity3d.com/ScriptReference/Rendering.GraphicsDeviceType.html

1
votes

Thank you sir Pac but i tried this one

PlayerSettings.SetGraphicsAPIs (BuildTarget.Android, new [] {UnityEngine.Rendering.GraphicsDeviceType.OpenGLES2});

and it works . Thank you also to everyone that help me. Sorry for my bad english