private void DrawDragLine(Rect pos) { Event e = Event.current; int w = 10; Rect d = new Rect(sideWidth, pos.y, w, pos.height + 25); GUIDraw.DrawRect(d, new Color(0, 0, 0, 0)); if (d.Contains(e.mousePosition)) { EditorGUIUtility.AddCursorRect(d, MouseCursor.ResizeHorizontal); lineDrag = (e.type == EventType.mouseDrag) ? true : false; } if (lineDrag && e.type == EventType.MouseUp || e.mousePosition.x < 50 || e.mousePosition.x > EditorRect.width - 50) { lineDrag = false; } if (lineDrag) { sideWidth = e.mousePosition.x - w / 2; Repaint(); } }
private void DrawFileList() { Rect box = new Rect(5, 52, EditorRect.width - 10, EditorRect.height - 105); DrawRect(new Rect(0, 50, EditorRect.width, 15), new Color(.6f, .6f, .6f)); GUI.skin.label.fontSize = 8; EditorStyles.popup.fixedHeight = 20; EditorStyles.miniButtonLeft.fontSize = 8; EditorStyles.miniButtonMid.fontSize = 8; EditorStyles.miniButtonRight.fontSize = 8; GUI.Label(new Rect(5, 50, 100, 15), "Convert File List"); GUI.Label(new Rect(460, 70, 70, 25), "Export\nExtension"); GUI.BeginGroup(box); GUI.Box(new Rect(5, 45, box.width - 10, box.height - 50), ""); GUI.Box(new Rect(10, 60, box.width - 20, box.height - 74), ""); GUI.skin.label.fontSize = 9; GUI.skin.label.alignment = TextAnchor.MiddleCenter; GUI.Label(new Rect(15, 40, sideWidth - 15, 25), "Resource"); GUI.Label(new Rect(sideWidth + 15, 40, box.width - 20 - sideWidth, 25), "Convert To"); GUI.skin.label.alignment = TextAnchor.MiddleLeft; GUI.skin.label.fontSize = 8; GUI.skin.button.fontSize = 7; if (GUI.Button(new Rect(5, 20, 80, 20), new GUIContent("TextureImporter\nSettings", "General settings for the unity TextureImporter"))) { TextImportSetup(); } GUI.skin.button.fontSize = 8; if (GUI.Button(new Rect(100, 20, 80, 20), new GUIContent("Add", "Add a file to the converter list"), EditorStyles.miniButtonLeft)) { AddFile(); } if (draw) { GUI.enabled = (selectedIndex != -1) ? true : false; } if (GUI.Button(new Rect(180, 20, 80, 20), new GUIContent("Delete", "Remove selected file from the converter list"), EditorStyles.miniButtonMid)) { DeleteFile(); } if (draw) { GUI.enabled = (fLength > 0) ? true : false; } if (GUI.Button(new Rect(260, 20, 80, 20), new GUIContent("Clear List", "Clear the complete converter list"), EditorStyles.miniButtonRight)) { DeleteAll(); } if (draw) { GUI.enabled = true; } fTemp = fType; fType = EditorGUI.Popup(new Rect(500, 20, 60, 25), fType, fTypes); GUI.Button(new Rect(box.width - 65, 20, 60, 25), new GUIContent("", "Select a Extension for the export files"), GUIStyle.none); GUI.EndGroup(); if (fLength > 0) { scrollPos = GUI.BeginScrollView(new Rect(16, 113, box.width - 22, box.height - 76), scrollPos, new Rect(0, 0, box.width - 42, (22 * fLength))); GUI.skin.label.alignment = TextAnchor.MiddleLeft; Handles.color = new Color(.6f, .6f, .6f, .6f); for (int j = 0; j < fLength; j++) { Handles.DrawLine(new Vector3(0, Mathf.RoundToInt(-2 + j * 22) + 22, 0), new Vector3(box.width, Mathf.RoundToInt(-2 + j * 22) + 22, 0)); } Handles.color = Color.white; for (int i = 0; i < fLength; i++) { if (fList[i] != null) { GUI.color = (selectedIndex == i) ? new Color(1, .5f, 0, .3f) : new Color(1, 1, 1, .5f); if (GUI.Button(new Rect(-10, -2 + i * 22, box.width - 5, 21), "", ListStyle(i))) { ; if (selectedIndex == i) { selectedIndex = -1; } else if (selectedIndex != i) { selectedIndex = i; } } GUI.color = Color.white; GUI.Label(new Rect(10, 2 + i * 22, sideWidth - 22, 20), fList[i], GUIStyle.none); GUI.Label(new Rect(sideWidth, 2 + i * 22, EditorRect.width - sideWidth + 10, 20), Path.GetFileNameWithoutExtension(fList[i]) + "." + fTypes[fType], GUIStyle.none); } } GUI.EndScrollView(); } GUIDraw.DrawLine(new Vector2(sideWidth + box.x, 45 + box.y), new Vector2(sideWidth + box.x, box.height + box.y - 15), Color.grey); }
private void OnGUI() { TryInit(); #region Main setup //var debugFlags = DebugDisplayRegistry.DebugFlags; var enumType = (Type)null;//debugFlags.maskType; if (enumType == null || !enumType.IsEnum) { return; } enumInfos.Init(enumType); activeFlags.Count = enumInfos.Count; expandedFlags.Count = enumInfos.Count; if (styleSetup == null) { styleSetup = new GUISetup(); } #endregion Main setup #region Draw setup var bgMargin = 2; var lineMargin = 4; #endregion Draw setup var maskHasChanged = false; var itemCount = 0; for (int e = 0; e < enumInfos.Count; e++) { var value = enumInfos[e].value; //if (IsExpanded(value, ref debugFlags)) // itemCount += 1; } var titleRect = GUIDraw.BackgroundAuto(2, lineMargin, bgMargin, styleSetup.background); { titleRect = titleRect.TruncateX(titleRect.height) .TruncateX(-titleRect.height) .Inflate(-titleRect.height / 8); GUIDraw.Background(titleRect, 2, styleSetup.itemBG[0]); titleRect = titleRect.TruncateX(titleRect.height / 2); GUI.Label(titleRect, enumInfos.Type.Name, styleSetup.titleText); } var winRect = GUIDraw.BackgroundAuto(itemCount, lineMargin, bgMargin, styleSetup.background); { var lineRect = winRect; lineRect.height /= itemCount; for (int e = 0; e < enumInfos.Count; e++) { var value = enumInfos[e].value; var parentCount = 0; //debugFlags.CountParent(value); var hasChildren = 0; //debugFlags.HasChildren(value); //if (IsExpanded(value, ref debugFlags)) { var line = lineRect; var lockSize = 0.8f; { var lockRect = line.nh(line.height * (1.0f + lockSize)); GUIDraw.Background(lockRect, 0, styleSetup.itemBG[0]); lockRect = lockRect.TruncateX(lockRect.height); GUIDraw.Background(lockRect.Inflate(-2), 0, styleSetup.actives[0]); } //On-Off square var activeRect = GUIDraw.Square(GUIDraw.Square(ref line, 2), 0, styleSetup.actives[activeFlags[e] ? 1 : 0]); if (Event.current.type == EventType.MouseUp && activeRect.Contains(Event.current.mousePosition)) { maskHasChanged = true; activeFlags[e] = !activeFlags[e]; Repaint(); } //Parent offsets line = line.TruncateX(line.height * ((float)parentCount + lockSize)); line = GUIDraw.Background(line, 2, styleSetup.itemBG[0]); if (Event.current.type == EventType.MouseUp && line.Contains(Event.current.mousePosition)) { expandedFlags[e] = !expandedFlags[e]; Repaint(); } //Does this option has children //GUIDraw.Square(ref line, 0, hasChildren ? styleSetup.actives[0] : null); line = line.TruncateX(line.height / 2); GUI.Label(line, enumInfos[e].name, styleSetup.itemText); lineRect = lineRect.NextLine(); } } } //todo var manager = !EditorApplication.isPlaying ? null : TickableRegistry.GetManager<DebugDisplayManager>(); //todo if (manager != null) //todo { //todo if (maskHasChanged) //todo { //todo for (int e = 0; e < enumInfos.Count; e++) //todo { //todo debugFlags.SetStatus(enumInfos[e].value, activeFlags[e]); //todo } //todo DebugDisplayManager.DebugFlags = debugFlags; //todo manager.Build(); //todo } //todo } return; scrollPosition = EditorGUILayout.BeginScrollView(scrollPosition); { /* #region Draw setup * var margin2 = Vector2.one * 2; * var margin4 = Vector2.one * 4; * var windowRect = EditorGUILayout.GetControlRect(GUILayout.MinHeight(EditorGUIUtility.singleLineHeight * enumInfos.Count + margin4.y * 2)); * var lineRect = windowRect; * { * lineRect.x += margin4.x; * lineRect.width -= margin4.x * 2; * lineRect.height = EditorGUIUtility.singleLineHeight; * lineRect.y = windowRect.height - (lineRect.height + margin4.y); * } * var boxRect = lineRect; * { * boxRect.width = lineRect.height - margin2.y * 2; * boxRect.height = lineRect.height - margin2.x * 2; * boxRect.x += margin2.x; * boxRect.y += margin2.y; * } * var textRect = lineRect; * { * textRect.x += boxRect.width + margin2.x * 2; * textRect.width -= boxRect.width + margin2.x * 3; * textRect.height = EditorGUIUtility.singleLineHeight; * } #endregion Draw setup * #region Draw background * GUI.Box(windowRect, GUIContent.none, styleSetup.background); #endregion Draw background * #region Draw lines * * for (int i = enumInfos.Count - 1; i >= 0; i--) * { * var indent = manager != null ? manager.CountParents(i) : 0; * var oldX = lineRect.x; * var oldWidth = lineRect.width; * { * lineRect.x += indent * lineRect.height; * lineRect.width -= indent * lineRect.height; * boxRect.x += indent * lineRect.height; * textRect.x += indent * lineRect.height; * * GUI.Box(lineRect, GUIContent.none, styleSetup.m_item_background[Mathf.Min(indent, styleSetup.m_item_background.Count)]); * GUI.Box(boxRect, GUIContent.none, styleSetup.m_active[i % 2]); * GUI.Label(textRect, enumInfos[i].name, styleSetup.m_item_text); * } * lineRect.x = oldX; * lineRect.width = oldWidth; * lineRect.y -= lineRect.height; * boxRect.x = oldX + margin2.x; * boxRect.y -= lineRect.height; * textRect.x = oldX + boxRect.width + margin2.x * 2; * textRect.y -= lineRect.height; * } * #endregion Draw lines */ } EditorGUILayout.EndScrollView(); //m_enum_data.Sort((a, b) => //{ // if (a.value == DebugDisplayType.OVERRIDE_DEACTIVATE_ALL) // return -1; // if (b.value == DebugDisplayType.OVERRIDE_DEACTIVATE_ALL) // return 1; // return String.Compare(a.name, b.name); //}); return; /* * * * //DEBUG DISPLAY ----------------------------------------------------------------------- * * //var colors = new Color[enumValues.Length]; * //colors[(int)DebugType.Raycast] = new Color(1, 1, 1, 1); * //colors[(int)DebugType.Navigation] = new Color(1, 1, 1, 1); * //colors[(int)DebugType.Effects] = new Color(1, 1, 1, 1); * //colors[(int)DebugType.Electricity] = new Color(1, 1, 1, 1); * //colors[(int)DebugType.Robots] = new Color(1, 1, 1, 1); * //colors[(int)DebugType.Ash] = new Color(1, 1, 1, 1); * //colors[(int)DebugType.Physic] = new Color(1, 1, 1, 1); * * m_scrollPosition = GUILayout.BeginScrollView(m_scrollPosition, false, true); * * GUILayout.BeginHorizontal(); * var backupColor = GUI.color; * GUI.color = new Color(0.8f, 1.0f, 0.8f, 1.0f); * EditorGUILayout.LabelField(new GUIContent("A", "On All Objects"), GUILayout.Width(12)); * * GUI.color = new Color(0.8f, 1.0f, 0.8f, 1.0f); * EditorGUILayout.LabelField(new GUIContent("S", "On Selected Objects"), GUILayout.Width(12)); * * GUI.color = backupColor; * EditorGUILayout.Space(); * GUILayout.Label("Duration", GUILayout.Width(60)); * var oldDuration = 0; //TODO DebugDisplay.Duration; * var newDuration = EditorGUILayout.FloatField(GUIContent.none, oldDuration, GUILayout.Width(30)); * if (newDuration != oldDuration) * { * //TODO DebugDisplay.Duration = newDuration; * } * GUILayout.EndHorizontal(); * * bool valueChanged = false; * foreach (var d in m_enum_data) * { * var debugType = d.value; * * GUILayout.BeginHorizontal(); * * var oldValue = false; * var newValue = false; * * //oldValue = DebugDisplay.IsUnselectedActive(debugType); * //GUI.color = new Color(0.8f, 0.8f, 0.8f, 1.0f); * //newValue = EditorGUILayout.Toggle(oldValue, GUILayout.Width(12)); * //if (oldValue != newValue) * //{ * // valueChanged = true; * // DebugDisplay.SetActive(debugType, false, newValue); * //} * * oldValue = DebugDisplay.IsActive(debugType); * GUI.color = new Color(0.8f, 1.0f, 0.8f, 1.0f); * newValue = EditorGUILayout.Toggle(oldValue, GUILayout.Width(12)); * GUI.color = backupColor; * * if (oldValue != newValue) * { * valueChanged = true; * DebugDisplay.SetActive(debugType, newValue); * } * * GUILayout.Label(d.name); * * GUILayout.EndHorizontal(); * } * * if (valueChanged) * { * SceneView.RepaintAll(); * } * * GUILayout.EndScrollView(); */ }