首次提交
This commit is contained in:
109
Assets/Plugins/FairyGUI/Scripts/UI/Gears/GearAnimation.cs
Normal file
109
Assets/Plugins/FairyGUI/Scripts/UI/Gears/GearAnimation.cs
Normal file
@@ -0,0 +1,109 @@
|
||||
using System.Collections.Generic;
|
||||
using FairyGUI.Utils;
|
||||
|
||||
namespace FairyGUI
|
||||
{
|
||||
class GearAnimationValue
|
||||
{
|
||||
public bool playing;
|
||||
public int frame;
|
||||
public string animationName;
|
||||
public string skinName;
|
||||
|
||||
public GearAnimationValue(bool playing, int frame)
|
||||
{
|
||||
this.playing = playing;
|
||||
this.frame = frame;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gear is a connection between object and controller.
|
||||
/// </summary>
|
||||
public class GearAnimation : GearBase
|
||||
{
|
||||
Dictionary<string, GearAnimationValue> _storage;
|
||||
GearAnimationValue _default;
|
||||
|
||||
public GearAnimation(GObject owner)
|
||||
: base(owner)
|
||||
{
|
||||
}
|
||||
|
||||
protected override void Init()
|
||||
{
|
||||
_default = new GearAnimationValue(((IAnimationGear)_owner).playing, ((IAnimationGear)_owner).frame);
|
||||
if (_owner is GLoader3D)
|
||||
{
|
||||
_default.animationName = ((GLoader3D)_owner).animationName;
|
||||
_default.skinName = ((GLoader3D)_owner).skinName;
|
||||
}
|
||||
_storage = new Dictionary<string, GearAnimationValue>();
|
||||
}
|
||||
|
||||
override protected void AddStatus(string pageId, ByteBuffer buffer)
|
||||
{
|
||||
GearAnimationValue gv;
|
||||
if (pageId == null)
|
||||
gv = _default;
|
||||
else
|
||||
{
|
||||
gv = new GearAnimationValue(false, 0);
|
||||
_storage[pageId] = gv;
|
||||
}
|
||||
|
||||
gv.playing = buffer.ReadBool();
|
||||
gv.frame = buffer.ReadInt();
|
||||
}
|
||||
|
||||
public void AddExtStatus(string pageId, ByteBuffer buffer)
|
||||
{
|
||||
GearAnimationValue gv;
|
||||
if (pageId == null)
|
||||
gv = _default;
|
||||
else
|
||||
gv = _storage[pageId];
|
||||
gv.animationName = buffer.ReadS();
|
||||
gv.skinName = buffer.ReadS();
|
||||
}
|
||||
|
||||
override public void Apply()
|
||||
{
|
||||
_owner._gearLocked = true;
|
||||
|
||||
GearAnimationValue gv;
|
||||
if (!_storage.TryGetValue(_controller.selectedPageId, out gv))
|
||||
gv = _default;
|
||||
|
||||
IAnimationGear mc = (IAnimationGear)_owner;
|
||||
mc.frame = gv.frame;
|
||||
mc.playing = gv.playing;
|
||||
if (_owner is GLoader3D)
|
||||
{
|
||||
((GLoader3D)_owner).animationName = gv.animationName;
|
||||
((GLoader3D)_owner).skinName = gv.skinName;
|
||||
}
|
||||
|
||||
_owner._gearLocked = false;
|
||||
}
|
||||
|
||||
override public void UpdateState()
|
||||
{
|
||||
IAnimationGear mc = (IAnimationGear)_owner;
|
||||
GearAnimationValue gv;
|
||||
if (!_storage.TryGetValue(_controller.selectedPageId, out gv))
|
||||
_storage[_controller.selectedPageId] = gv = new GearAnimationValue(mc.playing, mc.frame);
|
||||
else
|
||||
{
|
||||
gv.playing = mc.playing;
|
||||
gv.frame = mc.frame;
|
||||
}
|
||||
|
||||
if (_owner is GLoader3D)
|
||||
{
|
||||
gv.animationName = ((GLoader3D)_owner).animationName;
|
||||
gv.skinName = ((GLoader3D)_owner).skinName;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 87e99c1910ca9684d8719dae7bdb7658
|
||||
timeCreated: 1535374214
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
203
Assets/Plugins/FairyGUI/Scripts/UI/Gears/GearBase.cs
Normal file
203
Assets/Plugins/FairyGUI/Scripts/UI/Gears/GearBase.cs
Normal file
@@ -0,0 +1,203 @@
|
||||
using FairyGUI.Utils;
|
||||
|
||||
namespace FairyGUI
|
||||
{
|
||||
/// <summary>
|
||||
/// Gear is a connection between object and controller.
|
||||
/// </summary>
|
||||
abstract public class GearBase
|
||||
{
|
||||
public static bool disableAllTweenEffect = false;
|
||||
|
||||
protected GObject _owner;
|
||||
protected Controller _controller;
|
||||
protected GearTweenConfig _tweenConfig;
|
||||
|
||||
public GearBase(GObject owner)
|
||||
{
|
||||
_owner = owner;
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
if (_tweenConfig != null && _tweenConfig._tweener != null)
|
||||
{
|
||||
_tweenConfig._tweener.Kill();
|
||||
_tweenConfig._tweener = null;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Controller object.
|
||||
/// </summary>
|
||||
public Controller controller
|
||||
{
|
||||
get
|
||||
{
|
||||
return _controller;
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
if (value != _controller)
|
||||
{
|
||||
_controller = value;
|
||||
if (_controller != null)
|
||||
Init();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public GearTweenConfig tweenConfig
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_tweenConfig == null)
|
||||
_tweenConfig = new GearTweenConfig();
|
||||
return _tweenConfig;
|
||||
}
|
||||
}
|
||||
|
||||
public void Setup(ByteBuffer buffer)
|
||||
{
|
||||
_controller = _owner.parent.GetControllerAt(buffer.ReadShort());
|
||||
Init();
|
||||
|
||||
int cnt = buffer.ReadShort();
|
||||
if (this is GearDisplay)
|
||||
{
|
||||
((GearDisplay)this).pages = buffer.ReadSArray(cnt);
|
||||
}
|
||||
else if (this is GearDisplay2)
|
||||
{
|
||||
((GearDisplay2)this).pages = buffer.ReadSArray(cnt);
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int i = 0; i < cnt; i++)
|
||||
{
|
||||
string page = buffer.ReadS();
|
||||
if (page == null)
|
||||
continue;
|
||||
|
||||
AddStatus(page, buffer);
|
||||
}
|
||||
|
||||
if (buffer.ReadBool())
|
||||
AddStatus(null, buffer);
|
||||
}
|
||||
|
||||
if (buffer.ReadBool())
|
||||
{
|
||||
_tweenConfig = new GearTweenConfig();
|
||||
_tweenConfig.easeType = (EaseType)buffer.ReadByte();
|
||||
_tweenConfig.duration = buffer.ReadFloat();
|
||||
_tweenConfig.delay = buffer.ReadFloat();
|
||||
}
|
||||
|
||||
if (buffer.version >= 2)
|
||||
{
|
||||
if (this is GearXY)
|
||||
{
|
||||
if (buffer.ReadBool())
|
||||
{
|
||||
((GearXY)this).positionsInPercent = true;
|
||||
for (int i = 0; i < cnt; i++)
|
||||
{
|
||||
string page = buffer.ReadS();
|
||||
if (page == null)
|
||||
continue;
|
||||
|
||||
((GearXY)this).AddExtStatus(page, buffer);
|
||||
}
|
||||
|
||||
if (buffer.ReadBool())
|
||||
((GearXY)this).AddExtStatus(null, buffer);
|
||||
}
|
||||
}
|
||||
else if (this is GearDisplay2)
|
||||
((GearDisplay2)this).condition = buffer.ReadByte();
|
||||
}
|
||||
|
||||
if (buffer.version >= 4 && _tweenConfig != null && _tweenConfig.easeType == EaseType.Custom)
|
||||
{
|
||||
_tweenConfig.customEase = new CustomEase();
|
||||
_tweenConfig.customEase.Create(buffer.ReadPath());
|
||||
}
|
||||
|
||||
if (buffer.version >= 6)
|
||||
{
|
||||
if (this is GearAnimation)
|
||||
{
|
||||
for (int i = 0; i < cnt; i++)
|
||||
{
|
||||
string page = buffer.ReadS();
|
||||
if (page == null)
|
||||
continue;
|
||||
|
||||
((GearAnimation)this).AddExtStatus(page, buffer);
|
||||
}
|
||||
|
||||
if (buffer.ReadBool())
|
||||
((GearAnimation)this).AddExtStatus(null, buffer);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
virtual public void UpdateFromRelations(float dx, float dy)
|
||||
{
|
||||
}
|
||||
|
||||
abstract protected void AddStatus(string pageId, ByteBuffer buffer);
|
||||
abstract protected void Init();
|
||||
|
||||
/// <summary>
|
||||
/// Call when controller active page changed.
|
||||
/// </summary>
|
||||
abstract public void Apply();
|
||||
|
||||
/// <summary>
|
||||
/// Call when object's properties changed.
|
||||
/// </summary>
|
||||
abstract public void UpdateState();
|
||||
}
|
||||
|
||||
public class GearTweenConfig
|
||||
{
|
||||
/// <summary>
|
||||
/// Use tween to apply change.
|
||||
/// </summary>
|
||||
public bool tween;
|
||||
|
||||
/// <summary>
|
||||
/// Ease type.
|
||||
/// </summary>
|
||||
public EaseType easeType;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public CustomEase customEase;
|
||||
|
||||
/// <summary>
|
||||
/// Tween duration in seconds.
|
||||
/// </summary>
|
||||
public float duration;
|
||||
|
||||
/// <summary>
|
||||
/// Tween delay in seconds.
|
||||
/// </summary>
|
||||
public float delay;
|
||||
|
||||
internal uint _displayLockToken;
|
||||
internal GTweener _tweener;
|
||||
|
||||
public GearTweenConfig()
|
||||
{
|
||||
tween = true;
|
||||
easeType = EaseType.QuadOut;
|
||||
duration = 0.3f;
|
||||
delay = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
13
Assets/Plugins/FairyGUI/Scripts/UI/Gears/GearBase.cs.meta
Normal file
13
Assets/Plugins/FairyGUI/Scripts/UI/Gears/GearBase.cs.meta
Normal file
@@ -0,0 +1,13 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2050e67af29d06a44834f7ffbfe14e83
|
||||
timeCreated: 1535374214
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
142
Assets/Plugins/FairyGUI/Scripts/UI/Gears/GearColor.cs
Normal file
142
Assets/Plugins/FairyGUI/Scripts/UI/Gears/GearColor.cs
Normal file
@@ -0,0 +1,142 @@
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using FairyGUI.Utils;
|
||||
|
||||
namespace FairyGUI
|
||||
{
|
||||
class GearColorValue
|
||||
{
|
||||
public Color color;
|
||||
public Color strokeColor;
|
||||
|
||||
public GearColorValue()
|
||||
{
|
||||
}
|
||||
|
||||
public GearColorValue(Color color, Color strokeColor)
|
||||
{
|
||||
this.color = color;
|
||||
this.strokeColor = strokeColor;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gear is a connection between object and controller.
|
||||
/// </summary>
|
||||
public class GearColor : GearBase, ITweenListener
|
||||
{
|
||||
Dictionary<string, GearColorValue> _storage;
|
||||
GearColorValue _default;
|
||||
|
||||
public GearColor(GObject owner)
|
||||
: base(owner)
|
||||
{
|
||||
}
|
||||
|
||||
protected override void Init()
|
||||
{
|
||||
_default = new GearColorValue();
|
||||
_default.color = ((IColorGear)_owner).color;
|
||||
if (_owner is ITextColorGear)
|
||||
_default.strokeColor = ((ITextColorGear)_owner).strokeColor;
|
||||
_storage = new Dictionary<string, GearColorValue>();
|
||||
}
|
||||
|
||||
override protected void AddStatus(string pageId, ByteBuffer buffer)
|
||||
{
|
||||
GearColorValue gv;
|
||||
if (pageId == null)
|
||||
gv = _default;
|
||||
else
|
||||
{
|
||||
gv = new GearColorValue(Color.black, Color.black);
|
||||
_storage[pageId] = gv;
|
||||
}
|
||||
|
||||
gv.color = buffer.ReadColor();
|
||||
gv.strokeColor = buffer.ReadColor();
|
||||
}
|
||||
|
||||
override public void Apply()
|
||||
{
|
||||
GearColorValue gv;
|
||||
if (!_storage.TryGetValue(_controller.selectedPageId, out gv))
|
||||
gv = _default;
|
||||
|
||||
if (_tweenConfig != null && _tweenConfig.tween && UIPackage._constructing == 0 && !disableAllTweenEffect)
|
||||
{
|
||||
if ((_owner is ITextColorGear) && gv.strokeColor.a > 0)
|
||||
{
|
||||
_owner._gearLocked = true;
|
||||
((ITextColorGear)_owner).strokeColor = gv.strokeColor;
|
||||
_owner._gearLocked = false;
|
||||
}
|
||||
|
||||
if (_tweenConfig._tweener != null)
|
||||
{
|
||||
if (_tweenConfig._tweener.endValue.color != gv.color)
|
||||
{
|
||||
_tweenConfig._tweener.Kill(true);
|
||||
_tweenConfig._tweener = null;
|
||||
}
|
||||
else
|
||||
return;
|
||||
}
|
||||
|
||||
if (((IColorGear)_owner).color != gv.color)
|
||||
{
|
||||
if (_owner.CheckGearController(0, _controller))
|
||||
_tweenConfig._displayLockToken = _owner.AddDisplayLock();
|
||||
|
||||
_tweenConfig._tweener = GTween.To(((IColorGear)_owner).color, gv.color, _tweenConfig.duration)
|
||||
.SetDelay(_tweenConfig.delay)
|
||||
.SetEase(_tweenConfig.easeType, _tweenConfig.customEase)
|
||||
.SetTarget(this)
|
||||
.SetListener(this);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_owner._gearLocked = true;
|
||||
((IColorGear)_owner).color = gv.color;
|
||||
if ((_owner is ITextColorGear) && gv.strokeColor.a > 0)
|
||||
((ITextColorGear)_owner).strokeColor = gv.strokeColor;
|
||||
_owner._gearLocked = false;
|
||||
}
|
||||
}
|
||||
|
||||
public void OnTweenStart(GTweener tweener)
|
||||
{
|
||||
}
|
||||
|
||||
public void OnTweenUpdate(GTweener tweener)
|
||||
{
|
||||
_owner._gearLocked = true;
|
||||
((IColorGear)_owner).color = tweener.value.color;
|
||||
_owner._gearLocked = false;
|
||||
|
||||
_owner.InvalidateBatchingState();
|
||||
}
|
||||
|
||||
public void OnTweenComplete(GTweener tweener)
|
||||
{
|
||||
_tweenConfig._tweener = null;
|
||||
if (_tweenConfig._displayLockToken != 0)
|
||||
{
|
||||
_owner.ReleaseDisplayLock(_tweenConfig._displayLockToken);
|
||||
_tweenConfig._displayLockToken = 0;
|
||||
}
|
||||
_owner.DispatchEvent("onGearStop", this);
|
||||
}
|
||||
|
||||
override public void UpdateState()
|
||||
{
|
||||
GearColorValue gv;
|
||||
if (!_storage.TryGetValue(_controller.selectedPageId, out gv))
|
||||
_storage[_controller.selectedPageId] = gv = new GearColorValue();
|
||||
gv.color = ((IColorGear)_owner).color;
|
||||
if (_owner is ITextColorGear)
|
||||
gv.strokeColor = ((ITextColorGear)_owner).strokeColor;
|
||||
}
|
||||
}
|
||||
}
|
||||
13
Assets/Plugins/FairyGUI/Scripts/UI/Gears/GearColor.cs.meta
Normal file
13
Assets/Plugins/FairyGUI/Scripts/UI/Gears/GearColor.cs.meta
Normal file
@@ -0,0 +1,13 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a4878a5e9a94c1d429c827f93ca3072b
|
||||
timeCreated: 1535374215
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
68
Assets/Plugins/FairyGUI/Scripts/UI/Gears/GearDisplay.cs
Normal file
68
Assets/Plugins/FairyGUI/Scripts/UI/Gears/GearDisplay.cs
Normal file
@@ -0,0 +1,68 @@
|
||||
using System;
|
||||
using FairyGUI.Utils;
|
||||
|
||||
namespace FairyGUI
|
||||
{
|
||||
/// <summary>
|
||||
/// Gear is a connection between object and controller.
|
||||
/// </summary>
|
||||
public class GearDisplay : GearBase
|
||||
{
|
||||
/// <summary>
|
||||
/// Pages involed in this gear.
|
||||
/// </summary>
|
||||
public string[] pages { get; set; }
|
||||
|
||||
int _visible;
|
||||
uint _displayLockToken;
|
||||
|
||||
public GearDisplay(GObject owner)
|
||||
: base(owner)
|
||||
{
|
||||
_displayLockToken = 1;
|
||||
}
|
||||
|
||||
override protected void AddStatus(string pageId, ByteBuffer buffer)
|
||||
{
|
||||
}
|
||||
|
||||
override protected void Init()
|
||||
{
|
||||
pages = null;
|
||||
}
|
||||
|
||||
override public void Apply()
|
||||
{
|
||||
_displayLockToken++;
|
||||
if (_displayLockToken == 0)
|
||||
_displayLockToken = 1;
|
||||
|
||||
if (pages == null || pages.Length == 0
|
||||
|| Array.IndexOf(pages, _controller.selectedPageId) != -1)
|
||||
_visible = 1;
|
||||
else
|
||||
_visible = 0;
|
||||
}
|
||||
|
||||
override public void UpdateState()
|
||||
{
|
||||
}
|
||||
|
||||
public uint AddLock()
|
||||
{
|
||||
_visible++;
|
||||
return _displayLockToken;
|
||||
}
|
||||
|
||||
public void ReleaseLock(uint token)
|
||||
{
|
||||
if (token == _displayLockToken)
|
||||
_visible--;
|
||||
}
|
||||
|
||||
public bool connected
|
||||
{
|
||||
get { return _controller == null || _visible > 0; }
|
||||
}
|
||||
}
|
||||
}
|
||||
13
Assets/Plugins/FairyGUI/Scripts/UI/Gears/GearDisplay.cs.meta
Normal file
13
Assets/Plugins/FairyGUI/Scripts/UI/Gears/GearDisplay.cs.meta
Normal file
@@ -0,0 +1,13 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f88c3ac62122e7141a5d6c41eb11da27
|
||||
timeCreated: 1535374215
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
55
Assets/Plugins/FairyGUI/Scripts/UI/Gears/GearDisplay2.cs
Normal file
55
Assets/Plugins/FairyGUI/Scripts/UI/Gears/GearDisplay2.cs
Normal file
@@ -0,0 +1,55 @@
|
||||
using System;
|
||||
using FairyGUI.Utils;
|
||||
|
||||
namespace FairyGUI
|
||||
{
|
||||
/// <summary>
|
||||
/// Gear is a connection between object and controller.
|
||||
/// </summary>
|
||||
public class GearDisplay2 : GearBase
|
||||
{
|
||||
/// <summary>
|
||||
/// Pages involed in this gear.
|
||||
/// </summary>
|
||||
public string[] pages { get; set; }
|
||||
public int condition;
|
||||
|
||||
int _visible;
|
||||
|
||||
public GearDisplay2(GObject owner)
|
||||
: base(owner)
|
||||
{
|
||||
}
|
||||
|
||||
override protected void AddStatus(string pageId, ByteBuffer buffer)
|
||||
{
|
||||
}
|
||||
|
||||
override protected void Init()
|
||||
{
|
||||
pages = null;
|
||||
}
|
||||
|
||||
override public void Apply()
|
||||
{
|
||||
if (pages == null || pages.Length == 0
|
||||
|| Array.IndexOf(pages, _controller.selectedPageId) != -1)
|
||||
_visible = 1;
|
||||
else
|
||||
_visible = 0;
|
||||
}
|
||||
|
||||
override public void UpdateState()
|
||||
{
|
||||
}
|
||||
public bool Evaluate(bool connected)
|
||||
{
|
||||
bool v = _controller == null || _visible > 0;
|
||||
if (this.condition == 0)
|
||||
v = v && connected;
|
||||
else
|
||||
v = v || connected;
|
||||
return v;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 96390d060150348e98dfe41bf7d23f5f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
65
Assets/Plugins/FairyGUI/Scripts/UI/Gears/GearFontSize.cs
Normal file
65
Assets/Plugins/FairyGUI/Scripts/UI/Gears/GearFontSize.cs
Normal file
@@ -0,0 +1,65 @@
|
||||
using System.Collections.Generic;
|
||||
using FairyGUI.Utils;
|
||||
|
||||
namespace FairyGUI
|
||||
{
|
||||
/// <summary>
|
||||
/// Gear is a connection between object and controller.
|
||||
/// </summary>
|
||||
public class GearFontSize : GearBase
|
||||
{
|
||||
Dictionary<string, int> _storage;
|
||||
int _default;
|
||||
GTextField _textField;
|
||||
|
||||
public GearFontSize(GObject owner)
|
||||
: base(owner)
|
||||
{
|
||||
}
|
||||
|
||||
protected override void Init()
|
||||
{
|
||||
if (_owner is GLabel)
|
||||
_textField = ((GLabel)_owner).GetTextField();
|
||||
else if (_owner is GButton)
|
||||
_textField = ((GButton)_owner).GetTextField();
|
||||
else
|
||||
_textField = (GTextField)_owner;
|
||||
|
||||
_default = _textField.textFormat.size;
|
||||
_storage = new Dictionary<string, int>();
|
||||
}
|
||||
|
||||
override protected void AddStatus(string pageId, ByteBuffer buffer)
|
||||
{
|
||||
if (pageId == null)
|
||||
_default = buffer.ReadInt();
|
||||
else
|
||||
_storage[pageId] = buffer.ReadInt();
|
||||
}
|
||||
|
||||
override public void Apply()
|
||||
{
|
||||
if (_textField == null)
|
||||
return;
|
||||
|
||||
_owner._gearLocked = true;
|
||||
|
||||
int cv;
|
||||
if (!_storage.TryGetValue(_controller.selectedPageId, out cv))
|
||||
cv = _default;
|
||||
|
||||
TextFormat tf = _textField.textFormat;
|
||||
tf.size = cv;
|
||||
_textField.textFormat = tf;
|
||||
|
||||
_owner._gearLocked = false;
|
||||
}
|
||||
|
||||
override public void UpdateState()
|
||||
{
|
||||
if (_textField != null)
|
||||
_storage[_controller.selectedPageId] = _textField.textFormat.size;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2d3a7b66a83334b44bb8630ecc980a59
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
51
Assets/Plugins/FairyGUI/Scripts/UI/Gears/GearIcon.cs
Normal file
51
Assets/Plugins/FairyGUI/Scripts/UI/Gears/GearIcon.cs
Normal file
@@ -0,0 +1,51 @@
|
||||
using System.Collections.Generic;
|
||||
using FairyGUI.Utils;
|
||||
|
||||
namespace FairyGUI
|
||||
{
|
||||
/// <summary>
|
||||
/// Gear is a connection between object and controller.
|
||||
/// </summary>
|
||||
public class GearIcon : GearBase
|
||||
{
|
||||
Dictionary<string, string> _storage;
|
||||
string _default;
|
||||
|
||||
public GearIcon(GObject owner)
|
||||
: base(owner)
|
||||
{
|
||||
}
|
||||
|
||||
protected override void Init()
|
||||
{
|
||||
_default = _owner.icon;
|
||||
_storage = new Dictionary<string, string>();
|
||||
}
|
||||
|
||||
override protected void AddStatus(string pageId, ByteBuffer buffer)
|
||||
{
|
||||
if (pageId == null)
|
||||
_default = buffer.ReadS();
|
||||
else
|
||||
_storage[pageId] = buffer.ReadS();
|
||||
}
|
||||
|
||||
override public void Apply()
|
||||
{
|
||||
_owner._gearLocked = true;
|
||||
|
||||
string cv;
|
||||
if (!_storage.TryGetValue(_controller.selectedPageId, out cv))
|
||||
cv = _default;
|
||||
|
||||
_owner.icon = cv;
|
||||
|
||||
_owner._gearLocked = false;
|
||||
}
|
||||
|
||||
override public void UpdateState()
|
||||
{
|
||||
_storage[_controller.selectedPageId] = _owner.icon;
|
||||
}
|
||||
}
|
||||
}
|
||||
13
Assets/Plugins/FairyGUI/Scripts/UI/Gears/GearIcon.cs.meta
Normal file
13
Assets/Plugins/FairyGUI/Scripts/UI/Gears/GearIcon.cs.meta
Normal file
@@ -0,0 +1,13 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 27b2a638ddb815f40994e0477c3ea4c0
|
||||
timeCreated: 1535374214
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
152
Assets/Plugins/FairyGUI/Scripts/UI/Gears/GearLook.cs
Normal file
152
Assets/Plugins/FairyGUI/Scripts/UI/Gears/GearLook.cs
Normal file
@@ -0,0 +1,152 @@
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using FairyGUI.Utils;
|
||||
|
||||
namespace FairyGUI
|
||||
{
|
||||
class GearLookValue
|
||||
{
|
||||
public float alpha;
|
||||
public float rotation;
|
||||
public bool grayed;
|
||||
public bool touchable;
|
||||
|
||||
public GearLookValue(float alpha, float rotation, bool grayed, bool touchable)
|
||||
{
|
||||
this.alpha = alpha;
|
||||
this.rotation = rotation;
|
||||
this.grayed = grayed;
|
||||
this.touchable = touchable;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gear is a connection between object and controller.
|
||||
/// </summary>
|
||||
public class GearLook : GearBase, ITweenListener
|
||||
{
|
||||
Dictionary<string, GearLookValue> _storage;
|
||||
GearLookValue _default;
|
||||
|
||||
public GearLook(GObject owner)
|
||||
: base(owner)
|
||||
{
|
||||
}
|
||||
|
||||
protected override void Init()
|
||||
{
|
||||
_default = new GearLookValue(_owner.alpha, _owner.rotation, _owner.grayed, _owner.touchable);
|
||||
_storage = new Dictionary<string, GearLookValue>();
|
||||
}
|
||||
|
||||
override protected void AddStatus(string pageId, ByteBuffer buffer)
|
||||
{
|
||||
GearLookValue gv;
|
||||
if (pageId == null)
|
||||
gv = _default;
|
||||
else
|
||||
{
|
||||
gv = new GearLookValue(0, 0, false, false);
|
||||
_storage[pageId] = gv;
|
||||
}
|
||||
|
||||
gv.alpha = buffer.ReadFloat();
|
||||
gv.rotation = buffer.ReadFloat();
|
||||
gv.grayed = buffer.ReadBool();
|
||||
gv.touchable = buffer.ReadBool();
|
||||
}
|
||||
|
||||
override public void Apply()
|
||||
{
|
||||
GearLookValue gv;
|
||||
if (!_storage.TryGetValue(_controller.selectedPageId, out gv))
|
||||
gv = _default;
|
||||
|
||||
if (_tweenConfig != null && _tweenConfig.tween && UIPackage._constructing == 0 && !disableAllTweenEffect)
|
||||
{
|
||||
_owner._gearLocked = true;
|
||||
_owner.grayed = gv.grayed;
|
||||
_owner.touchable = gv.touchable;
|
||||
_owner._gearLocked = false;
|
||||
|
||||
if (_tweenConfig._tweener != null)
|
||||
{
|
||||
if (_tweenConfig._tweener.endValue.x != gv.alpha || _tweenConfig._tweener.endValue.y != gv.rotation)
|
||||
{
|
||||
_tweenConfig._tweener.Kill(true);
|
||||
_tweenConfig._tweener = null;
|
||||
}
|
||||
else
|
||||
return;
|
||||
}
|
||||
|
||||
bool a = gv.alpha != _owner.alpha;
|
||||
bool b = gv.rotation != _owner.rotation;
|
||||
if (a || b)
|
||||
{
|
||||
if (_owner.CheckGearController(0, _controller))
|
||||
_tweenConfig._displayLockToken = _owner.AddDisplayLock();
|
||||
|
||||
_tweenConfig._tweener = GTween.To(new Vector2(_owner.alpha, _owner.rotation), new Vector2(gv.alpha, gv.rotation), _tweenConfig.duration)
|
||||
.SetDelay(_tweenConfig.delay)
|
||||
.SetEase(_tweenConfig.easeType, _tweenConfig.customEase)
|
||||
.SetUserData((a ? 1 : 0) + (b ? 2 : 0))
|
||||
.SetTarget(this)
|
||||
.SetListener(this);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_owner._gearLocked = true;
|
||||
_owner.alpha = gv.alpha;
|
||||
_owner.rotation = gv.rotation;
|
||||
_owner.grayed = gv.grayed;
|
||||
_owner.touchable = gv.touchable;
|
||||
_owner._gearLocked = false;
|
||||
}
|
||||
}
|
||||
|
||||
public void OnTweenStart(GTweener tweener)
|
||||
{
|
||||
}
|
||||
|
||||
public void OnTweenUpdate(GTweener tweener)
|
||||
{
|
||||
int flag = (int)tweener.userData;
|
||||
_owner._gearLocked = true;
|
||||
if ((flag & 1) != 0)
|
||||
_owner.alpha = tweener.value.x;
|
||||
if ((flag & 2) != 0)
|
||||
{
|
||||
_owner.rotation = tweener.value.y;
|
||||
_owner.InvalidateBatchingState();
|
||||
}
|
||||
_owner._gearLocked = false;
|
||||
}
|
||||
|
||||
public void OnTweenComplete(GTweener tweener)
|
||||
{
|
||||
_tweenConfig._tweener = null;
|
||||
if (_tweenConfig._displayLockToken != 0)
|
||||
{
|
||||
_owner.ReleaseDisplayLock(_tweenConfig._displayLockToken);
|
||||
_tweenConfig._displayLockToken = 0;
|
||||
}
|
||||
_owner.DispatchEvent("onGearStop", this);
|
||||
}
|
||||
|
||||
override public void UpdateState()
|
||||
{
|
||||
GearLookValue gv;
|
||||
if (!_storage.TryGetValue(_controller.selectedPageId, out gv))
|
||||
_storage[_controller.selectedPageId] = new GearLookValue(_owner.alpha, _owner.rotation, _owner.grayed, _owner.touchable);
|
||||
else
|
||||
{
|
||||
gv.alpha = _owner.alpha;
|
||||
gv.rotation = _owner.rotation;
|
||||
gv.grayed = _owner.grayed;
|
||||
gv.touchable = _owner.touchable;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
13
Assets/Plugins/FairyGUI/Scripts/UI/Gears/GearLook.cs.meta
Normal file
13
Assets/Plugins/FairyGUI/Scripts/UI/Gears/GearLook.cs.meta
Normal file
@@ -0,0 +1,13 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 77704143cdb38714196c9ff520a079f8
|
||||
timeCreated: 1535374214
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
163
Assets/Plugins/FairyGUI/Scripts/UI/Gears/GearSize.cs
Normal file
163
Assets/Plugins/FairyGUI/Scripts/UI/Gears/GearSize.cs
Normal file
@@ -0,0 +1,163 @@
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using FairyGUI.Utils;
|
||||
|
||||
namespace FairyGUI
|
||||
{
|
||||
class GearSizeValue
|
||||
{
|
||||
public float width;
|
||||
public float height;
|
||||
public float scaleX;
|
||||
public float scaleY;
|
||||
|
||||
public GearSizeValue(float width, float height, float scaleX, float scaleY)
|
||||
{
|
||||
this.width = width;
|
||||
this.height = height;
|
||||
this.scaleX = scaleX;
|
||||
this.scaleY = scaleY;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gear is a connection between object and controller.
|
||||
/// </summary>
|
||||
public class GearSize : GearBase, ITweenListener
|
||||
{
|
||||
Dictionary<string, GearSizeValue> _storage;
|
||||
GearSizeValue _default;
|
||||
|
||||
public GearSize(GObject owner)
|
||||
: base(owner)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
protected override void Init()
|
||||
{
|
||||
_default = new GearSizeValue(_owner.width, _owner.height, _owner.scaleX, _owner.scaleY);
|
||||
_storage = new Dictionary<string, GearSizeValue>();
|
||||
}
|
||||
|
||||
override protected void AddStatus(string pageId, ByteBuffer buffer)
|
||||
{
|
||||
GearSizeValue gv;
|
||||
if (pageId == null)
|
||||
gv = _default;
|
||||
else
|
||||
{
|
||||
gv = new GearSizeValue(0, 0, 1, 1);
|
||||
_storage[pageId] = gv;
|
||||
}
|
||||
|
||||
gv.width = buffer.ReadInt();
|
||||
gv.height = buffer.ReadInt();
|
||||
gv.scaleX = buffer.ReadFloat();
|
||||
gv.scaleY = buffer.ReadFloat();
|
||||
}
|
||||
|
||||
override public void Apply()
|
||||
{
|
||||
GearSizeValue gv;
|
||||
if (!_storage.TryGetValue(_controller.selectedPageId, out gv))
|
||||
gv = _default;
|
||||
|
||||
if (_tweenConfig != null && _tweenConfig.tween && UIPackage._constructing == 0 && !disableAllTweenEffect)
|
||||
{
|
||||
if (_tweenConfig._tweener != null)
|
||||
{
|
||||
if (_tweenConfig._tweener.endValue.x != gv.width || _tweenConfig._tweener.endValue.y != gv.height
|
||||
|| _tweenConfig._tweener.endValue.z != gv.scaleX || _tweenConfig._tweener.endValue.w != gv.scaleY)
|
||||
{
|
||||
_tweenConfig._tweener.Kill(true);
|
||||
_tweenConfig._tweener = null;
|
||||
}
|
||||
else
|
||||
return;
|
||||
}
|
||||
|
||||
bool a = gv.width != _owner.width || gv.height != _owner.height;
|
||||
bool b = gv.scaleX != _owner.scaleX || gv.scaleY != _owner.scaleY;
|
||||
if (a || b)
|
||||
{
|
||||
if (_owner.CheckGearController(0, _controller))
|
||||
_tweenConfig._displayLockToken = _owner.AddDisplayLock();
|
||||
|
||||
_tweenConfig._tweener = GTween.To(new Vector4(_owner.width, _owner.height, _owner.scaleX, _owner.scaleY),
|
||||
new Vector4(gv.width, gv.height, gv.scaleX, gv.scaleY), _tweenConfig.duration)
|
||||
.SetDelay(_tweenConfig.delay)
|
||||
.SetEase(_tweenConfig.easeType, _tweenConfig.customEase)
|
||||
.SetUserData((a ? 1 : 0) + (b ? 2 : 0))
|
||||
.SetTarget(this)
|
||||
.SetListener(this);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_owner._gearLocked = true;
|
||||
_owner.SetSize(gv.width, gv.height, _owner.CheckGearController(1, _controller));
|
||||
_owner.SetScale(gv.scaleX, gv.scaleY);
|
||||
_owner._gearLocked = false;
|
||||
}
|
||||
}
|
||||
|
||||
public void OnTweenStart(GTweener tweener)
|
||||
{
|
||||
}
|
||||
|
||||
public void OnTweenUpdate(GTweener tweener)
|
||||
{
|
||||
_owner._gearLocked = true;
|
||||
int flag = (int)tweener.userData;
|
||||
if ((flag & 1) != 0)
|
||||
_owner.SetSize(tweener.value.x, tweener.value.y, _owner.CheckGearController(1, _controller));
|
||||
if ((flag & 2) != 0)
|
||||
_owner.SetScale(tweener.value.z, tweener.value.w);
|
||||
_owner._gearLocked = false;
|
||||
|
||||
_owner.InvalidateBatchingState();
|
||||
}
|
||||
|
||||
public void OnTweenComplete(GTweener tweener)
|
||||
{
|
||||
_tweenConfig._tweener = null;
|
||||
if (_tweenConfig._displayLockToken != 0)
|
||||
{
|
||||
_owner.ReleaseDisplayLock(_tweenConfig._displayLockToken);
|
||||
_tweenConfig._displayLockToken = 0;
|
||||
}
|
||||
_owner.DispatchEvent("onGearStop", this);
|
||||
}
|
||||
|
||||
override public void UpdateState()
|
||||
{
|
||||
GearSizeValue gv;
|
||||
if (!_storage.TryGetValue(_controller.selectedPageId, out gv))
|
||||
_storage[_controller.selectedPageId] = new GearSizeValue(_owner.width, _owner.height, _owner.scaleX, _owner.scaleY);
|
||||
else
|
||||
{
|
||||
gv.width = _owner.width;
|
||||
gv.height = _owner.height;
|
||||
gv.scaleX = _owner.scaleX;
|
||||
gv.scaleY = _owner.scaleY;
|
||||
}
|
||||
}
|
||||
|
||||
override public void UpdateFromRelations(float dx, float dy)
|
||||
{
|
||||
if (_controller != null && _storage != null)
|
||||
{
|
||||
foreach (GearSizeValue gv in _storage.Values)
|
||||
{
|
||||
gv.width += dx;
|
||||
gv.height += dy;
|
||||
}
|
||||
_default.width += dx;
|
||||
_default.height += dy;
|
||||
|
||||
UpdateState();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
13
Assets/Plugins/FairyGUI/Scripts/UI/Gears/GearSize.cs.meta
Normal file
13
Assets/Plugins/FairyGUI/Scripts/UI/Gears/GearSize.cs.meta
Normal file
@@ -0,0 +1,13 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 254f71ab913968a4e853a99ce79f0266
|
||||
timeCreated: 1535374214
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
51
Assets/Plugins/FairyGUI/Scripts/UI/Gears/GearText.cs
Normal file
51
Assets/Plugins/FairyGUI/Scripts/UI/Gears/GearText.cs
Normal file
@@ -0,0 +1,51 @@
|
||||
using System.Collections.Generic;
|
||||
using FairyGUI.Utils;
|
||||
|
||||
namespace FairyGUI
|
||||
{
|
||||
/// <summary>
|
||||
/// Gear is a connection between object and controller.
|
||||
/// </summary>
|
||||
public class GearText : GearBase
|
||||
{
|
||||
Dictionary<string, string> _storage;
|
||||
string _default;
|
||||
|
||||
public GearText(GObject owner)
|
||||
: base(owner)
|
||||
{
|
||||
}
|
||||
|
||||
protected override void Init()
|
||||
{
|
||||
_default = _owner.text;
|
||||
_storage = new Dictionary<string, string>();
|
||||
}
|
||||
|
||||
override protected void AddStatus(string pageId, ByteBuffer buffer)
|
||||
{
|
||||
if (pageId == null)
|
||||
_default = buffer.ReadS();
|
||||
else
|
||||
_storage[pageId] = buffer.ReadS();
|
||||
}
|
||||
|
||||
override public void Apply()
|
||||
{
|
||||
_owner._gearLocked = true;
|
||||
|
||||
string cv;
|
||||
if (!_storage.TryGetValue(_controller.selectedPageId, out cv))
|
||||
cv = _default;
|
||||
|
||||
_owner.text = cv;
|
||||
|
||||
_owner._gearLocked = false;
|
||||
}
|
||||
|
||||
override public void UpdateState()
|
||||
{
|
||||
_storage[_controller.selectedPageId] = _owner.text;
|
||||
}
|
||||
}
|
||||
}
|
||||
13
Assets/Plugins/FairyGUI/Scripts/UI/Gears/GearText.cs.meta
Normal file
13
Assets/Plugins/FairyGUI/Scripts/UI/Gears/GearText.cs.meta
Normal file
@@ -0,0 +1,13 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d8b20f3a5dd39ec42bed3456334916fc
|
||||
timeCreated: 1535374215
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
177
Assets/Plugins/FairyGUI/Scripts/UI/Gears/GearXY.cs
Normal file
177
Assets/Plugins/FairyGUI/Scripts/UI/Gears/GearXY.cs
Normal file
@@ -0,0 +1,177 @@
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using FairyGUI.Utils;
|
||||
|
||||
namespace FairyGUI
|
||||
{
|
||||
class GearXYValue
|
||||
{
|
||||
public float x;
|
||||
public float y;
|
||||
public float px;
|
||||
public float py;
|
||||
|
||||
public GearXYValue(float x = 0, float y = 0, float px = 0, float py = 0)
|
||||
{
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.px = px;
|
||||
this.py = py;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gear is a connection between object and controller.
|
||||
/// </summary>
|
||||
public class GearXY : GearBase, ITweenListener
|
||||
{
|
||||
public bool positionsInPercent;
|
||||
|
||||
Dictionary<string, GearXYValue> _storage;
|
||||
GearXYValue _default;
|
||||
|
||||
public GearXY(GObject owner)
|
||||
: base(owner)
|
||||
{
|
||||
}
|
||||
|
||||
protected override void Init()
|
||||
{
|
||||
_default = new GearXYValue(_owner.x, _owner.y, _owner.x / _owner.parent.width, _owner.y / _owner.parent.height);
|
||||
_storage = new Dictionary<string, GearXYValue>();
|
||||
}
|
||||
|
||||
override protected void AddStatus(string pageId, ByteBuffer buffer)
|
||||
{
|
||||
GearXYValue gv;
|
||||
if (pageId == null)
|
||||
gv = _default;
|
||||
else
|
||||
{
|
||||
gv = new GearXYValue();
|
||||
_storage[pageId] = gv;
|
||||
}
|
||||
|
||||
gv.x = buffer.ReadInt();
|
||||
gv.y = buffer.ReadInt();
|
||||
}
|
||||
|
||||
public void AddExtStatus(string pageId, ByteBuffer buffer)
|
||||
{
|
||||
GearXYValue gv;
|
||||
if (pageId == null)
|
||||
gv = _default;
|
||||
else
|
||||
gv = _storage[pageId];
|
||||
gv.px = buffer.ReadFloat();
|
||||
gv.py = buffer.ReadFloat();
|
||||
}
|
||||
|
||||
override public void Apply()
|
||||
{
|
||||
GearXYValue gv;
|
||||
if (!_storage.TryGetValue(_controller.selectedPageId, out gv))
|
||||
gv = _default;
|
||||
|
||||
Vector2 endPos = new Vector2();
|
||||
|
||||
if (positionsInPercent && _owner.parent != null)
|
||||
{
|
||||
endPos.x = gv.px * _owner.parent.width;
|
||||
endPos.y = gv.py * _owner.parent.height;
|
||||
}
|
||||
else
|
||||
{
|
||||
endPos.x = gv.x;
|
||||
endPos.y = gv.y;
|
||||
}
|
||||
|
||||
if (_tweenConfig != null && _tweenConfig.tween && UIPackage._constructing == 0 && !disableAllTweenEffect)
|
||||
{
|
||||
if (_tweenConfig._tweener != null)
|
||||
{
|
||||
if (_tweenConfig._tweener.endValue.x != endPos.x || _tweenConfig._tweener.endValue.y != endPos.y)
|
||||
{
|
||||
_tweenConfig._tweener.Kill(true);
|
||||
_tweenConfig._tweener = null;
|
||||
}
|
||||
else
|
||||
return;
|
||||
}
|
||||
Vector2 origin = _owner.xy;
|
||||
|
||||
if (endPos != origin)
|
||||
{
|
||||
if (_owner.CheckGearController(0, _controller))
|
||||
_tweenConfig._displayLockToken = _owner.AddDisplayLock();
|
||||
|
||||
_tweenConfig._tweener = GTween.To(origin, endPos, _tweenConfig.duration)
|
||||
.SetDelay(_tweenConfig.delay)
|
||||
.SetEase(_tweenConfig.easeType, _tweenConfig.customEase)
|
||||
.SetTarget(this)
|
||||
.SetListener(this);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_owner._gearLocked = true;
|
||||
_owner.SetXY(endPos.x, endPos.y);
|
||||
_owner._gearLocked = false;
|
||||
}
|
||||
}
|
||||
|
||||
public void OnTweenStart(GTweener tweener)
|
||||
{//nothing
|
||||
}
|
||||
|
||||
public void OnTweenUpdate(GTweener tweener)
|
||||
{
|
||||
_owner._gearLocked = true;
|
||||
_owner.SetXY(tweener.value.x, tweener.value.y);
|
||||
_owner._gearLocked = false;
|
||||
|
||||
_owner.InvalidateBatchingState();
|
||||
}
|
||||
|
||||
public void OnTweenComplete(GTweener tweener)
|
||||
{
|
||||
_tweenConfig._tweener = null;
|
||||
if (_tweenConfig._displayLockToken != 0)
|
||||
{
|
||||
_owner.ReleaseDisplayLock(_tweenConfig._displayLockToken);
|
||||
_tweenConfig._displayLockToken = 0;
|
||||
}
|
||||
_owner.DispatchEvent("onGearStop", this);
|
||||
}
|
||||
|
||||
override public void UpdateState()
|
||||
{
|
||||
GearXYValue gv;
|
||||
if (!_storage.TryGetValue(_controller.selectedPageId, out gv))
|
||||
_storage[_controller.selectedPageId] = gv = new GearXYValue();
|
||||
|
||||
gv.x = _owner.x;
|
||||
gv.y = _owner.y;
|
||||
|
||||
gv.px = _owner.x / _owner.parent.width;
|
||||
gv.py = _owner.y / _owner.parent.height;
|
||||
|
||||
}
|
||||
|
||||
override public void UpdateFromRelations(float dx, float dy)
|
||||
{
|
||||
if (_controller != null && _storage != null && !positionsInPercent)
|
||||
{
|
||||
foreach (GearXYValue gv in _storage.Values)
|
||||
{
|
||||
gv.x += dx;
|
||||
gv.y += dy;
|
||||
}
|
||||
_default.x += dx;
|
||||
_default.y += dy;
|
||||
|
||||
UpdateState();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
13
Assets/Plugins/FairyGUI/Scripts/UI/Gears/GearXY.cs.meta
Normal file
13
Assets/Plugins/FairyGUI/Scripts/UI/Gears/GearXY.cs.meta
Normal file
@@ -0,0 +1,13 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 082a852494dc8b94485733188788d58c
|
||||
timeCreated: 1535374214
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
35
Assets/Plugins/FairyGUI/Scripts/UI/Gears/IAnimationGear.cs
Normal file
35
Assets/Plugins/FairyGUI/Scripts/UI/Gears/IAnimationGear.cs
Normal file
@@ -0,0 +1,35 @@
|
||||
|
||||
namespace FairyGUI
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public interface IAnimationGear
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
bool playing { get; set; }
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
int frame { get; set; }
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
float timeScale { get; set; }
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
bool ignoreEngineTimeScale { get; set; }
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="time"></param>
|
||||
void Advance(float time);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d68e5b2a3af5c444689f459a8b265df7
|
||||
timeCreated: 1476166204
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
26
Assets/Plugins/FairyGUI/Scripts/UI/Gears/IColorGear.cs
Normal file
26
Assets/Plugins/FairyGUI/Scripts/UI/Gears/IColorGear.cs
Normal file
@@ -0,0 +1,26 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace FairyGUI
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public interface IColorGear
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
Color color { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public interface ITextColorGear : IColorGear
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
Color strokeColor { get; set; }
|
||||
}
|
||||
}
|
||||
13
Assets/Plugins/FairyGUI/Scripts/UI/Gears/IColorGear.cs.meta
Normal file
13
Assets/Plugins/FairyGUI/Scripts/UI/Gears/IColorGear.cs.meta
Normal file
@@ -0,0 +1,13 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e872cd17b52152a4fa250c830b9bb8cd
|
||||
timeCreated: 1476166204
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user