소수점처리

This commit is contained in:
준학 노
2025-07-23 10:45:24 +09:00
parent 05ae017731
commit 9915b30166
2 changed files with 27 additions and 15 deletions

View File

@@ -91,8 +91,8 @@ public class BubbleUI : MonoBehaviour, IPointerEnterHandler, IPointerExitHandler
} }
datas = new List<string> datas = new List<string>
{ {
sourcedata.total_output.ToString(), IsFourDecimalPlaces(sourcedata.total_output),
sourcedata.total_defects.ToString() IsFourDecimalPlaces(sourcedata.total_defects)
}; };
detailObject.Set(title,datas); detailObject.Set(title,datas);
detailObject.GetComponent<RectTransform>().position = rt.position + new Vector3(150f, 75f); detailObject.GetComponent<RectTransform>().position = rt.position + new Vector3(150f, 75f);
@@ -131,8 +131,8 @@ public class BubbleUI : MonoBehaviour, IPointerEnterHandler, IPointerExitHandler
} }
datas = new List<string> datas = new List<string>
{ {
processordata.total_input.ToString(), IsFourDecimalPlaces(processordata.total_input),
processordata.total_processed.ToString() IsFourDecimalPlaces(processordata.total_processed)
}; };
detailObject.Set(title, datas); detailObject.Set(title, datas);
detailObject.GetComponent<RectTransform>().position = rt.position + new Vector3(150f, 75f); detailObject.GetComponent<RectTransform>().position = rt.position + new Vector3(150f, 75f);
@@ -146,8 +146,8 @@ public class BubbleUI : MonoBehaviour, IPointerEnterHandler, IPointerExitHandler
} }
datas = new List<string> datas = new List<string>
{ {
queuedata.current_length.ToString(), IsFourDecimalPlaces(queuedata.current_length),
queuedata.capacity.ToString() IsFourDecimalPlaces(queuedata.capacity)
}; };
detailObject.Set(title, datas); detailObject.Set(title, datas);
detailObject.GetComponent<RectTransform>().position = rt.position + new Vector3(150f, 75f); detailObject.GetComponent<RectTransform>().position = rt.position + new Vector3(150f, 75f);
@@ -161,8 +161,8 @@ public class BubbleUI : MonoBehaviour, IPointerEnterHandler, IPointerExitHandler
} }
datas = new List<string> datas = new List<string>
{ {
storedata.current_length.ToString(), IsFourDecimalPlaces(storedata.current_length),
storedata.capacity.ToString() IsFourDecimalPlaces(storedata.capacity)
}; };
detailObject.Set(title, datas); detailObject.Set(title, datas);
detailObject.GetComponent<RectTransform>().position = rt.position + new Vector3(150f, 75f); detailObject.GetComponent<RectTransform>().position = rt.position + new Vector3(150f, 75f);
@@ -176,11 +176,11 @@ public class BubbleUI : MonoBehaviour, IPointerEnterHandler, IPointerExitHandler
} }
datas = new List<string> datas = new List<string>
{ {
resourcedata.requesters.ToString(), IsFourDecimalPlaces(resourcedata.requesters),
resourcedata.claimers.ToString(), IsFourDecimalPlaces(resourcedata.claimers),
resourcedata.available.ToString(), IsFourDecimalPlaces(resourcedata.available),
resourcedata.original_capacity.ToString(), IsFourDecimalPlaces(resourcedata.original_capacity),
resourcedata.utilization.ToString() IsFourDecimalPlaces(resourcedata.utilization),
}; };
detailObject.Set(title, datas); detailObject.Set(title, datas);
detailObject.GetComponent<RectTransform>().position = rt.position + new Vector3(150f, 100f); detailObject.GetComponent<RectTransform>().position = rt.position + new Vector3(150f, 100f);
@@ -202,6 +202,18 @@ public class BubbleUI : MonoBehaviour, IPointerEnterHandler, IPointerExitHandler
} }
} }
private string IsFourDecimalPlaces(float value)
{
string numberString = value.ToString();
int decimalIndex = numberString.IndexOf('.');
if (decimalIndex == -1)
{
return numberString; // 소수점이 없는 경우
}
return numberString.Length - decimalIndex - 1 >= 4 ? string.Format("{0:N4}", value) : numberString ;
}
public void OnPointerEnter(PointerEventData eventData) public void OnPointerEnter(PointerEventData eventData)
{ {
if (detailObject) if (detailObject)

View File

@@ -21,9 +21,9 @@ namespace Octopus.Simulator.Networks
onParameterRecived += FindAnyObjectByType<ProjectDataManager>().RequestInfo; onParameterRecived += FindAnyObjectByType<ProjectDataManager>().RequestInfo;
onParameterRecived += FindAnyObjectByType<LogicDataManager>().RequestInfo; onParameterRecived += FindAnyObjectByType<LogicDataManager>().RequestInfo;
#if UNITY_EDITOR #if UNITY_EDITOR
config.projectId = "40"; config.projectId = "37";
//config.simulationId = "15"; //config.simulationId = "15";
config.logicId = "45"; config.logicId = "42";
WebParameters.config = config; WebParameters.config = config;
onParameterRecived?.Invoke(); onParameterRecived?.Invoke();
#else #else