Nekopletní fix
This commit is contained in:
@@ -6,6 +6,7 @@ using TMPro;
|
||||
#else
|
||||
using TMPro;
|
||||
#endif
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace MegaKoop.UI
|
||||
{
|
||||
@@ -37,6 +38,11 @@ namespace MegaKoop.UI
|
||||
private TMP_Dropdown ddResolution;
|
||||
private Button btnApplySettings;
|
||||
private Button btnBackFromSettings;
|
||||
private Slider slMaster;
|
||||
private Slider slMusic;
|
||||
private Slider slSFX;
|
||||
private Dropdown ddQualityUI;
|
||||
private Dropdown ddResolutionUI;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
@@ -44,25 +50,54 @@ namespace MegaKoop.UI
|
||||
RefreshPanelReferences();
|
||||
|
||||
// Buttons
|
||||
btnNewGame = FindButton("Button_NewGame");
|
||||
btnContinue = FindButton("Button_Continue");
|
||||
btnMultiplayer = FindButton("Button_Multiplayer");
|
||||
btnSettings = FindButton("Button_Settings");
|
||||
btnQuit = FindButton("Button_Quit");
|
||||
btnNewGame = FindButton("Button_NewGame", panelMain ? panelMain.transform : this.transform);
|
||||
btnContinue = FindButton("Button_Continue", panelMain ? panelMain.transform : this.transform);
|
||||
btnMultiplayer = FindButton("Button_Multiplayer", panelMain ? panelMain.transform : this.transform);
|
||||
btnSettings = FindButton("Button_Settings", panelMain ? panelMain.transform : this.transform);
|
||||
btnQuit = FindButton("Button_Quit", panelMain ? panelMain.transform : this.transform);
|
||||
|
||||
// Settings
|
||||
ddQuality = FindDropdown("Dropdown_Quality");
|
||||
tgFullscreen = FindToggle("Toggle_Fullscreen");
|
||||
ddResolution = FindDropdown("Dropdown_Resolution");
|
||||
btnApplySettings = FindButton("Button_ApplySettings");
|
||||
btnBackFromSettings = FindButton("Button_BackFromSettings");
|
||||
ddQuality = FindDropdown("Dropdown_Quality", panelSettings ? panelSettings.transform : this.transform);
|
||||
if (!ddQuality) ddQualityUI = FindUIDropdown("Dropdown_Quality", panelSettings ? panelSettings.transform : this.transform);
|
||||
tgFullscreen = FindToggle("Toggle_Fullscreen", panelSettings ? panelSettings.transform : this.transform);
|
||||
ddResolution = FindDropdown("Dropdown_Resolution", panelSettings ? panelSettings.transform : this.transform);
|
||||
if (!ddResolution) ddResolutionUI = FindUIDropdown("Dropdown_Resolution", panelSettings ? panelSettings.transform : this.transform);
|
||||
btnApplySettings = FindButton("Button_ApplySettings", panelSettings ? panelSettings.transform : this.transform);
|
||||
btnBackFromSettings = FindButton("Button_BackFromSettings", panelSettings ? panelSettings.transform : this.transform);
|
||||
slMaster = FindSlider("Slider_MasterVolume", panelSettings ? panelSettings.transform : this.transform);
|
||||
slMusic = FindSlider("Slider_MusicVolume", panelSettings ? panelSettings.transform : this.transform);
|
||||
slSFX = FindSlider("Slider_SFXVolume", panelSettings ? panelSettings.transform : this.transform);
|
||||
|
||||
if (!btnApplySettings && panelSettings) btnApplySettings = FindButtonByLabel("APPLY", panelSettings.transform);
|
||||
if (!btnBackFromSettings && panelSettings) btnBackFromSettings = FindButtonByLabel("BACK", panelSettings.transform);
|
||||
|
||||
WireEvents();
|
||||
|
||||
InitializeSettingsUI();
|
||||
|
||||
// Ensure initial panels
|
||||
ShowMainMenu();
|
||||
}
|
||||
|
||||
private Dropdown FindUIDropdown(string name, Transform scope = null)
|
||||
{
|
||||
if (scope != null)
|
||||
{
|
||||
var comps = scope.GetComponentsInChildren<Dropdown>(true);
|
||||
foreach (var c in comps)
|
||||
{
|
||||
if (c && c.name == name) return c;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
var all = Resources.FindObjectsOfTypeAll<Dropdown>();
|
||||
foreach (var c in all)
|
||||
{
|
||||
if (c && c.name == name && c.gameObject.scene.IsValid() && c.gameObject.scene.isLoaded) return c;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
// Allow UGUIMenuBuilder to inject panel refs directly
|
||||
public void SetPanels(GameObject main, GameObject settings, GameObject lobby)
|
||||
{
|
||||
@@ -93,32 +128,110 @@ namespace MegaKoop.UI
|
||||
return null;
|
||||
}
|
||||
|
||||
private Button FindButton(string name)
|
||||
private Button FindButton(string name, Transform scope = null)
|
||||
{
|
||||
var go = GameObject.Find(name);
|
||||
return go ? go.GetComponent<Button>() : null;
|
||||
if (scope != null)
|
||||
{
|
||||
var comps = scope.GetComponentsInChildren<Button>(true);
|
||||
foreach (var c in comps)
|
||||
{
|
||||
if (c && c.name == name) return c;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
var all = Resources.FindObjectsOfTypeAll<Button>();
|
||||
foreach (var c in all)
|
||||
{
|
||||
if (c && c.name == name && c.gameObject.scene.IsValid() && c.gameObject.scene.isLoaded) return c;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
private TMP_Dropdown FindDropdown(string name)
|
||||
private TMP_Dropdown FindDropdown(string name, Transform scope = null)
|
||||
{
|
||||
var go = GameObject.Find(name);
|
||||
return go ? go.GetComponent<TMP_Dropdown>() : null;
|
||||
if (scope != null)
|
||||
{
|
||||
var comps = scope.GetComponentsInChildren<TMP_Dropdown>(true);
|
||||
foreach (var c in comps)
|
||||
{
|
||||
if (c && c.name == name) return c;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
var all = Resources.FindObjectsOfTypeAll<TMP_Dropdown>();
|
||||
foreach (var c in all)
|
||||
{
|
||||
if (c && c.name == name && c.gameObject.scene.IsValid() && c.gameObject.scene.isLoaded) return c;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
private Toggle FindToggle(string name)
|
||||
private Toggle FindToggle(string name, Transform scope = null)
|
||||
{
|
||||
var go = GameObject.Find(name);
|
||||
return go ? go.GetComponent<Toggle>() : null;
|
||||
if (scope != null)
|
||||
{
|
||||
var comps = scope.GetComponentsInChildren<Toggle>(true);
|
||||
foreach (var c in comps)
|
||||
{
|
||||
if (c && c.name == name) return c;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
var all = Resources.FindObjectsOfTypeAll<Toggle>();
|
||||
foreach (var c in all)
|
||||
{
|
||||
if (c && c.name == name && c.gameObject.scene.IsValid() && c.gameObject.scene.isLoaded) return c;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private Slider FindSlider(string name, Transform scope = null)
|
||||
{
|
||||
if (scope != null)
|
||||
{
|
||||
var comps = scope.GetComponentsInChildren<Slider>(true);
|
||||
foreach (var c in comps)
|
||||
{
|
||||
if (c && c.name == name) return c;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
var all = Resources.FindObjectsOfTypeAll<Slider>();
|
||||
foreach (var c in all)
|
||||
{
|
||||
if (c && c.name == name && c.gameObject.scene.IsValid() && c.gameObject.scene.isLoaded) return c;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private Button FindButtonByLabel(string label, Transform scope)
|
||||
{
|
||||
if (!scope) return null;
|
||||
var btns = scope.GetComponentsInChildren<Button>(true);
|
||||
for (int i = 0; i < btns.Length; i++)
|
||||
{
|
||||
var t = btns[i].GetComponentInChildren<TextMeshProUGUI>(true);
|
||||
if (t && string.Equals(t.text?.Trim(), label, System.StringComparison.OrdinalIgnoreCase))
|
||||
return btns[i];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private void WireEvents()
|
||||
{
|
||||
if (btnNewGame) btnNewGame.onClick.AddListener(OnNewGame);
|
||||
if (btnContinue) btnContinue.onClick.AddListener(OnContinue);
|
||||
if (btnMultiplayer) btnMultiplayer.onClick.AddListener(OnOpenMultiplayer);
|
||||
if (btnSettings) btnSettings.onClick.AddListener(OnOpenSettings);
|
||||
if (btnQuit) btnQuit.onClick.AddListener(OnQuit);
|
||||
if (btnNewGame) btnNewGame.onClick.AddListener(OnNewGame); else Debug.LogWarning("[UGUIMainMenu] Button_NewGame not found");
|
||||
if (btnContinue) btnContinue.onClick.AddListener(OnContinue); else Debug.LogWarning("[UGUIMainMenu] Button_Continue not found");
|
||||
if (btnMultiplayer) btnMultiplayer.onClick.AddListener(OnOpenMultiplayer); else Debug.LogWarning("[UGUIMainMenu] Button_Multiplayer not found");
|
||||
if (btnSettings) btnSettings.onClick.AddListener(OnOpenSettings); else Debug.LogWarning("[UGUIMainMenu] Button_Settings not found");
|
||||
if (btnQuit) btnQuit.onClick.AddListener(OnQuit); else Debug.LogWarning("[UGUIMainMenu] Button_Quit not found");
|
||||
|
||||
if (btnApplySettings) btnApplySettings.onClick.AddListener(ApplySettings);
|
||||
if (btnBackFromSettings) btnBackFromSettings.onClick.AddListener(ShowMainMenu);
|
||||
if (btnApplySettings) btnApplySettings.onClick.AddListener(OnApplySettings); else Debug.LogWarning("[UGUIMainMenu] Button_ApplySettings not found");
|
||||
if (btnBackFromSettings) btnBackFromSettings.onClick.AddListener(ShowMainMenu); else Debug.LogWarning("[UGUIMainMenu] Button_BackFromSettings not found");
|
||||
|
||||
if (ddQuality) ddQuality.onValueChanged.AddListener(i => { Debug.Log("[UGUIMainMenu] Quality changed to index " + i); ddQuality.RefreshShownValue(); });
|
||||
if (ddResolution) ddResolution.onValueChanged.AddListener(i => { Debug.Log("[UGUIMainMenu] Resolution changed to index " + i); ddResolution.RefreshShownValue(); });
|
||||
if (ddQualityUI) ddQualityUI.onValueChanged.AddListener(i => { Debug.Log("[UGUIMainMenu] UI Quality changed to index " + i); ddQualityUI.RefreshShownValue(); });
|
||||
if (ddResolutionUI) ddResolutionUI.onValueChanged.AddListener(i => { Debug.Log("[UGUIMainMenu] UI Resolution changed to index " + i); ddResolutionUI.RefreshShownValue(); });
|
||||
if (tgFullscreen) tgFullscreen.onValueChanged.AddListener(v => { Debug.Log("[UGUIMainMenu] Fullscreen " + v); });
|
||||
if (slMaster) slMaster.onValueChanged.AddListener(v => { AudioListener.volume = v / 100f; });
|
||||
}
|
||||
|
||||
private void ShowMainMenu()
|
||||
@@ -158,6 +271,7 @@ namespace MegaKoop.UI
|
||||
if (panelMain) panelMain.SetActive(false);
|
||||
if (panelSettings) panelSettings.SetActive(true);
|
||||
if (panelLobby) panelLobby.SetActive(false);
|
||||
Debug.Log("[UGUIMainMenu] Open Settings");
|
||||
}
|
||||
|
||||
private void OnNewGame()
|
||||
@@ -211,19 +325,302 @@ namespace MegaKoop.UI
|
||||
{
|
||||
QualitySettings.SetQualityLevel(ddQuality.value, true);
|
||||
}
|
||||
else if (ddQualityUI)
|
||||
{
|
||||
QualitySettings.SetQualityLevel(ddQualityUI.value, true);
|
||||
}
|
||||
if (tgFullscreen)
|
||||
{
|
||||
Screen.fullScreen = tgFullscreen.isOn;
|
||||
}
|
||||
if (ddResolution)
|
||||
{
|
||||
var opt = ddResolution.options[ddResolution.value].text; // e.g., "1920x1080"
|
||||
var parts = opt.ToLower().Split('x');
|
||||
if (parts.Length == 2 && int.TryParse(parts[0], out int w) && int.TryParse(parts[1], out int h))
|
||||
if (ddResolution.options != null && ddResolution.options.Count > 0 && ddResolution.value >= 0 && ddResolution.value < ddResolution.options.Count)
|
||||
{
|
||||
Screen.SetResolution(w, h, Screen.fullScreenMode);
|
||||
var opt = ddResolution.options[ddResolution.value].text; // e.g., "1920x1080"
|
||||
var parts = opt.ToLower().Split('x');
|
||||
if (parts.Length == 2 && int.TryParse(parts[0], out int w) && int.TryParse(parts[1], out int h))
|
||||
{
|
||||
Screen.SetResolution(w, h, Screen.fullScreenMode);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (ddResolutionUI)
|
||||
{
|
||||
if (ddResolutionUI.options != null && ddResolutionUI.options.Count > 0 && ddResolutionUI.value >= 0 && ddResolutionUI.value < ddResolutionUI.options.Count)
|
||||
{
|
||||
var opt = ddResolutionUI.options[ddResolutionUI.value].text;
|
||||
var parts = opt.ToLower().Split('x');
|
||||
if (parts.Length == 2 && int.TryParse(parts[0], out int w) && int.TryParse(parts[1], out int h))
|
||||
{
|
||||
Screen.SetResolution(w, h, Screen.fullScreenMode);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (slMaster)
|
||||
{
|
||||
AudioListener.volume = slMaster.value / 100f;
|
||||
}
|
||||
}
|
||||
|
||||
private void OnApplySettings()
|
||||
{
|
||||
ApplySettings();
|
||||
SaveSettings();
|
||||
ShowMainMenu();
|
||||
Debug.Log("[UGUIMainMenu] Apply & Back to Main");
|
||||
}
|
||||
|
||||
private void InitializeSettingsUI()
|
||||
{
|
||||
if (ddQuality)
|
||||
{
|
||||
var names = QualitySettings.names;
|
||||
if (names != null && names.Length > 0)
|
||||
{
|
||||
ddQuality.ClearOptions();
|
||||
ddQuality.AddOptions(new List<string>(names));
|
||||
ddQuality.value = Mathf.Clamp(QualitySettings.GetQualityLevel(), 0, ddQuality.options.Count - 1);
|
||||
ddQuality.RefreshShownValue();
|
||||
}
|
||||
ddQuality.interactable = true;
|
||||
FixDropdownRaycasts(ddQuality);
|
||||
SetupDropdownTemplateCanvas(ddQuality);
|
||||
}
|
||||
else if (ddQualityUI)
|
||||
{
|
||||
var names = QualitySettings.names;
|
||||
if (names != null && names.Length > 0)
|
||||
{
|
||||
ddQualityUI.ClearOptions();
|
||||
ddQualityUI.AddOptions(new List<Dropdown.OptionData>(System.Array.ConvertAll(names, s => new Dropdown.OptionData(s))));
|
||||
ddQualityUI.value = Mathf.Clamp(QualitySettings.GetQualityLevel(), 0, ddQualityUI.options.Count - 1);
|
||||
ddQualityUI.RefreshShownValue();
|
||||
}
|
||||
if (ddQualityUI.captionText == null)
|
||||
{
|
||||
var cap = ddQualityUI.transform.Find("Label");
|
||||
if (cap) ddQualityUI.captionText = cap.GetComponent<Text>();
|
||||
}
|
||||
if (ddQualityUI.itemText == null && ddQualityUI.template)
|
||||
{
|
||||
var it = ddQualityUI.template.Find("Item");
|
||||
if (it)
|
||||
{
|
||||
var lbl = it.Find("Item Label");
|
||||
if (lbl) ddQualityUI.itemText = lbl.GetComponent<Text>();
|
||||
}
|
||||
}
|
||||
ddQualityUI.interactable = true;
|
||||
FixDropdownRaycasts(ddQualityUI);
|
||||
SetupDropdownTemplateCanvas(ddQualityUI);
|
||||
Debug.Log("[UGUIMainMenu] UI Quality options=" + (ddQualityUI.options != null ? ddQualityUI.options.Count : 0));
|
||||
}
|
||||
|
||||
if (ddResolution)
|
||||
{
|
||||
var seen = new HashSet<string>();
|
||||
var opts = new List<string>();
|
||||
string cur = Screen.currentResolution.width + "x" + Screen.currentResolution.height;
|
||||
int curIdx = 0;
|
||||
foreach (var r in Screen.resolutions)
|
||||
{
|
||||
string s = r.width + "x" + r.height;
|
||||
if (seen.Add(s))
|
||||
{
|
||||
if (s == cur) curIdx = opts.Count;
|
||||
opts.Add(s);
|
||||
}
|
||||
}
|
||||
if (opts.Count == 0)
|
||||
{
|
||||
opts.Add(cur);
|
||||
curIdx = 0;
|
||||
}
|
||||
ddResolution.ClearOptions();
|
||||
ddResolution.AddOptions(opts);
|
||||
ddResolution.value = Mathf.Clamp(curIdx, 0, ddResolution.options.Count - 1);
|
||||
ddResolution.RefreshShownValue();
|
||||
ddResolution.interactable = true;
|
||||
FixDropdownRaycasts(ddResolution);
|
||||
SetupDropdownTemplateCanvas(ddResolution);
|
||||
}
|
||||
else if (ddResolutionUI)
|
||||
{
|
||||
var seen = new HashSet<string>();
|
||||
var opts = new List<string>();
|
||||
string cur = Screen.currentResolution.width + "x" + Screen.currentResolution.height;
|
||||
int curIdx = 0;
|
||||
foreach (var r in Screen.resolutions)
|
||||
{
|
||||
string s = r.width + "x" + r.height;
|
||||
if (seen.Add(s))
|
||||
{
|
||||
if (s == cur) curIdx = opts.Count;
|
||||
opts.Add(s);
|
||||
}
|
||||
}
|
||||
if (opts.Count == 0)
|
||||
{
|
||||
opts.Add(cur);
|
||||
curIdx = 0;
|
||||
}
|
||||
ddResolutionUI.ClearOptions();
|
||||
ddResolutionUI.AddOptions(opts.ConvertAll(o => new Dropdown.OptionData(o)));
|
||||
ddResolutionUI.value = Mathf.Clamp(curIdx, 0, ddResolutionUI.options.Count - 1);
|
||||
ddResolutionUI.RefreshShownValue();
|
||||
ddResolutionUI.interactable = true;
|
||||
FixDropdownRaycasts(ddResolutionUI);
|
||||
SetupDropdownTemplateCanvas(ddResolutionUI);
|
||||
if (ddResolutionUI.captionText == null)
|
||||
{
|
||||
var cap = ddResolutionUI.transform.Find("Label");
|
||||
if (cap) ddResolutionUI.captionText = cap.GetComponent<Text>();
|
||||
}
|
||||
if (ddResolutionUI.itemText == null && ddResolutionUI.template)
|
||||
{
|
||||
var it = ddResolutionUI.template.Find("Item");
|
||||
if (it)
|
||||
{
|
||||
var lbl = it.Find("Item Label");
|
||||
if (lbl) ddResolutionUI.itemText = lbl.GetComponent<Text>();
|
||||
}
|
||||
}
|
||||
Debug.Log("[UGUIMainMenu] UI Resolution options=" + (ddResolutionUI.options != null ? ddResolutionUI.options.Count : 0));
|
||||
}
|
||||
|
||||
if (tgFullscreen)
|
||||
{
|
||||
tgFullscreen.isOn = Screen.fullScreen;
|
||||
tgFullscreen.interactable = true;
|
||||
}
|
||||
|
||||
LoadSettings();
|
||||
}
|
||||
|
||||
private void SaveSettings()
|
||||
{
|
||||
if (ddQuality) PlayerPrefs.SetInt("QualityLevel", ddQuality.value);
|
||||
PlayerPrefs.SetInt("Fullscreen", Screen.fullScreen ? 1 : 0);
|
||||
if (ddResolution && ddResolution.options.Count > 0)
|
||||
{
|
||||
var opt = ddResolution.options[ddResolution.value].text;
|
||||
var parts = opt.Split('x');
|
||||
if (parts.Length == 2 && int.TryParse(parts[0], out int w) && int.TryParse(parts[1], out int h))
|
||||
{
|
||||
PlayerPrefs.SetInt("ResolutionWidth", w);
|
||||
PlayerPrefs.SetInt("ResolutionHeight", h);
|
||||
}
|
||||
}
|
||||
if (slMaster) PlayerPrefs.SetFloat("MasterVolume", slMaster.value);
|
||||
if (slMusic) PlayerPrefs.SetFloat("MusicVolume", slMusic.value);
|
||||
if (slSFX) PlayerPrefs.SetFloat("SFXVolume", slSFX.value);
|
||||
PlayerPrefs.Save();
|
||||
}
|
||||
|
||||
private void LoadSettings()
|
||||
{
|
||||
if (ddQuality && ddQuality.options.Count > 0)
|
||||
{
|
||||
int q = PlayerPrefs.GetInt("QualityLevel", QualitySettings.GetQualityLevel());
|
||||
ddQuality.value = Mathf.Clamp(q, 0, ddQuality.options.Count - 1);
|
||||
ddQuality.RefreshShownValue();
|
||||
}
|
||||
else if (ddQualityUI && ddQualityUI.options.Count > 0)
|
||||
{
|
||||
int q = PlayerPrefs.GetInt("QualityLevel", QualitySettings.GetQualityLevel());
|
||||
ddQualityUI.value = Mathf.Clamp(q, 0, ddQualityUI.options.Count - 1);
|
||||
ddQualityUI.RefreshShownValue();
|
||||
}
|
||||
if (tgFullscreen)
|
||||
{
|
||||
bool full = PlayerPrefs.GetInt("Fullscreen", Screen.fullScreen ? 1 : 0) == 1;
|
||||
tgFullscreen.isOn = full;
|
||||
}
|
||||
if (ddResolution && ddResolution.options.Count > 0)
|
||||
{
|
||||
int w = PlayerPrefs.GetInt("ResolutionWidth", Screen.currentResolution.width);
|
||||
int h = PlayerPrefs.GetInt("ResolutionHeight", Screen.currentResolution.height);
|
||||
string key = w + "x" + h;
|
||||
int idx = ddResolution.options.FindIndex(o => o.text == key);
|
||||
if (idx >= 0)
|
||||
{
|
||||
ddResolution.value = idx;
|
||||
ddResolution.RefreshShownValue();
|
||||
}
|
||||
}
|
||||
else if (ddResolutionUI && ddResolutionUI.options.Count > 0)
|
||||
{
|
||||
int w = PlayerPrefs.GetInt("ResolutionWidth", Screen.currentResolution.width);
|
||||
int h = PlayerPrefs.GetInt("ResolutionHeight", Screen.currentResolution.height);
|
||||
string key = w + "x" + h;
|
||||
int idx = ddResolutionUI.options.FindIndex(o => o.text == key);
|
||||
if (idx >= 0)
|
||||
{
|
||||
ddResolutionUI.value = idx;
|
||||
ddResolutionUI.RefreshShownValue();
|
||||
}
|
||||
}
|
||||
if (slMaster)
|
||||
{
|
||||
var mv = PlayerPrefs.GetFloat("MasterVolume", 100f);
|
||||
slMaster.value = mv;
|
||||
AudioListener.volume = mv / 100f;
|
||||
}
|
||||
if (slMusic)
|
||||
{
|
||||
slMusic.value = PlayerPrefs.GetFloat("MusicVolume", 80f);
|
||||
}
|
||||
if (slSFX)
|
||||
{
|
||||
slSFX.value = PlayerPrefs.GetFloat("SFXVolume", 100f);
|
||||
}
|
||||
}
|
||||
|
||||
private void FixDropdownRaycasts(TMP_Dropdown dd)
|
||||
{
|
||||
if (!dd || dd.template == null) return;
|
||||
var tpl = dd.template;
|
||||
var vp = tpl.Find("Viewport");
|
||||
if (vp)
|
||||
{
|
||||
var img = vp.GetComponent<Image>();
|
||||
if (img) img.raycastTarget = false;
|
||||
}
|
||||
}
|
||||
|
||||
private void SetupDropdownTemplateCanvas(TMP_Dropdown dd)
|
||||
{
|
||||
if (!dd || dd.template == null) return;
|
||||
var tpl = dd.template;
|
||||
var cv = tpl.GetComponent<Canvas>();
|
||||
if (cv == null) cv = tpl.gameObject.AddComponent<Canvas>();
|
||||
cv.overrideSorting = true;
|
||||
cv.sortingOrder = 5000;
|
||||
if (!tpl.GetComponent<GraphicRaycaster>()) tpl.gameObject.AddComponent<GraphicRaycaster>();
|
||||
}
|
||||
|
||||
private void FixDropdownRaycasts(Dropdown dd)
|
||||
{
|
||||
if (!dd || dd.template == null) return;
|
||||
var tpl = dd.template;
|
||||
var vp = tpl.Find("Viewport");
|
||||
if (vp)
|
||||
{
|
||||
var img = vp.GetComponent<Image>();
|
||||
if (img) img.raycastTarget = false;
|
||||
}
|
||||
}
|
||||
|
||||
private void SetupDropdownTemplateCanvas(Dropdown dd)
|
||||
{
|
||||
if (!dd || dd.template == null) return;
|
||||
var tpl = dd.template;
|
||||
var cv = tpl.GetComponent<Canvas>();
|
||||
if (cv == null) cv = tpl.gameObject.AddComponent<Canvas>();
|
||||
cv.overrideSorting = true;
|
||||
cv.sortingOrder = 5000;
|
||||
if (!tpl.GetComponent<GraphicRaycaster>()) tpl.gameObject.AddComponent<GraphicRaycaster>();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
17162
UI/UI_Canvas 1.prefab
Normal file
17162
UI/UI_Canvas 1.prefab
Normal file
File diff suppressed because it is too large
Load Diff
7
UI/UI_Canvas 1.prefab.meta
Normal file
7
UI/UI_Canvas 1.prefab.meta
Normal file
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5d7cbc36e4a870b4a8f9960c98e02388
|
||||
PrefabImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user