Compile-driven bulk-copy loop (tools/engine-port/m1_copy_loop.py) pulled the precise reference closure of the battle-core roots, stopping at the classify god-object/View-VFX-UI boundary. 782 files; no re-explosion (M0 had estimated ~order 1000). Residual frontier = 52 shim-classified + 80 external (Unity/BCL) types to author next.
163 lines
4.0 KiB
C#
163 lines
4.0 KiB
C#
using System;
|
|
using UnityEngine;
|
|
|
|
[ExecuteInEditMode]
|
|
[AddComponentMenu("NGUI/Interaction/NGUI Slider")]
|
|
public class UISlider : UIProgressBar
|
|
{
|
|
private enum Direction
|
|
{
|
|
Horizontal,
|
|
Vertical,
|
|
Upgraded
|
|
}
|
|
|
|
[HideInInspector]
|
|
[SerializeField]
|
|
private Transform foreground;
|
|
|
|
[HideInInspector]
|
|
[SerializeField]
|
|
private float rawValue = 1f;
|
|
|
|
[HideInInspector]
|
|
[SerializeField]
|
|
private Direction direction = Direction.Upgraded;
|
|
|
|
[HideInInspector]
|
|
[SerializeField]
|
|
protected bool mInverted;
|
|
|
|
public bool isColliderEnabled
|
|
{
|
|
get
|
|
{
|
|
Collider component = GetComponent<Collider>();
|
|
if (component != null)
|
|
{
|
|
return component.enabled;
|
|
}
|
|
Collider2D component2 = GetComponent<Collider2D>();
|
|
if (component2 != null)
|
|
{
|
|
return component2.enabled;
|
|
}
|
|
return false;
|
|
}
|
|
}
|
|
|
|
[Obsolete("Use 'value' instead")]
|
|
public float sliderValue
|
|
{
|
|
get
|
|
{
|
|
return base.value;
|
|
}
|
|
set
|
|
{
|
|
base.value = value;
|
|
}
|
|
}
|
|
|
|
[Obsolete("Use 'fillDirection' instead")]
|
|
public bool inverted
|
|
{
|
|
get
|
|
{
|
|
return base.isInverted;
|
|
}
|
|
set
|
|
{
|
|
}
|
|
}
|
|
|
|
protected override void Upgrade()
|
|
{
|
|
if (direction != Direction.Upgraded)
|
|
{
|
|
mValue = rawValue;
|
|
if (foreground != null)
|
|
{
|
|
mFG = foreground.GetComponent<UIWidget>();
|
|
}
|
|
if (direction == Direction.Horizontal)
|
|
{
|
|
mFill = (mInverted ? FillDirection.RightToLeft : FillDirection.LeftToRight);
|
|
}
|
|
else
|
|
{
|
|
mFill = (mInverted ? FillDirection.TopToBottom : FillDirection.BottomToTop);
|
|
}
|
|
direction = Direction.Upgraded;
|
|
}
|
|
}
|
|
|
|
protected override void OnStart()
|
|
{
|
|
UIEventListener uIEventListener = UIEventListener.Get((mBG != null && (mBG.GetComponent<Collider>() != null || mBG.GetComponent<Collider2D>() != null)) ? mBG.gameObject : base.gameObject);
|
|
uIEventListener.onPress = (UIEventListener.BoolDelegate)Delegate.Combine(uIEventListener.onPress, new UIEventListener.BoolDelegate(OnPressBackground));
|
|
uIEventListener.onDrag = (UIEventListener.VectorDelegate)Delegate.Combine(uIEventListener.onDrag, new UIEventListener.VectorDelegate(OnDragBackground));
|
|
if (thumb != null && (thumb.GetComponent<Collider>() != null || thumb.GetComponent<Collider2D>() != null) && (mFG == null || thumb != mFG.cachedTransform))
|
|
{
|
|
UIEventListener uIEventListener2 = UIEventListener.Get(thumb.gameObject);
|
|
uIEventListener2.onPress = (UIEventListener.BoolDelegate)Delegate.Combine(uIEventListener2.onPress, new UIEventListener.BoolDelegate(OnPressForeground));
|
|
uIEventListener2.onDrag = (UIEventListener.VectorDelegate)Delegate.Combine(uIEventListener2.onDrag, new UIEventListener.VectorDelegate(OnDragForeground));
|
|
}
|
|
}
|
|
|
|
protected virtual void OnPressBackground(GameObject go, bool isPressed)
|
|
{
|
|
if (UICamera.currentScheme != UICamera.ControlScheme.Controller)
|
|
{
|
|
mCam = UICamera.currentCamera;
|
|
base.value = ScreenToValue(UICamera.lastEventPosition);
|
|
if (!isPressed && onDragFinished != null)
|
|
{
|
|
onDragFinished();
|
|
}
|
|
}
|
|
}
|
|
|
|
protected void OnDragBackground(GameObject go, Vector2 delta)
|
|
{
|
|
if (UICamera.currentScheme != UICamera.ControlScheme.Controller)
|
|
{
|
|
mCam = UICamera.currentCamera;
|
|
base.value = ScreenToValue(UICamera.lastEventPosition);
|
|
}
|
|
}
|
|
|
|
protected virtual void OnPressForeground(GameObject go, bool isPressed)
|
|
{
|
|
if (UICamera.currentScheme != UICamera.ControlScheme.Controller)
|
|
{
|
|
mCam = UICamera.currentCamera;
|
|
if (isPressed)
|
|
{
|
|
mOffset = ((mFG == null) ? 0f : (base.value - ScreenToValue(UICamera.lastEventPosition)));
|
|
}
|
|
else if (onDragFinished != null)
|
|
{
|
|
onDragFinished();
|
|
}
|
|
}
|
|
}
|
|
|
|
protected void OnDragForeground(GameObject go, Vector2 delta)
|
|
{
|
|
if (UICamera.currentScheme != UICamera.ControlScheme.Controller)
|
|
{
|
|
mCam = UICamera.currentCamera;
|
|
base.value = mOffset + ScreenToValue(UICamera.lastEventPosition);
|
|
}
|
|
}
|
|
|
|
public override void OnPan(Vector2 delta)
|
|
{
|
|
if (base.enabled && isColliderEnabled)
|
|
{
|
|
base.OnPan(delta);
|
|
}
|
|
}
|
|
}
|