2016-05-31 87 views
0

我正在爲我的遊戲製作一個倒數計時器,我需要爲這些精靈製作動畫:「3」,「2」,「1」,「Go!」。我知道如何做這個動畫,所以這不是我的問題。我的問題是:爲什麼Unity不讓我選擇所有4個精靈並對它們進行動畫處理? Screenshot 1爲什麼不會讓我的動畫使用我的雪碧?

Screenshot 2

如果您需要了解更多信息或其他圖片,只是讓我知道。謝謝! :)

+1

使用援引在Unity定時器。 – Fattie

+0

您是否試圖創建一個在4個子圖像之間轉換的動畫? – LeftRight92

+0

嘿,我想通了。這是我最好的愚蠢。謝謝您的回覆的,雖然,我會給予好評您的意見@JoeBlow –

回答

0

您不使用Sprite爲動畫元件(SpriteRenderer)設置動畫效果。精靈是具有一些特殊屬性的紋理,因此它被特別考慮。

你不動畫紋理,它只是一個形象,你有一組你交換創造動畫效果的紋理。

如果你想動畫的3-2-1-去,你首先需要創建一個Sprite遊戲物體,然後分配一個精靈紋理,然後創建一個動畫和動畫剪輯。

您的動畫將在特定時間交換當前紋理,最有可能與動畫事件交換。

事實上,它可能會更容易通過腳本來做到這一點:

// Drag sprites, make sure they are in order (3->2->1->Go) 
public Sprite[] sprites; 
public SpriteRenderer sp; 
int index = 0; 

void Start() 
{ 
    // Check your sprites and sp 
    InvokeRepeating("SwapSprite", 1.0f,1.0f); // Start timer to swap each second 
    sp.sprite = sprites[index]; // Set initial sprite 
} 

private void SwapSprite() 
{ 
    if(++index == sprites.Length) // Increase the index and check we run out of sprites 
    { 
     CancelInvoke(); 
     sp.enabled = false; // Remove the counter 
     this.enabled = false; // That scripts is no more useful (could be destroyed) 
     return; 
    } 
    sp.sprite = sprites[index]; // Set new sprite 
} 
+0

只是想通了,我的問題是,我今天想完全錯誤的!而不是點擊Sprite來設置動畫,我不得不點擊UI圖像。我花了幾個小時試圖弄清楚,畢竟是如此簡單! UGHH!但是,謝謝你的回答。因爲您花時間回覆並且知道您在說什麼,所以我會將其標記爲正確。謝謝:) –

+0

我會保存腳本爲它未來的需求情況! @Everts –