Unity3D报警告"Implicit downcast"?

在做unity的入门练习

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'.

阅读 2.2k
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题