1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889 |
- using BeinLab.Util;
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using UnityEngine.UI;
- using XRTool.Util;
- using XRTool.WorldUI;
- namespace XRTool.UI
- {
- /// <summary>
- /// 窗口管理面板
- /// </summary>
- public class SettingsDlg : MonoBehaviour
- {
- public bool isDelOnClose = false;
- private Button closeButton;
- private ToggleButton lockButton;
- private ToggleButton transferButton;
- private WorldDlg dlg;
- private void Start()
- {
- dlg = GetComponentInParent<WorldDlg>();
- if (dlg)
- {
- closeButton = UnityUtil.GetBreadthChild<Button>(transform, "CloseButton");
- lockButton = UnityUtil.GetBreadthChild<ToggleButton>(transform, "LockButton");
- transferButton = UnityUtil.GetBreadthChild<ToggleButton>(transform, "TransferButton");
- closeButton.onClick.AddListener(() => { dlg.Close(isDelOnClose); });
- lockButton.OnValueChanged += OnLockValueChanged;
- transferButton.OnValueChanged += OnTransferValueChanged;
- if (lockButton.isActiveAndEnabled)
- {
- TimerMgr.Instance.CreateTimer(() =>
- {
- OnLockValueChanged(lockButton.isOn);
- }, 0.02f);
- }
- if (transferButton.isActiveAndEnabled)
- {
- TimerMgr.Instance.CreateTimer(() =>
- {
- OnTransferValueChanged(transferButton.isOn);
- }, 0.02f);
- }
- }
- }
- private void OnEnable()
- {
- if (lockButton && lockButton.isActiveAndEnabled)
- {
- OnLockValueChanged(lockButton.isOn);
- }
- if (transferButton && transferButton.isActiveAndEnabled)
- {
- OnTransferValueChanged(transferButton.isOn);
- }
- }
- private void OnDestroy()
- {
- if (lockButton)
- {
- lockButton.OnValueChanged -= OnLockValueChanged;
- }
- if (transferButton)
- {
- transferButton.OnValueChanged -= OnTransferValueChanged;
- }
- }
- private void OnTransferValueChanged(bool obj)
- {
- if (dlg)
- {
- dlg.IsDragEnable = obj;
- }
- }
- private void OnLockValueChanged(bool obj)
- {
- if (dlg)
- {
- dlg.IsFaceLock = obj;
- }
- }
- }
- }
|