- Home /
How to slowly change an objects transparency
I want to have an image of my company logo appear when I start the program, and I want to slowly fade to back and then have it load a new scene, does anyone know how to slowly change the transparency of and object?
Answer by x4637x · Aug 16, 2017 at 03:52 AM
I think the best solution to your problem is Splash Screen.
But how do I do that if I am running unity personal edition?
Personal edition still can do the fade in and out like you said. It just can not disable the whole Splash Screen or the Unity logo.
The Unity Personal Edition license has the following limitations:
The Unity Splash Screen cannot be disabled.
The Unity logo cannot be disabled.
The opacity level can be set to a $$anonymous$$imum value of 0.5.
You should try it first.
Answer by Welgum · Aug 16, 2017 at 04:16 PM
You can use a SceneManager.LoadSceneAsync with an animation between the scenes.
Answer by M-G-Production · Aug 16, 2017 at 04:40 PM
This would be the most simple way to do it
Create a C# script, name it 'FadeOut' and then drag it on your logo gameObject. Then copy/paste the code and tweak it.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
public class FadeOut : MonoBehaviour
{
[Header("Fade Out Script")]
public Image logoImage;
[Tooltip("Will start the fade out after value (in seconds)")]
public float timeToStartFading = 2f;
[Tooltip("Higher values = faster Fade Out")]
public float fadeSpeed = 1f;
[Tooltip("Scene to Load (Must be stored in Builded Scenes Index -> File/Build Settings...)")]
public int sceneToLoad = 1;
public void Start()
{
//If you didn't drag the component
if (logoImage == null)
logoImage = GetComponent<Image>();
}
public void Update()
{
//Timer
if (timeToStartFading > 0)
{
timeToStartFading -= Time.deltaTime;
return;
}
//Modify the color by changing alpha value
logoImage.color = new Color(logoImage.color.r, logoImage.color.g, logoImage.color.b, logoImage.color.a - (fadeSpeed * Time.deltaTime));
//Basic scene change
if (logoImage.color.a <= 0)
SceneManager.LoadScene(sceneToLoad, LoadSceneMode.Single);
}
}
That doesn't work, it complains about this line of code " logoImage.color = new Color(logoImage.color.r, logoImage.color.g, logoImage.color.b, logoImage.color.a - (fadeSpeed * Time.deltaTime));" and It says: " Object reference not set to an instance of an object FadeOut.Update () (at Assets/Scripts/FadeOut.cs:35)" what do I do?
@ $$anonymous$$-G-Production oops, sorry, I forgot to add the @ symbol and your name.
Your answer
![](https://koobas.hobune.stream/wayback/20220612132813im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Fade 2 out of 3 gameobjects on the screen who have the same material 2 Answers
Transparent Character but Overriding Background 0 Answers
Can I Make Holes In Objects? 1 Answer
Transparency cone between object and camera 1 Answer
How can I make objects change color, then fade/return to its original color? 1 Answer