public override void OnInspectorGUI() { var barColor = new Color(0.3f, 0.5f, 0.7f, 0.1f); var barShadowColor = new Color(0.1f, 0.3f, 0.4f, 0.05f); var rect = EditorUtils.DrawTag("[UniKh.UIController]", usage.Replace("{0}", target.GetType().Name)); rect.xMin -= 14; rect.width += 14; var rectHeader = new Rect(rect.x, rect.y - 18, rect.width, rect.height + 4); EditorUtils.DrawOverlapHeaderRect(rectHeader, barColor, barShadowColor); var fontOrg = EditorStyles.label.font; EditorStyles.label.font = EditorUtils.EditorFontEditor; base.OnInspectorGUI(); var endRect = EditorGUILayout.GetControlRect(false, 2f); endRect.yMin += 8; endRect.yMax += 7; endRect.xMin -= 14; endRect.width += 14; var rectAll = new Rect(rect.xMin, rectHeader.yMax, rect.width, endRect.yMax - rectHeader.yMax); EditorGUI.DrawRect(rectAll, new Color(0.1f, 0.1f, 0.1f, 0.2f)); EditorGUI.DrawRect(endRect, new Color(0.05f, 0.05f, 0.1f, 0.2f)); EditorStyles.label.font = fontOrg; }
public override void OnInspectorGUI() { var r = EditorUtils.Render.BeginSandBox(); var rect = EditorUtils.DrawTag("[UniKh.ResPool]", null); rect.xMin -= 14; rect.width += 14; var rectHeader = new Rect(rect.x, rect.y - 18, rect.width, rect.height + 4); EditorUtils.DrawOverlapHeaderRect(rectHeader, new Color(0.7f, 0.5f, 0.4f), Color.black); var types = Assembly.GetAssembly(typeof(IdsAttribute)).GetTypes(); var lstEnumType = new List <IdsAttribute>(); IdsTree root = null; types.ForEach( type => { if (!Attribute.IsDefined(type, typeof(IdsAttribute))) { return; } var attr = type.GetCustomAttribute <IdsAttribute>(); var idSeg = new IdsTree(attr.SegStart, attr.SegEnd, type); root = root == null ? idSeg : root.Insert(idSeg); } ); if (null != root) { root.ForEach((t, d) => EditorGUILayout.LabelField(" - ".Repeat(d) + t.ToString())); EditorGUILayout.Space(); } if (!Application.isPlaying) { r.SetColor(new Color(1f, 0.3f, 0.2f)); EditorGUILayout.LabelField("Monitor will show while playing", EditorUtils.LabelEditorTagStyle); } else if (ResPool.Inst.pool != null) { var lst = ResPool.Inst.pool.Keys.ToList(); lst.Sort(); var lightLine = true; var maxKey = ResPool.Inst.pool.Keys.Reduce((prev, key) => prev > key ? prev : key, 0u); var maxKeyLength = maxKey.ToString().Length; var keyResId = "ResId".PadRight(maxKeyLength, ' '); r.SetColor(new Color(0.9f, 0.6f, 0.3f)); EditorGUILayout.LabelField($"|{keyResId}|InPool|All |Desc\t|", EditorUtils.LabelCodeStyle); var cCreated = new Color(0.8f, 0.8f, 0.8f); var cInUse = new Color(0.6f, 1f, 0.9f); var cTooMuch = new Color(1f, 0.5f, 0.5f); foreach (var key in lst) { var pool = ResPool.Inst.pool[key]; var poolCount = ResPool.Inst.pool[key].Count; var totalCreated = ResPool.Inst.totalCreated.TryGet(key, 0); var desc = null != root?root.Find(key).ToString() : "NONE"; r.SetColor( totalCreated == 0 ? Color.gray : totalCreated == poolCount ? cCreated : (totalCreated - poolCount) > 20 ? cTooMuch : cInUse ); EditorGUILayout.LabelField( $"|{key.ToString().PadRight(maxKeyLength, ' ')}|{poolCount.ToString().PadRight(6)}|{totalCreated.ToString().PadRight(6)}|{desc}\t|", EditorUtils.LabelCodeStyle ); var lineRect = GUILayoutUtility.GetLastRect(); if (lightLine) { EditorGUI.DrawRect(lineRect, new Color(0.7f, 0.7f, 0.7f, 0.05f)); } if (Event.current.type == EventType.MouseUp && lineRect.Contains(Event.current.mousePosition)) { WizardCreateLight.CreateWizard(key.ToString(), () => pool); } lightLine = !lightLine; } } else { r.SetColor(new Color(0.8f, 0.5f, 0.2f)); EditorGUILayout.LabelField("Empty pool", EditorUtils.LabelEditorTagStyle); } r.EndSandBox(); }