public override void OnInspectorGUI() { EditorGUILayout.PropertyField(serializedObject.FindProperty("threadCount")); EditorGUILayout.PropertyField(serializedObject.FindProperty("maxPixelError")); serializedObject.ApplyModifiedProperties(); if (Application.isPlaying) { QuadNodeGenerator qng = target as QuadNodeGenerator; EditorGUILayout.LabelField(qng.queueCount + " queued nodes"); double avgsfc, minsfc, maxsfc; double avgtree, mintree, maxtree; double avggrass, mingrass, maxgrass; avgsfc = minsfc = maxsfc = avgtree = mintree = maxtree = avggrass = mingrass = maxgrass = -1; lock (QuadNode.sfctimes) { if (QuadNode.sfctimes.Count > 0) { avgsfc = 0; minsfc = QuadNode.sfctimes[0]; maxsfc = QuadNode.sfctimes[0]; QuadNode.sfctimes.ForEach(l => { avgsfc += l; minsfc = Mathd.Min(l, minsfc); maxsfc = Mathd.Max(l, maxsfc); }); avgsfc /= QuadNode.sfctimes.Count; } } lock (QuadNode.treetimes) { if (QuadNode.treetimes.Count > 0) { avgtree = 0; mintree = QuadNode.treetimes[0]; maxtree = QuadNode.treetimes[0]; QuadNode.treetimes.ForEach(l => { avgtree += l; mintree = Mathd.Min(l, mintree); maxtree = Mathd.Max(l, maxtree); }); avgtree /= QuadNode.treetimes.Count; } } lock (QuadNode.grasstimes) { if (QuadNode.grasstimes.Count > 0) { avggrass = 0; mingrass = QuadNode.grasstimes[0]; maxgrass = QuadNode.grasstimes[0]; QuadNode.grasstimes.ForEach(l => { avggrass += l; mingrass = Mathd.Min(l, mingrass); maxgrass = Mathd.Max(l, maxgrass); }); avggrass /= QuadNode.grasstimes.Count; } } float w = EditorGUIUtility.labelWidth; EditorGUIUtility.labelWidth = 60f; EditorGUILayout.LabelField("Surface avg/min/max", EditorStyles.boldLabel); EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField(avgsfc.ToString("f3")); EditorGUILayout.LabelField(minsfc.ToString("f3")); EditorGUILayout.LabelField(maxsfc.ToString("f3")); EditorGUILayout.EndHorizontal(); EditorGUILayout.LabelField("Trees avg/min/max", EditorStyles.boldLabel); EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField(avgtree.ToString("f3")); EditorGUILayout.LabelField(mintree.ToString("f3")); EditorGUILayout.LabelField(maxtree.ToString("f3")); EditorGUILayout.EndHorizontal(); EditorGUILayout.LabelField("Grass avg/min/max", EditorStyles.boldLabel); EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField(avggrass.ToString("f3")); EditorGUILayout.LabelField(mingrass.ToString("f3")); EditorGUILayout.LabelField(maxgrass.ToString("f3")); EditorGUILayout.EndHorizontal(); EditorGUIUtility.labelWidth = w; } }
void Awake() { instance = this; }