Allow us to choose between multiple styles of watermarks, or maybe a system where a user can upload a custom splashscreen to be approved by moderators or anyone who can if they want a spash screen matching their game’s theme. The moderators would check if the unity logo is visible and is valid.
Or alternatively, a cheaper plan to just remove splash screens.
DevDunk
September 1, 2022, 9:04am
2
You can slightly customize it already.
More customization simply is a Unity Pro thing (very stupid, but that’s something up to Unity)
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.SceneManagement;
using System.Collections;
using TMPro;
namespace ZeredaGames
{
[RequireComponent(typeof(Canvas))]
public class CustomSplashScreen : MonoBehaviour
{
[SerializeField] int splashScreenCount = 1;
[SerializeField] Text companySignatureText;
[SerializeField] Image fadeImage;
[SerializeField] float fadeDuration = 2.135f;
[SerializeField] bool addSound;
[SerializeField] AudioClip splashAudioClip;
AudioSource source;
[SerializeField] bool addAnimation;
Animator animator;
[SerializeField] RuntimeAnimatorController animatorController;
[SerializeField] string runAnimationStateName = "Animate";
private void Awake()
{
if (animator == null && addAnimation)
{
if (GetComponent<Animator>() == null)
animator = gameObject.AddComponent<Animator>();
else
animator = GetComponent<Animator>();
if (animatorController != null)
animator.runtimeAnimatorController = animatorController;
}
if (source == null && addSound)
{
if(GetComponent<AudioSource>() == null)
source = gameObject.AddComponent<AudioSource>();
else
source = GetComponent<AudioSource>();
if (source.clip == null)
source.clip = splashAudioClip;
}
if (fadeImage != null) StartFade();
else
{
fadeImage = GameObject.Find("FadeImage").GetComponent<Image>();
StartFade();
}
}
void StartFade()
{
if (fadeImage != null)
FadeOutText(companySignatureText, 0);
FadeInImage(fadeImage, 0);
FadeOutImage(fadeImage, fadeDuration);
StartCoroutine(RunSplash(fadeDuration));
}
IEnumerator RunSplash(float startWaitTime)
{
if (addAnimation)
animator.Play(runAnimationStateName);
if (fadeImage != null)
FadeInText(companySignatureText, startWaitTime);
yield return new WaitForSeconds(startWaitTime);
if (addSound)
{
source.Play();
yield return new WaitWhile(() => source.isPlaying == false);
}
yield return new WaitForSeconds(startWaitTime);
FadeInImage(fadeImage, startWaitTime);
yield return new WaitForSeconds(startWaitTime);
SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex + 1);
}
#region Fading Display Message Text
/// <summary>
/// Displays a message over time and then disapears
/// </summary>
/// <param name="text">The Text field to modify</param>
/// <param name="message"></param>
/// <param name="color"></param>
/// <param name="fadeTimer"></param>
public static void DisplayFadeMessage(Text text, string message, Color color, float fadeTimer)
{
FadeInText(text, 0);
text.color = color;
text.text = message;
FadeOutText(text, fadeTimer);
}
/// <summary>
/// Displays a message over time and then disapears
/// </summary>
/// <param name="text">The Text field to modify</param>
/// <param name="message"></param>
/// <param name="color"></param>
/// <param name="fadeTimer"></param>
public static void DisplayFadeMessage(TMP_Text text, string message, Color color, float fadeTimer)
{
FadeInText(text, 0);
text.color = color;
text.text = message;
FadeOutText(text, fadeTimer);
}
/// <summary>
/// Fades out an Text over time. [Make full invisable]
/// </summary>
/// <param name="text">The text used to fade.</param>
/// <param name="fadeLength">How long it fades to alpha 0.</param>
static void FadeOutText(Text text, float fadeLength)
{
text.CrossFadeAlpha(0.0f, fadeLength, false);
if (text.color.a == 0)
text.text = "";
}
static void FadeOutText(TMP_Text text, float fadeLength)
{
text.CrossFadeAlpha(0.0f, fadeLength, false);
if (text.color.a == 0)
text.text = "";
}
/// <summary>
/// Fades in an Text over time. [Make full visable]
/// </summary>
/// <param name="text">The text used to fade.</param>
/// <param name="fadeLength">How long it fades to alpha 1.</param>
static void FadeInText(Text text, float fadeLength)
{
text.CrossFadeAlpha(1.0f, fadeLength, false);
}
static void FadeInText(TMP_Text text, float fadeLength)
{
text.CrossFadeAlpha(1.0f, fadeLength, false);
}
#endregion Fading Display Message Text
#region Fading Image
/// <summary>
/// Fades out an image over time. [Make full invisable]
/// </summary>
/// <param name="FadeImage">The Image used to fade.</param>
/// <param name="fadeLength">How long it fades to alpha 0.</param>
public static void FadeOutImage(Image image, float fadeLength)
{
image.gameObject.SetActive(true);
image.CrossFadeAlpha(0.0f, fadeLength, false);
}
/// <summary>
/// Fades in an image over time. [Make full visable]
/// </summary>
/// <param name="FadeImage">The Image used to fade.</param>
/// <param name="fadeLength">How long it fades to alpha 1.</param>
public static void FadeInImage(Image image, float fadeLength)
{
image.gameObject.SetActive(true);
image.CrossFadeAlpha(1.0f, fadeLength, false);
}
#endregion Fading Image
}
}