private static void ChangeUIScaling() { if ((bool)expUIScaling.GetValue()) { ModUI.GetCanvas().GetComponent <CanvasScaler>().matchWidthOrHeight = float.Parse(tuneScaling.GetValue().ToString()); } }
public void CreateConsoleUI() { AssetBundle ab = LoadAssets.LoadBundle(this, "console.unity3d"); UI = ab.LoadAsset <GameObject>("MSCLoader Console.prefab"); Texture2D cursor = ab.LoadAsset <Texture2D>("resizeCur.png"); ab.Unload(false); UI = Object.Instantiate(UI); UI.name = "MSCLoader Console"; console = UI.AddComponent <ConsoleView>(); console.viewContainer = UI.transform.GetChild(0).gameObject; console.inputField = console.viewContainer.transform.GetChild(0).gameObject.GetComponent <InputField>(); console.viewContainer.transform.GetChild(1).gameObject.GetComponent <Button>().onClick.AddListener(() => console.runCommand()); console.logTextArea = console.viewContainer.transform.GetChild(2).GetChild(0).gameObject.GetComponent <Text>(); console.viewContainer.transform.GetChild(4).gameObject.AddComponent <ConsoleUIResizer>().logview = console.viewContainer.transform.GetChild(2).gameObject; console.viewContainer.transform.GetChild(4).gameObject.GetComponent <ConsoleUIResizer>().scrollbar = console.viewContainer.transform.GetChild(3).gameObject; console.viewContainer.transform.GetChild(4).gameObject.GetComponent <ConsoleUIResizer>().cursor = cursor; EventTrigger trigger = console.viewContainer.transform.GetChild(4).gameObject.GetComponent <EventTrigger>(); EventTrigger.Entry entry = new EventTrigger.Entry(); entry.eventID = EventTriggerType.PointerEnter; entry.callback.AddListener((eventData) => { console.viewContainer.transform.GetChild(4).gameObject.GetComponent <ConsoleUIResizer>().OnMouseEnter(); }); trigger.delegates.Add(entry); entry = new EventTrigger.Entry(); entry.eventID = EventTriggerType.PointerExit; entry.callback.AddListener((eventData) => { console.viewContainer.transform.GetChild(4).gameObject.GetComponent <ConsoleUIResizer>().OnMouseExit(); }); trigger.delegates.Add(entry); UI.transform.SetParent(ModUI.GetCanvas().transform, false); }
public void CreateSettingsUI() { AssetBundle ab = AssetBundle.CreateFromMemoryImmediate(Properties.Resources.settingsui); //AssetBundle ab = LoadAssets.LoadBundle(this, "settingsui.unity3d"); UI = ab.LoadAsset <GameObject>("MSCLoader Settings.prefab"); ModButton = ab.LoadAsset <GameObject>("ModButton.prefab"); ModButton_Invalid = ab.LoadAsset <GameObject>("ModButton_Invalid.prefab"); ModLabel = ab.LoadAsset <GameObject>("ModViewLabel.prefab"); KeyBind = ab.LoadAsset <GameObject>("KeyBind.prefab"); modSettingsButton = ab.LoadAsset <GameObject>("Button_ms.prefab"); //For mod settings Checkbox = ab.LoadAsset <GameObject>("Checkbox.prefab"); setBtn = ab.LoadAsset <GameObject>("Button.prefab"); slider = ab.LoadAsset <GameObject>("Slider.prefab"); textBox = ab.LoadAsset <GameObject>("TextBox.prefab"); header = ab.LoadAsset <GameObject>("Header.prefab"); UI = UnityEngine.Object.Instantiate(UI); UI.AddComponent <ModUIDrag>(); UI.name = "MSCLoader Settings"; settings = UI.AddComponent <SettingsView>().Setup(this); modUpdateButton = UnityEngine.Object.Instantiate(modSettingsButton); modUpdateButton.name = "MSCLoader Update button"; modUpdateButton.transform.SetParent(ModUI.GetCanvas().transform, false); modUpdateButton.GetComponent <Button>().onClick.AddListener(() => CheckForUpdateButton()); modUpdateButton.transform.GetChild(0).GetComponent <Text>().text = "Check Updates"; modUpdateButton.SetActive((bool)modSetButton.GetValue()); modUpdateButton.AddComponent <SetButtonPos>().button = modUpdateButton; modSettingsButton = UnityEngine.Object.Instantiate(modSettingsButton); modSettingsButton.name = "MSCLoader Settings button"; modSettingsButton.transform.SetParent(ModUI.GetCanvas().transform, false); modSettingsButton.GetComponent <Button>().onClick.AddListener(() => settings.ToggleVisibility()); modSettingsButton.SetActive((bool)modSetButton.GetValue()); ab.Unload(false); // FREDTWEAK Transform canvas = GameObject.Find("MSCLoader Canvas").transform.Find("MSCLoader Settings/MSCLoader SettingsContainer/Settings/SettingsView"); canvas.GetChild(0).gameObject.SetActive(false); canvas.GetChild(1).gameObject.SetActive(false); canvas.GetChild(2).gameObject.SetActive(false); GameObject.Find("MSCLoader Canvas").transform.Find("MSCLoader Settings/MSCLoader SettingsContainer/ModKeyBinds/KeyBindsView/Text").GetComponent <Text>().text = "<color=lime><b>LMB</b></color> - Cancel\n<color=lime><b>RMB</b></color> - Set to None"; }
private static void ExpUIScaling() { if ((bool)expUIScaling.GetValue()) { ModUI.GetCanvas().GetComponent <CanvasScaler>().screenMatchMode = CanvasScaler.ScreenMatchMode.MatchWidthOrHeight; ChangeUIScaling(); } else { ModUI.GetCanvas().GetComponent <CanvasScaler>().screenMatchMode = CanvasScaler.ScreenMatchMode.Shrink; } }
void LoadCoreAssets() { AssetBundle ab = AssetBundle.CreateFromMemoryImmediate(Properties.Resources.core); guiskin = ab.LoadAsset <GUISkin>("MSCLoader.guiskin"); ModUI.messageBox = ab.LoadAsset <GameObject>("MSCLoader MB.prefab"); mainMenuInfo = ab.LoadAsset <GameObject>("MSCLoader Info.prefab"); GameObject loadingScreen = Resources.FindObjectsOfTypeAll <GameObject>().FirstOrDefault(x => x.name == "Loading" && x.transform.root == x.transform); TextMesh textMesh = loadingScreen.GetComponentsInChildren <TextMesh>(true)[0]; GameObject loadingPrefab = ab.LoadAsset <GameObject>("LoadingMods.prefab"); loading = Instantiate(loadingPrefab); loading.SetActive(false); loading.name = "MSCLoader loading screen"; loading.transform.SetParent(ModUI.GetCanvas().transform, false); loading.GetComponent <Image>().color = Color.black; Text loadingText = loading.transform.GetChild(0).GetComponent <Text>(); loadingText.text = "NOW LOADING MODS IN YEAR 1995..."; loadingText.font = textMesh.font; loadingText.color = textMesh.color; loadingText.transform.localScale = new Vector3(2f, 2f, 2f); loading.transform.GetChild(1).gameObject.SetActive(false); loading.transform.GetChild(2).gameObject.SetActive(false); loading.transform.GetChild(3).gameObject.SetActive(false); GameObject loadingMetaPrefab = ab.LoadAsset <GameObject>("MSCLoader pbar.prefab"); loadingMeta = Instantiate(loadingMetaPrefab); loadingMeta.SetActive(false); loadingMeta.name = "MSCLoader pbar"; loadingMeta.transform.SetParent(ModUI.GetCanvas().transform, false); Destroy(loadingPrefab); Destroy(loadingMetaPrefab); ab.Unload(false); }
void MainMenuInfo() { Text info, mf; GameObject mainMenuInfoPrefab = mainMenuInfo; mainMenuInfo = Instantiate(mainMenuInfoPrefab); Destroy(mainMenuInfoPrefab); mainMenuInfo.name = "MSCLoader Info"; menuInfoAnim = mainMenuInfo.GetComponent <Animator>(); menuInfoAnim.SetBool("isHidden", false); info = mainMenuInfo.transform.GetChild(0).gameObject.GetComponent <Text>(); mf = mainMenuInfo.transform.GetChild(1).gameObject.GetComponent <Text>(); modUpdates = mainMenuInfo.transform.GetChild(2).gameObject.GetComponent <Text>(); info.text = $"MSCLoader <color=cyan>v{ModLoaderVersion}</color> (Fredman Edition)"; mf.text = $"<color=orange>Mods folder:</color> {ModsFolder}"; modUpdates.text = string.Empty; mainMenuInfo.transform.SetParent(ModUI.GetCanvas().transform, false); }
public SettingsView Setup(ModSettings_menu ms) { modSettingsMenu = ms; settingViewContainer = transform.GetChild(0).gameObject; backButton = settingViewContainer.transform.GetChild(0).GetChild(1).gameObject; modInfo = settingViewContainer.transform.GetChild(2).gameObject; modKeybinds = settingViewContainer.transform.GetChild(1).gameObject; keybindsList = modKeybinds.transform.GetChild(0).GetChild(4).gameObject; modSettings = settingViewContainer.transform.GetChild(4).gameObject; settingsList = modSettings.transform.GetChild(0).GetChild(4).gameObject; modList = settingViewContainer.transform.GetChild(3).gameObject; modView = modList.transform.GetChild(0).gameObject; GameObject modSettingsView = modInfo.transform.GetChild(0).gameObject; disableMod = modSettingsView.transform.GetChild(2).GetComponent <Toggle>(); coreModCheckbox = settingViewContainer.transform.GetChild(6).GetChild(0).GetComponent <Toggle>(); modCount = settingViewContainer.transform.GetChild(6).GetChild(1).GetComponent <Text>(); infoText = modSettingsView.transform.GetChild(0).GetComponent <Text>(); descriptionText = modSettingsView.transform.GetChild(8).GetComponent <Text>(); nexusLink = modSettingsView.transform.GetChild(4).GetComponent <Button>(); rdLink = modSettingsView.transform.GetChild(5).GetComponent <Button>(); ghLink = modSettingsView.transform.GetChild(6).GetComponent <Button>(); backButton.GetComponent <Button>().onClick.AddListener(() => GoBack()); disableMod.onValueChanged.AddListener(DisableMod); coreModCheckbox.onValueChanged.AddListener(delegate { ToggleCoreCheckbox(); }); settingViewContainer.transform.GetChild(0).GetChild(2).GetComponent <Button>().onClick.AddListener(() => ToggleVisibility()); transform.SetParent(ModUI.GetCanvas().transform, false); SetVisibility(false); return(this); }
public void CreateSettingsUI() { AssetBundle ab = LoadAssets.LoadBundle(this, "settingsui.unity3d"); UI = ab.LoadAsset <GameObject>("MSCLoader Settings.prefab"); ModButton = ab.LoadAsset <GameObject>("ModButton.prefab"); ModButton_Invalid = ab.LoadAsset <GameObject>("ModButton_Invalid.prefab"); ModLabel = ab.LoadAsset <GameObject>("ModViewLabel.prefab"); KeyBind = ab.LoadAsset <GameObject>("KeyBind.prefab"); Button_ms = ab.LoadAsset <GameObject>("Button_ms.prefab"); // For mod settings Checkbox = ab.LoadAsset <GameObject>("Checkbox.prefab"); setBtn = ab.LoadAsset <GameObject>("Button.prefab"); slider = ab.LoadAsset <GameObject>("Slider.prefab"); textBox = ab.LoadAsset <GameObject>("TextBox.prefab"); header = ab.LoadAsset <GameObject>("Header.prefab"); UI = GameObject.Instantiate(UI); UI.AddComponent <ModUIDrag>(); UI.name = "MSCLoader Settings"; settings = UI.AddComponent <SettingsView>(); settings.ms = this; settings.settingViewContainer = UI.transform.GetChild(0).gameObject; settings.modList = settings.settingViewContainer.transform.GetChild(3).gameObject; settings.modView = settings.modList.transform.GetChild(0).gameObject; settings.modInfo = settings.settingViewContainer.transform.GetChild(2).gameObject; GameObject ModSettingsView = settings.modInfo.transform.GetChild(0).gameObject; settings.ModKeyBinds = settings.settingViewContainer.transform.GetChild(1).gameObject; settings.keybindsList = settings.ModKeyBinds.transform.GetChild(0).GetChild(4).gameObject; settings.modSettings = settings.settingViewContainer.transform.GetChild(4).gameObject; settings.modSettingsList = settings.modSettings.transform.GetChild(0).GetChild(4).gameObject; settings.coreModCheckbox = settings.settingViewContainer.transform.GetChild(6) .GetChild(0) .GetComponent <Toggle>(); settings.coreModCheckbox.onValueChanged.AddListener( delegate { settings.ToggleCoreCheckbox(); }); settings.noOfMods = settings.settingViewContainer.transform.GetChild(6) .GetChild(1) .GetComponent <Text>(); settings.goBackBtn = settings.settingViewContainer.transform.GetChild(0).GetChild(1).gameObject; settings.goBackBtn.GetComponent <Button>().onClick.AddListener( () => settings.goBack()); settings.settingViewContainer.transform.GetChild(0) .GetChild(2) .GetComponent <Button>() .onClick.AddListener(() => settings.toggleVisibility()); settings.DisableMod = ModSettingsView.transform.GetChild(2).GetComponent <Toggle>(); settings.DisableMod.onValueChanged.AddListener(settings.disableMod); settings.InfoTxt = ModSettingsView.transform.GetChild(0).GetComponent <Text>(); settings.descriptionTxt = ModSettingsView.transform.GetChild(8).GetComponent <Text>(); settings.nexusLink = ModSettingsView.transform.GetChild(4).GetComponent <Button>(); settings.rdLink = ModSettingsView.transform.GetChild(5).GetComponent <Button>(); settings.ghLink = ModSettingsView.transform.GetChild(6).GetComponent <Button>(); UI.transform.SetParent(ModUI.GetCanvas().transform, false); settings.SetVisibility(false); Button_ms = GameObject.Instantiate(Button_ms); Button_ms.name = "MSCLoader Settings button"; Button_ms.transform.SetParent(ModUI.GetCanvas().transform, false); Button_ms.GetComponent <Button>().onClick.AddListener( () => settings.toggleVisibility()); Button_ms.SetActive(true); if (!(bool)modSetButton.GetValue()) { Button_ms.SetActive(false); } ab.Unload(false); }