Skip to content

Commit 3e772c2

Browse files
committed
init
1 parent 730bc68 commit 3e772c2

File tree

222 files changed

+9524
-1
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

222 files changed

+9524
-1
lines changed

.gitignore

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# http://unity3d.com/learn/tutorials/modules/beginner/architecture/folders-in-version-control
2+
3+
# Unity generated
4+
Library/
5+
Temp/
6+
Obj/
7+
Build/
8+
Builds/
9+
Assets/AssetStoreTools*
10+
AssetBundleServerURL.bytes
11+
AssetBundleServerURL.bytes.meta
12+
AssetBundles/
13+
14+
# Autogenerated VS/MD solution and project files
15+
ExportedObj/
16+
*.csproj
17+
*.unityproj
18+
*.sln
19+
*.suo
20+
*.tmp
21+
*.user
22+
*.userprefs
23+
*.pidb
24+
*.booproj
25+
*.svd
26+
27+
28+
# Unity3D Generated File On Crash Reports
29+
sysinfo.txt
30+
31+
# Builds
32+
*.apk
33+
*.unitypackage
34+
35+
# JetBrains Rider C# IDE
36+
.idea/
37+
*.iml
38+
39+
# OS generated
40+
.DS_Store
41+
.DS_Store?
42+
.Spotlight-V100
43+
.Trashes
44+
ehthumbs.db
45+
Thumbs.db

Components/AbstractScreen.cs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// Copyright 2014 Tokarev Mikhail (also known as Deepscorn)
2+
// http://www.apache.org/licenses/LICENSE-2.0
3+
using UnityEngine;
4+
using System.Collections;
5+
6+
namespace Assets.Sources.Scripts.Basic
7+
{
8+
// it's MonoBehaviour (not just interface) to be able to drag-n-drop in editor
9+
public abstract class AbstractScreen : MonoBehaviour
10+
{
11+
// set whether screen must start open / close transition
12+
public abstract void SetOpen(bool open);
13+
14+
public abstract IEnumerator WaitForClosing();
15+
16+
public abstract bool IsOpeningOrOpened();
17+
}
18+
}

Components/AbstractScreen.cs.meta

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
// Copyright 2014 Tokarev Mikhail (also known as Deepscorn)
2+
// http://www.apache.org/licenses/LICENSE-2.0
3+
using UnityEngine;
4+
using System.Collections;
5+
using Assets.Sources.Util.Log;
6+
7+
namespace Assets.Sources.Scripts.Basic
8+
{
9+
// usecase: screen have one keyframe animation.
10+
// Inheritance tips: More animations with one keyframe may be launched/stopped in overriden SetOpen()
11+
// But do not forget to include them in overriden IsAnimating() to be sure
12+
// your animations wount be in transition when screen will be deactivated
13+
public class BlendAnimatorBasedScreen : AbstractScreen
14+
{
15+
public string AnimatorOpenBoolParamName = "Open";
16+
public string AnimatorStateOpenName = "Open";
17+
public string AnimatorStateClosedName = "Closed";
18+
19+
private int animatorOpenBoolParamNameHash;
20+
private Animator animator;
21+
22+
private Animator Animator
23+
{
24+
get
25+
{
26+
if (animator == null)
27+
{
28+
animator = GetComponent<Animator>();
29+
}
30+
return animator;
31+
}
32+
}
33+
34+
private int AnimatorOpenBoolParamNameHash
35+
{
36+
get
37+
{
38+
if (animatorOpenBoolParamNameHash == 0)
39+
{
40+
animatorOpenBoolParamNameHash = Animator.StringToHash(AnimatorOpenBoolParamName);
41+
}
42+
return animatorOpenBoolParamNameHash;
43+
}
44+
}
45+
46+
// set whether screen must start open / close transition
47+
public override void SetOpen(bool open)
48+
{
49+
Animator.SetBool(AnimatorOpenBoolParamNameHash, open);
50+
}
51+
52+
public override IEnumerator WaitForClosing()
53+
{
54+
var closedStateReached = false;
55+
var wantToClose = true;
56+
while (!closedStateReached && wantToClose)
57+
{
58+
if (!IsAnimating())
59+
{
60+
closedStateReached = Animator.GetCurrentAnimatorStateInfo(0).IsName(AnimatorStateClosedName);
61+
}
62+
wantToClose = !IsOpeningOrOpened();
63+
64+
yield return new WaitForEndOfFrame();
65+
}
66+
}
67+
68+
public override bool IsOpeningOrOpened()
69+
{
70+
return Animator.GetBool(AnimatorOpenBoolParamNameHash);
71+
}
72+
73+
// any additional animation on which we must wait before diactivating screen
74+
// must be specified in subclasses
75+
protected virtual bool IsAnimating()
76+
{
77+
return Animator.IsInTransition(0);
78+
}
79+
}
80+
}

Components/BlendAnimatorBasedScreen.cs.meta

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Components/Carousel.meta

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)