Game Development Reference
In-Depth Information
To make it even more useful, we can also represent this selection in the scene view as a
control handle. To do this, we simply add another function to our CameraTargetEd-
itor CustomEditor script; add the following OnSceneGUI function to the script:
void OnSceneGUI()
{
CameraLookAt targetScript = (CameraLookAt)target;
targetScript.cameraTarget = Handles.PositionHandle(
targetScript.cameraTarget, Quaternion.identity);
if (GUI.changed)
EditorUtility.SetDirty(target);
}
Just as the OnGUI method draws in to your game, this function will draw in to the editor
scene. Using the Handles.PositionHandle control, it will draw a regular handle-
bars control in the scene at the point you have specified, in this case, the camera's look-at
target, as seen here:
Camera Target (1) and Camera Transform (2)
Want more?? You can then alter how the handlebars will look on the screen with the fol-
lowing code:
Search WWH ::




Custom Search