Game Development Reference
In-Depth Information
38 System.Reflection.MethodInfo GetSizeOfMainGameView =
T.GetMethod("GetSizeOfMainGameView",System.Reflection.
BindingFlags.NonPublic | System.Reflection.BindingFlags.
Static);
39 return (Vector2)GetSizeOfMainGameView.Invoke(null,null);
40 }
41 //-------------------------------------------------------
42 }
43 //-------------------------------------------------------
The following are the comments in code sample 5-1:
Lines 27-31 : The Gizmos.DrawFrustum function accepts arguments such
as position and rotation in world space and not local space. This means
all positional arguments must first be transformed using a matrix from
local space to world space. This is achieved with the localToWorldMatrix
member of the Transform class. Additionally, the aspect argument requires
further calculation between the actual viewport height and width, and the
size of the game window in width and height.
Lines 35-40 : The GetGameViewSize function returns a 2D vector that express
the actual pixel dimensions of the Game tab view. It retrieves these values
using undocumented editor features. The "undocumented" nature of the
function call should be emphasized; this means that the code can easily be
broken or invalidated by future and even minor releases.
The following screenshot shows the frustum:
Frustum is shown even when the camera is deselected
 
Search WWH ::




Custom Search