Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
rngtm committed Nov 21, 2016
0 parents commit 7a953a3
Show file tree
Hide file tree
Showing 32 changed files with 361 additions and 0 deletions.
41 changes: 41 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# =============== #
# Unity generated #
# =============== #
Temp/
Obj/
UnityGenerated/
Library/

# ===================================== #
# Visual Studio / MonoDevelop generated #
# ===================================== #
ExportedObj/
*.svd
*.userprefs
*.csproj
*.pidb
*.suo
*.sln
*.user
*.unityproj
*.booproj

# ============ #
# OS generated #
# ============ #
.DS_Store
.DS_Store?
._*
.Spotlight-V100
.Trashes
Icon?
ehthumbs.db
Thumbs.db

# ============ #
# for others #
# ============ #

*.log #log files, for some plugins
*.pyc #python bytecode cache, for some plugins.
sysinfo.txt #Unity3D Generated File On Crash Reports
9 changes: 9 additions & 0 deletions Assets/AssetBookmarker.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions Assets/AssetBookmarker/Editor.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file added Assets/AssetBookmarker/Editor/BookmarkData.asset
Binary file not shown.
8 changes: 8 additions & 0 deletions Assets/AssetBookmarker/Editor/BookmarkData.asset.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

31 changes: 31 additions & 0 deletions Assets/AssetBookmarker/Editor/BookmarkData.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
///-----------------------------------
/// AssetBookmarker
/// @ 2016 RNGTM(https://github.com/rngtm)
///-----------------------------------
namespace AssetBookmarker
{
using System.Collections.Generic;
using UnityEngine;

/// <summary>
/// Bookmarkのデータ
/// </summary>
public class BookmarkData : ScriptableObject
{
[SerializeField]
private List<Object> assets;

/// <summary>
/// ブックマークとして登録しているアセット
/// </summary>
public List<Object> Assets { get { return this.assets; } }

/// <summary>
/// アセットをブックマークへ登録
/// </summary>
public void Register(Object asset)
{
this.assets.Add(asset);
}
}
}
12 changes: 12 additions & 0 deletions Assets/AssetBookmarker/Editor/BookmarkData.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

32 changes: 32 additions & 0 deletions Assets/AssetBookmarker/Editor/BookmarkUtility.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
///-----------------------------------
/// AssetBookmarker
/// @ 2016 RNGTM(https://github.com/rngtm)
///-----------------------------------
namespace AssetBookmarker
{
using System.Linq;
using System.IO;
using UnityEngine;
using UnityEditor;

public class BookmarkUtility : MonoBehaviour
{
/// <summary>
/// Bookmarkデータファイル名
/// </summary>
private static readonly string DataName = "BookmarkData.asset";

/// <summary>
/// Bookmarkデータのロード
/// </summary>
public static BookmarkData LoadData()
{
var monoScript = Resources.FindObjectsOfTypeAll<MonoScript>().FirstOrDefault(m => m.GetClass() == typeof(BookmarkUtility));
var path = AssetDatabase.GetAssetPath(monoScript);
var dirPath = Path.GetDirectoryName(path);
var dataPath = dirPath + Path.DirectorySeparatorChar + DataName;

return (BookmarkData)AssetDatabase.LoadAssetAtPath(dataPath, typeof(BookmarkData));
}
}
}
12 changes: 12 additions & 0 deletions Assets/AssetBookmarker/Editor/BookmarkUtility.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

152 changes: 152 additions & 0 deletions Assets/AssetBookmarker/Editor/BookmarkWindow.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
///-----------------------------------
/// AssetBookmarker
/// @ 2016 RNGTM(https://github.com/rngtm)
///-----------------------------------
namespace AssetBookmarker
{
using UnityEngine;
using UnityEditor;
using UnityEditorInternal;

/// <summary>
/// ブックマークの管理を行うウィンドウ
/// </summary>
public class BookmarkWindow : EditorWindow
{
/// <summary>
/// MenuItemのPriority
/// </summary>
private const int Priority = 10001;

/// <summary>
/// Bookmarkデータ
/// </summary>
private static BookmarkData _data;

/// <summary>
/// Bookmark表示用のReorderableList
/// </summary>
private ReorderableList list;

/// <summary>
/// ウィンドウを開く
/// </summary>
[MenuItem("Tools/AssetBookmarker")]
static void Open()
{
GetWindow<BookmarkWindow>();
}

/// <summary>
/// ウィンドウの描画処理
/// </summary>
void OnGUI()
{
if (_data == null)
{
_data = BookmarkUtility.LoadData();
}

if (this.list == null)
{
this.CreateList();
}

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

this.list.DoLayoutList();
}

/// <summary>
/// エディタ上で選択しているアセットをBookmarkへ登録
/// </summary>
[MenuItem("Assets/Add to bookmark list", false, Priority)]
static void RegisterSelection()
{
if (_data == null)
{
_data = BookmarkUtility.LoadData();
}

_data.Assets.AddRange(Selection.objects);
EditorUtility.SetDirty(_data);

var window = Resources.FindObjectsOfTypeAll<BookmarkWindow>();
if (window == null || window.Length == 0)
{
Open();
}
else
{
window[0].Repaint();
}
}

/// <summary>
/// RegisterSelectionのValidateメソッド
/// </summary>
[MenuItem("Assets/Add to bookmark list", true, Priority)]
static bool ValidateRegisterSelection()
{
return Selection.activeObject != null;
}

/// <summary>
/// ReorderableListを作成する
/// </summary>
void CreateList()
{
this.list = new ReorderableList(_data.Assets, typeof(Object));

this.list.drawHeaderCallback = (rect) =>
{
EditorGUI.LabelField(rect, "Bookmarks");
};

// 要素の描画
this.list.drawElementCallback = (rect, index, isActive, isFocused) =>
{
rect.y += 1;
rect.height -= 4;

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

var objectRect = new Rect(rect);
objectRect.width -= labelRect.width;
objectRect.x += labelRect.width;

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);
}
};

// フッター描画
this.list.drawFooterCallback = (rect) =>
{
if (this.list.count == 0)
{
rect.position -= new Vector2(0f, this.list.elementHeight + this.list.headerHeight + 3f);
}
else
{
rect.position -= new Vector2(0f, this.list.elementHeight * this.list.count + this.list.headerHeight + 3f);
}
ReorderableList.defaultBehaviours.DrawFooter(rect, list);
};

this.list.onChangedCallback += (index) =>
{
EditorUtility.SetDirty(_data);
};
}
}
}
12 changes: 12 additions & 0 deletions Assets/AssetBookmarker/Editor/BookmarkWindow.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file added Demo/1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Demo/2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Demo/3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Packages/AssetBookMarker-v1.0.unitypackage
Binary file not shown.
Binary file added ProjectSettings/AudioManager.asset
Binary file not shown.
Binary file added ProjectSettings/ClusterInputManager.asset
Binary file not shown.
Binary file added ProjectSettings/DynamicsManager.asset
Binary file not shown.
Binary file added ProjectSettings/EditorBuildSettings.asset
Binary file not shown.
Binary file added ProjectSettings/EditorSettings.asset
Binary file not shown.
Binary file added ProjectSettings/GraphicsSettings.asset
Binary file not shown.
Binary file added ProjectSettings/InputManager.asset
Binary file not shown.
Binary file added ProjectSettings/NavMeshProjectSettings.asset
Binary file not shown.
Binary file added ProjectSettings/NetworkManager.asset
Binary file not shown.
Binary file added ProjectSettings/Physics2DSettings.asset
Binary file not shown.
Binary file added ProjectSettings/ProjectSettings.asset
Binary file not shown.
1 change: 1 addition & 0 deletions ProjectSettings/ProjectVersion.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
m_EditorVersion: 5.5.0b7
Binary file added ProjectSettings/QualitySettings.asset
Binary file not shown.
Binary file added ProjectSettings/TagManager.asset
Binary file not shown.
Binary file added ProjectSettings/TimeManager.asset
Binary file not shown.
Binary file added ProjectSettings/UnityConnectSettings.asset
Binary file not shown.
42 changes: 42 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
Unity-AssetBookmarker
============
**AssetBookmarker** is a tool to bookmark Unity assets.

Usage
-------
1) Right-click the asset which you want to bookmark.
![](./Demo/1.png)

<br>

2) Select "Add to bookmark list" in context menu.
![](./Demo/2.png)

<br>

That's it!
![](./Demo/3.png)


License
-------
The MIT License (MIT)

Copyright (c) 2016 RNGTM (https://github.com/rngtm)

Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

0 comments on commit 7a953a3

Please sign in to comment.