Skip to content

Commit

Permalink
ブックマーク削除ボタンを追加しました。
Browse files Browse the repository at this point in the history
  • Loading branch information
rngtm committed Nov 25, 2016
1 parent 7a953a3 commit ce66d0c
Showing 1 changed file with 27 additions and 6 deletions.
33 changes: 27 additions & 6 deletions Assets/AssetBookmarker/Editor/BookmarkWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ void OnGUI()
}

EditorGUILayout.LabelField("ブックマークしたアセット一覧を表示します");

this.list.DoLayoutList();
}

Expand Down Expand Up @@ -110,23 +109,33 @@ void CreateList()
rect.height -= 4;

var labelRect = new Rect(rect);
labelRect.width = 17f;
labelRect.width = 13f;

var buttonRect = new Rect(rect);
buttonRect.x += labelRect.width + 8f;
buttonRect.width = 20f;
buttonRect.y += 1f;
buttonRect.height -= 2f;

var objectRect = new Rect(rect);
objectRect.width -= labelRect.width;
objectRect.x += labelRect.width;
objectRect.width -= labelRect.width + buttonRect.width + 18f;
objectRect.x += labelRect.width + buttonRect.width + 16f;

EditorGUI.LabelField(labelRect, index.ToString());

EditorGUI.BeginChangeCheck();
var asset = (Object)list.list[index];
asset = EditorGUI.ObjectField(objectRect, asset, typeof(Object), false);
if (EditorGUI.EndChangeCheck())
{
Debug.Log("Changed");
list.list[index] = asset;
EditorUtility.SetDirty(_data);
}

// remove
if (GUI.Button(buttonRect, "-"))
{
this.DoRemoveButton(list, index);
}
};

// フッター描画
Expand All @@ -148,5 +157,17 @@ void CreateList()
EditorUtility.SetDirty(_data);
};
}

/// <summary>
/// 要素の削除
/// </summary>
public void DoRemoveButton(ReorderableList list, int index)
{
EditorApplication.delayCall += () =>
{
list.list.RemoveAt(index);
this.Repaint();
};
}
}
}

0 comments on commit ce66d0c

Please sign in to comment.