Nextrek
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
|
/*
*
* Adventure Creator
* by Chris Burton, 2013-2014
*
* "tk2DIntegration.cs"
*
* This script contains a number of static functions for use
* in playing back 2DToolkit sprite animations. Requires 2DToolkit to work.
*
* To allow for 2DToolkit integration, the 'tk2DIsPresent'
* preprocessor must be defined. This can be done from
* Edit -> Project Settings -> Player, and entering
* 'tk2DIsPresent' into the Scripting Define Symbols text box
* for your game's build platform.
*
*/
using UnityEngine;
using System.Collections;
#if UNITY_EDITOR
using UnityEditor;
#endif
public class tk2DIntegration : ScriptableObject
{
public static bool IsDefinePresent ()
{
#if tk2DIsPresent
return true;
#else
return false;
#endif
}
public static bool PlayAnimation (Transform sprite, string clipName)
{
#if tk2DIsPresent
return (tk2DIntegration.PlayAnimation (sprite, clipName, false, WrapMode.Once));
#else
Debug.Log ("The line '#define tk2DIsPresent' in tk2DIntegration must be uncommented for 2D Toolkit integration to work.");
return true;
#endif
}
public static bool PlayAnimation (Transform sprite, string clipName, bool changeWrapMode, WrapMode wrapMode)
{
#if tk2DIsPresent
tk2dSpriteAnimationClip.WrapMode wrapMode2D = tk2dSpriteAnimationClip.WrapMode.Once;
if (wrapMode == WrapMode.Loop)
{
wrapMode2D = tk2dSpriteAnimationClip.WrapMode.Loop;
}
else if (wrapMode == WrapMode.PingPong)
{
wrapMode2D = tk2dSpriteAnimationClip.WrapMode.PingPong;
}
if (sprite && sprite.GetComponent <tk2dSpriteAnimator>())
{
tk2dSpriteAnimator anim = sprite.GetComponent <tk2dSpriteAnimator>();
tk2dSpriteAnimationClip clip = anim.GetClipByName (clipName);
if (clip != null)
{
if (!anim.IsPlaying (clip))
{
if (changeWrapMode)
{
clip.wrapMode = wrapMode2D;
}
anim.Play (clip);
}
return true;
}
return false;
}
#else
Debug.Log ("The line '#define tk2DIsPresent' in tk2DIntegration must be uncommented for 2D Toolkit integration to work.");
#endif
return true;
}
public static void StopAnimation (Transform sprite)
{
#if tk2DIsPresent
if (sprite && sprite.GetComponent <tk2dSpriteAnimator>())
{
tk2dSpriteAnimator anim = sprite.GetComponent <tk2dSpriteAnimator>();
anim.Stop ();
}
#else
Debug.Log ("The line '#define tk2DIsPresent' in tk2DIntegration must be uncommented for 2D Toolkit integration to work.");
#endif
}
public static bool IsAnimationPlaying (Transform sprite, string clipName)
{
#if tk2DIsPresent
tk2dSpriteAnimator anim = sprite.GetComponent <tk2dSpriteAnimator>();
tk2dSpriteAnimationClip clip = anim.GetClipByName (clipName);
if (clip != null)
{
if (anim.IsPlaying (clip))
{
return true;
}
}
#endif
return false;
}
}
|
Revision |
Author |
Commited |
Message |
83
|
FMMortaroli
|
Tue 13 May, 2014 11:32:51 +0000 |
|