Why Is yield return new WaitForSeconds() not working

Here Is My Script…

using UnityEngine;
using System.Collections;

public class SphereTextureChanger : MonoBehaviour 
{
	public Texture[] textures;
	public int[] Fade_InTimes;
	public int[] Wait_Times;
	public int[] Fade_OutTimes;

	private Material SphereMaterial;

	void Start () 
	{
		SphereMaterial = GetComponent<MeshRenderer>().material;

		if (Fade_InTimes.Length + Fade_OutTimes.Length + Wait_Times.Length + textures.Length == Fade_InTimes.Length * 4)
		{
			Debug.Log ("Animation Started");
			for (int i = 0; i < textures.Length; i++)
			{
				SphereMaterial.mainTexture = textures *;*

StartCoroutine (Waiter (Wait_Times*));
FadeIn (Fade_InTimes);
FadeOut (Fade_OutTimes);
_ }
}
}*_

* void Update ()*
* {*
if (Fade_InTimes.Length + Fade_OutTimes.Length + Wait_Times.Length + textures.Length != Fade_InTimes.Length * 4)
* {*
* Debug.LogError (“Number Of All Variables Are Not Equal”);*
* }*
* }*
* void FadeIn(int duration)*
* {*
* for(int i = 0; i<=128; i++)*
* {*
* StartCoroutine (Waiter (duration/128));*
* SphereMaterial.SetColor(“TintColor", new Color(SphereMaterial.GetColor("TintColor").r,SphereMaterial.GetColor("TintColor").g,SphereMaterial.GetColor("TintColor").b,i));
Debug.Log (SphereMaterial.GetColor("TintColor").ToString());*
* }*

* }*

* void FadeOut(int duration)
{
for(int i = 128; i>=0; i–)
{
StartCoroutine (Waiter (duration/128));_

SphereMaterial.SetColor(”_TintColor", new Color(SphereMaterial.GetColor(“_TintColor”).r,SphereMaterial.GetColor(“_TintColor”).g,SphereMaterial.GetColor(“_TintColor”).b, i));
Debug.Log (SphereMaterial.GetColor(“_TintColor”).ToString());*

* }*
* }*
* IEnumerator Waiter(float delay)*
* {*
* yield return new WaitForSecondsRealtime (delay);*
* }*
}
Everything is working Fine, But Only The Waiter() Is Not Working,It Is Not Delaying, Could Someone Tell Me My Mistake

Because you are passing duration as int, pass it as float, and it will work.

A coroutine can only delay the things in that function. So, you can do this.

using UnityEngine;
using System.Collections;

public class SphereTextureChanger : MonoBehaviour
{
    public Texture[] textures;
    public int[] Fade_InTimes;
    public int[] Wait_Times;
    public int[] Fade_OutTimes;

    private MeshRenderer sphereMeshRenderer;
    
    void Start()
    {

        sphereMeshRenderer = GetComponent<MeshRenderer>();

        if (Fade_InTimes.Length + Fade_OutTimes.Length + Wait_Times.Length + textures.Length == Fade_InTimes.Length * 4)
        {
            Debug.Log("Animation Started");
            StartCoroutine(TextureChangerCor());
        }
    }

    void Update()
    {
        if (Fade_InTimes.Length + Fade_OutTimes.Length + Wait_Times.Length + textures.Length != Fade_InTimes.Length * 4)
        {
            Debug.LogError("Number Of All Variables Are Not Equal");
        }
    }

    IEnumerator TextureChangerCor()
    {
        for (int i = 0; i < textures.Length; i++)
        {
            sphereMeshRenderer.material.mainTexture = textures*;*

// Delay
yield return new WaitForSecondsRealtime(Wait_Times*);*

yield return StartCoroutine(FadeInCor(Fade_InTimes*));
yield return StartCoroutine(FadeOutCor(Fade_OutTimes));
_}
}*_

IEnumerator FadeInCor(int duration)
{
for (int i = 0; i <= 128; i++)
{
Color c = sphereMeshRenderer.material.color;
c.a = i;
yield return new WaitForSecondsRealtime(duration / 128f);
sphereMeshRenderer.material.color = c;
Debug.Log(sphereMeshRenderer.material.color.ToString());
}
}

IEnumerator FadeOutCor(int duration)
{
for (int i = 128; i >= 0; i–)
{
Color c = sphereMeshRenderer.material.color;
c.a = i;
yield return new WaitForSecondsRealtime(duration / 128f);
sphereMeshRenderer.material.color = c;
Debug.Log(sphereMeshRenderer.material.color.ToString());
}
}
}
And you should notice that (int value / int value) always return an int value.
By the way, you have not change the MeshRenderer’s material, you change the ShpereMaterial, it’s a new instance, So you need a MeshRenderer which is not a new instance.
Maybe, this is what you want.
Of course, if you want a transparent effect, you have to give sphere a shader which supported transparent effect.