Hello, Creators,
I know there is thread about this issue, but there is something missing I can´t figure out what it is.
I have followed the tutorial about creating custom Actions and changes of resolution. I just want a toggle option to switch from fullscreen to windowed mode and the other way around.
First of all I created a global variable 9: IsFullScreen link to Options data. (9 is the variable´s ID, which I used in the script bellow).
Then I createad a Toggle button in the Options Menu - Toggle type: variable - Global boolean var: IsFullScreen
Action list on click: ToggleFullScreen . Here I added the custom action ActionIsFullScreen which uses the following script:
using UnityEngine;
using System.Collections.Generic;
using UnityEditor;
namespace AC
{
[System.Serializable]
public class ActionIsFullScreen : Action
{
// Declare properties here
public override ActionCategory Category { get { return ActionCategory.Custom; }}
public override string Title { get { return "IsFullScreen"; }}
public override string Description { get { return "This is a blank Action template."; }}
// Declare variables here
override public float Run()
{
bool isFullScreen = GlobalVariables.GetIntegerValue (9) == 0; // Replace '0' with your own variable's ID number
if (isFullScreen)
{
Screen.SetResolution(1920, 1080, isFullScreen);
KickStarter.playerMenus.RecalculateAll();
}
return 0f;
}
public override void Skip ()
{
Run ();
}
#if UNITY_EDITOR
public override void ShowGUI ()
{
// Action-specific Inspector GUI code here
}
public override string SetLabel ()
{
// (Optional) Return a string used to describe the specific action's job.
return string.Empty;
}
#endif
}
}
It looks like you're new here. If you want to get involved, click one of these buttons!
Comments
When I build the game and click the toggle button there is no change. I need help with this because I messed something and the game just runs in windowed mode.
Unity version is 2019.4.12f1 - Adventure Creator v1.76.1
Thanks.
Hello again,
As I have seen the latest AC version includes a Fullscreen option, I updated the project through a backup to Unity 2022.3.18f1 and AC 1.83 (with some issues but I will deal with them).
The Fullscreen button it just says Fullscreen label but it doesn´t have any properties or doesn´t run a custom script, action list or similar.
Your script references the variable as an Integer - but you've created a Bool in your Variables Manager.
You can use this instead in your Action:
IIRC you can configure this in Unity's Player Settings.
The latest AC includes a "Graphic Options" menu template, which you can install through the New Game Wizard's Modify existing option. This includes a full-screen checkbox, and can hide/remove the other UI objects from the prefab if not needed.
What I meant is the checkbox is missing.
Where, in the GraphicOptionsUI prefab? It's named tglFullScreen.
The label that sits beisde it should be a child of this object.
The Toggle component in the UI prefab is not linked to an AC element in the Menu Manager - the behaviour is controlled through the script attached to the prefab's root.
I understand what you say but in this case the next button in the "GraphicOptions" elements menu after FullScreenLabel is Quality PresetLabel.
There is no Toggle FullScreen there or in the properties as a child.
It's not in the Menu Manager as an element. It only exists in the UI prefab - see the "Linked Canvas prefab" field in the Menu's properties.
The Toggle is inside the UI prefab. It's behaviour is controlled by script - not through the Menu.
You can install this template using the New Game Wizard.
I see it now, thank you. I am used to use Adventure Creator as a source.
Anyways, I can´t check if the script whit your correction works because it seems the button doesn´t execute de Action List where the Custom Action is. I will see what I can do and post some updates.
The first Action (0) in the ActionList wasn´t fixed to the upperleft corner, I could move it around. I fixed it with a new one (adding it to the start didn´t work either). It executes the ActionList now but there is no change in the screen.
More updates later.
Since I couldn´t find the problem, I tried with the upgraded version and the graphic options works like a charm. It is marvellous, but...
Now the footsteps are gone because of the new version. I read the manual, added a couple, sounds: change footsteps, and nothing. I was happy with the ones I used before and now I have to add different surfaces and different sounds and check if that works.
And the script for the Steam Achievements gives me a new problem.
I found a solution but as reward I encounter new problems. It is always like that. I am done with games, it is a shame but it honestly drains me.
Changes made to AC you need to be aware of when upgrading can be found in the "Upgrade notes" sections of the Changelog.
Footstep Sounds went through a necessary upgrade in v1.81.0. The component now relies on the Surfaces system to determine what sounds get played, which makes for automation based on e.g. the floor's Material. The Manual's "Footstep sounds" chapter should cover what's involved.
Did you try my suggested script change in your previous version? An update isn't necessary just for the full-screen option.