Authored Unity primitive/object-model shim, VFX layer (control-flow-preserving, InstantVfx never invokes its action -- headless suppression), god-object stubs (GameMgr/EffectMgr/UIManager with faithfully-extracted nested enums), View/UI/Touch tree, LitJson+BetterList+Tuple copied, third-party stubs. Discovered Roslyn header-error masking: fixing class-header type errors unmasks body references, so the true copy closure is ~2570 files (was 782 under masking). Errors: masked-25720 -> 268; our shim files compile clean. Remaining: ~50 residual shim/external types, 24 NGUI UI-base overrides, static-type fixes, plus likely 1-2 more unmask waves.
233 lines
4.9 KiB
C#
233 lines
4.9 KiB
C#
using UnityEngine;
|
|
|
|
namespace Wizard.Dialog.Setting;
|
|
|
|
public class ItemToggle : Item
|
|
{
|
|
[SerializeField]
|
|
private SettingBase m_parant;
|
|
|
|
[SerializeField]
|
|
private UILabel m_titleLabel;
|
|
|
|
[SerializeField]
|
|
private UILabel _subTextLabel;
|
|
|
|
[SerializeField]
|
|
private UILabel m_stateLabel;
|
|
|
|
[SerializeField]
|
|
private UIToggle m_toggle;
|
|
|
|
[SerializeField]
|
|
private GameObject m_separatorLineObj;
|
|
|
|
[SerializeField]
|
|
private UISprite _spriteON;
|
|
|
|
[SerializeField]
|
|
private UISprite _spriteOFF;
|
|
|
|
[SerializeField]
|
|
private BoxCollider _collider;
|
|
|
|
private string m_OnText;
|
|
|
|
private string m_OffText;
|
|
|
|
private bool m_isPlaySe;
|
|
|
|
private void Awake()
|
|
{
|
|
m_titleLabel.text = string.Empty;
|
|
if (m_stateLabel != null)
|
|
{
|
|
m_stateLabel.text = string.Empty;
|
|
}
|
|
if (m_separatorLineObj != null)
|
|
{
|
|
m_separatorLineObj.SetActive(value: false);
|
|
}
|
|
_collider = m_toggle.GetComponent<BoxCollider>();
|
|
if (_subTextLabel != null)
|
|
{
|
|
_subTextLabel.gameObject.SetActive(value: false);
|
|
_subTextLabel.text = string.Empty;
|
|
}
|
|
AddChangeCallback(delegate
|
|
{
|
|
UpdateStateLabel();
|
|
if (m_isPlaySe)
|
|
{
|
|
GameMgr.GetIns().GetSoundMgr().PlaySe(m_toggle.value ? Se.TYPE.SYS_TOGGLE_ON : Se.TYPE.SYS_TOGGLE_OFF);
|
|
}
|
|
else
|
|
{
|
|
m_isPlaySe = true;
|
|
}
|
|
});
|
|
}
|
|
|
|
public void SetValue(bool value, bool isDisablePlayse = true)
|
|
{
|
|
m_toggle.value = value;
|
|
if (isDisablePlayse)
|
|
{
|
|
m_isPlaySe = false;
|
|
}
|
|
}
|
|
|
|
public bool GetValue()
|
|
{
|
|
return m_toggle.value;
|
|
}
|
|
|
|
public void SetTitleLabel(string title)
|
|
{
|
|
m_titleLabel.text = title;
|
|
}
|
|
|
|
public void SetSutTextLabel(string text)
|
|
{
|
|
_subTextLabel.gameObject.SetActive(value: true);
|
|
_subTextLabel.text = text;
|
|
}
|
|
|
|
public void SetStateText(string onText, string offText)
|
|
{
|
|
m_OnText = onText;
|
|
m_OffText = offText;
|
|
UpdateStateLabel();
|
|
}
|
|
|
|
public void SetActive_StateText(bool isActive)
|
|
{
|
|
m_stateLabel.gameObject.SetActive(isActive);
|
|
}
|
|
|
|
public void SetTitleTextLocalPos(Vector3 localPos)
|
|
{
|
|
m_titleLabel.transform.localPosition = localPos;
|
|
}
|
|
|
|
public void SetStateTextLocalPos(Vector3 localPos)
|
|
{
|
|
m_stateLabel.transform.localPosition = localPos;
|
|
}
|
|
|
|
public void SetToggleLocalPos(Vector3 localPos)
|
|
{
|
|
m_toggle.transform.localPosition = localPos;
|
|
}
|
|
|
|
private void UpdateStateLabel()
|
|
{
|
|
if (!string.IsNullOrEmpty(m_OnText) && !string.IsNullOrEmpty(m_OffText))
|
|
{
|
|
m_stateLabel.text = (m_toggle.value ? m_OnText : m_OffText);
|
|
}
|
|
}
|
|
|
|
public void SetToggleLooks(bool isNormal)
|
|
{
|
|
UIManager.SetObjectToGrey(m_toggle.gameObject, !isNormal);
|
|
bool value = GetValue();
|
|
SetValue(!value, isDisablePlayse: false);
|
|
SetValue(value, isDisablePlayse: false);
|
|
_collider.enabled = isNormal;
|
|
}
|
|
|
|
public void SetLabelLooks(bool isNormal)
|
|
{
|
|
UIManager.SetObjectToGrey(m_stateLabel.gameObject, !isNormal);
|
|
UIManager.SetObjectToGrey(m_titleLabel.gameObject, !isNormal);
|
|
}
|
|
|
|
public void SetSpriteONName(string spriteName, bool isMakePixelPerfect, bool isCollisionResize)
|
|
{
|
|
_spriteON.spriteName = spriteName;
|
|
if (isMakePixelPerfect)
|
|
{
|
|
_spriteON.MakePixelPerfect();
|
|
}
|
|
if (isCollisionResize)
|
|
{
|
|
_collider.size = new Vector3(_spriteON.width, _spriteON.height);
|
|
}
|
|
}
|
|
|
|
public void SetSpriteOFFName(string spriteName, bool isMakePixelPerfect, bool isCollisionResize)
|
|
{
|
|
_spriteOFF.spriteName = spriteName;
|
|
if (isMakePixelPerfect)
|
|
{
|
|
_spriteOFF.MakePixelPerfect();
|
|
}
|
|
if (isCollisionResize)
|
|
{
|
|
_collider.size = new Vector3(_spriteOFF.width, _spriteOFF.height);
|
|
}
|
|
}
|
|
|
|
public void SetButtonEnable(bool isEnable)
|
|
{
|
|
UIButton component = m_toggle.GetComponent<UIButton>();
|
|
if (null != component && component.enabled != isEnable)
|
|
{
|
|
component.enabled = isEnable;
|
|
}
|
|
}
|
|
|
|
public void SetValidator(UIToggle.Validate validator)
|
|
{
|
|
m_toggle.validator = validator;
|
|
}
|
|
|
|
public override void AddChangeCallback(EventDelegate.Callback callback)
|
|
{
|
|
EventDelegate.Add(m_toggle.onChange, callback);
|
|
}
|
|
|
|
public void ClearChangeCallback()
|
|
{
|
|
m_toggle.onChange.Clear();
|
|
}
|
|
|
|
public void AddChangeCallback(EventDelegate callback)
|
|
{
|
|
m_toggle.onChange.Add(callback);
|
|
}
|
|
|
|
public override void SetActive_SeparatorLine(bool isActive)
|
|
{
|
|
m_separatorLineObj.SetActive(isActive);
|
|
}
|
|
|
|
public void SetScrollView(UIScrollView view)
|
|
{
|
|
_collider.gameObject.AddMissingComponent<UIDragScrollView>().scrollView = view;
|
|
}
|
|
|
|
public void SetToggleEnable(bool isEnable)
|
|
{
|
|
if (!(m_toggle != null))
|
|
{
|
|
return;
|
|
}
|
|
m_toggle.enabled = isEnable;
|
|
if (isEnable)
|
|
{
|
|
return;
|
|
}
|
|
TweenColor[] componentsInChildren = m_toggle.GetComponentsInChildren<TweenColor>();
|
|
if (componentsInChildren != null)
|
|
{
|
|
TweenColor[] array = componentsInChildren;
|
|
for (int i = 0; i < array.Length; i++)
|
|
{
|
|
array[i].enabled = true;
|
|
}
|
|
}
|
|
}
|
|
}
|