void OnEnable() { EditorApplication.update += Update; if (VarTracer.Instance != null) { if (VarTracer.Instance.Graphs.Count == 0) VarTracer.AddChannel(); bool constainsCamera = VarTracer.Instance.VariableBodys.ContainsKey("Camera"); if (!constainsCamera || VarTracer.Instance.VariableBodys["Camera"].VariableDict.Count == 0) { VarTracerHandler.DefineVariable("CameraV_X", "Camera"); VarTracerHandler.DefineVariable("CameraV_Y", "Camera"); VarTracerHandler.DefineVariable("CameraV_Z", "Camera"); VarTracerHandler.DefineVariable("CameraV_T", "Camera"); VarTracerHandler.DefineVariable("PlayerV_X", "Player"); VarTracerHandler.DefineVariable("PlayerV_Y", "Player"); VarTracerHandler.DefineVariable("PlayerV_Z", "Player"); VarTracerHandler.DefineVariable("CameraV_T", "Camera"); VarTracerHandler.DefineVariable("FPS", "System"); VarTracerHandler.DefineEvent("JUMP","Camera"); VarTracerHandler.DefineVariable("NpcV_X", "Npc"); VarTracerHandler.DefineVariable("NpcV_Y", "Npc"); VarTracerHandler.DefineVariable("NpcV_Z", "Npc"); VarTracerHandler.DefineVariable("NpcV_T", "Npc"); } } VarTracer.AddChannel(); VarTracer.AddChannel(); }
private static void ShowVariableCombine() { VarTracer.ClearGraph(graphNumIndex.ToString()); foreach (var varName in variableCombineList) { VarTracer.AttachVariable(varName, graphNumIndex.ToString()); } }
private static void DrawGraphAttribute(KeyValuePair<string, VarTracerGraphItData> kv) { EditorGUILayout.LabelField(kv.Key,NameLabel); foreach (var varBodyName in GetAllVariableBodyFromChannel(kv.Key)) { NameLabel.normal.textColor = Color.white; EditorGUILayout.LabelField("{" + varBodyName + "}:", NameLabel); foreach (var entry in kv.Value.mData) { var variable = VarTracer.GetGraphItVariableByVariableName(entry.Key); VarTracerDataInternal g = entry.Value; if (variable.VarBodyName.Equals(varBodyName)) { if (kv.Value.mData.Count >= 1) { NameLabel.normal.textColor = g.mColor; } EditorGUILayout.LabelField(" [" + entry.Key + "]" + " Value: " + g.mCurrentValue.ToString(VarTracerConst.NUM_FORMAT_2),NameLabel); } } var varBody = VarTracer.Instance.VariableBodys[varBodyName]; foreach (var eventName in varBody.EventInfos.Keys) { //NameLabel.normal.textColor = varBody.EventColors[eventName]; NameLabel.normal.textColor = Color.white; EditorGUILayout.LabelField(" <Event> " + eventName,NameLabel); } } if (kv.Value.mData.Count >= 1) { HoverText.normal.textColor = Color.white; EditorGUILayout.LabelField("duration:" + (mWidth / kv.Value.XStep / VarTracerConst.FPS).ToString(VarTracerConst.NUM_FORMAT_3) + "(s)", HoverText, GUILayout.Width(140)); kv.Value.XStep = GUILayout.HorizontalSlider(kv.Value.XStep, 0.1f, 15, GUILayout.Width(160)); } }
void DrawVariableBar() { GUILayout.BeginVertical(); GUILayout.BeginHorizontal(); GUILayout.Space(10); int currentIndex = GUILayout.SelectionGrid(graphNumIndex, graphNumOption, 3, GUILayout.Width(90)); if (graphNumIndex != currentIndex) { graphNumIndex = currentIndex; ShowVariableCombine(); } GUILayout.Space(30); for (int i = 0; i < variableCombineList.Count; i++) { if (GUILayout.Button(variableCombineList[i],EventInstantButtonStyle, GUILayout.Width(90))) { variableCombineList.Remove(variableCombineList[i]); ShowVariableCombine(); } } GUILayout.Space(20); if (GUILayout.Button("Clear", EditorStyles.toolbarButton, GUILayout.Width(50), GUILayout.Height(25))) { variableCombineList.Clear(); ShowVariableCombine(); } if (GUILayout.Button("Clear All", EditorStyles.toolbarButton, GUILayout.Width(100))) VarTracer.ClearAll(); GUI.SetNextControlName("LoginIPTextField"); var currentStr = GUILayout.TextField(_IPField, GUILayout.Width(120)); if (!_IPField.Equals(currentStr)) { _IPField = currentStr; } if (GUI.GetNameOfFocusedControl().Equals("LoginIPTextField") && _IPField.Equals(VarTracerConst.RemoteIPDefaultText)) { _IPField = ""; } bool savedState = GUI.enabled; bool connected = NetManager.Instance != null && NetManager.Instance.IsConnected; GUI.enabled = !connected; if (GUILayout.Button("Connect", EditorStyles.toolbarButton, GUILayout.Width(80))) { _connectPressed = true; } GUI.enabled = connected; GUI.enabled = savedState; string buttonName; if (EditorApplication.isPaused) buttonName = "Resume"; else buttonName = "Pause"; if (GUILayout.Button(buttonName, EditorStyles.toolbarButton, GUILayout.Width(100))) { EditorApplication.isPaused = !EditorApplication.isPaused; if (EditorApplication.isPaused) StopVarTracer(); else StartVarTracer(); } if (m_isDrawLine) buttonName = "Draw Point"; else buttonName = "Draw Line"; if (GUILayout.Button(buttonName, EditorStyles.toolbarButton, GUILayout.Width(100))) { m_isDrawLine = !m_isDrawLine; } GUILayout.EndHorizontal(); var lineNum = CalculateVariableLineNum(); var varList = GetVariableList(); for (int i = 0; i < lineNum; i++) { GUILayout.BeginHorizontal(); GUILayout.Space(10); for (int j = 0; j < variableNumPerLine; j++) { if (j + i * variableNumPerLine >= varList.Count) continue; var var = varList[j + i * variableNumPerLine]; var saveColor = GUI.color; if (VarTracer.IsVariableOnShow(var.VarName)) GUI.color = Color.white; if (GUILayout.Button(var.VarName, EditorStyles.toolbarButton, GUILayout.Width(100))) { if (!variableCombineList.Contains(var.VarName)) { variableCombineList.Add(var.VarName); ShowVariableCombine(); } else { variableCombineList.Remove(variableCombineList[i]); ShowVariableCombine(); } } GUI.color = saveColor; } GUILayout.EndHorizontal(); } GUILayout.EndVertical(); }