製作地下室地圖、Raw Input 整合後續修正
This commit is contained in:
1 parent
81d2a150c2
commit
23c311e905
191 files changed
+59056
-9911
No files matched your search
@@ -0,0 +1,43 @@
|
||||
using UnityEngine;
|
||||
using TMPro;
|
||||
|
||||
// 選「無輔助」時,把輔助相關的設定變暗、不能操作 (這些設定在無輔助時本來就不會存)
|
||||
public class AssistOptionsLock : MonoBehaviour
|
||||
{
|
||||
[Header("UI 參照")]
|
||||
[Tooltip("輔助方式 Dropdown")]
|
||||
public TMP_Dropdown assistDropdown;
|
||||
|
||||
[Tooltip("無輔助時要變暗的物件 (Slider、Toggle、說明文字都可以拖進來)")]
|
||||
public GameObject[] targets;
|
||||
|
||||
[Header("外觀")]
|
||||
[Tooltip("變暗時的透明度")]
|
||||
[Range(0f, 1f)] public float dimAlpha = 0.35f;
|
||||
|
||||
void Start()
|
||||
{
|
||||
if (assistDropdown == null) return;
|
||||
|
||||
Apply(assistDropdown.value);
|
||||
assistDropdown.onValueChanged.AddListener(Apply);
|
||||
}
|
||||
|
||||
void Apply(int mode)
|
||||
{
|
||||
bool usable = mode != 0; // 0 = 無輔助
|
||||
|
||||
foreach (GameObject target in targets)
|
||||
{
|
||||
if (target == null) continue;
|
||||
|
||||
// 用 CanvasGroup 一次處理整個物件 (包含子物件) : 變暗、不能操作、滑鼠事件穿過去 (拖曳時面板還是能捲動)
|
||||
CanvasGroup group = target.GetComponent<CanvasGroup>();
|
||||
if (group == null) group = target.AddComponent<CanvasGroup>();
|
||||
|
||||
group.alpha = usable ? 1f : dimAlpha;
|
||||
group.interactable = usable;
|
||||
group.blocksRaycasts = usable;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user