public AudioProfilerDSPWire(AudioProfilerDSPView.AudioProfilerDSPNode source, AudioProfilerDSPView.AudioProfilerDSPNode target, AudioProfilerDSPInfo info) { this.source = source; this.target = target; this.info = info; this.targetPort = target.targetPort; }
public AudioProfilerDSPNode(AudioProfilerDSPView.AudioProfilerDSPNode firstTarget, AudioProfilerDSPInfo info, int x, int y, int level) { this.firstTarget = firstTarget; this.info = info; this.x = x; this.y = y; this.level = level; this.maxY = y; this.audible = ((info.flags & 1) != 0) && ((info.flags & 2) == 0); if (firstTarget != null) { this.audible &= firstTarget.audible; } }
public void OnGUI(Rect clippingRect, ProfilerProperty property, bool showInactiveDSPChains, bool highlightAudibleDSPChains, ref float zoomFactor, ref Vector2 scrollPos) { if (((Event.current.type == EventType.ScrollWheel) && clippingRect.Contains(Event.current.mousePosition)) && Event.current.shift) { float num = 1.05f; float num2 = zoomFactor; zoomFactor *= (Event.current.delta.y <= 0f) ? (1f / num) : num; scrollPos = (Vector2)(scrollPos + ((Event.current.mousePosition - scrollPos) * (zoomFactor - num2))); Event.current.Use(); } else if (Event.current.type == EventType.Repaint) { int num3 = 0x40; int num4 = 0x10; int num5 = 140; int num6 = 30; int num7 = num3 + 10; int num8 = 5; Dictionary <int, AudioProfilerDSPNode> dictionary = new Dictionary <int, AudioProfilerDSPNode>(); List <AudioProfilerDSPWire> list = new List <AudioProfilerDSPWire>(); AudioProfilerDSPInfo[] audioProfilerDSPInfo = property.GetAudioProfilerDSPInfo(); if (audioProfilerDSPInfo != null) { bool flag = true; foreach (AudioProfilerDSPInfo info in audioProfilerDSPInfo) { if (showInactiveDSPChains || ((info.flags & 1) != 0)) { if (!dictionary.ContainsKey(info.id)) { AudioProfilerDSPNode firstTarget = !dictionary.ContainsKey(info.target) ? null : dictionary[info.target]; if (firstTarget != null) { dictionary[info.id] = new AudioProfilerDSPNode(firstTarget, info, (firstTarget.x + num5) + num7, firstTarget.maxY, firstTarget.level + 1); firstTarget.maxY += num6 + num8; for (AudioProfilerDSPNode node2 = firstTarget; node2 != null; node2 = node2.firstTarget) { node2.maxY = Mathf.Max(node2.maxY, firstTarget.maxY); } } else if (flag) { flag = false; dictionary[info.id] = new AudioProfilerDSPNode(firstTarget, info, 10 + (num5 / 2), 10 + (num6 / 2), 1); } if (firstTarget != null) { list.Add(new AudioProfilerDSPWire(dictionary[info.id], firstTarget, info)); } } else { list.Add(new AudioProfilerDSPWire(dictionary[info.id], dictionary[info.target], info)); } } } foreach (KeyValuePair <int, AudioProfilerDSPNode> pair in dictionary) { AudioProfilerDSPNode node3 = pair.Value; node3.y += ((node3.maxY != node3.y) ? (node3.maxY - node3.y) : (num6 + num8)) / 2; } foreach (AudioProfilerDSPWire wire in list) { float num10 = 4f; AudioProfilerDSPNode source = wire.source; AudioProfilerDSPNode target = wire.target; AudioProfilerDSPInfo info2 = wire.info; Vector3 p = new Vector3((source.x - (num5 * 0.5f)) * zoomFactor, source.y * zoomFactor, 0f); Vector3 vector3 = new Vector3((target.x + (num5 * 0.5f)) * zoomFactor, (target.y + (wire.targetPort * num10)) * zoomFactor, 0f); int outCode = GetOutCode(p, clippingRect); int num12 = GetOutCode(vector3, clippingRect); if ((outCode & num12) == 0) { float width = 3f; Handles.color = new Color(info2.weight, 0f, 0f, (highlightAudibleDSPChains && !source.audible) ? 0.4f : 1f); Vector3[] points = new Vector3[] { p, vector3 }; Handles.DrawAAPolyLine(width, 2, points); } } foreach (AudioProfilerDSPWire wire2 in list) { AudioProfilerDSPNode node6 = wire2.source; AudioProfilerDSPNode node7 = wire2.target; AudioProfilerDSPInfo info3 = wire2.info; if (info3.weight != 1f) { int num14 = node6.x - ((num7 + num5) / 2); int num15 = (node7 == null) ? node7.y : (node7.y + ((int)((((num14 - node7.x) - (num5 * 0.5f)) * (node6.y - node7.y)) / ((float)((node6.x - node7.x) - num5))))); this.DrawRectClipped(new Rect((float)(num14 - (num3 / 2)), (float)(num15 - (num4 / 2)), (float)num3, (float)num4), new Color(1f, 0.3f, 0.2f, (highlightAudibleDSPChains && !node6.audible) ? 0.4f : 1f), $"{100f * info3.weight:0.00}%", clippingRect, zoomFactor); } } foreach (KeyValuePair <int, AudioProfilerDSPNode> pair2 in dictionary) { AudioProfilerDSPNode node8 = pair2.Value; AudioProfilerDSPInfo info4 = node8.info; if (dictionary.ContainsKey(info4.target) && (node8.firstTarget == dictionary[info4.target])) { string audioProfilerNameByOffset = property.GetAudioProfilerNameByOffset(info4.nameOffset); float num16 = 0.01f * info4.cpuLoad; float num17 = 0.1f; bool flag2 = (info4.flags & 1) != 0; bool flag3 = (info4.flags & 2) != 0; Color col = new Color((flag2 && !flag3) ? Mathf.Clamp((float)((2f * num17) * num16), (float)0f, (float)1f) : 0.5f, (flag2 && !flag3) ? Mathf.Clamp((float)(2f - ((2f * num17) * num16)), (float)0f, (float)1f) : 0.5f, !flag3 ? (!flag2 ? 0.5f : 0f) : 1f, (highlightAudibleDSPChains && !node8.audible) ? 0.4f : 1f); audioProfilerNameByOffset = audioProfilerNameByOffset.Replace("ChannelGroup", "Group").Replace("FMOD Channel", "Channel").Replace("FMOD WaveTable Unit", "Wavetable").Replace("FMOD Resampler Unit", "Resampler").Replace("FMOD Channel DSPHead Unit", "Channel DSP").Replace("FMOD Channel DSPHead Unit", "Channel DSP") + $" ({num16:0.00}%)"; this.DrawRectClipped(new Rect(node8.x - (num5 * 0.5f), node8.y - (num6 * 0.5f), (float)num5, (float)num6), col, audioProfilerNameByOffset, clippingRect, zoomFactor); if (node8.audible) { if (info4.numLevels >= 1) { float height = (num6 - 6) * Mathf.Clamp(info4.level1, 0f, 1f); this.DrawRectClipped(new Rect((node8.x - (num5 * 0.5f)) + 3f, (node8.y - (num6 * 0.5f)) + 3f, 4f, (float)(num6 - 6)), Color.black, null, clippingRect, zoomFactor); this.DrawRectClipped(new Rect((node8.x - (num5 * 0.5f)) + 3f, (((node8.y - (num6 * 0.5f)) - 3f) + num6) - height, 4f, height), Color.red, null, clippingRect, zoomFactor); } if (info4.numLevels >= 2) { float num19 = (num6 - 6) * Mathf.Clamp(info4.level2, 0f, 1f); this.DrawRectClipped(new Rect((node8.x - (num5 * 0.5f)) + 8f, (node8.y - (num6 * 0.5f)) + 3f, 4f, (float)(num6 - 6)), Color.black, null, clippingRect, zoomFactor); this.DrawRectClipped(new Rect((node8.x - (num5 * 0.5f)) + 8f, (((node8.y - (num6 * 0.5f)) - 3f) + num6) - num19, 4f, num19), Color.red, null, clippingRect, zoomFactor); } } } } } } }
public void OnGUI(Rect clippingRect, ProfilerProperty property, bool showInactiveDSPChains, bool highlightAudibleDSPChains, ref float zoomFactor, ref Vector2 scrollPos) { if (Event.current.type == EventType.ScrollWheel && clippingRect.Contains(Event.current.mousePosition) && Event.current.shift) { float num = 1.05f; float num2 = zoomFactor; zoomFactor *= ((Event.current.delta.y <= 0f) ? (1f / num) : num); scrollPos += (Event.current.mousePosition - scrollPos) * (zoomFactor - num2); Event.current.Use(); } else if (Event.current.type == EventType.Repaint) { int num3 = 64; int num4 = 16; int num5 = 140; int num6 = 30; int num7 = num3 + 10; int num8 = 5; Dictionary <int, AudioProfilerDSPView.AudioProfilerDSPNode> dictionary = new Dictionary <int, AudioProfilerDSPView.AudioProfilerDSPNode>(); List <AudioProfilerDSPView.AudioProfilerDSPWire> list = new List <AudioProfilerDSPView.AudioProfilerDSPWire>(); AudioProfilerDSPInfo[] audioProfilerDSPInfo = property.GetAudioProfilerDSPInfo(); if (audioProfilerDSPInfo != null) { bool flag = true; AudioProfilerDSPInfo[] array = audioProfilerDSPInfo; for (int i = 0; i < array.Length; i++) { AudioProfilerDSPInfo info = array[i]; if (showInactiveDSPChains || (info.flags & 1) != 0) { if (!dictionary.ContainsKey(info.id)) { AudioProfilerDSPView.AudioProfilerDSPNode audioProfilerDSPNode = (!dictionary.ContainsKey(info.target)) ? null : dictionary[info.target]; if (audioProfilerDSPNode != null) { dictionary[info.id] = new AudioProfilerDSPView.AudioProfilerDSPNode(audioProfilerDSPNode, info, audioProfilerDSPNode.x + num5 + num7, audioProfilerDSPNode.maxY, audioProfilerDSPNode.level + 1); audioProfilerDSPNode.maxY += num6 + num8; for (AudioProfilerDSPView.AudioProfilerDSPNode audioProfilerDSPNode2 = audioProfilerDSPNode; audioProfilerDSPNode2 != null; audioProfilerDSPNode2 = audioProfilerDSPNode2.firstTarget) { audioProfilerDSPNode2.maxY = Mathf.Max(audioProfilerDSPNode2.maxY, audioProfilerDSPNode.maxY); } } else if (flag) { flag = false; dictionary[info.id] = new AudioProfilerDSPView.AudioProfilerDSPNode(audioProfilerDSPNode, info, 10 + num5 / 2, 10 + num6 / 2, 1); } if (audioProfilerDSPNode != null) { list.Add(new AudioProfilerDSPView.AudioProfilerDSPWire(dictionary[info.id], audioProfilerDSPNode, info)); } } else { list.Add(new AudioProfilerDSPView.AudioProfilerDSPWire(dictionary[info.id], dictionary[info.target], info)); } } } foreach (KeyValuePair <int, AudioProfilerDSPView.AudioProfilerDSPNode> current in dictionary) { AudioProfilerDSPView.AudioProfilerDSPNode value = current.Value; value.y += ((value.maxY != value.y) ? (value.maxY - value.y) : (num6 + num8)) / 2; } foreach (AudioProfilerDSPView.AudioProfilerDSPWire current2 in list) { float num9 = 4f; AudioProfilerDSPView.AudioProfilerDSPNode source = current2.source; AudioProfilerDSPView.AudioProfilerDSPNode target = current2.target; AudioProfilerDSPInfo info2 = current2.info; Vector3 vector = new Vector3(((float)source.x - (float)num5 * 0.5f) * zoomFactor, (float)source.y * zoomFactor, 0f); Vector3 vector2 = new Vector3(((float)target.x + (float)num5 * 0.5f) * zoomFactor, ((float)target.y + (float)current2.targetPort * num9) * zoomFactor, 0f); int outCode = AudioProfilerDSPView.GetOutCode(vector, clippingRect); int outCode2 = AudioProfilerDSPView.GetOutCode(vector2, clippingRect); if ((outCode & outCode2) == 0) { float width = 3f; Handles.color = new Color(info2.weight, 0f, 0f, (highlightAudibleDSPChains && !source.audible) ? 0.4f : 1f); Handles.DrawAAPolyLine(width, 2, new Vector3[] { vector, vector2 }); } } foreach (AudioProfilerDSPView.AudioProfilerDSPWire current3 in list) { AudioProfilerDSPView.AudioProfilerDSPNode source2 = current3.source; AudioProfilerDSPView.AudioProfilerDSPNode target2 = current3.target; AudioProfilerDSPInfo info3 = current3.info; if (info3.weight != 1f) { int num10 = source2.x - (num7 + num5) / 2; int num11 = (target2 == null) ? target2.y : ((int)((float)target2.y + ((float)(num10 - target2.x) - (float)num5 * 0.5f) * (float)(source2.y - target2.y) / (float)(source2.x - target2.x - num5))); this.DrawRectClipped(new Rect((float)(num10 - num3 / 2), (float)(num11 - num4 / 2), (float)num3, (float)num4), new Color(1f, 0.3f, 0.2f, (highlightAudibleDSPChains && !source2.audible) ? 0.4f : 1f), string.Format("{0:0.00}%", 100f * info3.weight), clippingRect, zoomFactor); } } foreach (KeyValuePair <int, AudioProfilerDSPView.AudioProfilerDSPNode> current4 in dictionary) { AudioProfilerDSPView.AudioProfilerDSPNode value2 = current4.Value; AudioProfilerDSPInfo info4 = value2.info; if (dictionary.ContainsKey(info4.target) && value2.firstTarget == dictionary[info4.target]) { string text = property.GetAudioProfilerNameByOffset(info4.nameOffset); float num12 = 0.01f * info4.cpuLoad; float num13 = 0.1f; bool flag2 = (info4.flags & 1) != 0; bool flag3 = (info4.flags & 2) != 0; Color col = new Color((flag2 && !flag3) ? Mathf.Clamp(2f * num13 * num12, 0f, 1f) : 0.5f, (flag2 && !flag3) ? Mathf.Clamp(2f - 2f * num13 * num12, 0f, 1f) : 0.5f, (!flag3) ? ((!flag2) ? 0.5f : 0f) : 1f, (highlightAudibleDSPChains && !value2.audible) ? 0.4f : 1f); text = text.Replace("ChannelGroup", "Group"); text = text.Replace("FMOD Channel", "Channel"); text = text.Replace("FMOD WaveTable Unit", "Wavetable"); text = text.Replace("FMOD Resampler Unit", "Resampler"); text = text.Replace("FMOD Channel DSPHead Unit", "Channel DSP"); text = text.Replace("FMOD Channel DSPHead Unit", "Channel DSP"); text += string.Format(" ({0:0.00}%)", num12); this.DrawRectClipped(new Rect((float)value2.x - (float)num5 * 0.5f, (float)value2.y - (float)num6 * 0.5f, (float)num5, (float)num6), col, text, clippingRect, zoomFactor); if (value2.audible) { if (info4.numLevels >= 1) { float num14 = (float)(num6 - 6) * Mathf.Clamp(info4.level1, 0f, 1f); this.DrawRectClipped(new Rect((float)value2.x - (float)num5 * 0.5f + 3f, (float)value2.y - (float)num6 * 0.5f + 3f, 4f, (float)(num6 - 6)), Color.black, null, clippingRect, zoomFactor); this.DrawRectClipped(new Rect((float)value2.x - (float)num5 * 0.5f + 3f, (float)value2.y - (float)num6 * 0.5f - 3f + (float)num6 - num14, 4f, num14), Color.red, null, clippingRect, zoomFactor); } if (info4.numLevels >= 2) { float num15 = (float)(num6 - 6) * Mathf.Clamp(info4.level2, 0f, 1f); this.DrawRectClipped(new Rect((float)value2.x - (float)num5 * 0.5f + 8f, (float)value2.y - (float)num6 * 0.5f + 3f, 4f, (float)(num6 - 6)), Color.black, null, clippingRect, zoomFactor); this.DrawRectClipped(new Rect((float)value2.x - (float)num5 * 0.5f + 8f, (float)value2.y - (float)num6 * 0.5f - 3f + (float)num6 - num15, 4f, num15), Color.red, null, clippingRect, zoomFactor); } } } } } } }