Skip to content

Commit 8827f28

Browse files
committed
Update links to new documentation site.
1 parent c685805 commit 8827f28

File tree

4 files changed

+197
-16
lines changed

4 files changed

+197
-16
lines changed
Lines changed: 183 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,192 @@
1-
# The basics
1+
2+
# ElementAnimationToolkit
3+
4+
[Documentation]("https://docs.instance.id/elementanimationtoolkit/")
5+
6+
### A collection of Unity UIElements animation extension methods, new animated elements, and examples.
7+
![](media/intro_animation.gif)
8+
9+
### Note: UIElements Animations are listed as Experimental by Unity - API subject to change. Also, since Element Animation Toolkit is currently underactive development, it is possible for API changes in this library as well
10+
11+
#### The intent of this package is to help asset developers more easily create their own animation sequences via code.
12+
Though, I have been adding some new "ready to go" UIElement types, such as the "AnimatedFoldout", which you just use as you would a a typical foldout comes animated with no additional coding, minus some exposed properties to adjust the animation to your liking. I do intend to add more of these as I go along.
13+
14+
This package began simply as a small collection of helpers methods I created across my last few projects to make animating editor elements much easier and finally put into a single place. I continue to add to it as I go along but decided to put together several examples and wanted to share them.
15+
16+
### Install via OpenUPM
17+
openupm add id.instance.elementanimationtoolkit
18+
19+
### Unity Package Manager
20+
https://github.com/instance-id/elementanimationtoolkit.git#upm
221

322
### Usage:
423

5-
Note: The code is pretty heavily documented and the summaries for extension methods have examples in them.
24+
Examples: Tools > instance.id > Element Animation Toolkit
25+
26+
Note: The code is pretty ~~heavily~~ excessively documented and currently most method summaries for extension methods have examples in them. Be sure to check the comments for additional details!
27+
28+
![](https://i.imgur.com/hY3DGDA.png)
29+
30+
31+
<details>
32+
<summary>Example: Method IDE summary for 'HoverColor()'</summary>
33+
34+
```cs
35+
/// <summary>
36+
/// Adds forecolor hover capability that will not be lost like CSS:hover when programatically setting background color
37+
/// </summary>
38+
/// <example>
39+
/// <code>
40+
/// var originalColor = GetColor.FromHex("#BABABA");
41+
/// var hoverColor = GetColor.FromHex("#2F569C");
42+
///
43+
/// label.HoverColor(originalColor, hoverColor);
44+
/// </code>
45+
/// </example>
46+
```
47+
</details>
48+
49+
There are several fairly basic base animation helper methods which can easily be used on their own, but are also the basis of the more complex animation sequences:
50+
51+
### Background Color Fade-In
52+
![](media/background_fade_example.gif)
53+
(The initial fade from gray to blue)
54+
55+
<details>
56+
<summary>Example animation base helper: AnimateBackgroundColor()</summary>
57+
Usage:
58+
59+
```c#
60+
61+
Color originalColor = GetColor.FromHex("#BABABA");
62+
Color fadeColor = GetColor.FromHex("#2F569C");
63+
var durationOfFade = 250; // In milliseconds
64+
65+
VisualElement visualElement = new VisualElement();
66+
visualElement.AnimateBackgroundColor(originalColor, fadeColor, durationOfFade);
67+
68+
```
69+
70+
</details>
71+
72+
---
73+
74+
### Hover Border Pulse
75+
![](media/hoverborderpulse_example.gif)
76+
<details>
77+
<summary>Example hover animation: HoverBorderPulse()</summary>
78+
79+
Usage:
80+
81+
```c#
82+
VisualElement visualElement = new VisualElement();
83+
visualElement.HoverBorderPulse(pulseStartColor: GetColor.FromHex("#7F3B3A"), pulseEndColor: GetColor.FromHex("#2F569C"), colorDuration: 500);
84+
```
85+
86+
</details>
87+
88+
---
89+
90+
### Fade-in sequence
91+
![](media/fade_example.gif)
92+
93+
<details>
94+
<summary>Example complex animation sequence: AnimFadeInSequence()</summary>
95+
96+
Usage:
97+
98+
```c#
99+
Label label = new Label {text = "Click button to make me fade!"};
100+
101+
const int fadeInTime = 500;
102+
const float displayTime = 2000f;
103+
const int fadeOutTime = 500;
104+
string newText = "then back to the original!";
105+
var originalTextColor = GetColor.FromHex("#BABABA");
106+
var animatedTextColor = GetColor.FromHex("#607FAE");
107+
108+
label.AnimFadeInSequence(newText, animatedTextColor, originalTextColor, fadeInTime, displayTime, fadeOutTime);
109+
```
110+
111+
</details>
112+
113+
Then, of course, there is everything in between.
114+
115+
Additionally there are many helper methods relating to many different Types from Color to opening weblinks in the browser.
116+
117+
<details>
118+
<summary>Example color helper method: GetColor.FromHex()</summary>
119+
120+
Usage:
121+
```cs
122+
Color color = GetColor.FromHex("#CCCCCC");
123+
```
124+
125+
Implementation:
126+
127+
```cs
128+
public static Color FromHex(this string color)
129+
{
130+
if (!color.StartsWith("#")) Debug.LogWarning("The FromHex() function must be used on a hexadecimal string beginning with #");
131+
ColorUtility.TryParseHtmlString(color, out var outColor);
132+
return outColor;
133+
}
134+
```
135+
136+
</details>
137+
138+
<details>
139+
<summary>Example creating an external url link : OpenURL() </summary>
140+
141+
Usage:
142+
```cs
143+
VisualElement visualElement = new VisualElement();
144+
visualElement.OpenURL("https://github.com/instance-id/ElementAnimationToolkit");
145+
```
146+
147+
Implementation:
148+
149+
```cs
150+
public static T OpenURL<T>(this T element, string url) where T : VisualElement
151+
{
152+
element.RegisterCallback<MouseUpEvent>(evt =>
153+
{
154+
if (evt.button == 0)
155+
{
156+
Application.OpenURL(url);
157+
evt.StopPropagation();
158+
}
159+
});
160+
161+
return element;
162+
}
163+
```
164+
165+
</details>
6166

7167
Important files:
8168

169+
Assets/instance.id/ElementAnimationToolkit/Editor/EATKEditor.cs
170+
This file is the primary example and demonstrative reference for most major features and is the main editor window of the package
171+
where you can view examples of several different types of animations and their usage.
172+
173+
You can access the main editor window via Tools > instance.id > Element Animation Toolkit
174+
175+
There are three buttons per row, Editor, Anim, and USS.
176+
177+
![](media/rowbuttons.png)
178+
179+
The editor button will take you directly to the editor code specific to that element where you will see the C# implementation of UIElements as well as most callback registrations.
180+
181+
The Anim button takes you to another section of the file in which you can see the declaration, setup, and execution of any animation specific functions,
182+
183+
Lastly is the USS button, which takes you to the USS stylesheet and the location of the particular animation if you need.
9184

10-
Assets/instance.id/Element Animation Toolkit/UIElementsAnimationEditor.cs
11-
This file is the primary example and demonstratitive reference for most major features and is the main editor window of the package where you can view examples of several different types of animations and their usage.
185+
The animations without a row of buttons have a right-click context menu implemented which has similar options to jump directly into
186+
the code at the proper location for the animation. (The methods I have created for jumping straight to the proper lines of code
187+
are of course included and you are welcome to take advantage of them for your own needs.)
188+
![](media/jumptomenu.png)
12189

13-
There are three buttons per row, Editor, Anim, and USS. The editor button will take you directly to the editor code specific to that rows animation where you will see the C# implementation of UIElements as well as most callback registrations. The Anim button takes you to another section of the file in which you can see the declaration, setup, and execution of any animation specific functions, and lastly is the USS button, which takes you to the USS stylesheet and the location of the particular animation if you need. The
14190

15-
The animations without a row of buttons have a right-click context menu implemented which has similar options to jump directly into the code at the proper location for the animation. (The methods I have created for jumping straight to the proper lines of code are of course included and you are welcome to take advantage of them for your own needs.)
191+
---
192+
![alt text](https://i.imgur.com/cg5ow2M.png "instance.id")

Assets/instance.id/ElementAnimationToolkit/Editor/EATKEditor.cs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ private void BuildToolbarButtons(Toolbar toolbar)
243243
// -- Set the initial opacity to 0 so that it can fade in when opened --
244244
new AnimatedLabel {text = "Documentation", style = {opacity = 0.Zero()}}
245245
.Create(out var docsLabel).ToUSS(nameof(docsLabel)).SetParent(menuInfoContainer)
246-
.OpenURL("https://help.instance.id/");
246+
.OpenURL("https://docs.instance.id/elementanimationtoolkit/");
247247

248248
// ----------------------------------------------------- @MenuInfoToggle
249249
// -- The below Toggle lets us utilize it's "ValueChanged" callback, --
@@ -281,27 +281,27 @@ private void BuildToolbarButtons(Toolbar toolbar)
281281
colorDuration: 500);
282282
}
283283

284-
// ------------------------------------------- @BuildInfoContainer
284+
// ------------------------------------------ @InstanceIdContainer
285285
// ---------------------------------------------------------------
286-
private VisualElement BuildInfoContainer()
286+
private VisualElement BuildInstanceIdContainer()
287287
{
288-
var infoContainer = new VisualElement();
289-
infoContainer.NameAsUSS(nameof(infoContainer));
290-
infoContainer.AddToClassList("rightEdgePadding");
288+
var instanceIdContainer = new VisualElement();
289+
instanceIdContainer.NameAsUSS(nameof(instanceIdContainer));
290+
instanceIdContainer.AddToClassList("rightEdgePadding");
291291

292292
instanceidLabel = new AnimatedLabel {text = "instance.id"};
293293
instanceidLabel.NameAsUSS(nameof(instanceidLabel));
294294
instanceidLabel.JumpToCode(
295295
jumpTargets: new List<JumpTarget>
296296
{
297297
new JumpTarget {Locator = "_IntroAnimateIdLabel", MenuTitle = "Jump to Animation", JumpType = JumpType.Animation},
298-
new JumpTarget {Locator = "_BuildInfoContainer", MenuTitle = "Jump to Element", JumpType = JumpType.Element},
298+
new JumpTarget {Locator = "_InstanceIdContainer", MenuTitle = "Jump to Element", JumpType = JumpType.Element},
299299
new JumpTarget {Locator = "_InstanceIdLabel", MenuTitle = "Jump to USS", JumpType = JumpType.USS},
300300
},
301301
additionalMenus: new Dictionary<string, Action> {{"Replay Animation", AnimateIdLabel}});
302302

303-
infoContainer.Add(instanceidLabel);
304-
return infoContainer;
303+
instanceIdContainer.Add(instanceidLabel);
304+
return instanceIdContainer;
305305
}
306306

307307
#endregion
@@ -382,7 +382,7 @@ private void BuildImageAnimation() // @formatter:on
382382
imageAnimationLabelColumn.Add(new VisualElement[] {imageAnimationAnimatedFoldout, imageAnimationLabel});
383383

384384
// -- Image Animation Info Column --------
385-
nestedInfoColumn.Add(new[] {BuildInfoContainer(), imageAnimationButtonContainer});
385+
nestedInfoColumn.Add(new[] {BuildInstanceIdContainer(), imageAnimationButtonContainer});
386386

387387
// -- Add elements to Row Container ------
388388
var items = new[] {imageAnimationButton, imageAnimationLabelColumn, imageAnimationSpacer, nestedInfoColumn};

Assets/instance.id/ElementAnimationToolkit/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
### A collection of Unity UIElements animation extension methods, new animated elements, and examples.
55
![](Documentation/media/intro_animation.gif)
66

7+
## [Documentation]("https://docs.instance.id/elementanimationtoolkit/")
8+
79
### Note: UIElements Animations are listed as Experimental by Unity - API subject to change. Also, since Element Animation Toolkit is currently underactive development, it is possible for API changes in this library as well
810

911
#### The intent of this package is to help asset developers more easily create their own animation sequences via code.

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
### A collection of Unity UIElements animation extension methods, new animated elements, and examples.
55
![](media/intro_animation.gif)
66

7+
## [Documentation]("https://docs.instance.id/elementanimationtoolkit/")
8+
79
### Note: UIElements Animations are listed as Experimental by Unity - API subject to change. Also, since Element Animation Toolkit is currently underactive development, it is possible for API changes in this library as well
810

911
#### The intent of this package is to help asset developers more easily create their own animation sequences via code.

0 commit comments

Comments
 (0)