hi how can i change the alpha, but between time, for ex 1f of time ?
heres my script for something like that
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
//using UnityEngine.SceneManagement;
public class Fade : MonoBehaviour
{
public Image splashImage;
IEnumerator Start()
{
splashImage.canvasRenderer.SetAlpha (0.0f);
FadeIn ();
yield return new WaitForSeconds(2.5f);
//FadeOut ();
//yield return new WaitForSeconds (2.5f);
//SceneManager.LoadScene (loadLevel);
}
void FadeIn()
{
splashImage.CrossFadeAlpha (1.0f, 1.5f, false);
}
//void FadeOut()
//{
// splashImage.CrossFadeAlpha (0.0f, 2.5f, false);
//}
}
ty, but didnt work on gameobject
That code assumes you have a UI image + a canvas renderer component. What sort of game object is it? What material does it use?
yeah, like @MirzaBeig said, my script is for an image, you will have to be more detailed in what you are trying to accomplish
is a simple image like gameobject aand i need to change the “sprite render”
post some pics of your inspector or code or something
i need to change alpha like 1 seccond and back to alpha 1
yeah the script i provided should work, you will have to change it to a game object but it should still work,
rueda.CrossFadeAlpha(1.0f, 1.5f, false); is not working, because say croosfadealpha is not for gameobject
you are going to want to fade the material attached to that
i didnt understand u , srry i speak spanish, i made a pubic gameobject to assign it
srry i didnt understand u, i speak spanish and i have a public gameobject with that object
don’t know if this is correct
Si se trata de un objeto de juego, se va a querer atenuar el material adjunto a esa imagen
like this ?
SĂ, ahora cambia el alfa del material “Centro” y deberĂas ir bien
and how i change centro xdd
AquĂ, sĂłlo escribiĂł esto para que espero que pueda ayudar de lo contrario no sĂ© quĂ© más hacer para ayudar
using UnityEngine;
using System.Collections;
public class ChangeApha : MonoBehaviour
{
public Keycode increaseAlpha;
public Keycode decreaseAlpha;
public float alphaLevel = .5f;
// Use this for initialization
void Start ()
{
}
// Update is called once per frame
void Update ()
{
if(Input.GetKeyDown (increaseAlpha))
{
alphaLevel += .05f;
}
if(Input.GetKeyDown(decreaseAlpha))
{
alphaLevel -= .05f;
}
GetComponent<SpriteRenderer> ().color = new Color (1,1,1,alphalevel);
}
}
ty but i dont need with key i need with time and idk if i should use delta time
If you do += 1.0f * Time.DeltaTime, then it will be over a second. Change the first value to however long you want the transition.