Forum rules - please read before posting.

Menu toggle getting stuck

Hi,
I have a variable to check whether the game should be set in landscape or portrait mode. However, when you click the button, the actionlist on click runs, but it gets stuck on landscape (the original option, so the text doesnt even change), if you try to click it again nothing happens.

Screenshots: https://imgur.com/a/zq7l6Gf

Code paste:

using System.Collections;
using System.Collections.Generic;
using UnityEngine.UI;
using UnityEngine;
using AC;

public class ViewportPortrait : MonoBehaviour {

[SerializeField] public GameObject uicamera;

// Use this for initialization
void Start()
{
if (AC.GlobalVariables.GetBooleanValue(313,false))
{
Camera.main.rect = new Rect(0, 0.5f, 1f, 0.5f);
Screen.orientation = ScreenOrientation.Portrait;
uicamera.SetActive(true);
Canvas.ForceUpdateCanvases();
}
else
{
Camera.main.rect = new Rect(0, 0, 1f, 1f);
uicamera.SetActive(false);
Screen.orientation = ScreenOrientation.LandscapeLeft;
Canvas.ForceUpdateCanvases();
}
Canvas.ForceUpdateCanvases();
}
}

Im on unity 2018.2.21f1 and the latest version of AC

Comments

  • Are you using the Object: Add or remove Action for the sole purpose of running the code above?

    If this is spawned at runtime, your "uicamera" field likely isn't set.

    Better to make the Start function public, and then use the Object: Call event Action to trigger the function directly, so that it can run each time it's triggered.

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.
Do NOT follow this link or you will be banned from the site!