コード例 #1
0
ファイル: CursorMaker.cs プロジェクト: SpecialAPI/CursorAPI
 /// <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;
 }
コード例 #2
0
ファイル: CursorMaker.cs プロジェクト: SpecialAPI/CursorAPI
 /// <summary>
 /// Builds a cursor using <paramref name="cursorTex"/> as it's texture.
 /// </summary>
 /// <param name="cursorTex">The cursor's texture.</param>
 public static void BuildCursor(Texture2D cursorTex)
 {
     if (addedCursorTextures == null || addedCursorLabelTexts == null)
     {
         Init();
     }
     CursorTools.Add(ref UIRootPrefab.GetComponentInChildren <GameCursorController>().cursors, cursorTex);
     CursorTools.Add(ref UIRootPrefab.transform.Find("OptionsMenuPanelDave").Find("CentralOptionsPanel").Find("GameplayOptionsScrollablePanel").Find("CursorSelectorPanel").GetComponent <BraveOptionsMenuItem>().labelOptions, "[sprite \"" +
                     cursorTex.name + "\"]");
     if (GameUIRoot.Instance != null)
     {
         CursorTools.Add(ref GameUIRoot.Instance.GetComponentInChildren <GameCursorController>().cursors, cursorTex);
         CursorTools.Add(ref GameUIRoot.Instance.transform.Find("OptionsMenuPanelDave").Find("CentralOptionsPanel").Find("GameplayOptionsScrollablePanel").Find("CursorSelectorPanel").GetComponent <BraveOptionsMenuItem>().labelOptions, "[sprite \"" +
                         cursorTex.name + "\"]");
         GameUIRoot.Instance.gameObject.GetOrAddComponent <UIRootProcessedFlag>();
     }
     addedCursorTextures.Add(cursorTex);
     addedCursorLabelTexts.Add("[sprite \"" + cursorTex.name + "\"]");
     UIRootPrefab.Manager.DefaultAtlas.AddNewItemToAtlas(cursorTex);
 }
コード例 #3
0
ファイル: CursorMaker.cs プロジェクト: SpecialAPI/CursorAPI
 /// <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;
 }