Dark









How do I use Dark
Below are practical examples compiled from projects for learning and reference purposes

Featured Snippets


File name: PhotonGUI.cs Copy
69     {
70         get
71         {
72             if( m_DefaultRemoveButtonStyle == null )
73             {
74                 m_DefaultRemoveButtonStyle = new GUIStyle();
75                 m_DefaultRemoveButtonStyle.fixedWidth = 30;
76                 m_DefaultRemoveButtonStyle.fixedHeight = 20;
77                 m_DefaultRemoveButtonStyle.active.background = ReorderableListResources.CreatePixelTexture( "Dark Pixel (List GUI)", new Color32( 18, 18, 18, 255 ) );
78                 m_DefaultRemoveButtonStyle.imagePosition = ImagePosition.ImageOnly;
79                 m_DefaultRemoveButtonStyle.alignment = TextAnchor.MiddleCenter;
80             }
81
82             return m_DefaultRemoveButtonStyle;
83         }
84     }
File name: ReorderableListResources.cs Copy
61         private static string[] s_DarkSkin = {
62             "iVBORw0KGgoAAAANSUhEUgAAAB4AAAAQCAYAAAABOs/SAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAIBJREFUeNpiVFZW/u/i4sLw4sULBnoACQkJhj179jAwMQwQGHoWl5aWgvHI8TGlgIXU4MUn1t3dPcx8HB8fD2cvXLgQQ0xHR4c2FmMzmBTLhl5QYwt2cn1MtsXkWjg4gvrt27fgWoMeAGQXCDD+//+fQUVF5T89fXvnzh1GgAADAFmSI1Ed3FqgAAAAAElFTkSuQmCC",
63             "iVBORw0KGgoAAAANSUhEUgAAAB4AAAAQCAYAAAABOs/SAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAHlJREFUeNpiFBER+f/jxw8GNjY2BnqAX79+MXBwcDAwMQwQGHoWv3nzBoxHjo8pBSykBi8+MWAOGWY+5uLigrO/ffuGIYbMppnF5Fg2tFM1yKfk+pbkoKZGEA+OVP3nzx+6WQizi/H///8MoqKi/+np2y9fvjACBBgAoTYjgvihfz0AAAAASUVORK5CYII=",
64             "iVBORw0KGgoAAAANSUhEUgAAAAUAAAAECAYAAABGM/VAAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAD1JREFUeNpi/P//P4OKisp/Bii4c+cOIwtIwMXFheHFixcMEhISYAVMINm3b9+CBUA0CDCiazc0NGQECDAAdH0YelA27kgAAAAASUVORK5CYII=",
65             "iVBORw0KGgoAAAANSUhEUgAAAAkAAAAFCAYAAACXU8ZrAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAACRJREFUeNpizM3N/c9AADAqKysTVMTi5eXFSFAREFPHOoAAAwBCfwcAO8g48QAAAABJRU5ErkJggg==",
66             "iVBORw0KGgoAAAANSUhEUgAAAAgAAAAECAYAAACzzX7wAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAACJJREFUeNpi/P//PwM+wHL06FG8KpgYCABGZWVlvCYABBgA7/sHvGw+cz8AAAAASUVORK5CYII=",
67             "iVBORw0KGgoAAAANSUhEUgAAAAgAAAAECAYAAACzzX7wAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAACBJREFUeNpi/P//PwM+wPKfgAomBgKAhYuLC68CgAADAAxjByOjCHIRAAAAAElFTkSuQmCC",
68             "iVBORw0KGgoAAAANSUhEUgAAAAUAAAAECAYAAABGM/VAAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAADtJREFUeNpi/P//P4OKisp/Bii4c+cOIwtIQE9Pj+HLly9gQRCfBcQACbx69QqmmAEseO/ePQZkABBgAD04FXsmmijSAAAAAElFTkSuQmCC"
69         };
File name: ReorderableListResources.cs Copy
168         private static void LoadResourceAssets()
169         {
170             var skin = EditorGUIUtility.isProSkin ? s_DarkSkin : s_LightSkin;
171             s_Cached = new Texture2D[ skin.Length ];
172
173             for( int i = 0; i < s_Cached.Length; ++i )
174             {
175                 // Get image data (PNG) from base64 encoded strings.
176                 byte[] imageData = Convert.FromBase64String( skin[ i ] );
177
178                 // Gather image size from image data.
179                 int texWidth, texHeight;
180                 GetImageSize( imageData, out texWidth, out texHeight );
181
182                 // Generate texture asset.
183                 var tex = new Texture2D( texWidth, texHeight, TextureFormat.ARGB32, false, true );
184                 tex.hideFlags = HideFlags.HideAndDontSave;
185                 tex.name = "(Generated) ReorderableList:" + i;
186                 tex.filterMode = FilterMode.Point;
187                 tex.LoadImage( imageData );
188
189                 s_Cached[ i ] = tex;
190             }
191
192             s_LightSkin = null;
193             s_DarkSkin = null;
194         }
File name: Program.cs Copy
23         static void Main(string[] args)
24         {
25             byte right = 0;
26             byte left = 1;
27             byte down = 2;
28             byte up = 3;
29             int lastFoodTime = 0;
30             int foodDissapearTime = 8000;
31             int negativePoints = 0;
32
33             Position[] directions = new Position[]
34             {
35                 new Position(0, 1), // right
36                 new Position(0, -1), // left
37                 new Position(1, 0), // down
38                 new Position(-1, 0), // up
39             };
40             double sleepTime = 100;
41             int direction = right;
42             Random randomNumbersGenerator = new Random();
43             Console.BufferHeight = Console.WindowHeight;
44             lastFoodTime = Environment.TickCount;
45
46             List obstacles = new List()
47             {
48                 new Position(12, 12),
49                 new Position(14, 20),
50                 new Position(7, 7),
51                 new Position(19, 19),
52                 new Position(6, 9),
53             };
54             foreach (Position obstacle in obstacles)
55             {
56                 Console.ForegroundColor = ConsoleColor.Cyan;
57                 Console.SetCursorPosition(obstacle.col, obstacle.row);
58                 Console.Write("=");
59             }
60
61             Queue snakeElements = new Queue();
62             for (int i = 0; i <= 5; i++)
63             {
64                 snakeElements.Enqueue(new Position(0, i));
65             }
66
67             Position food;
68             do
69             {
70                 food = new Position(randomNumbersGenerator.Next(0, Console.WindowHeight),
71                     randomNumbersGenerator.Next(0, Console.WindowWidth));
72             }
73             while (snakeElements.Contains(food) || obstacles.Contains(food));
74             Console.SetCursorPosition(food.col, food.row);
75             Console.ForegroundColor = ConsoleColor.Yellow;
76             Console.Write("@");
77
78             foreach (Position position in snakeElements)
79             {
80                 Console.SetCursorPosition(position.col, position.row);
81                 Console.ForegroundColor = ConsoleColor.DarkGray;
82                 Console.Write("*");
83             }
84
85             while (true)
86             {
87                 negativePoints++;
88
89                 if (Console.KeyAvailable)
90                 {
91                     ConsoleKeyInfo userInput = Console.ReadKey();
92                     if (userInput.Key == ConsoleKey.LeftArrow)
93                     {
94                         if (direction != right) direction = left;
95                     }
96                     if (userInput.Key == ConsoleKey.RightArrow)
97                     {
98                         if (direction != left) direction = right;
99                     }
100                     if (userInput.Key == ConsoleKey.UpArrow)
101                     {
102                         if (direction != down) direction = up;
103                     }
104                     if (userInput.Key == ConsoleKey.DownArrow)
105                     {
106                         if (direction != up) direction = down;
107                     }
108                 }
109
110                 Position snakeHead = snakeElements.Last();
111                 Position nextDirection = directions[direction];
112
113                 Position snakeNewHead = new Position(snakeHead.row + nextDirection.row,
114                     snakeHead.col + nextDirection.col);
115
116                 if (snakeNewHead.col < 0) snakeNewHead.col = Console.WindowWidth - 1;
117                 if (snakeNewHead.row < 0) snakeNewHead.row = Console.WindowHeight - 1;
118                 if (snakeNewHead.row >= Console.WindowHeight) snakeNewHead.row = 0;
119                 if (snakeNewHead.col >= Console.WindowWidth) snakeNewHead.col = 0;
120
121                 if (snakeElements.Contains(snakeNewHead) || obstacles.Contains(snakeNewHead))
122                 {
123                     Console.SetCursorPosition(0, 0);
124                     Console.ForegroundColor = ConsoleColor.Red;
125                     Console.WriteLine("Game over!");
126                     int userPoints = (snakeElements.Count - 6) * 100 - negativePoints;
127                     //if (userPoints < 0) userPoints = 0;
128                     userPoints = Math.Max(userPoints, 0);
129                     Console.WriteLine("Your points are: {0}", userPoints);
130                     return;
131                 }
132
133                 Console.SetCursorPosition(snakeHead.col, snakeHead.row);
134                 Console.ForegroundColor = ConsoleColor.DarkGray;
135                 Console.Write("*");
136
137                 snakeElements.Enqueue(snakeNewHead);
138                 Console.SetCursorPosition(snakeNewHead.col, snakeNewHead.row);
139                 Console.ForegroundColor = ConsoleColor.Gray;
140                 if (direction == right) Console.Write(">");
141                 if (direction == left) Console.Write("<");
142                 if (direction == up) Console.Write("^");
143                 if (direction == down) Console.Write("v");
144
145
146                 if (snakeNewHead.col == food.col && snakeNewHead.row == food.row)
147                 {
148                     // feeding the snake
149                     do
150                     {
151                         food = new Position(randomNumbersGenerator.Next(0, Console.WindowHeight),
152                             randomNumbersGenerator.Next(0, Console.WindowWidth));
153                     }
154                     while (snakeElements.Contains(food) || obstacles.Contains(food));
155                     lastFoodTime = Environment.TickCount;
156                     Console.SetCursorPosition(food.col, food.row);
157                     Console.ForegroundColor = ConsoleColor.Yellow;
158                     Console.Write("@");
159                     sleepTime--;
160
161                     Position obstacle = new Position();
162                     do
163                     {
164                         obstacle = new Position(randomNumbersGenerator.Next(0, Console.WindowHeight),
165                             randomNumbersGenerator.Next(0, Console.WindowWidth));
166                     }
167                     while (snakeElements.Contains(obstacle) ||
168                         obstacles.Contains(obstacle) ||
169                         (food.row != obstacle.row && food.col != obstacle.row));
170                     obstacles.Add(obstacle);
171                     Console.SetCursorPosition(obstacle.col, obstacle.row);
172                     Console.ForegroundColor = ConsoleColor.Cyan;
173                     Console.Write("=");
174                 }
175                 else
176                 {
177                     // moving...
178                     Position last = snakeElements.Dequeue();
179                     Console.SetCursorPosition(last.col, last.row);
180                     Console.Write(" ");
181                 }
182
183                 if (Environment.TickCount - lastFoodTime >= foodDissapearTime)
184                 {
185                     negativePoints = negativePoints + 50;
186                     Console.SetCursorPosition(food.col, food.row);
187                     Console.Write(" ");
188                     do
189                     {
190                         food = new Position(randomNumbersGenerator.Next(0, Console.WindowHeight),
191                             randomNumbersGenerator.Next(0, Console.WindowWidth));
192                     }
193                     while (snakeElements.Contains(food) || obstacles.Contains(food));
194                     lastFoodTime = Environment.TickCount;
195                 }
196
197                 Console.SetCursorPosition(food.col, food.row);
198                 Console.ForegroundColor = ConsoleColor.Yellow;
199                 Console.Write("@");
200
201                 sleepTime -= 0.01;
202
203                 Thread.Sleep((int)sleepTime);
204             }
205         }

Download file with original file name:Dark

Dark 111 lượt xem

Gõ tìm kiếm nhanh...