Elin Decompiled Documentation EA 23.102 Nightly
Loading...
Searching...
No Matches
PUIExampleCharts.cs
Go to the documentation of this file.
1using UnityEngine;
2using UnityEngine.UI;
3
5
6public class PUIExampleCharts : MonoBehaviour
7{
9
10 public Slider sliderAka;
11
12 public Slider sliderBlauw;
13
14 public Slider sliderGelb;
15
16 public Slider sliderVerde;
17
18 [Range(0.1f, 0.25f)]
19 public float barChartBarWidth = 0.2f;
20
21 private Rect barChartBounds = new Rect(0.45f, 0.05f, 0.5f, 0.5f);
22
23 private Vector2 pieChartCenter = new Vector2(0.7f, 0.8f);
24
25 private float pieChartRadius = 0.1f;
26
27 private Color red = new Color(1f, 0.196f, 0f);
28
29 private Color blue = new Color(0f, 0.47f, 1f);
30
31 private Color yellow = new Color(1f, 0.92f, 0f);
32
33 private Color green = new Color(0f, 1f, 0.176f);
34
36
38
39 private void Start()
40 {
41 sliderAka.onValueChanged.AddListener(delegate
42 {
43 Draw();
44 });
45 sliderBlauw.onValueChanged.AddListener(delegate
46 {
47 Draw();
48 });
49 sliderGelb.onValueChanged.AddListener(delegate
50 {
51 Draw();
52 });
53 sliderVerde.onValueChanged.AddListener(delegate
54 {
55 Draw();
56 });
57 barChartAxisStroke = new StrokeStyle(Color.black, 0.006f, StrokeScaleMode.Relative);
58 barChartBgStroke = new StrokeStyle(new Color(0f, 0f, 0f, 0.2f), 0.0025f, StrokeScaleMode.Relative);
59 Draw();
60 }
61
62 private void Draw()
63 {
65 float num = barChartBounds.height / 9f;
66 for (int i = 0; i < 8; i++)
67 {
68 float y = barChartBounds.yMin + (float)(i + 1) * num;
69 primitiveCanvas.DrawLine(new Vector2(barChartBounds.xMin, y), new Vector2(barChartBounds.xMax, y), barChartBgStroke);
70 }
71 float num2 = barChartBounds.width * barChartBarWidth;
72 float num3 = (barChartBounds.width - num2 * 4f) / 5f;
73 Rect rect = new Rect(barChartBounds.xMin + num3 * 1f, barChartBounds.yMin, num2, sliderAka.value * barChartBounds.height * 0.01f);
75 rect = new Rect(barChartBounds.xMin + num3 * 2f + num2 * 1f, barChartBounds.yMin, num2, sliderBlauw.value * barChartBounds.height * 0.01f);
77 rect = new Rect(barChartBounds.xMin + num3 * 3f + num2 * 2f, barChartBounds.yMin, num2, sliderGelb.value * barChartBounds.height * 0.01f);
79 rect = new Rect(barChartBounds.xMin + num3 * 4f + num2 * 3f, barChartBounds.yMin, num2, sliderVerde.value * barChartBounds.height * 0.01f);
81 Vector2[] points = new Vector2[3]
82 {
83 new Vector2(barChartBounds.xMin, barChartBounds.yMax),
85 new Vector2(barChartBounds.xMax, barChartBounds.yMin)
86 };
87 primitiveCanvas.DrawPath(points, barChartAxisStroke, closePath: false);
88 float num4 = sliderAka.value + sliderBlauw.value + sliderGelb.value + sliderVerde.value;
89 float num5 = 0f;
90 float num6 = sliderAka.value / num4 * 360f;
92 num5 += num6;
93 num6 = sliderBlauw.value / num4 * 360f;
95 num5 += num6;
96 num6 = sliderGelb.value / num4 * 360f;
98 num5 += num6;
99 num6 = sliderVerde.value / num4 * 360f;
102 }
103}
void DrawPath(Vector2[] points)
void DrawCircle(Vector2 center, float radius, Color fillColor)
void DrawLine(Vector2 point1, Vector2 point2)
void DrawRectangle(float x, float y, float width, float height, Color fillColor)