How do I set the canvas scale mode in script?

I know there is help here : Redirect to... title of new-page and in various other places, but I can’t find a single example of it’s usage anywhere. Everything I tried gives me errors.

Specifically I want to set my canvasScaler scale mode to be ScaleWithScreenSize.

eg…

myCanvasScaler.ScaleMode=ScaleMode.ScaleWithScreenSize; 

won’t work.

Thanks

Zach’s answers is correct.Thank You! But if you are looking for Javascript it’s…

myCanvasScaler.uiScaleMode = myCanvasScaler.ScaleMode.ScaleWithScreenSize;

It’s slightly elusive, but the scripting API of CanvasScaler can be found here.

I think this will produce the desired result:

UnityEngine.UI.CanvasScaler c = GetComponent<UnityEngine.UI.CanvasScaler>();
c.uiScaleMode = UnityEngine.UI.CanvasScaler.ScaleMode.ScaleWithScreenSize;

It’s worth noting that the documentation page for CanvasScaler.uiScaleMode links to the wrong ScaleMode (the correct one is this one); anyone know how to report this?