一、创建一个面板作为遮罩面板,然后指定大小
接着创建一个控制该面板的脚本(将这个脚本FadeInAndOut添加给该面板)
/***
* Title:"智慧工厂" 项目
* 主题:全局层:面板物体的淡入淡出
* Description:
* 功能:
* 1、实现面板的淡入淡出功能
* Date:2017
* Version:0.1版本
* Author:Coffee
* Modify Recoder:
*/
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
namespace Global
{
public class FadeInAndOut : MonoBehaviour
{
public float colorChangeSpeed = 3F; //面板透明颜色变化的速度
private Image _ChangeImage; //需要改变透明度的组件
private bool _PanelFadeIn = true; //淡入标识
private bool _PanelFadeOut = false; //淡出标识
private void Start()
{
//获取到Image组件
_ChangeImage