|
- public class BrawlerPlayerBarTemp : MonoBehavior
- {
-
- // Define all Canvases and GUIX controls here
- Texture2D playerHealthMaskTexture;
- Color[] playerHealthColors;
- Texture2D playerHealthTexture;
-
- public BrawlerPlayerBarTemp()
- {
- // Set up the texture that will be used for the power bar (need to custom mask it).
- playerHealthMaskTexture = (Texture2D)Resources.Load("UI/Brawler/PlayerBarHealthMask");
- playerHealthTexture = new Texture2D(playerHealthMaskTexture.width, playerHealthMaskTexture.height, TextureFormat.ARGB32, true);
-
- int width = playerHealthMaskTexture.width;
- int height = playerHealthMaskTexture.height;
-
- for (int i = 0; i < width; i++)
- {
- for (int j = 0; j < height; j++)
- {
- int bitIdx = i + j * width;
- if ((playerHealthColors[bitIdx]).a > 0)
- {
- playerHealthColors[bitIdx] = new Color(1f, 0f, 0f, 1f);
- }
- else
- {
- playerHealthColors[bitIdx] = new Color(0f, 0f, 0f, 0f);
- }
- }
- }
- }
-
- public void OnGUI {
- playerHealthTexture.SetPixels(playerHealthColors);
- playerHealthTexture.Apply();
- GUI.DrawTexture(new Rect(0, 0, 300, 120), playerHealthTexture);
- }
复制代码 |
评分
-
查看全部评分
|