Ejemplo n.º 1
0
    static bool init()
    {
        if (z == null)
        {
            z = FindObjectOfType <Zdanmaku>();
        }

        //if (z == null)
        //    z = new GameObject("Zdanmuku").AddComponent<Zdanmaku>();

        if (z == null)
        {
            throw new System.Exception("需要初始化(Initialize required!),请打开(Go to) :Tools/Zdanmaku/Zdanmaku Utility Panel初始化");
        }

        z.c = FindObjectOfType <Canvas>();

        //if (z.c == null)
        //    z.c = new GameObject("Canvas").AddComponent<Canvas>();

        if (z.c == null)
        {
            throw new System.Exception("场景里至少需要一个canvas(Canvas required!) ,请点击(Go to) :GameObject/UI/Canvas新建一个canvas物体");
        }

        return(true);
    }
Ejemplo n.º 2
0
    IEnumerator AddDanmaku()
    {
        for (int i = 0; i < 500; i++)
        {
            yield return(new WaitForSeconds(0.5f));

            float f = Random.Range(3, 8);
            Zdanmaku.Show(GetString(Random.Range(0, 6)), GetColor(Random.Range(0, 6)), Random.Range(0f, 0.89f), Random.Range(30, 70), f);
        }
    }
Ejemplo n.º 3
0
    private void OnGUI()
    {
        if (!isPause)
        {
            if (GUI.Button(new Rect(0, 0, 200, 100), "Pause"))
            {
                Zdanmaku.Pause(); isPause = true;
            }
        }

        if (isPause)
        {
            if (GUI.Button(new Rect(0, 0, 200, 100), "Continue"))
            {
                Zdanmaku.Continue(); isPause = false;
            }
        }
    }
Ejemplo n.º 4
0
 private void Awake()
 {
     z = this;
 }
Ejemplo n.º 5
0
    void OnGUI()
    {
        GUILayout.Label("弹幕样式(Danmaku Style)");

        GUILayout.BeginVertical("box");

        GUILayout.BeginHorizontal();


        if (handler == null)
        {
            handler = FindObjectOfType <Zdanmaku>();
        }


        if (handler == null)
        {
            GUI.color = Color.red;
            if (GUILayout.Button("init"))
            {
                init();
            }
            GUILayout.EndHorizontal();
            GUILayout.EndVertical();
            this.ShowNotification(new GUIContent("需要初始化才能使用,点击init按钮\n(Click init button)"));
            return;
        }


        GUILayout.Label(new GUIContent("弹幕字体(Font)"));

        handler.font = (Font)EditorGUILayout.ObjectField(handler.font, typeof(Font), false);

        GUILayout.EndHorizontal();


        handler.direction = (Zdanmaku.Direction)EditorGUILayout.EnumPopup("弹幕方向(Direction)", handler.direction);

        handler.alpha = (float)EditorGUILayout.Slider("透明度", handler.alpha, 0, 1);


        GUILayout.EndVertical();

        GUILayout.Label("弹幕设置(Danmaku Setting)");


        GUILayout.BeginVertical("box");

        handler.mode = (Zdanmaku.Mode)EditorGUILayout.EnumPopup("弹幕模式(Mode)", handler.mode);

        handler.step = (int)EditorGUILayout.Slider("流畅度(Smooth)", handler.step, 32, 2048);

        handler.maxDisplay = (int)EditorGUILayout.Slider("同时显示(Concurrent Display)", handler.maxDisplay, 2, 512);

        handler.rate = (float)EditorGUILayout.Slider("消逝偏移(Disappear Offset)", handler.rate, 0.004f, 0.007f);

        GUILayout.EndVertical();


        GUILayout.Label("性能");

        GUILayout.BeginVertical("box");

        handler.maxPool = (int)EditorGUILayout.Slider("对象池容量(Objs Pool Size)", handler.maxPool, 2, 512);

        handler.maxObject = (int)EditorGUILayout.Slider("缓存(Cache)", handler.maxObject, 64, 512);

        handler.timeInterval = (float)EditorGUILayout.Slider("缓存检测间隔(Read Cache Sleep)", handler.timeInterval, 0.05f, 4f);

        this.ShowNotification(new GUIContent("显示弹幕(Display a Danmaku):\nZdanmaku.Show()\n\n参数为(Parameters):\n弹幕内容,颜色,偏移,大小,持续时间\nContent,Color,Offset,Size,Duration"));

        GUILayout.EndVertical();
    }