I cant use PlayerSettings SetGraphicsAPIs

Viewed 18

I'm making a mobile game and to put an option that improves performance I want to switch between OpenGLE2 and OpenGLE3, the problem I have is that it won't let me build if the script has the UnityEditor, I've read that I have to put it in a folder in Assets, and even though it lets me build I have to leave the script out of my scene and I don't know how to call a script then.

using UnityEditor;
using UnityEngine.Rendering;

public class Prueba
{
    static void PonerELgl2()
    {
        GraphicsDeviceType[] Caca = new GraphicsDeviceType[2];
        Caca[0] = GraphicsDeviceType.OpenGLES2;
        Caca[1] = GraphicsDeviceType.OpenGLES3;
        PlayerSettings.SetGraphicsAPIs(BuildTarget.Android, Caca);
    }
    public void PonerELgl3()
    {
        GraphicsDeviceType[] Caca = new GraphicsDeviceType[2];
        Caca[1] = GraphicsDeviceType.OpenGLES2;
        Caca[0] = GraphicsDeviceType.OpenGLES3;
        PlayerSettings.SetGraphicsAPIs(BuildTarget.Android, Caca);
    }
}

This is my code and I would appreciate if you also tell me how I can call the function from another script that is in the scene or a button.

0 Answers
Related