Beispiel #1
0
        // ------------------------------------------------------------------------------------------------------------------

        private void GenerateAssets()
        {
            // generate all needed assets so that I do not need anything else but this script in the project folder
            textures = new Texture2D[2];

            Color32 cBlack = new Color32(0, 0, 0, 255);
            Color32 cWhite = new Color32(255, 255, 255, 255);
            Color32 cGrey  = new Color32(128, 128, 128, 255);

            // create the background
            textures[0] = new Texture2D(4, 4, TextureFormat.RGBA32, false);
            EdGameUtil.TextureFill(textures[0], cBlack);
            EdGameUtil.TextureRect(textures[0], cWhite, 0, 0, 3, 3);

            // create the cell/block texture
            textures[1] = new Texture2D(CellSize, CellSize, TextureFormat.RGBA32, false);
            EdGameUtil.TextureFill(textures[1], cWhite);
            EdGameUtil.TextureFillRect(textures[1], cGrey, CellSize / 2 - 2, CellSize / 2 - 2, 4, 4);
            EdGameUtil.TextureRect(textures[1], cGrey, 0, 0, CellSize - 1, CellSize - 1);

            // apply common texture settings
            foreach (Texture2D t in textures)
            {
                t.wrapMode   = TextureWrapMode.Clamp;
                t.filterMode = FilterMode.Point;
                t.hideFlags  = HideFlags.HideAndDontSave;
            }

            // create the styles
            backStyle = new GUIStyle()
            {
                border = new RectOffset(1, 1, 1, 1), normal = { background = textures[0] }
            };
        }
Beispiel #2
0
        // ------------------------------------------------------------------------------------------------------------------

        private void GenerateAssets()
        {
            // generate all needed assets so that I do not need any texture resources in the project
            textures = new Texture2D[3];

            Color32 cBlack = new Color32(0, 0, 0, 255);
            Color32 cWhite = new Color32(255, 255, 255, 255);
            Color32 cGrey  = new Color32(128, 128, 128, 255);
            Color32 cTrans = new Color32(0, 0, 0, 0);

            // create the background
            textures[0] = new Texture2D(4, 4, TextureFormat.RGBA32, false);
            EdGameUtil.TextureFill(textures[0], cBlack);
            EdGameUtil.TextureRect(textures[0], cWhite, 0, 0, 3, 3);

            // create the cell/bubble texture
            textures[1] = new Texture2D(CellSize, CellSize, TextureFormat.RGBA32, false);
            EdGameUtil.TextureFill(textures[1], cTrans);
            EdGameUtil.TextureDrawCircleFilled(textures[1], cWhite, CellSizeHalf, CellSizeHalf, CellSizeHalf);
            EdGameUtil.TextureDrawCircle(textures[1], cGrey, CellSizeHalf, CellSizeHalf, CellSizeHalf);
            EdGameUtil.TextureDrawCircleFilled(textures[1], cGrey, CellSizeHalf, CellSizeHalf, CellSizeHalf / 3);

            // create indicator texture
            textures[2] = new Texture2D(CellSizeHalf, CellSize * 3, TextureFormat.RGBA32, false);
            EdGameUtil.TextureFill(textures[2], cTrans);
            EdGameUtil.TextureDrawVLine(textures[2], cGrey, textures[2].width / 2, 0, textures[2].height - 1);
            EdGameUtil.TextureDrawLine(textures[2], cGrey, textures[2].width / 2, 0, 0, textures[2].height / 4);
            EdGameUtil.TextureDrawLine(textures[2], cGrey, textures[2].width / 2, 0, textures[2].width - 1, textures[2].height / 4);

            // apply common texture settings
            foreach (Texture2D t in textures)
            {
                t.wrapMode   = TextureWrapMode.Clamp;
                t.filterMode = FilterMode.Point;
                t.hideFlags  = HideFlags.HideAndDontSave;
            }

            // create the styles
            backStyle = new GUIStyle()
            {
                border = new RectOffset(1, 1, 1, 1), normal = { background = textures[0] }
            };
            scoreStyle = new GUIStyle()
            {
                normal = { textColor = Color.green }
            };
        }