public static void Postfix(FejdStartup __instance) { var mainGui = __instance.m_mainMenu; guiBundle = guiBundle ?? EmbeddedAsset.LoadAssetBundle("Assets.valheimtwitchgui"); var prefab = guiBundle.LoadAsset <GameObject>("Valheim Twitch GUI"); gui = UnityEngine.Object.Instantiate(prefab); gui.transform.SetParent(mainGui.transform); guiScript = gui.GetComponent <ValheimTwitchGUIScript>(); guiScript.mainButton.OnClick(() => OnMainButtonClick()); guiScript.refreshRewardButton.OnClick(() => { Plugin.Instance.UpdateRwardsList(); UpdateRewardGrid(); }); guiScript.rewardSettings.OnSettingsChanged += OnRewardSettingschanged; guiScript.addRewardForm.OnSave += OnNewRewardSave; UpdateMainButonText(); UpdateRewardGrid(); ShowUpdatePanel(); LoadShortcuts(); }
private static void Postfix(ref Minimap __instance) { if (Configuration.Current.Map.IsEnabled) { Minimap_AddPin_Patch.shareablePins = new List <Minimap.PinType>() { Minimap.PinType.Icon0, Minimap.PinType.Icon1, Minimap.PinType.Icon2, Minimap.PinType.Icon3, Minimap.PinType.Icon4 }; GameObject iconPanelOld = GameObjectAssistant.GetChildComponentByName <Transform>("IconPanel", __instance.m_largeRoot).gameObject; for (int i = 0; i < 5; i++) { GameObjectAssistant.GetChildComponentByName <Transform>("Icon" + i.ToString(), iconPanelOld).gameObject.SetActive(false); } GameObjectAssistant.GetChildComponentByName <Transform>("Bkg", iconPanelOld).gameObject.SetActive(false); iconPanelOld.SetActive(false); __instance.m_nameInput.gameObject.SetActive(false); if (mapPinBundle == null) { mapPinBundle = AssetBundle.LoadFromStream(EmbeddedAsset.LoadEmbeddedAsset("Assets.Bundles.map-pin-ui")); } GameObject pinEditorPanelParent = mapPinBundle.LoadAsset <GameObject>("MapPinEditor"); pinEditorPanel = GameObject.Instantiate(pinEditorPanelParent.transform.GetChild(0).gameObject); pinEditorPanel.transform.SetParent(__instance.m_largeRoot.transform, false); pinEditorPanel.SetActive(false); pinName = pinEditorPanel.GetComponentInChildren <InputField>(); if (pinName != null) { Debug.Log("Pin Name loaded properly"); } Minimap theInstance = __instance; GameObjectAssistant.GetChildComponentByName <Transform>("OK", pinEditorPanel).gameObject.GetComponent <Button>().onClick.AddListener(delegate { AddPin(ref theInstance); }); GameObjectAssistant.GetChildComponentByName <Transform>("Cancel", pinEditorPanel).gameObject.GetComponent <Button>().onClick.AddListener(delegate { Minimap.instance.m_wasFocused = false; pinEditorPanel.SetActive(false); }); iconSelected = pinEditorPanel.GetComponentInChildren <Dropdown>(); iconSelected.options.Clear(); int ind = 0; List <string> list = new List <string> { "Fire", "Home", "Hammer", "Circle", "Rune" }; foreach (string option in list) { iconSelected.options.Add(new Dropdown.OptionData(option, Minimap.instance.m_icons[ind].m_icon)); ind++; } if (iconSelected != null) { Debug.Log("Dropdown loaded properly"); } sharePin = pinEditorPanel.GetComponentInChildren <Toggle>(); if (sharePin != null) { Debug.Log("Share pin loaded properly"); } if (!Configuration.Current.Map.shareablePins || Configuration.Current.Map.shareAllPins) { sharePin.gameObject.SetActive(false); } } }
public static void Load() { //Load the logo from embedded asset Stream logoStream = EmbeddedAsset.LoadEmbeddedAsset("Assets.logo.png"); Texture2D logoTexture = LoadPng(logoStream); VPlusLogoSprite = Sprite.Create(logoTexture, new Rect(0, 0, logoTexture.width, logoTexture.height), new Vector2(0.5f, 0.5f)); logoStream.Dispose(); }
public static void Load() { norseFont = Resources.FindObjectsOfTypeAll <Font>().FirstOrDefault(fnt => fnt.name == "Norse"); //norseFont = Resources.FindObjectsOfTypeAll<Font>().FirstOrDefault(fnt => fnt.name == "Arial"); modSettingsBundle = AssetBundle.LoadFromStream(EmbeddedAsset.LoadEmbeddedAsset("Assets.Bundles.settings-ui")); modSettingsPanelCloner = modSettingsBundle.LoadAsset <GameObject>("Mod Settings"); enableToggle = modSettingsBundle.LoadAsset <GameObject>("Toggle_Enable"); uiTooltipPrefab = modSettingsBundle.LoadAsset <GameObject>("SettingsTooltip"); keycodeNames = Enum.GetNames(typeof(KeyCode)); modSettingsPanelCloner.SetActive(false); }
public static void Postfix(Player __instance, ref HashSet <string> ___m_shownTutorials) { // Remove old custom tutorial messages int count = ___m_shownTutorials.Count; ___m_shownTutorials.RemoveWhere(hash => hash.StartsWith(Plugin.GUID)); UnityEngine.Debug.Log($"Removed {count - ___m_shownTutorials.Count} messages"); audioSource = __instance.gameObject.AddComponent <AudioSource>(); whistleClip = EmbeddedAsset.LoadAudioClip("Assets.calling-whistle.wav"); Log.Info($"Audio time {audioSource.time}"); }
public static void Load() { //Load the logo from embedded asset Stream logoStream = EmbeddedAsset.LoadEmbeddedAsset("Assets.logo.png"); Texture2D logoTexture = Helper.LoadPng(logoStream); VPlusLogoSprite = Sprite.Create(logoTexture, new Rect(0, 0, logoTexture.width, logoTexture.height), new Vector2(0.5f, 0.5f)); logoStream.Dispose(); //Load the banner from embedded asset Stream bannerStream = EmbeddedAsset.LoadEmbeddedAsset("Assets.ZapHosting.png"); Texture2D bannerTexture = Helper.LoadPng(bannerStream); VPlusBannerSprite = Sprite.Create(bannerTexture, new Rect(0, 0, bannerTexture.width, bannerTexture.height), new Vector2(0.5f, 0.5f)); bannerStream.Dispose(); //Load the bannerfrom embedded asset Stream bannerHoverStream = EmbeddedAsset.LoadEmbeddedAsset("Assets.ZapHosting_hover.png"); Texture2D bannerHoverTexture = Helper.LoadPng(bannerHoverStream); VPlusBannerHoverSprite = Sprite.Create(bannerHoverTexture, new Rect(0, 0, bannerHoverTexture.width, bannerHoverTexture.height), new Vector2(0.5f, 0.5f)); bannerHoverStream.Dispose(); }