Skip to content

Commit 30f8ecc

Browse files
committed
Add support for changing skeleton animation in controller and transition.
1 parent 796bd4d commit 30f8ecc

File tree

4 files changed

+66
-2
lines changed

4 files changed

+66
-2
lines changed

Assets/Scripts/UI/GLoader3D.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,7 @@ public string animationName
237237
{
238238
_animationName = value;
239239
OnChange("animationName");
240+
UpdateGear(5);
240241
}
241242
}
242243

@@ -251,6 +252,7 @@ public string skinName
251252
{
252253
_skinName = value;
253254
OnChange("skinName");
255+
UpdateGear(5);
254256
}
255257
}
256258

Assets/Scripts/UI/Gears/GearAnimation.cs

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ class GearAnimationValue
77
{
88
public bool playing;
99
public int frame;
10+
public string animationName;
11+
public string skinName;
1012

1113
public GearAnimationValue(bool playing, int frame)
1214
{
@@ -31,6 +33,11 @@ public GearAnimation(GObject owner)
3133
protected override void Init()
3234
{
3335
_default = new GearAnimationValue(((IAnimationGear)_owner).playing, ((IAnimationGear)_owner).frame);
36+
if (_owner is GLoader3D)
37+
{
38+
_default.animationName = ((GLoader3D)_owner).animationName;
39+
_default.skinName = ((GLoader3D)_owner).skinName;
40+
}
3441
_storage = new Dictionary<string, GearAnimationValue>();
3542
}
3643

@@ -49,6 +56,17 @@ override protected void AddStatus(string pageId, ByteBuffer buffer)
4956
gv.frame = buffer.ReadInt();
5057
}
5158

59+
public void AddExtStatus(string pageId, ByteBuffer buffer)
60+
{
61+
GearAnimationValue gv;
62+
if (pageId == null)
63+
gv = _default;
64+
else
65+
gv = _storage[pageId];
66+
gv.animationName = buffer.ReadS();
67+
gv.skinName = buffer.ReadS();
68+
}
69+
5270
override public void Apply()
5371
{
5472
_owner._gearLocked = true;
@@ -60,6 +78,11 @@ override public void Apply()
6078
IAnimationGear mc = (IAnimationGear)_owner;
6179
mc.frame = gv.frame;
6280
mc.playing = gv.playing;
81+
if (_owner is GLoader3D)
82+
{
83+
((GLoader3D)_owner).animationName = gv.animationName;
84+
((GLoader3D)_owner).skinName = gv.skinName;
85+
}
6386

6487
_owner._gearLocked = false;
6588
}
@@ -69,12 +92,18 @@ override public void UpdateState()
6992
IAnimationGear mc = (IAnimationGear)_owner;
7093
GearAnimationValue gv;
7194
if (!_storage.TryGetValue(_controller.selectedPageId, out gv))
72-
_storage[_controller.selectedPageId] = new GearAnimationValue(mc.playing, mc.frame);
95+
_storage[_controller.selectedPageId] = gv = new GearAnimationValue(mc.playing, mc.frame);
7396
else
7497
{
7598
gv.playing = mc.playing;
7699
gv.frame = mc.frame;
77100
}
101+
102+
if (_owner is GLoader3D)
103+
{
104+
gv.animationName = ((GLoader3D)_owner).animationName;
105+
gv.skinName = ((GLoader3D)_owner).skinName;
106+
}
78107
}
79108
}
80109
}

Assets/Scripts/UI/Gears/GearBase.cs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,24 @@ public void Setup(ByteBuffer buffer)
124124
_tweenConfig.customEase = new CustomEase();
125125
_tweenConfig.customEase.Create(buffer.ReadPath());
126126
}
127+
128+
if (buffer.version >= 6)
129+
{
130+
if (this is GearAnimation)
131+
{
132+
for (int i = 0; i < cnt; i++)
133+
{
134+
string page = buffer.ReadS();
135+
if (page == null)
136+
continue;
137+
138+
((GearAnimation)this).AddExtStatus(page, buffer);
139+
}
140+
141+
if (buffer.ReadBool())
142+
((GearAnimation)this).AddExtStatus(null, buffer);
143+
}
144+
}
127145
}
128146

129147
virtual public void UpdateFromRelations(float dx, float dy)

Assets/Scripts/UI/Transition.cs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -408,7 +408,7 @@ public float totalDuration
408408
{
409409
get { return _totalDuration; }
410410
}
411-
411+
412412
/// <summary>
413413
///
414414
/// </summary>
@@ -472,6 +472,10 @@ public void SetValue(string label, params object[] aParams)
472472
tvalue.frame = Convert.ToInt32(aParams[0]);
473473
if (aParams.Length > 1)
474474
tvalue.playing = Convert.ToBoolean(aParams[1]);
475+
if (aParams.Length > 2)
476+
tvalue.animationName = (string)aParams[2];
477+
if (aParams.Length > 3)
478+
tvalue.skinName = (string)aParams[3];
475479
}
476480
break;
477481

@@ -1322,6 +1326,10 @@ void ApplyValue(TransitionItem item)
13221326
((IAnimationGear)item.target).playing = value.playing;
13231327
((IAnimationGear)item.target).timeScale = _timeScale;
13241328
((IAnimationGear)item.target).ignoreEngineTimeScale = _ignoreEngineTimeScale;
1329+
if (value.animationName != null)
1330+
((GLoader3D)item.target).animationName = value.animationName;
1331+
if (value.skinName != null)
1332+
((GLoader3D)item.target).skinName = value.skinName;
13251333
}
13261334
break;
13271335

@@ -1527,6 +1535,11 @@ void DecodeValue(TransitionItem item, ByteBuffer buffer, object value)
15271535
case TransitionActionType.Animation:
15281536
((TValue_Animation)value).playing = buffer.ReadBool();
15291537
((TValue_Animation)value).frame = buffer.ReadInt();
1538+
if (buffer.version >= 6)
1539+
{
1540+
((TValue_Animation)value).animationName = buffer.ReadS();
1541+
((TValue_Animation)value).skinName = buffer.ReadS();
1542+
}
15301543
break;
15311544

15321545
case TransitionActionType.Visible:
@@ -1662,6 +1675,8 @@ class TValue_Animation
16621675
public int frame;
16631676
public bool playing;
16641677
public bool flag;
1678+
public string animationName;
1679+
public string skinName;
16651680
}
16661681

16671682
class TValue_Sound

0 commit comments

Comments
 (0)