Ejemplo n.º 1
0
 public ProfilerChart(ProfilerArea area, Chart.ChartType type, float dataScale, int seriesCount)
 {
     this.m_Area = area;
     this.m_Type = type;
     this.m_DataScale = dataScale;
     this.m_Chart = new Chart();
     this.m_Data = new ChartData();
     this.m_Series = new ChartSeries[seriesCount];
     this.m_Active = this.ReadActiveState();
     this.ApplyActiveState();
 }
Ejemplo n.º 2
0
 public int DoChartGUI(int currentFrame, ProfilerArea currentArea, out Chart.ChartAction action)
 {
   if (Event.current.type == EventType.Repaint)
   {
     string[] strArray = new string[this.m_Series.Length];
     for (int index = 0; index < this.m_Series.Length; ++index)
     {
       int statisticsIdentifier = ProfilerDriver.GetStatisticsIdentifier(!this.m_Data.hasOverlay ? this.m_Series[index].identifierName : "Selected" + this.m_Series[index].identifierName);
       strArray[index] = ProfilerDriver.GetFormattedStatisticsValue(currentFrame, statisticsIdentifier);
     }
     this.m_Data.selectedLabels = strArray;
   }
   if (this.m_Icon == null)
     this.m_Icon = EditorGUIUtility.TextContentWithIcon(this.GetLocalizedChartName(), "Profiler." + Enum.GetName(typeof (ProfilerArea), (object) this.m_Area));
   return this.m_Chart.DoGUI(this.m_Type, currentFrame, this.m_Data, this.m_Area, currentArea == this.m_Area, this.m_Icon, out action);
 }
Ejemplo n.º 3
0
		public int DoChartGUI(int currentFrame, ProfilerArea currentArea, out Chart.ChartAction action)
		{
			if (Event.current.type == EventType.Repaint)
			{
				string[] array = new string[this.m_Series.Length];
				for (int i = 0; i < this.m_Series.Length; i++)
				{
					string propertyName = (!this.m_Data.hasOverlay) ? this.m_Series[i].identifierName : ("Selected" + this.m_Series[i].identifierName);
					int statisticsIdentifier = ProfilerDriver.GetStatisticsIdentifier(propertyName);
					array[i] = ProfilerDriver.GetFormattedStatisticsValue(currentFrame, statisticsIdentifier);
				}
				this.m_Data.selectedLabels = array;
			}
			if (this.m_Icon == null)
			{
				this.m_Icon = EditorGUIUtility.TextContent("Profiler." + Enum.GetName(typeof(ProfilerArea), this.m_Area));
			}
			return this.m_Chart.DoGUI(this.m_Type, currentFrame, this.m_Data, this.m_Area, currentArea == this.m_Area, this.m_Icon, out action);
		}
Ejemplo n.º 4
0
		private void LabelDraggerDrag(int chartControlID, Chart.ChartType chartType, ChartData cdata, Rect r, bool active)
		{
			if (chartType == Chart.ChartType.Line || !active)
			{
				return;
			}
			Event current = Event.current;
			EventType typeForControl = current.GetTypeForControl(chartControlID);
			if (typeForControl != EventType.MouseDown && typeForControl != EventType.MouseUp && typeForControl != EventType.KeyDown && typeForControl != EventType.MouseDrag)
			{
				return;
			}
			if (typeForControl == EventType.KeyDown && current.keyCode == KeyCode.Escape && this.m_DragItemIndex != -1)
			{
				GUIUtility.hotControl = 0;
				Array.Copy(this.m_ChartOrderBackup, cdata.chartOrder, this.m_ChartOrderBackup.Length);
				this.m_DragItemIndex = -1;
				current.Use();
			}
			int num = 0;
			int i = cdata.charts.Length - 1;
			while (i >= 0)
			{
				if ((current.type == EventType.MouseUp && this.m_MouseDownIndex != -1) || current.type == EventType.MouseDown)
				{
					Rect rect = new Rect(r.x + 10f + 40f, r.y + 20f + (float)(num * 11), 9f, 9f);
					if (rect.Contains(current.mousePosition))
					{
						this.m_DragItemIndex = -1;
						if (current.type == EventType.MouseUp && this.m_MouseDownIndex == i)
						{
							this.m_MouseDownIndex = -1;
							cdata.charts[cdata.chartOrder[i]].enabled = !cdata.charts[cdata.chartOrder[i]].enabled;
							if (chartType == Chart.ChartType.StackedFill)
							{
								this.SaveChartsSettingsEnabled(cdata);
							}
						}
						else
						{
							this.m_MouseDownIndex = i;
						}
						current.Use();
					}
				}
				if (current.type == EventType.MouseDown)
				{
					Rect rect2 = new Rect(r.x, r.y + 20f + (float)(num * 11), 170f, 11f);
					if (rect2.Contains(current.mousePosition))
					{
						this.m_MouseDownIndex = -1;
						this.m_DragItemIndex = i;
						this.m_DragDownPos = current.mousePosition;
						this.m_DragDownPos.x = this.m_DragDownPos.x - rect2.x;
						this.m_DragDownPos.y = this.m_DragDownPos.y - rect2.y;
						this.m_ChartOrderBackup = new int[cdata.chartOrder.Length];
						Array.Copy(cdata.chartOrder, this.m_ChartOrderBackup, this.m_ChartOrderBackup.Length);
						GUIUtility.hotControl = chartControlID;
						Event.current.Use();
					}
				}
				else
				{
					if (this.m_DragItemIndex != -1 && typeForControl == EventType.MouseDrag && i != this.m_DragItemIndex)
					{
						float y = current.mousePosition.y;
						float num2 = r.y + 20f + (float)(num * 11);
						if (y >= num2 && y < num2 + 11f)
						{
							int num3 = cdata.chartOrder[i];
							cdata.chartOrder[i] = cdata.chartOrder[this.m_DragItemIndex];
							cdata.chartOrder[this.m_DragItemIndex] = num3;
							this.m_DragItemIndex = i;
							this.SaveChartsSettingsOrder(cdata);
						}
					}
				}
				i--;
				num++;
			}
			if (typeForControl == EventType.MouseDrag && this.m_DragItemIndex != -1)
			{
				current.Use();
			}
			if (typeForControl == EventType.MouseUp && GUIUtility.hotControl == chartControlID)
			{
				GUIUtility.hotControl = 0;
				this.m_DragItemIndex = -1;
				current.Use();
			}
		}
Ejemplo n.º 5
0
		private void DrawLabelDragger(Chart.ChartType type, Rect r, ChartData cdata)
		{
			Vector2 mousePosition = Event.current.mousePosition;
			if (type == Chart.ChartType.StackedFill)
			{
				int num = 0;
				int i = cdata.charts.Length - 1;
				while (i >= 0)
				{
					Rect position = (this.m_DragItemIndex != i) ? new Rect(r.x, r.y + 20f + (float)(num * 11), 170f, 11f) : new Rect(r.x, mousePosition.y - this.m_DragDownPos.y, 170f, 11f);
					if (cdata.charts[cdata.chartOrder[i]].enabled)
					{
						GUI.backgroundColor = cdata.charts[cdata.chartOrder[i]].color;
					}
					else
					{
						GUI.backgroundColor = Color.black;
					}
					GUI.Label(position, cdata.charts[cdata.chartOrder[i]].name, Chart.ms_Styles.paneSubLabel);
					i--;
					num++;
				}
			}
			else
			{
				for (int j = 0; j < cdata.charts.Length; j++)
				{
					Rect position2 = new Rect(r.x, r.y + 20f + (float)(j * 11), 170f, 11f);
					GUI.backgroundColor = cdata.charts[j].color;
					GUI.Label(position2, cdata.charts[j].name, Chart.ms_Styles.paneSubLabel);
				}
			}
			GUI.backgroundColor = Color.white;
		}
Ejemplo n.º 6
0
		public int DoGUI(Chart.ChartType type, int selectedFrame, ChartData cdata, ProfilerArea area, bool active, GUIContent icon, out Chart.ChartAction action)
		{
			action = Chart.ChartAction.None;
			if (cdata == null)
			{
				return selectedFrame;
			}
			int numberOfFrames = cdata.NumberOfFrames;
			if (Chart.ms_Styles == null)
			{
				Chart.ms_Styles = new Chart.Styles();
			}
			int controlID = GUIUtility.GetControlID(Chart.s_ChartHash, FocusType.Keyboard);
			Rect rect = GUILayoutUtility.GetRect(GUIContent.none, Chart.ms_Styles.background, new GUILayoutOption[]
			{
				GUILayout.MinHeight(120f)
			});
			Rect rect2 = rect;
			rect2.x += 170f;
			rect2.width -= 170f;
			Event current = Event.current;
			if (current.GetTypeForControl(controlID) == EventType.MouseDown && rect.Contains(current.mousePosition))
			{
				action = Chart.ChartAction.Activated;
			}
			if (this.m_DragItemIndex == -1)
			{
				selectedFrame = this.HandleFrameSelectionEvents(selectedFrame, controlID, rect2, cdata, numberOfFrames);
			}
			Rect rect3 = rect2;
			rect3.x -= 170f;
			rect3.width = 170f;
			GUI.Label(new Rect(rect3.x, rect3.y, rect3.width, 20f), GUIContent.Temp(string.Empty, icon.tooltip));
			if (current.type == EventType.Repaint)
			{
				Chart.ms_Styles.rightPane.Draw(rect2, false, false, active, false);
				Chart.ms_Styles.leftPane.Draw(rect3, EditorGUIUtility.TempContent(icon.text), false, false, active, false);
				if (this.m_NotSupportedWarning == null)
				{
					rect2.height -= 1f;
					if (type == Chart.ChartType.StackedFill)
					{
						this.DrawChartStacked(selectedFrame, cdata, rect2);
					}
					else
					{
						this.DrawChartLine(selectedFrame, cdata, rect2);
					}
				}
				else
				{
					Rect position = rect2;
					position.x += 56.1000023f;
					position.y += 43f;
					GUI.Label(position, this.m_NotSupportedWarning, EditorStyles.boldLabel);
				}
				rect3.x += 10f;
				rect3.y += 10f;
				GUIStyle.none.Draw(rect3, EditorGUIUtility.TempContent(icon.image), false, false, false, false);
				rect3.x += 40f;
				this.DrawLabelDragger(type, rect3, cdata);
			}
			else
			{
				rect3.y += 10f;
				this.LabelDraggerDrag(controlID, type, cdata, rect3, active);
			}
			if (area == ProfilerArea.GPU)
			{
				GUI.Label(new Rect(rect.x + 170f - (float)Chart.ms_Styles.performanceWarning.image.width, rect.yMax - (float)Chart.ms_Styles.performanceWarning.image.height - 2f, (float)Chart.ms_Styles.performanceWarning.image.width, (float)Chart.ms_Styles.performanceWarning.image.height), Chart.ms_Styles.performanceWarning);
			}
			if (GUI.Button(new Rect(rect.x + 170f - 13f - 2f, rect.y + 2f, 13f, 13f), GUIContent.none, Chart.ms_Styles.closeButton))
			{
				action = Chart.ChartAction.Closed;
			}
			return selectedFrame;
		}
Ejemplo n.º 7
0
 private void LabelDraggerDrag(int chartControlID, Chart.ChartType chartType, ChartData cdata, Rect r, bool active)
 {
   if (chartType == Chart.ChartType.Line || !active)
     return;
   Event current = Event.current;
   EventType typeForControl = current.GetTypeForControl(chartControlID);
   switch (typeForControl)
   {
     case EventType.MouseDown:
     case EventType.MouseUp:
     case EventType.KeyDown:
     case EventType.MouseDrag:
       if (typeForControl == EventType.KeyDown && current.keyCode == KeyCode.Escape && this.m_DragItemIndex != -1)
       {
         GUIUtility.hotControl = 0;
         Array.Copy((Array) this.m_ChartOrderBackup, (Array) cdata.chartOrder, this.m_ChartOrderBackup.Length);
         this.m_DragItemIndex = -1;
         current.Use();
       }
       int num1 = 0;
       int index = cdata.charts.Length - 1;
       while (index >= 0)
       {
         if ((current.type == EventType.MouseUp && this.m_MouseDownIndex != -1 || current.type == EventType.MouseDown) && new Rect((float) ((double) r.x + 10.0 + 40.0), r.y + 20f + (float) (num1 * 11), 9f, 9f).Contains(current.mousePosition))
         {
           this.m_DragItemIndex = -1;
           if (current.type == EventType.MouseUp && this.m_MouseDownIndex == index)
           {
             this.m_MouseDownIndex = -1;
             cdata.charts[cdata.chartOrder[index]].enabled = !cdata.charts[cdata.chartOrder[index]].enabled;
             if (chartType == Chart.ChartType.StackedFill)
               this.SaveChartsSettingsEnabled(cdata);
           }
           else
             this.m_MouseDownIndex = index;
           current.Use();
         }
         if (current.type == EventType.MouseDown)
         {
           Rect rect = new Rect(r.x, r.y + 20f + (float) (num1 * 11), 170f, 11f);
           if (rect.Contains(current.mousePosition))
           {
             this.m_MouseDownIndex = -1;
             this.m_DragItemIndex = index;
             this.m_DragDownPos = current.mousePosition;
             this.m_DragDownPos.x -= rect.x;
             this.m_DragDownPos.y -= rect.y;
             this.m_ChartOrderBackup = new int[cdata.chartOrder.Length];
             Array.Copy((Array) cdata.chartOrder, (Array) this.m_ChartOrderBackup, this.m_ChartOrderBackup.Length);
             GUIUtility.hotControl = chartControlID;
             Event.current.Use();
           }
         }
         else if (this.m_DragItemIndex != -1 && typeForControl == EventType.MouseDrag && index != this.m_DragItemIndex)
         {
           float y = current.mousePosition.y;
           float num2 = r.y + 20f + (float) (num1 * 11);
           if ((double) y >= (double) num2 && (double) y < (double) num2 + 11.0)
           {
             int num3 = cdata.chartOrder[index];
             cdata.chartOrder[index] = cdata.chartOrder[this.m_DragItemIndex];
             cdata.chartOrder[this.m_DragItemIndex] = num3;
             this.m_DragItemIndex = index;
             this.SaveChartsSettingsOrder(cdata);
           }
         }
         --index;
         ++num1;
       }
       if (typeForControl == EventType.MouseDrag && this.m_DragItemIndex != -1)
         current.Use();
       if (typeForControl != EventType.MouseUp || GUIUtility.hotControl != chartControlID)
         break;
       GUIUtility.hotControl = 0;
       this.m_DragItemIndex = -1;
       current.Use();
       break;
   }
 }
Ejemplo n.º 8
0
 private void DrawLabelDragger(Chart.ChartType type, Rect r, ChartData cdata)
 {
   Vector2 mousePosition = Event.current.mousePosition;
   if (type == Chart.ChartType.StackedFill)
   {
     int num = 0;
     int index = cdata.charts.Length - 1;
     while (index >= 0)
     {
       Rect position = this.m_DragItemIndex != index ? new Rect(r.x, r.y + 20f + (float) (num * 11), 170f, 11f) : new Rect(r.x, mousePosition.y - this.m_DragDownPos.y, 170f, 11f);
       GUI.backgroundColor = !cdata.charts[cdata.chartOrder[index]].enabled ? Color.black : cdata.charts[cdata.chartOrder[index]].color;
       GUI.Label(position, cdata.charts[cdata.chartOrder[index]].name, Chart.ms_Styles.paneSubLabel);
       --index;
       ++num;
     }
   }
   else
   {
     for (int index = 0; index < cdata.charts.Length; ++index)
     {
       Rect position = new Rect(r.x, r.y + 20f + (float) (index * 11), 170f, 11f);
       GUI.backgroundColor = cdata.charts[index].color;
       GUI.Label(position, cdata.charts[index].name, Chart.ms_Styles.paneSubLabel);
     }
   }
   GUI.backgroundColor = Color.white;
 }