Documentation for the Unity C# Library
Loading...
Searching...
No Matches
BreakdownDebug.cs
Go to the documentation of this file.
1using System;
2using System.Collections;
3using System.Collections.Generic;
4using System.Text;
5using PixoVR.Event;
6using TMPro;
7using UnityEngine;
8
9public struct BreakdownDebugInfo
10{
12 public int BreakdownPercent;
13
14 public BreakdownDebugInfo(ItemsEnum item, int value)
15 {
16 ItemEnum = item;
17 BreakdownPercent = value;
18 }
19}
20
21public class BreakdownDebug : MonoBehaviour
22{
23 [SerializeField] private TMP_Text _text;
24
25 private List<BreakdownDebugInfo> _allBreakdowns = new List<BreakdownDebugInfo>();
27 public void SetQuizData(QuizData data)
28 {
29 _quizData = data;
31 }
32
33 public void AddBreakdownsInfo(StepFunction function)
34 {
35 List<BreakdownDebugInfo> listGameObjects = new List<BreakdownDebugInfo>();
37 var stringsOfPercent = function.value.Split(new char[] { '#' });
38 bool isOneForAll = stringsOfPercent.Length < function.itemsForAction.Count;
39
40
41 for(int i = 0; i < function.itemsForAction.Count; i++)
42 {
43 int percents = isOneForAll ? int.Parse(stringsOfPercent[0]) : int.Parse(stringsOfPercent[i]);
44 listGameObjects.Add(new BreakdownDebugInfo(function.itemsForAction[i], percents));
45 }
46
47 _allBreakdowns.AddRange(listGameObjects);
49 }
50
51 private void UpdateDebugUI()
52 {
53 StringBuilder stringBuilder = new StringBuilder();
54 foreach (var quiz in _quizData.ListOfQuizzes)
55 {
56 foreach (var question in quiz.Questions)
57 {
58 int index = _allBreakdowns.FindIndex(x => x.ItemEnum == question.BreakableObjectID);
59 if (index != -1)
60 {
61 stringBuilder.AppendLine($"{question.BreakableObjectID} -------> {_allBreakdowns[index].BreakdownPercent}");
62 }
63 else
64 {
65 stringBuilder.AppendLine($"{question.BreakableObjectID} -------> NONE");
66 }
67 }
68 }
69
70 Debug.Log($"BreakdownDebug data {stringBuilder}");
71 // _text.text = stringBuilder.ToString();
72 }
73}
TMP_Text _text
[SerializeField]
void AddBreakdownsInfo(StepFunction function)
void SetQuizData(QuizData data)
List< BreakdownDebugInfo > _allBreakdowns
List< Quiz > ListOfQuizzes
Definition QuizData.cs:14
ItemsEnum
Represents a list of ID for interactable objects.
Definition ItemsEnum.cs:11
BreakdownDebugInfo(ItemsEnum item, int value)