Playmaker Forum

PlayMaker Help & Tips => PlayMaker Help => Topic started by: holyfingers on September 22, 2016, 12:09:48 PM

Title: Is it possible to set the FullscreenMode from Playmaker?
Post by: holyfingers on September 22, 2016, 12:09:48 PM
Hello there,

I'm trying to make a little action to set the Fullscreen Mode (https://docs.unity3d.com/ScriptReference/D3D11FullscreenMode.html) 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
Title: Re: Is it possible to set the FullscreenMode from Playmaker?
Post by: Fat Pug Studio on September 22, 2016, 01:47:52 PM
Have you checked out the unity scripting reference?

https://docs.unity3d.com/ScriptReference/Screen-fullScreen.html
Title: Re: Is it possible to set the FullscreenMode from Playmaker?
Post by: Alex Chouls 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.

Title: Re: Is it possible to set the FullscreenMode from Playmaker?
Post by: holyfingers 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