LevelScript.js
#pragma strict
var experience : int;
function Level() : int
{
return experience / 750;
}
LevelScriptEditor.js
#pragma strict
@CustomEditor (LevelScript)
class LevelScriptEditor extends Editor
{
function OnInspectorGUI()
{
var myLevelScript : LevelScript = target;
myLevelScript.experience = EditorGUILayout.IntField("Experience", myLevelScript.experience);
EditorGUILayout.LabelField("Level", myLevelScript.Level().ToString());
}
}
(视频用的是c#
,不过我比较熟悉javscript
,就用了javascript
的格式)
虽然最后程序成功了,但是unity报了警告有点在意。有人知道是什么意思么?
Assets/Editor/LevelScriptEditor.js(8,42): BCW0028: WARNING: Implicit downcast from 'UnityEngine.Object' to 'LevelScript'.