本文整理汇总了C#中UVAnimation类的典型用法代码示例。如果您正苦于以下问题:C# UVAnimation类的具体用法?C# UVAnimation怎么用?C# UVAnimation使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
UVAnimation类属于命名空间,在下文中一共展示了UVAnimation类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Start
// Use this for initialization
public override void Start()
{
base.Start();
GetComponent<SimpleFollow>().enabled = false;
sprite = spriteManager.AddSprite(gameObject, width, height, 0, 127, 128, 128, false);
// Create and setup anims
UVAnimation anim = new UVAnimation();
var firstFrame = spriteManager.PixelCoordToUVCoord(new Vector2(0, 127));
var cellSize = spriteManager.PixelSpaceToUVSpace(new Vector2(128, 128));
anim.BuildUVAnim(firstFrame, cellSize, 8, 8, 14, 15);
anim.name = "Idle";
anim.loopCycles = -1;
sprite.AddAnimation(anim);
anim = new UVAnimation();
firstFrame = spriteManager.PixelCoordToUVCoord(new Vector2(0, 383));
cellSize = spriteManager.PixelSpaceToUVSpace(new Vector2(128, 128));
anim.BuildUVAnim(firstFrame, cellSize, 8, 8, 16, 15);
anim.name = "Die";
anim.loopCycles = 0;
sprite.AddAnimation(anim);
sprite.PlayAnim("Idle");
}
示例2: Start
// Use this for initialization
void Start()
{
sprite = spriteManager.AddSprite(gameObject, width, height, 0, 127, 128, 128, false);
// Create and setup anims
UVAnimation anim = new UVAnimation();
var firstFrame = spriteManager.PixelCoordToUVCoord(new Vector2(0, 127));
var cellSize = spriteManager.PixelSpaceToUVSpace(new Vector2(128, 128));
anim.BuildUVAnim(firstFrame, cellSize, 8, 8, 13, 15);
anim.name = "Idle";
anim.loopCycles = -1;
sprite.AddAnimation(anim);
anim = new UVAnimation();
firstFrame = spriteManager.PixelCoordToUVCoord(new Vector2(0, 127));
cellSize = spriteManager.PixelSpaceToUVSpace(new Vector2(128, 128));
anim.BuildUVAnim(firstFrame, cellSize, 8, 8, 13, 30);
anim.name = "Arm";
anim.loopCycles = -1;
sprite.AddAnimation(anim);
anim = new UVAnimation();
firstFrame = spriteManager.PixelCoordToUVCoord(new Vector2(256, 383));
cellSize = spriteManager.PixelSpaceToUVSpace(new Vector2(128, 128));
anim.BuildUVAnim(firstFrame, cellSize, 8, 8, 8, 30);
anim.name = "Explode";
anim.loopCycles = 1;
sprite.AddAnimation(anim);
sprite.PlayAnim("Idle");
}
示例3: Start
public override void Start()
{
base.Start();
sprite = spriteManager.AddSprite(gameObject, width, height, 0, 127, 128, 128, false);
// Create and setup anims
UVAnimation anim = new UVAnimation();
var firstFrame = spriteManager.PixelCoordToUVCoord(new Vector2(0, 127));
var cellSize = spriteManager.PixelSpaceToUVSpace(new Vector2(128, 128));
anim.BuildUVAnim(firstFrame, cellSize, 8, 8, 14, 15);
anim.name = "Idle";
anim.loopCycles = -1;
sprite.AddAnimation(anim);
anim = new UVAnimation();
firstFrame = spriteManager.PixelCoordToUVCoord(new Vector2(0, 383));
cellSize = spriteManager.PixelSpaceToUVSpace(new Vector2(128, 128));
anim.BuildUVAnim(firstFrame, cellSize, 8, 8, 16, 15);
anim.name = "Die";
anim.loopCycles = 0;
sprite.AddAnimation(anim);
sprite.PlayAnim("Idle");
dolphin = GameObject.Find("DolphinSprite");
Util.Assert(dolphin != null);
}
示例4: Start
// Use this for initialization
void Start()
{
sprite = spriteManager.AddSprite(gameObject, width, height, 0, 511, 512, 512, false);
// Create and setup anims
UVAnimation anim = new UVAnimation();
var firstFrame = spriteManager.PixelCoordToUVCoord(new Vector2(0, 511));
var cellSize = spriteManager.PixelSpaceToUVSpace(new Vector2(512, 512));
anim.BuildUVAnim(firstFrame, cellSize, 8, 8, 16, 15);
anim.name = "Idle";
anim.loopCycles = -1;
sprite.AddAnimation(anim);
anim = new UVAnimation();
firstFrame = spriteManager.PixelCoordToUVCoord(new Vector2(0, 1023));
cellSize = spriteManager.PixelSpaceToUVSpace(new Vector2(512, 512));
anim.BuildUVAnim(firstFrame, cellSize, 8, 8, 19, 15);
anim.name = "Surprise";
anim.loopCycles = 0;
sprite.AddAnimation(anim);
sprite.PlayAnim("Idle");
}
示例5: Start
void Start()
{
var transTest = new GameObject("MaterialTransform_"+ this.name);
transTest.transform.position = transform.TransformPoint(transTest.transform.position);
transTest.transform.position += new Vector3(0, 0, _depthLayer) * _depthScaleFactor;
transTest.transform.localScale = new Vector3(_scaleX, _scaleY, 0.5f);
_sprite = _spriteManager.AddSprite(transTest, _width, _height, 0, (int)_cellSize.x-1, (int)_cellSize.x, (int)_cellSize.x, false);
for (var i = 0; i < _anims.Length; i++)
{
var anim = new UVAnimation();
var firstFrameCoords = new Vector2(
//_anims[i].firstFrame.x * _cellSize.x,
0,
_anims[i].firstFrame.y * _cellSize.y);
var firstFrame = _spriteManager.PixelCoordToUVCoord(firstFrameCoords);
var cellSize = _spriteManager.PixelSpaceToUVSpace(_cellSize);
anim.BuildUVAnim(firstFrame, cellSize, _anims[i].columns, _anims[i].rows, _anims[i].totalCells, _anims[i].fps, (int)(_anims[i].firstFrame.x));
anim.name = _anims[i].name;
anim.loopCycles = _anims[i].loopCycles;
_sprite.AddAnimation(anim);
}
_currentAnimation = _defaultAnimation;
_sprite.PlayAnim(_defaultAnimation);
}
示例6: CreateAnimation
protected UVAnimation CreateAnimation(string animName, Vector2 startUVPos, Vector2 UVSize, int animCells, int loopCycles, bool pingPongAnim, float framerate){
UVAnimation anim = new UVAnimation();
anim.name = animName;
anim.loopCycles = loopCycles;
anim.framerate = framerate;
if(pingPongAnim)
anim.loopReverse = true;
anim.BuildUVAnim(startUVPos, UVSize, spriteSheetCols, spriteSheetRows, animCells, framerate);
return anim;
}
示例7: Start
// Use this for initialization
void Start()
{
sprite = spriteManager.AddSprite(this.gameObject,2,2,new Vector2(.5f,.5f), new Vector2(.25f, .5f), new Vector3(0,0,0), true);
stabbing = new UVAnimation();
stabbing.name="stabbing";
stabbing.SetAnim(stabbing.BuildUVAnim(new Vector2(.5f,.5f),new Vector2(.25f,.5f),2,2,3,2));
stabbing.loopCycles=-1; // makes animation loop infinitely
stabbing.loopReverse = true; // makes animation go in reverse after it's completed
sprite.AddAnimation(stabbing);
sprite.PlayAnim("stabbing");
}
示例8: Start
// Use this for initialization
void Start()
{
width = collider.bounds.size.x * 2 + 0.15f;
height = collider.bounds.size.y * 2 + 0.15f;
sprite = spriteManager.AddSprite(gameObject, width, height, 0, 127, 128, 128, false);
// Create and setup anims
UVAnimation anim = new UVAnimation();
var firstFrame = spriteManager.PixelCoordToUVCoord(new Vector2(0, 127));
var cellSize = spriteManager.PixelSpaceToUVSpace(new Vector2(128, 128));
anim.BuildUVAnim(firstFrame, cellSize, 8, 8, 11, 15);
anim.name = "Idle";
anim.loopCycles = -1;
sprite.AddAnimation(anim);
sprite.PlayAnim("Idle");
}
示例9: DrawAnimation
public void DrawAnimation() {
// Put sprite on the client object
GameObject totem = GameObject.Find("TotemMono");
totem.renderer.enabled = false;
Sprite totemSprite = spriteManager.AddSprite(totem, 1f, 1f, new Vector2(0, 0.5f), new Vector2(0.5f, 0.5f), Vector3.zero, false);
// Set up animation
UVAnimation anim = new UVAnimation();
anim.name = "animation1";
anim.loopCycles = -1;
anim.framerate = framerate;
anim.BuildUVAnim(new Vector2(0, 0.5f), new Vector2(0.5f, 0.5f), 2, 2, 4, framerate);
// Prepare sprite
totemSprite.AddAnimation(anim);
totemSprite.PlayAnim("animation1");
}
示例10: drawAnim
public void drawAnim(ArrayList polesWithLights)
{
print (polesWithLights.Count);
int len = polesWithLights.Count;
clients = new Sprite[len*amount];
xForms = new GameObject[len*amount];
initPositions = new Vector3[len * amount];
flaps = new UVAnimation[7];
for (int i = 0; i < 7; i++) {
flaps[i] = new UVAnimation ();
flaps[i].name = "flap_"+(7-i);
flaps[i].loopCycles = -1;
flaps[i].framerate = 14;
flaps[i].BuildUVAnim (new Vector2 (0f, (i+7f) / 14f), new Vector2 (1f / 14f, 1f / 14f), 14, 14, 14, 14);
}
int ct = 0;
int lampCount = 0;
for (int j = 0; j < polesWithLights.Count; j++) {
for (int i = 0; i < amount; i++) {
Transform pole = (Transform) polesWithLights[j];
// print (pole);
GameObject lamp = pole.Find("bulb").gameObject;
Vector3 p = new Vector3(lamp.transform.position.x+Random.Range(-2,2),lamp.transform.position.y-Random.Range(0,15),lamp.transform.position.z+Random.Range(-2,2));
initPositions[ct] = p;
xForms[ct] = Instantiate (gClient, p, Quaternion.identity) as GameObject;
xForms[ct].transform.parent = GameObject.Find("parent/poles").transform;
Sprite tempClient = spManager.AddSprite (xForms [ct], 1f, 1f, new Vector2 (0f, 7f / 14f), new Vector2 (1f / 14f, 1f / 14f), Vector3.zero, true);
clients [ct] = tempClient;//spManager.AddSprite (xForms [ct], 1f, 1f, new Vector2 (0f, 7f / 14f), new Vector2 (1f / 14f, 1f / 14f), Vector3.zero, true);
spManager.SetBillboarded (clients [ct]);
for (int q = 0; q < 7; q++) {
UVAnimation tFlap = flaps [q];
clients [ct].AddAnimation (tFlap);
}
clients [ct].PlayAnim ("flap_1");
ct++;
lampCount++;
// print (i+ " " + j + " " + ct);
}
}
built = true;
}
示例11: Start
// Use this for initialization
void Start()
{
sprite = spriteManager.AddSprite(gameObject, width, height, 0, 127, 128, 128, false);
// Create and setup anims
UVAnimation anim = new UVAnimation();
var firstFrame = spriteManager.PixelCoordToUVCoord(new Vector2(0, 127));
var cellSize = spriteManager.PixelSpaceToUVSpace(new Vector2(128, 128));
anim.BuildUVAnim(firstFrame, cellSize, 8, 8, 10, 15);
anim.name = "Idle";
anim.loopCycles = 0;
sprite.AddAnimation(anim);
sprite.PlayAnim("Idle");
sprite.SetAnimCompleteDelegate(delegate()
{
Destroy(transform.parent.gameObject);
});
}
示例12: PlayAnimInReverse
/// <summary>
/// Like PlayAnim, but plays the animation in reverse.
/// See <see cref="PlayAnim"/>.
/// </summary>
/// <param name="anim">Reference to the animation to play in reverse.</param>
public void PlayAnimInReverse(UVAnimation anim)
{
#if UNITY_4_0 || UNITY_4_1 || UNITY_4_2 || UNITY_4_3 || UNITY_4_4 || UNITY_4_5 || UNITY_4_6 || UNITY_4_7 || UNITY_4_8 || UNITY_4_9
if (deleted || !gameObject.activeInHierarchy)
#else
if (deleted || !gameObject.active)
#endif
return;
curAnim = anim;
curAnim.Reset();
curAnim.PlayInReverse();
// Ensure the framerate is not 0 so we don't
// divide by zero:
if (anim.framerate != 0.0f)
{
timeBetweenAnimFrames = 1f / anim.framerate;
}
else
{
timeBetweenAnimFrames = 1f; // Just some dummy value since it won't be used
}
timeSinceLastFrame = timeBetweenAnimFrames;
// Only add to the animated list if
// the animation has more than 1 frame:
if ((anim.GetFrameCount() > 1 || anim.onAnimEnd != UVAnimation.ANIM_END_ACTION.Do_Nothing) && anim.framerate != 0.0f)
{
StepAnim(0);
// Start coroutine
if (!animating)
{
//animating = true;
AddToAnimatedList();
//StartCoroutine(AnimationPump());
}
}
else
{
// Make sure we are no longer in the animation pump:
PauseAnim();
// Since this is a single-frame anim,
// call our delegate before setting
// the frame so that our behavior is
// consistent with multi-frame anims:
if (animCompleteDelegate != null)
animCompleteDelegate(this);
StepAnim(0);
}
}
示例13: PlayAnim
/// <summary>
/// Starts playing the specified animation
/// Note: this doesn't resume from a pause,
/// it completely restarts the animation. To
/// unpause, use <see cref="UnpauseAnim"/>.
/// </summary>
/// <param name="anim">A reference to the animation to play.</param>
public void PlayAnim(UVAnimation anim)
{
PlayAnim(anim, 0);
}
示例14: StepAnim
// Steps to the next frame of sprite animation
public override bool StepAnim(float time)
{
if (curAnim == null)
return false;
timeSinceLastFrame += Mathf.Max(0, time);
//timeSinceLastFrame += time;
framesToAdvance = (timeSinceLastFrame / timeBetweenAnimFrames);
// If there's nothing to do, return:
if (framesToAdvance < 1)
{
if (crossfadeFrames)
SetColor(new Color(1f, 1f, 1f, (1f - framesToAdvance)));
return true;
}
//timeSinceLastFrame -= timeBetweenAnimFrames * (float)framesToAdvance;
while (framesToAdvance >= 1f)
{
if (curAnim.GetNextFrame(ref frameInfo))
{
#if SPRITE_FRAME_DELEGATE
// Notify the delegate:
if(framesToAdvance >= 1f)
if (animFrameDelegate != null)
animFrameDelegate(this, curAnim.GetCurPosition());
#endif
framesToAdvance -= 1f;
timeSinceLastFrame -= timeBetweenAnimFrames;
}
else
{
// We reached the end of our animation
if (crossfadeFrames)
SetColor(Color.white);
// See if we should revert to a static appearance,
// default anim, or do nothing, etc:
switch (curAnim.onAnimEnd)
{
case UVAnimation.ANIM_END_ACTION.Do_Nothing:
PauseAnim();
// Update mesh UVs:
uvRect = frameInfo.uvs;
SetBleedCompensation();
// Resize if selected:
if (autoResize || pixelPerfect)
CalcSize();
break;
case UVAnimation.ANIM_END_ACTION.Revert_To_Static:
RevertToStatic();
break;
case UVAnimation.ANIM_END_ACTION.Play_Default_Anim:
// Notify the delegates:
/*
#if SPRITE_FRAME_DELEGATE
if (animFrameDelegate != null)
animFrameDelegate(this, curAnim.GetCurPosition());
#endif
*/
if (animCompleteDelegate != null)
animCompleteDelegate(this);
// Play the default animation:
PlayAnim(defaultAnim);
return false;
case UVAnimation.ANIM_END_ACTION.Hide:
Hide(true);
break;
case UVAnimation.ANIM_END_ACTION.Deactivate:
#if UNITY_4_0 || UNITY_4_1 || UNITY_4_2 || UNITY_4_3 || UNITY_4_4 || UNITY_4_5 || UNITY_4_6 || UNITY_4_7 || UNITY_4_8 || UNITY_4_9
gameObject.SetActive(false);
#else
gameObject.active = false;
#endif
break;
case UVAnimation.ANIM_END_ACTION.Destroy:
// Notify the delegates:
/*
#if SPRITE_FRAME_DELEGATE
if (animFrameDelegate != null)
animFrameDelegate(this, curAnim.GetCurPosition());
#endif
*/
if (animCompleteDelegate != null)
animCompleteDelegate(this);
Delete();
Destroy(gameObject);
break;
//.........这里部分代码省略.........
示例15: CopyAll
/// <summary>
/// Copies all the attributes of another sprite,
/// including its edit-time TextureAnimations.
/// </summary>
/// <param name="s">A reference to the sprite to be copied.</param>
public virtual void CopyAll(SpriteRoot s)
{
AutoSpriteBase sp;
base.Copy(s);
// Check the type:
if (!(s is AutoSpriteBase))
return;
sp = (AutoSpriteBase)s;
States = new TextureAnim[sp.States.Length];
for (int i = 0; i < States.Length; ++i)
{
States[i] = new TextureAnim();
States[i].Copy(sp.States[i]);
}
animations = new UVAnimation[States.Length];
for (int i = 0; i < States.Length; ++i)
{
animations[i] = new UVAnimation();
animations[i].SetAnim(States[i], i);
}
doNotTrimImages = sp.doNotTrimImages;
}