コード例 #1
0
    /// <summary>
    /// show lines
    /// </summary>
    void MadeGammaCue()
    {
        GameObject l = Instantiate(line_pre) as GameObject;

        l.transform.SetParent(transform);
        l.name = "Edge_cue";

        LineRenderer lr = l.GetComponent <LineRenderer> ();

        if (lr)
        {
            lr.startColor    = Color.red;
            lr.endColor      = Color.red;
            lr.startWidth    = lr.endWidth = 0.05f;
            lr.positionCount = alphas.Length;
            for (var i = 0; i < alphas.Length; i++)
            {
                Vector3       new_pt  = new Vector3(i / 255f, alphas [i] / 255f, 0);
                Vector3       ss_pt   = new Vector3(new_pt.x, new_pt.y, 0);
                Vector3       new_pt2 = Vector3.zero;
                MP_ScreenGrid ms      = transform.parent.GetComponent <MP_ScreenGrid>();
                if (ms)
                {
                    new_pt2 = ms.getWorldPt(ss_pt);
                }
                new_pt2.z = -0.1f;
                lr.SetPosition(i, new_pt2);
            }
        }
    }
コード例 #2
0
    /// <summary>
    ///
    /// </summary>
    void Start()
    {
        global_array_foucs_col = COLUMNS / 2; //default col is half of screen
        global_array_foucs_row = ROWS / 2;


        if (layout == ScreenLayout.L_1X1)
        {
            max_cols = COLUMNS + 1;
            max_rows = ROWS + 1;

            GameObject screen = Instantiate(screen_pre) as GameObject;
            screen.transform.position = new Vector3(40, 0, -10f);
            Transform screen_grid = screen.transform.Find("MP_ScreenGrid");
            Material  m           = screen_grid.GetComponent <Renderer>().material;
            m.mainTexture = targetTexture;
            m.SetVector("_UVRect", new Vector4(0, 0, 1f, 1f));
            MP_ScreenGrid sg = screen_grid.GetComponentInChildren <MP_ScreenGrid>();
            sg.screen_width  = Screen.width;
            sg.screen_height = Screen.height;
            sg.SetGridCount(COLUMNS, ROWS);
            sg.showGrid = showGrid;
            sg.isFocus  = true;
            screenGrids.Add(sg);
        }
        else if (layout == ScreenLayout.L_2X2)
        {
        }
        else if (layout == ScreenLayout.L_2X1 || (layout == ScreenLayout.L_3X1) || (layout == ScreenLayout.L_4X1))
        {
            int iblend_count = (int)blend_count;
            //print(iblend_count);
            // how many screen

            max_cols = screen_count * (COLUMNS + 1);
            max_rows = ROWS + 1;

            // b_uv_step is a all width include normal and blend area
            // b_uv_step_u is overlap blend width in texture
            float b_uv_step   = COLUMNS * 1.0f / (COLUMNS * screen_count - iblend_count * (screen_count - 1));
            float b_uv_step_u = iblend_count * 1.0f / COLUMNS * b_uv_step;

            for (int i = 0; i < screen_count; i++)
            {
                GameObject screen = Instantiate(screen_pre) as GameObject;
                screen.transform.position = transform.position + new Vector3((i + 1) * 20 + 20, 0, -10f);
                Transform screen_grid = screen.transform.Find("MP_ScreenGrid");
                Material  m           = screen_grid.GetComponent <Renderer>().material;
                m.mainTexture = targetTexture;
                float   u_start = (b_uv_step - b_uv_step_u) * i;
                Vector4 uv_rect = new Vector4(u_start, 0f, b_uv_step, 1);
                m.SetVector("_UVRect", uv_rect);
                //m.SetVector("_RGB", Vector4.zero);
                MP_ScreenGrid sg = screen_grid.GetComponent <MP_ScreenGrid>();
                sg.screen_id = i;
                sg.SetGridCount(COLUMNS, ROWS);

                // in editor mode only use first monitor width
#if UNITY_EDITOR
                sg.screen_width  = Screen.width;
                sg.screen_height = Screen.height;
#else
                if (sg.screen_id < Display.displays.Length)
                {
                    sg.screen_width  = Display.displays[sg.screen_id].systemWidth;
                    sg.screen_height = Display.displays[sg.screen_id].systemHeight;
                }
                else
                {
                    sg.screen_width  = screen_width;
                    sg.screen_height = screen_height;
                }
#endif

                sg.GirdColor   = Color.blue;
                sg.showGrid    = showGrid;
                sg.isFocus     = false;
                sg.blend_count = iblend_count;
                if (i == 0)
                {
                    sg.isFocus = true;
                }
                screenGrids.Add(sg);
            }
        }
    }