/// <summary> /// Unloads <see cref="CursorMaker"/>, <see cref="ResourceGetter"/> and <see cref="CursorTools"/>. /// </summary> public static void Unload() { if (!m_initialized) { return; } if (addedCursorLabelTexts != null) { BraveOptionsMenuItem menu = UIRootPrefab.transform.Find("OptionsMenuPanelDave").Find("CentralOptionsPanel").Find("GameplayOptionsScrollablePanel").Find("CursorSelectorPanel").GetComponent <BraveOptionsMenuItem>(); foreach (string str in addedCursorLabelTexts) { CursorTools.Remove(ref menu.labelOptions, str); } if (GameUIRoot.Instance != null) { BraveOptionsMenuItem instanceMenu = GameUIRoot.Instance.transform.Find("OptionsMenuPanelDave").Find("CentralOptionsPanel").Find("GameplayOptionsScrollablePanel").Find("CursorSelectorPanel").GetComponent <BraveOptionsMenuItem>(); foreach (string str in addedCursorLabelTexts) { CursorTools.Remove(ref instanceMenu.labelOptions, str); } } addedCursorLabelTexts.Clear(); addedCursorLabelTexts = null; } if (addedCursorTextures != null) { foreach (Texture2D texture in addedCursorTextures) { CursorTools.Remove(ref UIRootPrefab.GetComponentInChildren <GameCursorController>().cursors, texture); } if (GameUIRoot.Instance != null) { foreach (Texture2D texture in addedCursorTextures) { CursorTools.Remove(ref GameUIRoot.Instance.GetComponentInChildren <GameCursorController>().cursors, texture); } } addedCursorTextures.Clear(); addedCursorTextures = null; } if (GameUIRoot.Instance != null && GameUIRoot.Instance.GetComponent <UIRootProcessedFlag>() != null) { UnityEngine.Object.Destroy(GameUIRoot.Instance.GetComponent <UIRootProcessedFlag>()); } CursorTools.Unload(); ResourceGetter.Unload(); dfManagerStartHook?.Dispose(); UIRootPrefab = null; m_initialized = false; }
/// <summary> /// Initializes <see cref="CursorMaker"/>, <see cref="ResourceGetter"/> and <see cref="CursorTools"/>. /// </summary> public static void Init() { if (m_initialized) { return; } addedCursorLabelTexts = new List <string>(); addedCursorTextures = new List <Texture2D>(); CursorTools.Init(); ResourceGetter.Init(); UIRootPrefab = CursorTools.LoadAssetFromAnywhere <GameObject>("UI Root").GetComponent <GameUIRoot>(); dfManagerStartHook = new Hook( typeof(dfGUIManager).GetMethod("Start"), typeof(CursorMaker).GetMethod("DFManagerStartHook") ); if (GameUIRoot.Instance != null) { GameUIRoot.Instance.gameObject.GetOrAddComponent <UIRootProcessedFlag>(); } m_initialized = true; }
/// <summary> /// Builds a cursor using the <see cref="Texture2D"/> with the project filepath of <paramref name="cursorTexPath"/> as it's texture. /// </summary> /// <param name="cursorTexPath">The project filepath to your cursor's texture.</param> public static void BuildCursor(string cursorTexPath) { BuildCursor(ResourceGetter.GetTextureFromResource(cursorTexPath)); }