Skip to content

Commit d7942f5

Browse files
committed
add readme
1 parent 9a5f872 commit d7942f5

File tree

1 file changed

+289
-1
lines changed

1 file changed

+289
-1
lines changed

README.md

Lines changed: 289 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,289 @@
1-
# uni-debug-menu
1+
# UniDebugMenu
2+
3+
横向きかつクリックやタップ可能なゲームで使用できる
4+
カスタマイズ可能なデバッグメニュー
5+
6+
## 機能
7+
8+
- 3種類のメニュー表示を使用可能
9+
- テキスト表示
10+
- ボタン表示
11+
- カスタマイズ可能なボタン表示
12+
- 大量のデータを実装可能
13+
- 多階層のメニューを実装可能
14+
- 検索可能
15+
- カテゴリ分け可能
16+
- トースト表示
17+
- イベント検知
18+
- ドラッグ可能な開くボタン
19+
- どこからでも開ける
20+
- 複数解像度対応
21+
22+
## バージョン
23+
24+
- Unity 2018.3.7f1
25+
26+
## サンプル
27+
28+
### トップ画面
29+
30+
![](https://cdn-ak.f.st-hatena.com/images/fotolife/b/baba_s/20190318/20190318121622.png)
31+
32+
### システム情報
33+
34+
![](https://cdn-ak.f.st-hatena.com/images/fotolife/b/baba_s/20190318/20190318121129.png)
35+
36+
![](https://cdn-ak.f.st-hatena.com/images/fotolife/b/baba_s/20190318/20190318121138.png)
37+
38+
![](https://cdn-ak.f.st-hatena.com/images/fotolife/b/baba_s/20190318/20190318121145.png)
39+
40+
### システムコマンド
41+
42+
![](https://cdn-ak.f.st-hatena.com/images/fotolife/b/baba_s/20190318/20190318121153.png)
43+
44+
![](https://cdn-ak.f.st-hatena.com/images/fotolife/b/baba_s/20190318/20190318121201.png)
45+
46+
### ゲームオブジェクト一覧
47+
48+
![](https://cdn-ak.f.st-hatena.com/images/fotolife/b/baba_s/20190318/20190318121208.png)
49+
50+
### ログ情報
51+
52+
![](https://cdn-ak.f.st-hatena.com/images/fotolife/b/baba_s/20190318/20190318121215.png)
53+
54+
![](https://cdn-ak.f.st-hatena.com/images/fotolife/b/baba_s/20190318/20190318121224.png)
55+
56+
## 3種類のメニュー表示を使用可能
57+
58+
### テキスト表示
59+
60+
![](https://cdn-ak.f.st-hatena.com/images/fotolife/b/baba_s/20190318/20190318121129.png)
61+
62+
### ボタン表示
63+
64+
![](https://cdn-ak.f.st-hatena.com/images/fotolife/b/baba_s/20190318/20190318121245.png)
65+
66+
![](https://cdn-ak.f.st-hatena.com/images/fotolife/b/baba_s/20190318/20190318121252.png)
67+
68+
### カスタマイズ可能なボタン表示
69+
70+
![](https://cdn-ak.f.st-hatena.com/images/fotolife/b/baba_s/20190318/20190318121153.png)
71+
72+
## 大量のデータを実装可能
73+
74+
![](https://cdn-ak.f.st-hatena.com/images/fotolife/b/baba_s/20190318/20190318121306.gif)
75+
76+
## 多階層のメニューを実装可能
77+
78+
![](https://cdn-ak.f.st-hatena.com/images/fotolife/b/baba_s/20190318/20190318121326.gif)
79+
80+
## 検索可能
81+
82+
![](https://cdn-ak.f.st-hatena.com/images/fotolife/b/baba_s/20190318/20190318122249.gif)
83+
84+
## カテゴリ分け可能
85+
86+
![](https://cdn-ak.f.st-hatena.com/images/fotolife/b/baba_s/20190318/20190318122302.gif)
87+
88+
## トースト表示
89+
90+
![](https://cdn-ak.f.st-hatena.com/images/fotolife/b/baba_s/20190318/20190318122324.gif)
91+
92+
## ドラッグ可能な開くボタン
93+
94+
![](https://cdn-ak.f.st-hatena.com/images/fotolife/b/baba_s/20190318/20190318122400.gif)
95+
96+
## どこからでも開ける
97+
98+
![](https://cdn-ak.f.st-hatena.com/images/fotolife/b/baba_s/20190318/20190318122651.gif)
99+
100+
## 複数解像度対応
101+
102+
### 18:9
103+
104+
![](https://cdn-ak.f.st-hatena.com/images/fotolife/b/baba_s/20190318/20190318122531.png)
105+
106+
### 4:3
107+
108+
![](https://cdn-ak.f.st-hatena.com/images/fotolife/b/baba_s/20190318/20190318122547.png)
109+
110+
## スクリプト
111+
112+
### 基本
113+
114+
```cs
115+
using UnityEngine;
116+
using UnityEngine.SceneManagement;
117+
118+
namespace UniDebugMenu.Example
119+
{
120+
/// <summary>
121+
/// デバッグメニューのサンプルを管理するクラス
122+
/// </summary>
123+
public sealed class UniDebugMenuExampleScene : MonoBehaviour
124+
{
125+
//==============================================================================
126+
// 変数
127+
//==============================================================================
128+
private ExampleTopListCreator m_creator;
129+
130+
//==============================================================================
131+
// 関数
132+
//==============================================================================
133+
/// <summary>
134+
/// 初期化される時に呼び出されます
135+
/// </summary>
136+
private void Awake()
137+
{
138+
// デバッグメニューのトップ画面のリストを管理するインスタンスを作成します
139+
m_creator = new ExampleTopListCreator();
140+
m_creator.Init();
141+
142+
// デバッグメニューのシーンを加算で読み込みます
143+
SceneManager.LoadScene( "UniDebugMenuScene", LoadSceneMode.Additive );
144+
145+
// デバッグメニューでコマンドが実行された時に呼び出されます
146+
UniDebugMenuScene.mOnChange += () => Debug.Log( "UniDebugMenuScene.mOnChange" );
147+
148+
// DM ボタンが押された時にデバッグメニューのトップ画面を開くように設定します
149+
UniDebugMenuScene.mOnOpen += () => DMType.BUTTON_COL_3.Open( m_creator );
150+
}
151+
152+
/// <summary>
153+
/// デバッグメニューを開くボタンが押された
154+
/// </summary>
155+
public void OnClick1()
156+
{
157+
// デバッグメニューのトップ画面を開きます
158+
DMType.BUTTON_COL_3.Open( m_creator );
159+
}
160+
161+
/// <summary>
162+
/// システムコマンドの画面を開くボタンが押された
163+
/// </summary>
164+
public void OnClick2()
165+
{
166+
// デバッグメニューのシステムコマンドの画面を開きます
167+
DMType.COMMAND_TAB_6.Open( new SystemCommandListCreator() );
168+
}
169+
170+
/// <summary>
171+
/// デバッグメニューを開く DM ボタンを透明にするボタンが押された
172+
/// </summary>
173+
public void OnClick3()
174+
{
175+
// DM ボタンを透明にします
176+
// DM ボタンは透明になるだけで当たり判定は有効のままになります
177+
// true:不透明 false:透明
178+
UniDebugMenuScene.SetOpenButtonVisible( false );
179+
}
180+
181+
/// <summary>
182+
/// デバッグメニューを削除するボタンが押された
183+
/// </summary>
184+
public void OnClick4()
185+
{
186+
// デバッグメニューのゲームオブジェクトを削除します
187+
if ( UniDebugMenuScene.Destroy() )
188+
{
189+
// デバッグメニューのゲームオブジェクトが削除できた場合は
190+
// デバッグメニューのシーンもアンロードします
191+
SceneManager.UnloadSceneAsync( "UniDebugMenuScene" );
192+
}
193+
}
194+
}
195+
}
196+
```
197+
198+
### リスト生成
199+
200+
```cs
201+
using System;
202+
using System.Collections.Generic;
203+
using System.Linq;
204+
using UnityEngine;
205+
206+
namespace UniDebugMenu.Example
207+
{
208+
/// <summary>
209+
/// デバッグメニューのトップ画面のリストを作成するクラス
210+
/// </summary>
211+
[Serializable]
212+
public sealed class ExampleTopListCreator : ListCreatorBase<ActionData>, IDisposable
213+
{
214+
//==============================================================================
215+
// 変数(readonly)
216+
//==============================================================================
217+
private readonly ActionData[] m_sourceList;
218+
219+
// ログ情報のリストを作成するインスタンス
220+
private readonly LogListCreator m_logDataCreator = new LogListCreator( 1500 );
221+
222+
//==============================================================================
223+
// 変数
224+
//==============================================================================
225+
private IList<ActionData> m_list;
226+
227+
//==============================================================================
228+
// プロパティ
229+
//==============================================================================
230+
public override int Count => m_list.Count;
231+
232+
public override ActionData[] OptionActionList => new []
233+
{
234+
new ActionData( "ボタン1" , () => Debug.Log( "ボタン1が押されました" ) ),
235+
new ActionData( "ボタン2" , () => Debug.Log( "ボタン2が押されました" ) ),
236+
new ActionData( "ボタン3" , () => Debug.Log( "ボタン3が押されました" ) ),
237+
new ActionData( "ボタン4" , () => Debug.Log( "ボタン4が押されました" ) ),
238+
new ActionData( "ボタン5" , () => Debug.Log( "ボタン5が押されました" ) ),
239+
};
240+
241+
//==============================================================================
242+
// 関数
243+
//==============================================================================
244+
/// <summary>
245+
/// コンストラクタ
246+
/// </summary>
247+
public ExampleTopListCreator()
248+
{
249+
m_sourceList = new []
250+
{
251+
new ActionData( "テキスト表示サンプル" , () => OpenAdd( DMType.TEXT_TAB_6 , new TextListCreatorExample() ) ),
252+
new ActionData( "ボタン表示サンプル 2列" , () => OpenAdd( DMType.BUTTON_COL_2 , new TextListCreatorExample() ) ),
253+
new ActionData( "ボタン表示サンプル 3列" , () => OpenAdd( DMType.BUTTON_COL_3 , new TextListCreatorExample() ) ),
254+
new ActionData( "システム情報" , () => OpenAdd( DMType.TEXT_TAB_6 , new SystemInfoListCreator() ) ),
255+
new ActionData( "システムコマンド" , () => OpenAdd( DMType.COMMAND_TAB_6 , new SystemCommandListCreator() ) ),
256+
new ActionData( "ゲームオブジェクト一覧" , () => OpenAdd( DMType.COMMAND_TAB_6 , new GameObjectListCreator() ) ),
257+
new ActionData( "ログ情報" , () => OpenAdd( DMType.TEXT_TAB_6 , m_logDataCreator ) ),
258+
};
259+
}
260+
261+
/// <summary>
262+
/// 初期化します
263+
/// </summary>
264+
public void Init() => m_logDataCreator.Init();
265+
266+
/// <summary>
267+
/// 破棄します
268+
/// </summary>
269+
public void Dispose() => m_logDataCreator.Dispose();
270+
271+
/// <summary>
272+
/// リストの表示に使用するデータを作成します
273+
/// </summary>
274+
protected override void DoCreate( ListCreateData data )
275+
{
276+
m_list = m_sourceList
277+
.Where( c => data.IsMatch( c.m_text ) )
278+
.ToArray()
279+
.ReverseIf( data.IsReverse )
280+
;
281+
}
282+
283+
/// <summary>
284+
/// 指定されたインデックスの要素の表示に使用するデータを返します
285+
/// </summary>
286+
protected override ActionData DoGetElemData( int index ) => m_list.ElementAtOrDefault( index );
287+
}
288+
}
289+
```

0 commit comments

Comments
 (0)