我希望我的问题不重复; 我有一个统一的问题。 我写了一个透明的类(淡入/淡出循环)的对象。这是正确的。 我在场景中放了两个按钮,他们在画布的地方。 运行后,尽管我已经为画布中的透明对象写了一个命令,但里面的所有内容都变为透明(淡入和淡出循环)。 我不知道。 请帮忙。统一的透明3d
MyClass的
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using System.Threading;
using System;
public class Transparent : MonoBehaviour {
private float duration = .7f;
public float waitTime;
IEnumerator co2;
// Update is called once per frame void
public void start_tranparecncy()
{
this.co2=this.blink();
this.StartCoroutine (this.co2);
}
IEnumerator blink() {
//Color textureColor = this.transform.GetComponent<SpriteRenderer>().material.color;
Color textureColor = this.transform.GetComponent<Image>().material.color;
//textureColor.a = Mathf.PingPong(Time.time, duration)/duration;
//this.GetComponent<SpriteRenderer>().material.color = textureColor;
while (true) { // this could also be a condition indicating "alive or dead"
// we scale all axis, so they will have the same value,
// so we can work with a float instead of comparing vectors
textureColor.a=Mathf.PingPong (Time.time, duration)/duration;
this.transform.transform.GetComponent<Image>().material.color = textureColor;
// reset the timer
yield return new WaitForSeconds (waitTime);
}
//end of if(this.transform.childCount =0)
}
void stop_Transparency()
{
this.StopCoroutine (this.co2);
}
}
请提供您的代码,如果可能的话,图片也 – Thalthanas
目前还不清楚。请使用正确的命名约定。你可能是指函数而不是_command_?什么是_canvas place_?你的意思是屏幕空间 - 覆盖? “所有内部的东西都变得透明”,这不是你想要达到的目标吗? Unity中的透明度? – MrDos
@EmreE哦,对不起 –