Git Product home page Git Product logo

simplenotification's Introduction

简单的Unity全局通知

WebGl示例

资源使用方式

  1. 直接克隆该项目
  2. 导入unitypackage包

使用方法

显示通知

示例调用:

GameObject _notice =  Notice.Instance.AccordingToNotice(new Notice.NotifyVariable()
        {
            //通知文字
            text = "通知文字",
            //通知颜色
            color = Color.Red,
            //通知是否自动消失
            whetherToShutDownAutomatical = true,
            //通知消失时间
            showTime = 3.0f
        },(g) =>
        {
            //点击通知后删除通知
            Notice.Instance.CloseToInform(g);
        });

关闭对应通知

示例调用:

Notice.Instance.CloseToInform(_notice);

关闭所有通知

示例调用:

Notice.Instance.CloseToInform();

更换通知颜色与文字

示例调用:

public void LoadingNotice()
    {
        Coroutine _Load = null;
        
        GameObject _g= Notice.Instance.AccordingToNotice(new Notice.NotifyVariable()
        {
            text = "加载中",
            color = new Color(1.0f,0.5f,0.5f,0.5f),
            whetherToShutDownAutomatical = false,
            showTime = 0
        }, (g) =>
        {
            Notice.Instance.CloseToInform(g);
            StopCoroutine(_Load);
        });
        
         _Load = StartCoroutine(Load(_g));
    }

    IEnumerator Load(GameObject g)
    {
        string s = "加载中";
        float timer=0;
        while (true)
        {
            if (s.Length>=10)
            {
                s = "加载中";
            }
            else
            {
                s += ".";
            }
            Notice.Instance.ChangeNotice(g,null, s);
            yield return new WaitForSeconds(0.5f);
            timer += 0.5f;
            if (timer>5.0f)
            {
                Notice.Instance.ChangeNotice(g,new Color(0.5f,1.0f,0.5f,0.5f),"加载完成");
                //延迟一秒关闭
                yield return new WaitForSeconds(1.0f);
                Notice.Instance.CloseToInform(g);
                break;
            }
        }
    }

演示视频

20220331_193941.mp4

simplenotification's People

Contributors

cr-zhichen avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.