Skip to content
This repository was archived by the owner on Feb 18, 2025. It is now read-only.

Commit c4ae59a

Browse files
committed
Add: Migration Guides
1 parent b6f7802 commit c4ae59a

File tree

4 files changed

+185
-1
lines changed

4 files changed

+185
-1
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,10 @@ or open Packages/manifest.json and add the following to the dependencies block.
107107
}
108108
```
109109

110+
### Migration Guides
111+
112+
Magic Tween is an actively developed library, and there is a possibility of breaking changes with each version. For information on migrating from previous versions, please refer to the [Migration Guides](migration.md).
113+
110114
## Basic Usage
111115

112116
By introducing Magic Tween, numerous extension methods for creating tweens on traditional Unity components are added. Below is an example of animating the position of a Transform using these extension methods:

README_JA.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ https://github.com/AnnulusGames/MagicTween.git?path=/MagicTween/Assets/MagicTwee
110110

111111
### 移行ガイド
112112

113-
Magic Tweenは現在開発中のライブラリであり、バージョン毎に破壊的変更が行われる可能性があります。過去バージョンからの移行に関しては[]()を参照してください。
113+
Magic Tweenは現在開発中のライブラリであり、バージョン毎に破壊的変更が行われる可能性があります。過去バージョンからの移行に関しては[移行ガイド](migration_ja.md)を参照してください。
114114

115115
## 基本の使い方
116116

migration.md

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
# Migration Guides
2+
3+
Magic Tween is an actively developed library, and there may be breaking changes associated with version updates. Here, we provide migration guides for transitioning to different versions.
4+
5+
## v0.1 to v0.2
6+
7+
### Overview
8+
9+
In the transition from v0.1 to v0.2, the design of ECS tweens has been completely revamped. This means that you'll need to make some changes to your code when using Magic Tween with ECS.
10+
11+
### Changes related to Tween.Entity
12+
13+
Starting from v0.2, `Tween.Entity.To()` and `Tween.Entity.FromTo()` require the specification of the component type as a type argument:
14+
15+
```cs
16+
Entity entity;
17+
float endValue;
18+
float duration;
19+
20+
// v0.1
21+
Tween.Entity.To<ExampleTranslator>(entity, endValue, duration);
22+
23+
// v0.2
24+
Tween.Entity.To<ExampleComponent, ExampleTranslator>(entity, endValue, duration);
25+
```
26+
27+
### Renaming of Translator Structs for LocalTransform Support
28+
29+
In line with the above change, we've reduced the verbosity by renaming Translator structs that support LocalTransform. In v0.2, we've removed the "LocalTransform" prefix from their names:
30+
31+
```cs
32+
Entity entity;
33+
float3 endValue;
34+
float duration;
35+
36+
// v0.1
37+
Tween.Entity.To<LocalTransformPositionTranslator>(entity, endValue, duration);
38+
39+
// v0.2
40+
Tween.Entity.To<LocalTransform, PositionTranslator>(entity, endValue, duration);
41+
```
42+
43+
## Changes related to Custom Translators
44+
45+
We have removed the `TargetEntity` property from `ITweenTranslator`. Starting from v0.2, tracking the target entity is handled by dedicated components.
46+
47+
```cs
48+
// v0.1
49+
public struct ExampleTranslator : ITweenTranslator<float, ExampleComponent>
50+
{
51+
// TargetEntity is required for entity tracking
52+
public Entity TargetEntity { get; set; }
53+
54+
public void Apply(ref ExampleComponent component, in float value)
55+
{
56+
component.value = value;
57+
}
58+
59+
public float GetValue(ref ExampleComponent component)
60+
{
61+
return component.value;
62+
}
63+
}
64+
65+
// v0.2
66+
public struct ExampleTranslator : ITweenTranslator<float, ExampleComponent>
67+
{
68+
// TargetEntity is no longer required
69+
70+
public void Apply(ref ExampleComponent component, in float value)
71+
{
72+
component.value = value;
73+
}
74+
75+
public float GetValue(ref ExampleComponent component)
76+
{
77+
return component.value;
78+
}
79+
}
80+
```
81+
82+
Additionally, `TweenTranslationSystemBase` now has type arguments for specifying TweenOptions and TweenPlugins. Starting from v0.2, you must specify both of these when creating a system:
83+
84+
```csharp
85+
// v0.1
86+
public partial class ExampleTweenTranslationSystem : TweenTranslationSystemBase<float, ExampleComponent, ExampleTranslator> { }
87+
88+
// v0.2
89+
public partial class ExampleTweenTranslationSystem : TweenTranslationSystemBase<float, NoOptions, FloatTweenPlugins, ExampleComponent, ExampleTranslator> { }
90+
```

migration_ja.md

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
# Migration Guides
2+
3+
Magic Tweenは現在も開発中のライブラリであり、バージョンの移行に伴った破壊的変更が行われる可能性があります。ここでは、バージョンのアップデートに伴う移行のガイドを提供します。
4+
5+
## v0.1 to v0.2
6+
7+
### 概要
8+
9+
v0.1からv0.2では、ECSに関するTweenの設計を一新しました。これにより、ECSでMagic Tweenを用いる際のコードにいくつか変更を加える必要が生じます。
10+
11+
### Tween.Entityに関する変更
12+
13+
`Tween.Entity.To()`および`Tween.Entity.FromTo()`はv0.2よりComponentの型引数の指定が必要になりました。
14+
15+
```cs
16+
Entity entity;
17+
float endValue;
18+
float duration;
19+
20+
// v0.1
21+
Tween.Entity.To<ExampleTranslator>(entity, endValue, duration);
22+
23+
// v0.2
24+
Tween.Entity.To<ExampleComponent, ExampleTranslator>(entity, endValue, duration);
25+
```
26+
27+
### LocalTransformに対応したTranslatorの構造体の名前を変更
28+
29+
上記の変更に伴い、記述量を削減するためLocalTransformに対応したTranslatorの名前を変更しました。v0.2では接頭辞のLocalTransformを削除した名前に変更されています。
30+
31+
```cs
32+
Entity entity;
33+
float3 endValue;
34+
float duration;
35+
36+
// v0.1
37+
Tween.Entity.To<LocalTransformPositionTranslator>(entity, endValue, duration);
38+
39+
// v0.2
40+
Tween.Entity.To<LocalTransform, PositionTranslator>(entity, endValue, duration);
41+
```
42+
43+
## カスタムTranslatorに関する変更
44+
45+
`ITweenTranslator`から`TargetEntity`のプロパティを削除しました。v0.2からは対象のEntityの追跡は専用のComponentによって行われます。
46+
47+
```cs
48+
// v0.1
49+
public struct ExampleTranslator : ITweenTranslator<float, ExampleComponent>
50+
{
51+
// Entityの追跡にTargetEntityが必要
52+
public Entity TargetEntity { get; set; }
53+
54+
public void Apply(ref ExampleComponent component, in float value)
55+
{
56+
component.value = value;
57+
}
58+
59+
public float GetValue(ref ExampleComponent component)
60+
{
61+
return component.value;
62+
}
63+
}
64+
65+
// v0.2
66+
public struct ExampleTranslator : ITweenTranslator<float, ExampleComponent>
67+
{
68+
// TargetEntityが不要に
69+
70+
public void Apply(ref ExampleComponent component, in float value)
71+
{
72+
component.value = value;
73+
}
74+
75+
public float GetValue(ref ExampleComponent component)
76+
{
77+
return component.value;
78+
}
79+
}
80+
```
81+
82+
また、`TweenTranslationSystemBase`にTweenOptionsとTweenPluginを指定する型引数が追加されました。v0.2からはこれら二つを指定してSystemを作成する必要があります。
83+
84+
```cs
85+
// v0.1
86+
public partial class ExampleTweenTranslationSystem : TweenTranslationSystemBase<float, ExampleComponent, ExampleTranslator> { }
87+
88+
// v0.2
89+
public partial class ExampleTweenTranslationSystem : TweenTranslationSystemBase<float, NoOptions, FloatTweenPlugins, ExampleComponent, ExampleTranslator> { }
90+
```

0 commit comments

Comments
 (0)