1212
1313namespace UKUIHelper
1414{
15- [ BepInPlugin ( "zed.uk.uihelper" , "UK UI Helper" , "0.6.2 " ) ]
15+ [ BepInPlugin ( "zed.uk.uihelper" , "UK UI Helper" , "0.7.0 " ) ]
1616 public class UIHelper : BaseUnityPlugin
1717 {
18+ private DefaultControls . Resources resources ;
1819 private Sprite sprite , checkMarkSprite , dropDownSprite ;
1920 private Font font ;
2021
@@ -24,6 +25,7 @@ public class UIHelper : BaseUnityPlugin
2425 private void Awake ( )
2526 {
2627 UnityEngine . SceneManagement . SceneManager . sceneLoaded += Scene ;
28+ resources = new DefaultControls . Resources ( ) ;
2729 instance = this ;
2830 path = System . Reflection . Assembly . GetAssembly ( typeof ( UIHelper ) ) . Location ;
2931 workDir = Path . GetDirectoryName ( path ) ;
@@ -39,6 +41,9 @@ private void Awake()
3941 checkMarkSprite = Sprite . Create ( texture2 , new Rect ( 0 , 0 , 64 , 64 ) , new Vector2 ( 0.5f , 0.5f ) , 64f , 0 , SpriteMeshType . Tight ) ;
4042 texture3 . LoadImage ( File . ReadAllBytes ( workDir + "\\ Sprites\\ Dropdown.png" ) ) ;
4143 dropDownSprite = Sprite . Create ( texture3 , new Rect ( 0 , 0 , 64 , 64 ) , new Vector2 ( 0.5f , 0.5f ) , 64f , 0 , SpriteMeshType . Tight ) ;
44+ resources . background = sprite ;
45+ resources . checkmark = checkMarkSprite ;
46+ resources . dropdown = dropDownSprite ;
4247 Logger . LogInfo ( "Done" ) ;
4348 }
4449 void Scene ( UnityEngine . SceneManagement . Scene scene , UnityEngine . SceneManagement . LoadSceneMode loadSceneMode )
@@ -76,6 +81,7 @@ public static GameObject CreateButton()
7681 text . name = "Text" ;
7782 text . GetComponent < RectTransform > ( ) . SetParent ( blank . GetComponent < RectTransform > ( ) ) ;
7883 text . GetComponent < RectTransform > ( ) . SetAnchor ( AnchorPresets . StretchAll ) ;
84+ text . GetComponent < RectTransform > ( ) . sizeDelta = Vector2 . zero ;
7985 text . GetComponent < RectTransform > ( ) . SetPivot ( PivotPresets . MiddleCenter ) ;
8086 text . GetComponent < Text > ( ) . text = "Button" ;
8187 text . GetComponent < Text > ( ) . fontSize = 32 ;
@@ -100,19 +106,17 @@ public static GameObject CreateText()
100106 blank . GetComponent < Text > ( ) . color = Color . black ;
101107 return blank ;
102108 }
103- /* public static GameObject CreateDropdown()
109+ public static GameObject CreateDropdown ( )
104110 {
105- bool tmp = instance.isTMPPresent;
106- GameObject blank = new GameObject();
107- blank.name = "Dropdown";
108- blank.AddComponent<RectTransform>();
109- blank.AddComponent<CanvasRenderer>();
110- blank.GetComponent<RectTransform>().sizeDelta = new Vector2(200,50);
111- blank.GetComponent<RectTransform>().pivot = new Vector2(0.5f,0.5f);
112- blank.GetComponent<RectTransform>().anchorMin = new Vector2(0.5f,0.5f);
113- blank.GetComponent<RectTransform>().anchorMax = new Vector2(0.5f,0.5f);
111+ GameObject blank = DefaultControls . CreateDropdown ( instance . resources ) ;
112+ Text [ ] texts = blank . GetComponents < Text > ( ) ;
113+ foreach ( Text txt in texts )
114+ {
115+ txt . color = Color . black ;
116+ txt . fontSize = 24 ;
117+ }
114118 return blank ;
115- }*/
119+ }
116120 public static GameObject CreateInputField ( )
117121 {
118122 GameObject blank = CreateImage ( ) ;
0 commit comments