[Engine.Engine] EditorEngine=MyEditor.MyEditorEngineEditorEngine類別提供許多虛擬函式可供覆載,以下列出重要的函式:
- Init():引擎初始化。
- PreExit():關閉引擎前會呼叫這個函式。
- Tick( DeltaSeconds ):更新遊戲時會呼叫這個函式。
- Exec( Command, OutputDevice=GLog ):執行控制台指令。
- PlayInEditor():在編輯器中啓動試玩功能時會呼叫這個函式。
- EndPlayMap() :在編輯器中關閉試玩功能時會呼叫這個函式。
範例
以下程式碼示範如何增加一個讓UEd開啟指定資源的命令。使用者只需要知道資源路徑,不需要在內容瀏覽器裡點開才能編輯資源。
class MyEdEngine extends UnrealEdEngine native; cpptext { // FExec interface virtual UBOOL Exec(const TCHAR* Cmd, FOutputDevice& Ar = *GLog); }實作碼:
UBOOL UMyEdEngine::Exec(const TCHAR* Cmd, FOutputDevice& Ar); { if( Super::Exec(Cmd, Ar) ) { return TRUE; } const TCHAR* Command = Cmd; if( ParseCommand(&Command, TEXT("OpenObjectEditor")) ) { UObject* LoadedObject = UObject::StaticLoadObject( UObject::StaticClass(), NULL, Command, NULL, LOAD_None, NULL); if( LoadedObject && OpenObjectEditor(LoadedObject) ) { return TRUE; } } return FALSE; } UBOOL OpenObjectEditor(UObject* Object) { // Show a busy cursor meanwhile. const FScopedBusyCursor BusyCursor; UGenericBrowserType* BrowserType = ConstructObject<UGenericBrowserType>( UGenericBrowserType_All::StaticClass() ); BrowserType->Init(); return BrowserType->ShowObjectEditor( Object ); }
沒有留言:
張貼留言