本文整理汇总了C#中UnityEditor.SceneView.LookAtDirect方法的典型用法代码示例。如果您正苦于以下问题:C# SceneView.LookAtDirect方法的具体用法?C# SceneView.LookAtDirect怎么用?C# SceneView.LookAtDirect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UnityEditor.SceneView
的用法示例。
在下文中一共展示了SceneView.LookAtDirect方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ArrowKeys
public static void ArrowKeys(SceneView sv)
{
Event current = Event.current;
int controlId = GUIUtility.GetControlID(FocusType.Passive);
if (GUIUtility.hotControl != 0 && GUIUtility.hotControl != controlId || EditorGUI.actionKey)
return;
switch (current.GetTypeForControl(controlId))
{
case EventType.KeyDown:
switch (current.keyCode)
{
case KeyCode.UpArrow:
sv.viewIsLockedToObject = false;
if (sv.m_Ortho.value)
SceneViewMotion.s_Motion.y = 1f;
else
SceneViewMotion.s_Motion.z = 1f;
GUIUtility.hotControl = controlId;
current.Use();
return;
case KeyCode.DownArrow:
sv.viewIsLockedToObject = false;
if (sv.m_Ortho.value)
SceneViewMotion.s_Motion.y = -1f;
else
SceneViewMotion.s_Motion.z = -1f;
GUIUtility.hotControl = controlId;
current.Use();
return;
case KeyCode.RightArrow:
sv.viewIsLockedToObject = false;
SceneViewMotion.s_Motion.x = 1f;
GUIUtility.hotControl = controlId;
current.Use();
return;
case KeyCode.LeftArrow:
sv.viewIsLockedToObject = false;
SceneViewMotion.s_Motion.x = -1f;
GUIUtility.hotControl = controlId;
current.Use();
return;
default:
return;
}
case EventType.KeyUp:
if (GUIUtility.hotControl != controlId)
break;
switch (current.keyCode)
{
case KeyCode.UpArrow:
case KeyCode.DownArrow:
SceneViewMotion.s_Motion.z = 0.0f;
SceneViewMotion.s_Motion.y = 0.0f;
current.Use();
return;
case KeyCode.RightArrow:
case KeyCode.LeftArrow:
SceneViewMotion.s_Motion.x = 0.0f;
current.Use();
return;
default:
return;
}
case EventType.Layout:
if (GUIUtility.hotControl != controlId)
break;
Vector3 forward;
if (!sv.m_Ortho.value)
{
forward = Camera.current.transform.forward + Camera.current.transform.up * 0.3f;
forward.y = 0.0f;
forward.Normalize();
}
else
forward = Camera.current.transform.forward;
Vector3 movementDirection = SceneViewMotion.GetMovementDirection();
sv.LookAtDirect(sv.pivot + Quaternion.LookRotation(forward) * movementDirection, sv.rotation);
if ((double) SceneViewMotion.s_Motion.sqrMagnitude == 0.0)
{
sv.pivot = sv.pivot;
SceneViewMotion.s_FlySpeed = 0.0f;
GUIUtility.hotControl = 0;
break;
}
sv.Repaint();
break;
}
}
示例2: ArrowKeys
public static void ArrowKeys(SceneView sv)
{
Event current = Event.current;
int controlID = GUIUtility.GetControlID(FocusType.Passive);
if (((GUIUtility.hotControl == 0) || (GUIUtility.hotControl == controlID)) && !EditorGUI.actionKey)
{
EventType typeForControl = current.GetTypeForControl(controlID);
if (typeForControl == EventType.KeyDown)
{
switch (current.keyCode)
{
case KeyCode.UpArrow:
sv.viewIsLockedToObject = false;
if (!sv.m_Ortho.value)
{
s_Motion.z = 1f;
}
else
{
s_Motion.y = 1f;
}
GUIUtility.hotControl = controlID;
current.Use();
return;
case KeyCode.DownArrow:
sv.viewIsLockedToObject = false;
if (!sv.m_Ortho.value)
{
s_Motion.z = -1f;
}
else
{
s_Motion.y = -1f;
}
GUIUtility.hotControl = controlID;
current.Use();
return;
case KeyCode.RightArrow:
sv.viewIsLockedToObject = false;
s_Motion.x = 1f;
GUIUtility.hotControl = controlID;
current.Use();
break;
case KeyCode.LeftArrow:
sv.viewIsLockedToObject = false;
s_Motion.x = -1f;
GUIUtility.hotControl = controlID;
current.Use();
break;
}
}
else if (typeForControl == EventType.KeyUp)
{
if (GUIUtility.hotControl == controlID)
{
switch (current.keyCode)
{
case KeyCode.UpArrow:
case KeyCode.DownArrow:
s_Motion.z = 0f;
s_Motion.y = 0f;
current.Use();
break;
case KeyCode.RightArrow:
case KeyCode.LeftArrow:
s_Motion.x = 0f;
current.Use();
break;
}
}
}
else if ((typeForControl == EventType.Layout) && (GUIUtility.hotControl == controlID))
{
Vector3 forward;
if (!sv.m_Ortho.value)
{
forward = Camera.current.transform.forward + ((Vector3) (Camera.current.transform.up * 0.3f));
forward.y = 0f;
forward.Normalize();
}
else
{
forward = Camera.current.transform.forward;
}
Vector3 movementDirection = GetMovementDirection();
sv.LookAtDirect(sv.pivot + (Quaternion.LookRotation(forward) * movementDirection), sv.rotation);
if (s_Motion.sqrMagnitude == 0f)
{
sv.pivot = sv.pivot;
s_FlySpeed = 0f;
GUIUtility.hotControl = 0;
}
else
{
sv.Repaint();
}
//.........这里部分代码省略.........
示例3: OnSceneGUI
public void OnSceneGUI(SceneView scene)
{
if(fixView)
scene.LookAtDirect(scene.pivot, fixedRotation);
HandleUtility.AddDefaultControl(GUIUtility.GetControlID(FocusType.Passive));
if(Event.current.isMouse){
if(Event.current.button == 0){
if(Event.current.type == EventType.MouseDown) startCreatingCells();
else if(Event.current.type == EventType.MouseUp) endCreatingCells();
else createCell();
}
else if(Event.current.button == 1){
if(Event.current.type == EventType.MouseDown) startMovingGrid();
else if(Event.current.type == EventType.MouseUp) endMovingGrid();
else moveGrid();
}
scene.Repaint();
}
Vector3 centerGridPoint = map.getMousePositionOverMap(HandleUtility.GUIPointToWorldRay(Event.current.mousePosition), Mathf.RoundToInt(gridHeight*2f)/2f);
map.ghostCell(centerGridPoint, 0.5f);
Vector3[] puntos = new Vector3[4];
puntos[0] = new Vector3(centerGridPoint.x - cellSize/2.0f,centerGridPoint.y,centerGridPoint.z - cellSize/2.0f);
puntos[1] = new Vector3(centerGridPoint.x - cellSize/2.0f,centerGridPoint.y,centerGridPoint.z + cellSize/2.0f);
puntos[2] = new Vector3(centerGridPoint.x + cellSize/2.0f,centerGridPoint.y,centerGridPoint.z + cellSize/2.0f);
puntos[3] = new Vector3(centerGridPoint.x + cellSize/2.0f,centerGridPoint.y,centerGridPoint.z - cellSize/2.0f);
Handles.DrawSolidRectangleWithOutline(puntos, Color.yellow, Color.white);
}
示例4: OnSceneGUI
public void OnSceneGUI()
{
current = Event.current;
if (!current.isKey || current.type != EventType.keyDown)
return;
sceneView = UnityEditor.SceneView.lastActiveSceneView;
eulerAngles = sceneView.camera.transform.rotation.eulerAngles;
rotHelper = sceneView.camera.transform.rotation;
switch (current.keyCode)
{
case KeyCode.Keypad1:
if (current.control == false)
sceneView.LookAtDirect(SceneView.lastActiveSceneView.pivot, Quaternion.Euler(new Vector3(0f, 360f, 0f)));
else
sceneView.LookAtDirect(SceneView.lastActiveSceneView.pivot, Quaternion.Euler(new Vector3(0f, 180f, 0f)));
break;
case KeyCode.Keypad2:
sceneView.LookAtDirect(SceneView.lastActiveSceneView.pivot, rotHelper * Quaternion.Euler(new Vector3(-15f, 0f, 0f)));
break;
case KeyCode.Keypad3:
if (current.control == false)
sceneView.LookAtDirect(SceneView.lastActiveSceneView.pivot, Quaternion.Euler(new Vector3(0f, 270f, 0f)));
else
sceneView.LookAtDirect(SceneView.lastActiveSceneView.pivot, Quaternion.Euler(new Vector3(0f, 90f, 0f)));
break;
case KeyCode.Keypad4:
sceneView.LookAtDirect(SceneView.lastActiveSceneView.pivot, Quaternion.Euler(new Vector3(eulerAngles.x, eulerAngles.y + 15f, eulerAngles.z)));
break;
case KeyCode.Keypad5:
sceneView.orthographic = !sceneView.orthographic;
break;
case KeyCode.Keypad6:
sceneView.LookAtDirect(SceneView.lastActiveSceneView.pivot, Quaternion.Euler(new Vector3(eulerAngles.x, eulerAngles.y - 15f, eulerAngles.z)));
break;
case KeyCode.Keypad7:
if (current.control == false)
sceneView.LookAtDirect(SceneView.lastActiveSceneView.pivot, Quaternion.Euler(new Vector3(90f, 0f, 0f)));
else
sceneView.LookAtDirect(SceneView.lastActiveSceneView.pivot, Quaternion.Euler(new Vector3(270f, 0f, 0f)));
break;
case KeyCode.Keypad8:
sceneView.LookAtDirect(SceneView.lastActiveSceneView.pivot, rotHelper * Quaternion.Euler(new Vector3(15f, 0f, 0f)));
break;
case KeyCode.KeypadPeriod:
if (Selection.transforms.Length == 1)
sceneView.LookAtDirect(Selection.activeTransform.position, sceneView.camera.transform.rotation);
else if (Selection.transforms.Length > 1)
{
Vector3 tempVec = new Vector3();
for (int i = 0; i < Selection.transforms.Length; i++)
{
tempVec += Selection.transforms[i].position;
}
sceneView.LookAtDirect((tempVec / Selection.transforms.Length), sceneView.camera.transform.rotation);
}
break;
case KeyCode.KeypadMinus:
SceneView.RepaintAll();
sceneView.size *= 1.1f;
break;
case KeyCode.KeypadPlus:
SceneView.RepaintAll();
sceneView.size /= 1.1f;
break;
}
}
示例5: OnSceneGUI
public void OnSceneGUI(SceneView scene)
{
if(setPerspective){
/* Selection.transforms */
setPerspective = false;
float angle = 30;
Texture baseTile = IsoSettingsManager.getInstance().getIsoSettings().defautTextureScale;
if(baseTile != null){
float angulo = Mathf.Rad2Deg * Mathf.Acos(baseTile.height / (baseTile.width*1f));
angle = 90f - angulo;
}
scene.LookAtDirect(scene.pivot,Quaternion.Euler(angle, 45, 0));
scene.orthographic = true;
if(fixView)
fixedRotation = Quaternion.Euler(angle, 45, 0);
scene.Repaint();
}
if(fixView)
scene.LookAtDirect(scene.pivot,fixedRotation);
HandleUtility.AddDefaultControl(GUIUtility.GetControlID(FocusType.Passive));
if(Event.current.isMouse){
if(Event.current.button == 0){
if(Event.current.type == EventType.MouseDown) startCreatingCells();
else if(Event.current.type == EventType.MouseUp) endCreatingCells();
else createCell();
}
else if(Event.current.button == 1){
if(Event.current.type == EventType.MouseDown) startMovingGrid();
else if(Event.current.type == EventType.MouseUp) endMovingGrid();
else moveGrid();
}
scene.Repaint();
}
Vector3 centerGridPoint = map.getMousePositionOverMap(HandleUtility.GUIPointToWorldRay(Event.current.mousePosition), Mathf.RoundToInt(gridHeight*2f)/2f);
map.ghostCell(centerGridPoint, 0.5f);
Vector3[] puntos = new Vector3[4];
puntos[0] = new Vector3(centerGridPoint.x - cellSize/2.0f,centerGridPoint.y,centerGridPoint.z - cellSize/2.0f);
puntos[1] = new Vector3(centerGridPoint.x - cellSize/2.0f,centerGridPoint.y,centerGridPoint.z + cellSize/2.0f);
puntos[2] = new Vector3(centerGridPoint.x + cellSize/2.0f,centerGridPoint.y,centerGridPoint.z + cellSize/2.0f);
puntos[3] = new Vector3(centerGridPoint.x + cellSize/2.0f,centerGridPoint.y,centerGridPoint.z - cellSize/2.0f);
Handles.DrawSolidRectangleWithOutline(puntos, Color.yellow, Color.white);
}