I have now unity 5.4.1f1 personal
when running the game pressing play in editor not errors everything is fine.
When trying to make Build And Run standalone for pc i’m getting errors:
Error building Player because scripts had compiler errors
And
Assets/MyScripts/FullScreenPlayMode.cs(1,7): error CS0246: The type or namespace name `UnityEditor’ could not be found. Are you missing a using directive or an assembly reference?
And this is my script and i don’t see any errors built it again i can play the game through the editor this errors come up only when making Build And Run:
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 int tabHeight = 22;
void Start()
{
FullscreenPlayMode ();
}
void FullscreenPlayMode()
{
EditorApplication.playmodeStateChanged -= CheckPlayModeState;
EditorApplication.playmodeStateChanged += CheckPlayModeState;
}
void CheckPlayModeState()
{
if (EditorApplication.isPlaying)
{
FullScreenGameWindow();
}
else
{
CloseGameWindow();
}
}
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;
}
void FullScreenGameWindow(){
EditorWindow gameView = GetMainGameView();
gameView.titleContent.text = "Game (Stereo)";
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;
}
void CloseGameWindow(){
EditorWindow gameView = GetMainGameView();
gameView.Close();
}
void Update()
{
if(Input.GetKey("escape")) {//When a key is pressed down it see if it was the escape key if it was it will execute the code
//CloseGameWindow(); // Quits the game
Application.Quit();
}
}
}