Skip to content

Commit 1451af0

Browse files
committed
fix: fixing a bug with probe colors not being set, also randomizing ProbeProperties color queue
1 parent a185482 commit 1451af0

File tree

5 files changed

+19
-12
lines changed

5 files changed

+19
-12
lines changed

Assets/Scripts/Pinpoint/Probes/ProbeManager.cs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,7 @@ public Color Color
180180
UIUpdateEvent.Invoke();
181181
if (ActiveProbeManager == this)
182182
ActiveProbeUIUpdateEvent.Invoke();
183+
Debug.Log(_color);
183184
}
184185
}
185186

@@ -216,6 +217,10 @@ private async void Awake()
216217
UUID = Guid.NewGuid().ToString();
217218
UpdateName();
218219

220+
// Set color
221+
if (_probeRenderer != null)
222+
_color = ProbeProperties.NextColor;
223+
219224
// Record default materials
220225
_defaultMaterials = new Dictionary<GameObject, Material>();
221226
_activeRenderers = new();
@@ -243,10 +248,6 @@ private async void Awake()
243248

244249
_axisControl = GameObject.Find("AxisControl").GetComponent<AxisControl>();
245250

246-
// Set color
247-
if (_probeRenderer != null)
248-
_color = ProbeProperties.NextColor;
249-
250251
_probeController.FinishedMovingEvent.AddListener(UpdateName);
251252
_probeController.MovedThisFrameEvent.AddListener(ProbeMoved);
252253
}
@@ -262,8 +263,6 @@ private void Start()
262263
if (_probeRenderer) _probeRenderer.material.color = _color;
263264

264265
UIUpdateEvent.Invoke();
265-
if (ActiveProbeManager == this)
266-
ActiveProbeUIUpdateEvent.Invoke();
267266
}
268267

269268
/// <summary>

Assets/Scripts/Pinpoint/Probes/ProbeProperties.cs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,19 @@ public class ProbeProperties
2727
new Color(0.6196078431372549f, 0.8549019607843137f, 0.8980392156862745f, 1.0f)
2828
};
2929

30-
private static Queue<int> _colorIdxQueue = new Queue<int>(Enumerable.Range(0, ProbeColors.Count));
30+
private static Queue<int> _colorIdxQueue;
31+
32+
public static void InitializeColors()
33+
{
34+
List<int> idxList = Enumerable.Range(0, ProbeColors.Count).ToList();
35+
_colorIdxQueue = new Queue<int>();
36+
while (idxList.Count() > 0)
37+
{
38+
int idx = Random.Range(0, idxList.Count() - 1);
39+
_colorIdxQueue.Enqueue(idxList[idx]);
40+
idxList.RemoveAt(idx);
41+
}
42+
}
3143

3244
/// <summary>
3345
/// Get the next Probe Color

Assets/Scripts/Pinpoint/Probes/UI/ProbeUIManager.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,6 @@ private void Awake()
4949

5050
GameObject main = GameObject.Find("main");
5151

52-
// Set color properly
53-
UpdateColors();
54-
5552
// Set probe to be un-selected
5653
ProbeSelected(false);
5754

Assets/Scripts/Pinpoint/TrajectoryPlannerManager.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ private void Awake()
136136
#if UNITY_WEBGL && !UNITY_EDITOR
137137
WebGLInput.captureAllKeyboardInput = true;
138138
#endif
139+
ProbeProperties.InitializeColors();
139140

140141
SetProbeControl(false);
141142

Assets/Scripts/Pinpoint/UI/BregmaLambdaBehavior.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ public void ResetBLDistance()
2828
/// <param name="blDistance"></param>
2929
public void SetBLRange(float min, float max, float blDistance)
3030
{
31-
Debug.Log("Range set");
3231
_blDistance = blDistance;
3332

3433
_blSlider.minValue = min;
@@ -38,7 +37,6 @@ public void SetBLRange(float min, float max, float blDistance)
3837

3938
public void SetText(float value)
4039
{
41-
Debug.Log("Text set");
4240
_sliderText.text = $"{Mathf.RoundToInt(value * 100f) / 100f}";
4341
}
4442

0 commit comments

Comments
 (0)