Hi there.
I’ve got the problem.
Screen.width and Screen.height both return wrong values in my custom editor.
Here is my very simplified code:
File Editor/ScrSizeEditor.cs
using UnityEngine;
using System.Collections;
using UnityEditor;
[CustomEditor(typeof(ScrSize))]
public class ScrSizeEditor : Editor
{
public override void OnInspectorGUI()
{
Debug.Log(string.Format("Screen size at edit-time: {0}x{1}", Screen.width, Screen.height));
}
}
File ScrSize.cs
using UnityEngine;
using System.Collections;
[ExecuteInEditMode]
public class ScrSize : MonoBehaviour
{
void Update()
{
Debug.Log(string.Format("Screen size at runtime : {0}x{1}", Screen.width, Screen.height));
}
}
The output is:
Screen size at runtime : 1024x768
and
Screen size at edit-time: 464x947
Why this happened?
What have I missed?
Either there is a bug?
I’m using Unity 4.6.1p2 on PC with windows 8.1.
Thanks.