コード例 #1
0
    private void InitSubTextures()
    {
        float colPace = 1f / m_columnCount;
        float rowPace = 1f / m_rowCount;

        m_singleTextureWidth  = m_width / m_columnCount;
        m_singleTextureHeight = m_height / m_rowCount;

        m_images       = new RawImage[m_columnCount][];
        m_textures     = new Texture2D[m_columnCount][];
        m_colors       = new Color32[m_columnCount][][];
        m_texturesTags = new bool[m_columnCount][];

        for (int column = 0; column < m_columnCount; column++)
        {
            m_images[column]       = new RawImage[m_rowCount];
            m_textures[column]     = new Texture2D[m_rowCount];
            m_colors[column]       = new Color32[m_rowCount][];
            m_texturesTags[column] = new bool[m_rowCount];

            for (int row = 0; row < m_rowCount; row++)
            {
                GameObject imageGameObject = new GameObject();
                imageGameObject.name = "Whiteboard Texture (col " + column + ", row " + row + ")";

                RawImage image = imageGameObject.AddComponent <RawImage>();

                image.rectTransform.SetParent(transform);
                image.rectTransform.localPosition = Vector3.zero;

                image.rectTransform.anchorMin = new Vector2(column * colPace, row * rowPace);
                image.rectTransform.anchorMax = new Vector2((column + 1) * colPace, (row + 1) * rowPace);
                image.rectTransform.pivot     = image.rectTransform.anchorMin + new Vector2(colPace / 2, rowPace / 2);
                image.rectTransform.offsetMin = Vector2.zero;
                image.rectTransform.offsetMax = Vector2.zero;


                Texture2D texture = new Texture2D(m_singleTextureWidth, m_singleTextureHeight);
                texture.name = "Whiteboard Texture2D (col " + column + ", row " + row + ")";
                Color32[] colors = new Color32[m_singleTextureHeight * m_singleTextureWidth];

                for (int i = 0; i < m_singleTextureHeight; i++)
                {
                    for (int j = 0; j < m_singleTextureWidth; j++)
                    {
                        colors[i * m_singleTextureWidth + j] = new Color32(255, 255, 255, 0);
                    }
                }

                m_colors[column][row] = colors.Clone() as Color32[];
                texture.SetPixels32(m_colors[column][row]);
                texture.Apply();

                m_textures[column][row]     = texture;
                image.texture               = texture;
                m_images[column][row]       = image;
                m_texturesTags[column][row] = false;
            }
        }
    }
コード例 #2
0
ファイル: Color32Test.cs プロジェクト: taumenov/sharpkml
        public void TestConstruction()
        {
            // Verify construction from an int.
            Color32 color = new Color32(OpaqueBlack);

            Assert.That(color.Abgr, Is.EqualTo(OpaqueBlack));

            // Verify construction from a bunch of RGBA bytes.
            color = new Color32(0xff, 0x00, 0x00, 0xff);
            Assert.That(color.Abgr, Is.EqualTo(OpaqueRed));

            // Verify Clone
            Color32 other = new Color32(OpaqueBlue);

            color = other.Clone();
            Assert.That(color.Abgr, Is.EqualTo(OpaqueBlue));

            // Verify parse from a string using mixed case.
            color = Color32.Parse("ff0000FF");
            Assert.That(color.Abgr, Is.EqualTo(OpaqueRed));


            // Verify correct behaviour with poorly formed string data.
            //
            // Any string supplied that is less than 8 chars is filled from the front
            // with zeros (and will thus be completely transparent).

            // An fully empty string initalizes to all zeroes (transparent black).
            color = Color32.Parse(string.Empty);
            Assert.That(color.ToString(), Is.EqualTo("00000000"));

            color = Color32.Parse("ffffff");
            Assert.That(color.ToString(), Is.EqualTo("00ffffff"));

            color = Color32.Parse("ff");
            Assert.That(color.ToString(), Is.EqualTo("000000ff"));

            // Only the first eight chars are used for construction from string. Extra
            // chars at the end of the input string are ignored.
            color = Color32.Parse("aabbccddee");
            Assert.That(color.ToString(), Is.EqualTo("aabbccdd"));

            // The input string here has two valid hex values in the first eight chars.
            // ( the "a" and "c" in "Not a c") and those are the only chars that
            // won't be replaced with zeroes.
            color = Color32.Parse("Not a color value");
            Assert.That(color.ToString(), Is.EqualTo("0000a0c0"));
        }
コード例 #3
0
ファイル: Color32Test.cs プロジェクト: karun10/KML2SQL
        public void TestConstruction()
        {
            // Verify construction from an int.
            Color32 color = new Color32(OpaqueBlack);
            Assert.That(color.Abgr, Is.EqualTo(OpaqueBlack));

            // Verify construction from a bunch of RGBA bytes.
            color = new Color32(0xff, 0x00, 0x00, 0xff);
            Assert.That(color.Abgr, Is.EqualTo(OpaqueRed));

            // Verify Clone
            Color32 other = new Color32(OpaqueBlue);
            color = other.Clone();
            Assert.That(color.Abgr, Is.EqualTo(OpaqueBlue));

            // Verify parse from a string using mixed case.
            color = Color32.Parse("ff0000FF");
            Assert.That(color.Abgr, Is.EqualTo(OpaqueRed));

            // Verify correct behaviour with poorly formed string data.
            //
            // Any string supplied that is less than 8 chars is filled from the front
            // with zeros (and will thus be completely transparent).

            // An fully empty string initalizes to all zeroes (transparent black).
            color = Color32.Parse(string.Empty);
            Assert.That(color.ToString(), Is.EqualTo("00000000"));

            color = Color32.Parse("ffffff");
            Assert.That(color.ToString(), Is.EqualTo("00ffffff"));

            color = Color32.Parse("ff");
            Assert.That(color.ToString(), Is.EqualTo("000000ff"));

            // Only the first eight chars are used for construction from string. Extra
            // chars at the end of the input string are ignored.
            color = Color32.Parse("aabbccddee");
            Assert.That(color.ToString(), Is.EqualTo("aabbccdd"));

            // The input string here has two valid hex values in the first eight chars.
            // ( the "a" and "c" in "Not a c") and those are the only chars that
            // won't be replaced with zeroes.
            color = Color32.Parse("Not a color value");
            Assert.That(color.ToString(), Is.EqualTo("0000a0c0"));
        }