資源簡介
使用unity3D開發的游戲,界面用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;
///?
///?Draw?an?enlarged?sprite?within?the?specified?texture?atlas.
///?
public?Rect?DrawSprite?(Texture2D?tex?Rect?sprite?Material?mat)?{?return?DrawSprite(tex?sprite?mat?true?0);?}
///?
///?Draw?an?enlarged?sprite?within?the?specified?texture?atlas.
///?
public?Rect?DrawSprite?(Texture2D?tex?Rect?sprite?Material?mat?bool?addPadding)
{
return?DrawSprite(tex?sprite?mat?addPadding?0);
}
///?
///?Draw?an?enlarged?sprite?within?the?specified?texture?atlas.
///?
public?Rect?DrawSprite?(Texture2D?tex?Rect?sprite?Material?mat?bool?addPadding?int?maxSize)
{
float?paddingX?=?addPadding???4f?/?tex.width?:?0f;
float?paddingY?=?addPadding???4f?/?tex.height?:?0f;
float?ratio?=?(sprite.height?+?paddingY)?/?(sprite.width?+?paddingX);
ratio?*=?(float)tex.height?/?tex.width;
//?Draw?the?checkered?background
Color?c?=?GUI.color;
Rect?rect?=?NGUIEditorTools.DrawBackground(tex?ratio);
GUI.color?=?c;
if?(maxSize?>?0)
{
float?dim?=?maxSize?/?Mathf.Max(rect.width?rect.height);
rect.width?*=?dim;
rect.height?*=?dim;
}
//?We?only?want?to?draw?into?this?rectangle
if?(Event.current.type?==?EventType.Repaint)
{
if?(mat?==?null)
{
GUI.DrawTextureWithTexCoords(rect?tex?sprite);
}
else
{
//?NOTE:?DrawPreviewTexture?doesn‘t?seem?to?support?BeginGroup-based?clipping
//?when?a?custom?material?is?specified.?It?seems?to?be?a?bug?in?Unity.
//?Passing?‘null‘?for?the?material?or?omitting?the?parameter?clips?as?expected.
UnityEditor.EditorGUI.DrawPreviewTexture(sprite?tex?mat);
//UnityEditor.EditorGUI.DrawPreviewTexture(drawRect?tex);
//GUI.DrawTexture(drawRect?tex);
}
rect?=?new?Rect(sprite.x?+?rect.x?sprite.y?+?rect.y?sprite.width?sprite.height);
}
return?rect;
}
///?
///?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?+?“‘?“);
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2013-05-23?16:49??wzq2\
?????文件????????8613??2013-05-23?16:37??wzq2\Assembly-CSharp-Editor-vs.csproj
?????文件????????8607??2013-05-23?16:37??wzq2\Assembly-CSharp-Editor.csproj
?????文件??????110163??2013-05-23?16:46??wzq2\Assembly-CSharp-Editor.pidb
?????文件???????14858??2013-05-23?16:37??wzq2\Assembly-CSharp-vs.csproj
?????文件???????14858??2013-05-23?16:37??wzq2\Assembly-CSharp.csproj
?????文件??????360642??2013-05-23?16:46??wzq2\Assembly-CSharp.pidb
?????文件????????5827??2013-05-21?19:49??wzq2\Assembly-Unitysc
?????文件???????11500??2013-05-21?19:43??wzq2\Assembly-Unitysc
?????文件????????5827??2013-05-21?19:49??wzq2\Assembly-Unitysc
?????目錄???????????0??2013-05-21?20:04??wzq2\Assets\
?????目錄???????????0??2013-05-14?20:29??wzq2\Assets\NGUI\
?????目錄???????????0??2013-05-23?16:38??wzq2\Assets\NGUI\Examples\
?????目錄???????????0??2013-05-14?20:29??wzq2\Assets\NGUI\Examples\Animations\
?????文件???????11216??2013-05-06?09:57??wzq2\Assets\NGUI\Examples\Animations\Button.anim
?????文件???????10240??2013-05-06?09:57??wzq2\Assets\NGUI\Examples\Animations\Checkmark.anim
?????文件???????12904??2013-05-06?09:57??wzq2\Assets\NGUI\Examples\Animations\Logo.anim
?????文件???????11816??2013-05-06?09:57??wzq2\Assets\NGUI\Examples\Animations\Window?-?Back.anim
?????文件???????11704??2013-05-06?09:57??wzq2\Assets\NGUI\Examples\Animations\Window?-?Forward.anim
?????目錄???????????0??2012-08-01?11:07??wzq2\Assets\NGUI\Examples\Atlases\
?????目錄???????????0??2013-05-14?20:29??wzq2\Assets\NGUI\Examples\Atlases\Fantasy\
?????文件????????3546??2013-05-06?09:57??wzq2\Assets\NGUI\Examples\Atlases\Fantasy\Fantasy?Atlas.mat
?????文件????????7597??2013-05-06?09:57??wzq2\Assets\NGUI\Examples\Atlases\Fantasy\Fantasy?Atlas.prefab
?????文件?????1192501??2013-05-06?09:57??wzq2\Assets\NGUI\Examples\Atlases\Fantasy\Fantasy?Atlas.psd
?????文件???????16006??2013-05-06?09:57??wzq2\Assets\NGUI\Examples\Atlases\Fantasy\Fantasy?Font?-?Normal.prefab
?????文件???????21846??2013-05-06?09:57??wzq2\Assets\NGUI\Examples\Atlases\Fantasy\Fantasy?Font?-?Normal.txt
?????目錄???????????0??2013-05-14?20:29??wzq2\Assets\NGUI\Examples\Atlases\Refractive\
?????文件?????1654198??2013-05-06?09:57??wzq2\Assets\NGUI\Examples\Atlases\Refractive\Refractive?Atlas?-?Bump.psd
?????文件???????98430??2013-05-06?09:57??wzq2\Assets\NGUI\Examples\Atlases\Refractive\Refractive?Atlas?-?Masks.psd
?????文件????????4117??2013-05-06?09:57??wzq2\Assets\NGUI\Examples\Atlases\Refractive\Refractive?Atlas.mat
?????文件????????7696??2013-05-06?09:57??wzq2\Assets\NGUI\Examples\Atlases\Refractive\Refractive?Atlas.prefab
............此處省略846個文件信息
評論
共有 條評論