Three logo images in unity for a looming switch

Source: Internet
Author: User

public Gameobject Canvas;
Private Transform logoparent;
Private Transform Logo_logo; Logo One
Private Transform Logo_qmtgtrans; Logo two
Private Transform Logo_brand; Logo three
private float Timer; Timer
Private float time = 5f; Total length of delay
Private float Alpha = 1f;
private float alphaspeed = 3f; The time of the alpha gradient, 1, is 1 seconds for the gradient, and 2 is 2 seconds.
Displaystate displaystate = Displaystate.start;
public void Start (Gameobject Cav)
{
Canvas = CAV;
Displaystate = Displaystate.start;
var logoparentprafab = resources.load<transform> ("uiprefabs/logoparent");
Logoparent = Gameobject.instantiate (Logoparentprafab);
Logoparent.setparent (Canvas.transform, false);
Logo_logo = LogoParent.transform.Find ("Logo_logo");
Logo_qmtgtrans = LogoParent.transform.Find ("Logo_qmtg");
Logo_brand = LogoParent.transform.Find ("Logo_brand");
}

public void Update ()
{
Logodisplay ();
}
Logo Display Status Toggle
private void Logodisplay ()
{
if (displaystate = = Displaystate.start)
{
Timer = time;
Displaystate = Displaystate.delay;
}
if (displaystate = = Displaystate.delay)
{
Delaytime (Displaystate.minusalpha);
}
if (displaystate = = Displaystate.minusalpha)
{
if (Logo_logo! = null)
Alphacontrol (True, Displaystate.addalpha, Logo_logo.gameobject);
}
if (displaystate = = Displaystate.addalpha)
{
if (Logo_qmtgtrans! = null)
Alphacontrol (False, Displaystate.delay2, logo_qmtgtrans.gameobject);
}
if (displaystate = = displaystate.delay2)
{
Delaytime (DISPLAYSTATE.MINUSALPHA2);
}
if (displaystate = = DISPLAYSTATE.MINUSALPHA2)
{
if (Logo_qmtgtrans! = null)
Alphacontrol (True, DISPLAYSTATE.ADDALPHA2, Logo_qmtgtrans.gameobject);
}
if (displaystate = = DISPLAYSTATE.ADDALPHA2)
{
if (Logo_brand! = null)
Alphacontrol (False, Displaystate.delay3, logo_brand.gameobject);
}
if (displaystate = = displaystate.delay3)
{
Delaytime (DISPLAYSTATE.MINUSALPHA3);
}
if (displaystate = = DISPLAYSTATE.MINUSALPHA3)
{
if (Logo_brand! = null)
Alphacontrol (True, Displaystate.start, Logo_brand.gameobject);
}
}
Control alpha value Decrease and increase
private void Alphacontrol (bool minus, displaystate nextstate, Gameobject _logo)
{
if (minus)
{
Alpha-= Time.deltatime * 1/alphaspeed;
if (Alpha <= 0)
{
Displaystate = nextstate;
if (_logo.name = = "Logo_logo")
//{
Logo_logo.gameObject.SetActive (TRUE);
Logo_qmtgTrans.gameObject.SetActive (FALSE);
Logo_brand.gameObject.SetActive (FALSE);
//}
else if (_logo.name = = "Logo_qmtg")
//{
Logo_logo.gameObject.SetActive (FALSE);
Logo_qmtgTrans.gameObject.SetActive (TRUE);
Logo_brand.gameObject.SetActive (FALSE);
//}
else if (_logo.name = = "Logo_brand")
//{
Logo_logo.gameObject.SetActive (FALSE);
Logo_qmtgTrans.gameObject.SetActive (FALSE);
Logo_brand.gameObject.SetActive (TRUE);
//}
Else
//{
Debug.logerror ("logo disappears");
//}
}
_logo. Getcomponent<rawimage> (). color = new Color (1, 1, 1, Alpha);
}
Else
{
Alpha + = Time.deltatime * 1/alphaspeed;
if (Alpha >= 1)
{
Displaystate = nextstate;
}
_logo. Getcomponent<rawimage> (). color = new Color (1, 1, 1, Alpha);
}
}
Delay and toggle Status
private void Delaytime (Displaystate _state)
{
Timer-= Time.deltatime;
if (Timer <= 0)
{
Displaystate = _state;
Timer = time;
}
}
Display various status enumerations for logos
Private Enum Displaystate
{
Start
Delay
Minusalpha,
Addalpha,
Delay2,
MINUSALPHA2,
ADDALPHA2,
Delay3,
MINUSALPHA3,
End
}

Three logo images in unity for a looming switch

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.