茫茫網海中的冷日 - 對這文章發表回應
茫茫網海中的冷日
         
茫茫網海中的冷日
發生過的事,不可能遺忘,只是想不起來而已!
 恭喜您是本站第 1675072 位訪客!  登入  | 註冊
主選單

Google 自訂搜尋

Goole 廣告

隨機相片
IMG_60D_00177.jpg

授權條款

使用者登入
使用者名稱:

密碼:


忘了密碼?

現在就註冊!

對這文章發表回應

發表限制: 非會員 可以發表

發表者: 冷日 發表時間: 2015/4/22 8:39:00
making a fadeout with the new GUI in 4.6?

I figured that making a fadeout transition with the new GUI system would be easy, my plan was: create a black panel (Image component) that fills the whole screen, control the alpha with a Mathf.Lerp and there! fadeout accomplished!.... the problem is, I have no idea how to access the alpha of the Image Component... is there a way to do that? or maybe an even easier way to do fadeouts/fadeins with this new Gui system? thanks in advance!

You should use the gui element's color field. color.a represents the alpha value, so that's what you should change.

Use a CanvasGroup component on the parent panel (not the Image), and fade the Alpha of that.
     using UnityEngine;
     using System.Collections;

     public class GUIFadeScript : MonoBehaviour {

         public CanvasGroup fadeCanvasGroup;

         public IEnumerator FadeToBlack(float speed)
         {
             while (fadeCanvasGroup.alpha < 1f)
             {
                 fadeCanvasGroup.alpha += speed * Time.deltaTime;

                 yield return null;
             }
         }

     }


You have to have an image. I just used myImage as an example. You can get the image component by going
     Image myImage = GetComponent<Image>();
     myImage.color = new Color(0.0f, 0.0f, 0.0f, Mathf.Lerp(myImage.color.a, 0.0f, Time.deltaTime));



原文出處:making a fadeout with the new GUI in 4.6? - Unity Answers
內容圖示
url email imgsrc image code quote
樣本
bold italic underline linethrough   












 [詳情...]
validation picture

注意事項:
預覽不需輸入認證碼,僅真正發送文章時才會檢查驗證碼。
認證碼有效期10分鐘,若輸入資料超過10分鐘,請您備份內容後,重新整理本頁並貼回您的內容,再輸入驗證碼送出。

選項

Powered by XOOPS 2.0 © 2001-2008 The XOOPS Project|