Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //----IMPORTANT MULTPLE SCRIPTS AHEAD!!!!----
- //SceneManager.cs----------------------------------------------------------
- //----------------------------------------------------------
- //----------------------------------------------------------
- using UnityEngine;
- using UnityEngine.UI;
- using System.Collections;
- public class SceneManager : MonoBehaviour
- {
- public GameObject transitionGO;
- bool isFadingIn = true;
- public GameObject current;
- public void TransformToImage(GameObject target){
- StartCoroutine(FadeInAndOut(target));
- }
- IEnumerator FadeInAndOut(GameObject target){
- int fadeSpeed = 3;
- Image transitionImage = transitionGO.GetComponent<Image>();
- transitionImage.raycastTarget = true;
- Color transitionColor = transitionImage.color;
- while (isFadingIn) {
- transitionColor.a += fadeSpeed * Time.deltaTime;
- if (transitionColor.a >= 1) {
- isFadingIn = false;
- transitionColor.a = 1;
- }
- transitionImage.color = transitionColor;
- yield return new WaitForEndOfFrame();
- }
- transitionImage.raycastTarget = false;
- current.SetActive(false);
- target.SetActive(true);
- current = target;
- while (!isFadingIn) {
- transitionColor.a -= fadeSpeed * Time.deltaTime;
- if (transitionColor.a <= 0) {
- transitionColor.a = 0;
- isFadingIn = true;
- }
- transitionImage.color = transitionColor;
- yield return new WaitForEndOfFrame();
- }
- }
- }
- //CustomButton.cs----------------------------------------------------------
- //----------------------------------------------------------
- //----------------------------------------------------------
- using UnityEngine;
- using UnityEngine.UI;
- public class CustomButton : MonoBehaviour
- {
- // Start is called before the first frame update
- void Start()
- {
- this.GetComponent<Image>().alphaHitTestMinimumThreshold = 0.1f;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement