using GadgetCore.API; using GadgetCore.API.ConfigMenu; using System; using UnityEngine; using UnityEngine.SceneManagement; namespace ScreenshotMode { [Gadget("ScreenshotMode", RequiredOnClients: false)] public class ScreenshotMode : Gadget { public const string MOD_VERSION = "1.0"; // Set this to the version of your mod. public const string CONFIG_VERSION = "1.0"; // Increment this whenever you change your mod's config file. public override IGadgetConfigMenu GetConfigMenu() { return null; } public override string GetModDescription() { return "A mod that adds options to hide hud elements and the player to be able to take clean screenshots."; } protected override void Initialize() { Logger.Log("Screenshot Mode v" + Info.Mod.Version); Core.logger = Logger; SceneManager.sceneLoaded += OnSceneLoaded; } internal static void OnSceneLoaded(Scene scene, LoadSceneMode mode) { if (scene.buildIndex == 1) { AddOptions(); } } private static void AddOptions() { try { var options = GameObject.Find("Main Camera").transform.Find("menuPause").Find("optionsmenu").gameObject; var fulls = options.transform.Find("bFullscreen"); fulls.localPosition = new Vector3(0.446f, 0.284f, 0.39f); var mode = GameObject.Instantiate(options.transform.Find("bFullscreen").gameObject); mode.transform.SetParent(options.transform); mode.transform.localPosition = new Vector3(0.446f, 0.431f, 0.39f); mode.transform.localEulerAngles = fulls.transform.localEulerAngles; mode.transform.localScale = fulls.transform.localScale; mode.name = "bScreenshotMode"; Update(); } catch (Exception e) { Core.logger.Log(e); } } internal static void Update() { var text = ""; switch (Core.state) { case 0: text = "Screenshot Mode"; SetHudState(true); SetPlayerState(true); break; case 1: text = "No Hud"; SetHudState(false); SetPlayerState(true); break; case 2: text = "No Hud/Player"; SetHudState(false); SetPlayerState(false); break; } var options = GameObject.Find("Main Camera").transform.Find("menuPause").Find("optionsmenu").gameObject; var mode = options.transform.Find("bScreenshotMode"); mode.transform.GetChild(0).GetComponent().text = text; mode.transform.GetChild(0).GetChild(0).GetComponent().text = text; } private static void SetPlayerState(bool visible) { if (MenuScript.player != null) { SetState(MenuScript.player.transform.Find("e").Find("newplayer"), visible); SetState(MenuScript.player.transform.Find("W"), visible); } } private static void SetHudState(bool visible) { SetState(GameObject.Find("Main Camera").transform.Find("inventoryBar"), visible); SetState(GameObject.Find("Main Camera").transform.Find("barObjective"), visible); SetState(GameObject.Find("Main Camera").transform.Find("buildBar"), visible); SetState(GameObject.Find("Main Camera").transform.Find("txtBuild"), visible, 0); } private static void SetState(Transform t, bool v, int defaultRot = -180) { t.localEulerAngles = new Vector3(t.localEulerAngles.x, v ? defaultRot : 90, t.localEulerAngles.z); } } }