资源简介
unity ngui计算器小案例,能使初学ngui的能容易上手,
代码片段和文件信息
using UnityEngine;
using UnityEditor;
using System.Collections.Generic;
///
/// Inspector class used to edit Inventory Databases.
///
[CustomEditor(typeof(InvDatabase))]
public class InvDatabaseInspector : Editor
{
static int mIndex = 0;
bool mConfirmDelete = false;
///
/// Helper function that sets the index to the index of the specified item.
///
public static void SelectIndex (InvDatabase db InvbaseItem item)
{
mIndex = 0;
foreach (InvbaseItem i in db.items)
{
if (i == item) break;
++mIndex;
}
}
///
/// Draw the inspector widget.
///
public override void OnInspectorGUI ()
{
EditorGUIUtility.LookLikeControls(80f);
InvDatabase db = target as InvDatabase;
NGUIEditorTools.DrawSeparator();
InvbaseItem item = null;
if (db.items == null || db.items.Count == 0)
{
mIndex = 0;
}
else
{
mIndex = Mathf.Clamp(mIndex 0 db.items.Count - 1);
item = db.items[mIndex];
}
if (mConfirmDelete)
{
// Show the confirmation dialog
GUILayout.Label(“Are you sure you want to delete ‘“ + item.name + “‘?“);
NGUIEditorTools.DrawSeparator();
GUILayout.BeginHorizontal();
{
GUI.backgroundColor = Color.green;
if (GUILayout.Button(“Cancel“)) mConfirmDelete = false;
GUI.backgroundColor = Color.red;
if (GUILayout.Button(“Delete“))
{
NGUIEditorTools.RegisterUndo(“Delete Inventory Item“ db);
db.items.RemoveAt(mIndex);
mConfirmDelete = false;
}
GUI.backgroundColor = Color.white;
}
GUILayout.EndHorizontal();
}
else
{
// Database icon atlas
UIAtlas atlas = EditorGUILayout.objectField(“Icon Atlas“ db.iconAtlas typeof(UIAtlas) false) as UIAtlas;
if (atlas != db.iconAtlas)
{
NGUIEditorTools.RegisterUndo(“Databse Atlas change“ db);
db.iconAtlas = atlas;
foreach (InvbaseItem i in db.items) i.iconAtlas = atlas;
}
// Database ID
int dbID = EditorGUILayout.IntField(“Database ID“ db.databaseID);
if (dbID != db.databaseID)
{
NGUIEditorTools.RegisterUndo(“Database ID change“ db);
db.databaseID = dbID;
}
// “New“ button
GUI.backgroundColor = Color.green;
if (GUILayout.Button(“New Item“))
{
NGUIEditorTools.RegisterUndo(“Add Inventory Item“ db);
InvbaseItem bi = new InvbaseItem();
bi.iconAtlas = db.iconAtlas;
bi.id16 = (db.items.Count > 0) ? db.items[db.items.Count - 1].id16 + 1 : 0;
db.items.Add(bi);
mIndex = db.items.Count - 1;
if (item != null)
{
bi.name = “Copy of “ + item.name;
bi.description = item.description;
bi.slot = item.slot;
bi.color = item.color;
bi.iconName = item.iconName;
bi.attachment = item.attachment;
bi.minItemLevel = item.minItemLevel;
bi.maxItemLevel = item.maxItemLevel;
foreach (InvStat stat in item.sta
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 7589 2013-07-15 09:35 NGUI_protect\Assembly-CSharp-Editor-vs.csproj
文件 7583 2013-07-15 09:35 NGUI_protect\Assembly-CSharp-Editor.csproj
文件 87668 2013-07-15 09:38 NGUI_protect\Assembly-CSharp-Editor.pidb
文件 13598 2013-07-15 16:17 NGUI_protect\Assembly-CSharp-vs.csproj
文件 13598 2013-07-15 16:17 NGUI_protect\Assembly-CSharp.csproj
文件 328540 2013-07-15 16:21 NGUI_protect\Assembly-CSharp.pidb
I.A.... 63448 2013-07-15 16:20 NGUI_protect\Assets\Level\computers.unity
I.A.... 11216 2012-08-23 05:49 NGUI_protect\Assets\NGUI\Examples\Animations\Button.anim
I.A.... 10912 2012-08-23 05:49 NGUI_protect\Assets\NGUI\Examples\Animations\Checkmark.anim
I.A.... 12904 2012-08-23 05:49 NGUI_protect\Assets\NGUI\Examples\Animations\Logo.anim
I.A.... 11816 2012-08-23 05:48 NGUI_protect\Assets\NGUI\Examples\Animations\Window - Back.anim
I.A.... 11704 2012-08-23 05:49 NGUI_protect\Assets\NGUI\Examples\Animations\Window - Forward.anim
I.A.... 3546 2012-08-23 05:49 NGUI_protect\Assets\NGUI\Examples\Atlases\Fantasy\Fantasy Atlas.mat
I.A.... 7597 2012-08-23 05:49 NGUI_protect\Assets\NGUI\Examples\Atlases\Fantasy\Fantasy Atlas.prefab
I.A.... 1192501 2012-08-23 05:49 NGUI_protect\Assets\NGUI\Examples\Atlases\Fantasy\Fantasy Atlas.psd
I.A.... 16006 2012-08-23 05:48 NGUI_protect\Assets\NGUI\Examples\Atlases\Fantasy\Fantasy Font - Normal.prefab
I.A.... 21846 2012-08-23 05:49 NGUI_protect\Assets\NGUI\Examples\Atlases\Fantasy\Fantasy Font - Normal.txt
I.A.... 1654198 2012-08-23 05:49 NGUI_protect\Assets\NGUI\Examples\Atlases\Refractive\Refractive Atlas - Bump.psd
I.A.... 98430 2012-08-23 05:48 NGUI_protect\Assets\NGUI\Examples\Atlases\Refractive\Refractive Atlas - Masks.psd
I.A.... 4117 2012-08-23 05:49 NGUI_protect\Assets\NGUI\Examples\Atlases\Refractive\Refractive Atlas.mat
I.A.... 7185 2012-08-23 05:49 NGUI_protect\Assets\NGUI\Examples\Atlases\Refractive\Refractive Atlas.prefab
I.A.... 354488 2012-08-23 05:48 NGUI_protect\Assets\NGUI\Examples\Atlases\Refractive\Refractive Atlas.psd
I.A.... 13878 2012-08-23 05:49 NGUI_protect\Assets\NGUI\Examples\Atlases\Refractive\Refractive Font - Header.prefab
I.A.... 37748 2012-08-23 05:49 NGUI_protect\Assets\NGUI\Examples\Atlases\Refractive\Refractive Font - Header.txt
I.A.... 13962 2012-08-23 05:49 NGUI_protect\Assets\NGUI\Examples\Atlases\Refractive\Refractive Font - Normal.prefab
I.A.... 31928 2012-08-23 05:49 NGUI_protect\Assets\NGUI\Examples\Atlases\Refractive\Refractive Font - Normal.txt
I.A.... 3672 2012-08-23 05:49 NGUI_protect\Assets\NGUI\Examples\Atlases\SciFi\SciFi Atlas.mat
I.A.... 7301 2012-08-23 05:48 NGUI_protect\Assets\NGUI\Examples\Atlases\SciFi\SciFi Atlas.prefab
I.A.... 610522 2012-08-23 05:49 NGUI_protect\Assets\NGUI\Examples\Atlases\SciFi\SciFi Atlas.psd
I.A.... 13298 2012-08-23 05:49 NGUI_protect\Assets\NGUI\Examples\Atlases\SciFi\SciFi Font - Header.prefab
............此处省略1727个文件信息
相关资源
- NGUI Next-Gen UI v3.11.4
- NGUIv3.9.7
- EmWin计算器_使用栈_带括号_适用于安富
- hp39gii调试工具包
- NGUI: Next-Gen UI v3.12.0b 2018年5月
- Unity3d之NGUI简单计算器入门
- unity -NGUI的背包系统
- 工程计算源代码
- 最新版NGUI 3.9.9 官方完整包
- NGUI v3.12.1最新版
- 阿里钉钉DingUI4.0设计组件XD.sketch
- NGUI 3.12.1
- NGUI3.6.4 最新版本NGUI ngui
- 仿小米计算器源码
- 水蒸汽性质计算器 水,水蒸汽性质计
- vs2010+qt四则混合运算计算器
- NGUI v3.12.1 2018 最新版NGUI
- Unity NGUI 滑动列表渐变缩放,偏移,渐
- 利用VS2010 和qt 4.8.4编写的加法计算器
- 自制51单片机共阳共阴数码混用计算器
- 【BMI指数计算器V1.0】项目实战101646
- Unity 3D NGUI实战教程(完整版)
- VC课程设计计算器
- NGUI多个版本合集
- Unity3D项目游戏设置界面NGUI
- 《软件工程》人工成本及投资回收率
- AHP法计算器
- 一元稀疏多项式计算器 数据结构课程
- 编译原理布尔表达式计算器
- BpmAnlyz一款超级猛的歌曲BPM计算器!我
评论
共有 条评论