public override void OnInspectorGUI() { DrawDefaultInspector(); WSpriteResizer tgt = (WSpriteResizer)target; EU.VPadding(() => { tgt.data.ForEach(d => { if (GUILayout.Button("RESIZE " + d.FolderPaths.Ellipsis(50))) { Pack(d); } EditorUtils.VSpacing(); }); }); EU.VPadding(() => { EU.BtnWithAlert("RESIZE ALL", () => { tgt.data.ForEach(d => Pack(d)); }); }); }
public bool Build(BuildCallback cb) { int cur = cb.Origins.IndexOf(cb.Value); EU.VPadding(() => { if (null != cb.AddAction && GUILayout.Button(cb.AddAction.Label)) { T item = new T(); cb.Origins.Add(item); if (null != cb.AddAction.OnAdd) { cb.AddAction.OnAdd.Invoke(cb.Origins.Count); } } EditorGUILayout.LabelField(cb.Label, EditorStyles.boldLabel); if (m_alignment == Align.V) { GUILayout.BeginVertical(); } else { GUILayout.BeginHorizontal(); } cb.Origins.Loop((t, idx) => { EU.HGroup(() => { bool isSelected = idx == cur; var style = new GUIStyle(GUI.skin.button); style.normal.textColor = isSelected ? Color.cyan : Color.white; if (null != cb.Prefix) { cb.Prefix(t); } if (GUILayout.Button(cb.Mapper(t), style)) { cb.OnSelected.Invoke(new SelectState <T>(idx, cb.Origins[idx])); cur = idx; } if (null != cb.Suffix) { cb.Suffix(t); } if (null != cb.MoveAction && cb.Origins.Count > idx + 1) { EU.BtnWithAlert("V", () => { if (cb.MoveAction.Move != null) { cb.MoveAction.Move(idx); } else { cb.Origins.Swap(idx, idx + 1); } cb.MoveAction.OnMoved.Invoke(); }, GUILayout.Width(20f)); } if (null != cb.DelAction) { EU.BtnWithAlert(cb.DelAction.Label, () => { if (null != cb.DelAction.OnDelete) { cb.DelAction.OnDelete(new SelectState <T>(idx, cb.Origins[idx])); } else { cb.Origins.RemoveAt(idx); } if (null != cb.DelAction.OnDeleted) { cb.DelAction.OnDeleted.Invoke(idx); } }, GUILayout.Width(20f)); } }); }); if (m_alignment == Align.V) { GUILayout.EndVertical(); } else { GUILayout.EndHorizontal(); } }); return(cur > -1); }