playMaker

Author Topic: Is it possible to set the FullscreenMode from Playmaker?  (Read 2498 times)

holyfingers

  • Playmaker Newbie
  • *
  • Posts: 34
  • 3D-artist and fledgling Unity Dev.
    • holyfingers.co.uk
Is it possible to set the FullscreenMode from Playmaker?
« on: September 22, 2016, 12:09:48 PM »
Hello there,

I'm trying to make a little action to set the Fullscreen Mode from within a settings menu in my game, this is what I've got so far:

Code: [Select]
using System;
using UnityEngine;

namespace HutongGames.PlayMaker.Actions
{
[ActionCategory("ScreenSettings")]
[Tooltip("Sets the fullscreen mode to either Exclusive or FullscreenWindow on various platforms.")]
public class SetFullscreenMode : FsmStateAction
{

[Tooltip("Fullscreen Mode")]
public UnityEditor.D3D9FullscreenMode dx9FullscreenMode;
public UnityEditor.D3D11FullscreenMode dx11FullscreenMode;
public UnityEditor.MacFullscreenMode macFullscreenMode;


public override void Reset()
{

dx9FullscreenMode = UnityEditor.D3D9FullscreenMode.FullscreenWindow;
dx11FullscreenMode = UnityEditor.D3D11FullscreenMode.FullscreenWindow;
macFullscreenMode = UnityEditor.MacFullscreenMode.FullscreenWindow;

}

public override void OnEnter()
{
UnityEditor.D3D11FullscreenMode = dx11FullscreenMode.Value;


}
}
}

I'm having difficulty setting the values, currently getting a "`System.Enum.Value' is inaccessible due to its protection level" error message?

If anyone has any ideas I'd be super grateful,

Cheers,

Nick
Twitter: @holyfingers

Fat Pug Studio

  • Beta Group
  • Hero Member
  • *
  • Posts: 1294
    • Fat Pug Studio
Re: Is it possible to set the FullscreenMode from Playmaker?
« Reply #1 on: September 22, 2016, 01:47:52 PM »
Have you checked out the unity scripting reference?

https://docs.unity3d.com/ScriptReference/Screen-fullScreen.html
Available for Playmaker work

Alex Chouls

  • Administrator
  • Hero Member
  • *****
  • Posts: 4000
  • Official Playmaker Support
    • LinkedIn
Re: Is it possible to set the FullscreenMode from Playmaker?
« Reply #2 on: September 22, 2016, 03:43:06 PM »
You have to define the enum type using the ObjectTypeAttribute:

[ObjectType(typeof(UnityEditor.D3D9FullscreenMode))]
public UnityEditor.D3D9FullscreenMode dx9FullscreenMode;

However you're going to run into other problems since UnityEditor is unavailable in builds! It is only available in the Editor.


holyfingers

  • Playmaker Newbie
  • *
  • Posts: 34
  • 3D-artist and fledgling Unity Dev.
    • holyfingers.co.uk
Re: Is it possible to set the FullscreenMode from Playmaker?
« Reply #3 on: September 22, 2016, 04:12:37 PM »
Ah, thanks Alex, that makes sense.

There are apparently command line arguments for setting borderless or exclusive mode when running standalone builds, so I assume there must be some other way of setting it outside of the editor? There doesn't seem to be any documentation I can find though!

I'll maybe leave it for the moment and see if it's updated in a future Unity!

Thanks again,

Nick
Twitter: @holyfingers