示例#1
0
    // ================================================================ //

    // フェーダーを作る.
    public Botan.Fader      createFader()
    {
        Botan.Fader fader = (GameObject.Instantiate(this.fader_prefab) as GameObject).GetComponent <Botan.Fader>();

        Transform fader_panel_transform = this.uiCanvas.transform.Find("FaderPanel");

        if (fader_panel_transform != null)
        {
            fader.GetComponent <RectTransform>().SetParent(fader_panel_transform);
        }
        else
        {
            fader.GetComponent <RectTransform>().SetParent(this.uiCanvas.GetComponent <RectTransform>());
            fader.GetComponent <RectTransform>().SetAsLastSibling();
        }

        fader.GetComponent <RectTransform>().localPosition = Vector3.zero;
        fader.GetComponent <RectTransform>().localScale    = new Vector3(Screen.width + 2.0f, Screen.height + 2.0f, 1.0f);              // 保険で少し大きくしておく.

        return(fader);
    }
    // ================================================================ //

    public Botan.Fader      createFader()
    {
        Botan.Fader fader = (GameObject.Instantiate(this.fader_prefab) as GameObject).GetComponent <Botan.Fader>();

        return(fader);
    }
示例#3
0
        void    Update()
        {
            // ---------------------------------------------------------------- //
            // 色の補間.

            Vector3 rgb_current = Fader.color_to_vector3(this.colors.current);
            Vector3 rgb_goal    = Fader.color_to_vector3(this.colors.goal);

            this.is_fading = false;

            float min_distance = 0.01f;

            if (Vector3.Distance(rgb_current, rgb_goal) < min_distance)
            {
                rgb_current = rgb_goal;
            }
            else
            {
                Vector3 rgb_next = Vector3.Lerp(rgb_current, rgb_goal, this.fade_rate);

                Vector3 distance_vector = rgb_next - rgb_current;

                if (distance_vector.magnitude < min_distance)
                {
                    distance_vector.Normalize();
                    distance_vector *= min_distance;

                    rgb_next = rgb_current + distance_vector;
                }
                rgb_current = rgb_next;

                this.is_fading = true;
            }


            // ---------------------------------------------------------------- //
            // アルファーの補間.

            float alpha_current = this.colors.current.a;
            float alpha_goal    = this.colors.goal.a;

            if (Mathf.Abs(alpha_goal - alpha_current) < min_distance)
            {
                alpha_current = alpha_goal;
            }
            else
            {
                float alpha_next = Mathf.Lerp(alpha_current, alpha_goal, this.fade_rate);

                if (Mathf.Abs(alpha_next - alpha_current) < min_distance)
                {
                    alpha_next = alpha_current + min_distance * Mathf.Sign(alpha_next - alpha_current);
                }
                alpha_current = alpha_next;

                this.is_fading = true;
            }

            // ---------------------------------------------------------------- //
            // UI.Image にセットする.

            this.colors.current = Fader.vector3_to_color(rgb_current, alpha_current);

            if (this.colors.current.a > 0.0f)
            {
                this.ui_image.color   = this.colors.current;
                this.ui_image.enabled = true;
            }
            else
            {
                this.ui_image.enabled = false;
            }
        }