私は統一性を使用しています。5.4.1f1 Windows上のパーソナルコンピュータ64bitスタンドアロンモードでもエスケープキーを押してもゲームを終了できません。どうすれば解決できますか?
私が行ったすべてのステップとこれまでに試したことすべてを説明します。
Firs time元のコードで新しいC#ファイルを作成しました: これでエスケープキーを押すとエディタに戻りますが、ゲームを終了しません! [InitializeOnLoad]を使用すると、エディタの再生ボタンを停止してゲームを終了することはできません。ゲームを終了するには、スタンドアロンモードでBuild And Runを実行するだけで済みます。その後、Application.Quit()を実行することができます。私は何か他のものを試したかったよう
using UnityEditor;
using UnityEngine;
using System.Collections;
[InitializeOnLoad]
public class FullscreenPlayMode : MonoBehaviour {
//The size of the toolbar above the game view, excluding the OS border.
private static int tabHeight = 22;
static FullscreenPlayMode()
{
EditorApplication.playmodeStateChanged -= CheckPlayModeState;
EditorApplication.playmodeStateChanged += CheckPlayModeState;
EditorApplication.update += Update;
}
static void CheckPlayModeState()
{
if (EditorApplication.isPlaying)
{
FullScreenGameWindow();
}
else
{
CloseGameWindow();
}
}
static EditorWindow GetMainGameView(){
EditorApplication.ExecuteMenuItem("Window/Game");
System.Type T = System.Type.GetType("UnityEditor.GameView,UnityEditor");
System.Reflection.MethodInfo GetMainGameView = T.GetMethod("GetMainGameView",System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Static);
System.Object Res = GetMainGameView.Invoke(null,null);
return (EditorWindow)Res;
}
static void FullScreenGameWindow(){
EditorWindow gameView = GetMainGameView();
Rect newPos = new Rect(0, 0 - tabHeight, Screen.currentResolution.width, Screen.currentResolution.height + tabHeight);
gameView.position = newPos;
gameView.minSize = new Vector2(Screen.currentResolution.width, Screen.currentResolution.height + tabHeight);
gameView.maxSize = gameView.minSize;
gameView.position = newPos;
}
static void CloseGameWindow(){
EditorWindow gameView = GetMainGameView();
gameView.Close();
}
static void Update()
{
if (Input.GetKey (KeyCode.Escape))
{
CloseGameWindow();
}
}
}
その後このため、機能していません。 私は[InitializeOnLoad]行を削除しましたが、スクリプトの残りの部分は変更しませんでした。
今回は、[InitializeOnLoad]行を削除した後、スクリプトをThirdPersonControllerにドラッグしました。
私が前にエディタを作って、エスケープキーを押してゲームを開始すると、エディタに戻りますが、ゲームを終了しません!
しかし、今、私は&実行を構築する>メニューファイルで行った場合、私はなります2つのエラー:
最初のエラーは次のとおりです。
資産/ MyScripts/FullScreenPlayMode.cs(1 、7):エラーCS0246:型または名前空間の名前 `UnityEditor 'が見つかりませんでした。 usingディレクティブまたはアセンブリ参照がありませんか?
2番目のエラー:
場合:プレーヤーを構築
エラーにスクリプトは、だから私は、このリンクで解決すると仮定何この溶液に行ってきましたコンパイルエラーに
を持っていたので、私はファイルのスクリプトをEDITORディレクトリに移動してから、スクリプトをThirdPersonControllerにドラッグすることができません。スクリプトがエディタスクリプトであると言うメッセージを投げます。
#if UNITY_EDITOR
// Editor specific code here
#endif
ので、私がトップで、スクリプトでそれをやった:私は、リンク内の第二の溶液しようとした場合
#if UNITY_EDITOR
using UnityEditor;
#endif
、スクリプト・ファイルは、エディタのディレクトリにありません! 私は新しい別のエラーになっています&実行ビルドを行い、この時間:
資産/ MyScripts/FullScreenPlayMode.cs(34,16):エラーCS0246を:型または名前空間名 'EditorWindowを」が見つかりませんでした。 。 usingディレクティブまたはアセンブリ参照がありませんか?
EditorWindowでこのエラーが見つかりませんでした。このエラーは、#ifと#endifを使用したときに発生します。
これまでに試したすべての点で、別の問題が発生しました。