本文整理汇总了C#中UnityEditor.SceneView.LookAt方法的典型用法代码示例。如果您正苦于以下问题:C# SceneView.LookAt方法的具体用法?C# SceneView.LookAt怎么用?C# SceneView.LookAt使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UnityEditor.SceneView
的用法示例。
在下文中一共展示了SceneView.LookAt方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: UpdateSetCam
private void UpdateSetCam(SceneView scene)
{
if (SetCam)
{
if (EditorApplication.isPlaying && !EditorApplication.isPaused)
{
var t = Camera.main.transform;
scene.LookAt(t.position, t.rotation, 3);
//Camera.main.GetComponent<GUILayer>().enabled = true;
}
else
{
var t = Camera.main.transform;
t.position = scene.camera.transform.position;
t.rotation = scene.camera.transform.rotation;
//Camera.main.GetComponent<GUILayer>().enabled = false;
}
}
}
示例2: DrawSceneGUI
private void DrawSceneGUI(SceneView view)
{
isMouseOverGoID = -1;
isMouseOverCompID = -1;
Rect isMouseOverRect = default(Rect);
if (currentFrameData != null && currentFrameData.particleSystems != null) {
//--------------- GUI --------------------
foreach (SGenericParticleSystem system in currentFrameData.particleSystems) {
if (system == null || !system.emit || !system.enabled || system.particles == null || system.particles.positions == null || !representors.ContainsKey(system.instanceID))
continue;
Bounds bounds = new Bounds(system.position, Vector3.zero);
if (system.particles.positions.Length > 0)
bounds = GetBoundsFromParticlePositions(system.instanceID, system.particles);
if (Vector3.Dot(view.camera.transform.forward, bounds.center - view.camera.transform.position) > 0) {
Rect bbRect = SceneVisualsHelper.GetRectFromBounds(bounds);
if (isMouseOverCompID != -1 && isMouseOverRect.Contains(bbRect.center))
continue;
Rect iconRect = VisualResources.DrawIcon(EditorIcon.playbackToggles, 1, bbRect.center, 1f, true);
if (iconRect.Contains(Event.current.mousePosition)) {
isMouseOverCompID = system.instanceID;
isMouseOverGoID = system.goInstanceID;
//--------------- Arrow & BB Rect --------------------
SceneVisualsHelper.DrawBBArrow(bbRect);
//SceneVisualsHelper.DrawBBRect(bbRect);
//--------------- Arrow & BB Rect --------------------
//--------------- Layout init --------------------
float width = 200f;
float infoHeight = 70f;
float left = bbRect.xMax + 16;
float top = bbRect.y + (bbRect.height / 2f) - (infoHeight / 2f);
GUI.contentColor = Color.white;
EditorHelper.styleLabelSceneVisuals.fontSize = 12;
//--------------- Layout init --------------------
//--------------- Label --------------------
Rect labelRect = new Rect(left, top, width, 20);
VisualResources.DrawTexture(labelRect, VisualResources.proConsoleLineDark);
GUI.Label(labelRect, !string.IsNullOrEmpty(system.name) ? system.name : "N/A", EditorHelper.styleLabelSceneVisuals);
//--------------- Label --------------------
//--------------- Particle Info --------------------
GUI.contentColor = Color.black;
EditorHelper.styleLabelSceneVisuals.fontSize = 9;
Rect contentRect = new Rect(left, top + 20, width, infoHeight - 20);
isMouseOverRect = contentRect;
VisualResources.DrawTexture(contentRect, VisualResources.gray);
string infoLabel =
(system.isLegacy ? "[LEGACY]\n" : "[SHURIKEN]\n") +
"Particle count : " + (system.particles.positions.Length / 3) + "\n" +
"Rendermode : " + system.renderer.renderMode + "\n" +
"Simulation space : " + (system.isWorldSpace ? "world" : "local") + "\n";
GUI.Label(new Rect(left, top + 15, width, infoHeight), infoLabel, EditorHelper.styleLabelSceneVisuals);
//--------------- Particle Info --------------------
//--------------- Navigation --------------------
//if (Event.current.type == EventType.MouseDown) {
if (Handles.Button(bounds.center, Quaternion.identity, 10, 10, Handles.CubeCap)) {
if (isMouseTapID == isMouseOverCompID) { //already selected
Transform camTrans = view.camera.transform;
view.LookAt(bounds.center, Quaternion.LookRotation(bounds.center - camTrans.position, Vector3.up), Mathf.Max(1, bounds.extents.magnitude * 2f));
if (vBugBaseWindow.CheckIfOpen(typeof(vBugHierarchyWindow))) {
vBugHierarchyWindow hierarchyWin = EditorWindow.GetWindow<vBugHierarchyWindow>();
if (hierarchyWin != null)
hierarchyWin.NavigateToID(isMouseOverGoID);
}
}
isMouseTapID = isMouseOverCompID;
}
//--------------- Navigation --------------------
}
}
}
//--------------- GUI --------------------
GUI.contentColor = Color.white;
}
if (isMouseOverCompID == -1)
isMouseTapID = -1;
}
示例3: ViewFromNiceAngle
private void ViewFromNiceAngle(SceneView view, bool forcePerspective)
{
Vector3 forward = view.rotation * Vector3.forward;
forward.y = 0.0f;
forward = !(forward == Vector3.zero) ? forward.normalized : Vector3.forward;
forward.y = -0.5f;
bool ortho = !forcePerspective && view.orthographic;
view.LookAt(view.pivot, Quaternion.LookRotation(forward), view.size, ortho);
this.SwitchDirNameVisible(!ortho ? 7 : 6);
}
示例4: ViewAxisDirection
private void ViewAxisDirection(SceneView view, int dir)
{
bool ortho = view.orthographic;
if (Event.current != null && (Event.current.shift || Event.current.button == 2))
ortho = true;
view.LookAt(view.pivot, SceneViewRotation.kDirectionRotations[dir], view.size, ortho);
this.SwitchDirNameVisible(dir);
}
示例5: ViewSetOrtho
private void ViewSetOrtho(SceneView view, bool ortho)
{
view.LookAt(view.pivot, view.rotation, view.size, ortho);
}
示例6: UpdateSetCam
private void UpdateSetCam(SceneView scene)
{
if (SetCam)
{
if (EditorApplication.isPlaying && !EditorApplication.isPaused && Camera.main != null)
{
var t = Camera.main.transform;
scene.LookAt(t.position, t.rotation, 3);
}
}
}
示例7: OnSceneUpdate
private void OnSceneUpdate(SceneView scene)
{
if (Event.current.isMouse) idletime = DateTime.Now;
var ago = Selection.activeGameObject;
if (SetPivot)
{
var move = oldpos - ago.transform.position;
foreach (Transform t in ago.transform)
{
t.position += move;
}
}
if (ago != null)
oldpos = ago.transform.position;
var scenecam = scene.camera;
if (SetCam)
{
if (EditorApplication.isPlaying && !EditorApplication.isPaused)
{
var t = Camera.main.transform;
scene.LookAt(t.position,t.rotation,3);
Camera.main.GetComponent<GUILayer>().enabled = true;
}
else
{
var t = Camera.main.transform;
t.position = scene.camera.transform.position;
t.rotation = scene.camera.transform.rotation;
Camera.main.GetComponent<GUILayer>().enabled = false;
}
}
var e = Event.current;
var p = e.mousePosition;
if (e.keyCode == KeyCode.G && e.type == EventType.KeyUp)
{
Ray r = HandleUtility.GUIPointToWorldRay(new Vector2(p.x, p.y));
RaycastHit h;
if (Physics.Raycast(r, out h))
scene.LookAt(h.point - 5 * r.direction, scenecam.transform.rotation, 5);
if (e.modifiers == EventModifiers.Control && Selection.activeGameObject != null)
{
Undo.RegisterSceneUndo("rtools");
var o = (GameObject)EditorUtility.InstantiatePrefab(Selection.activeGameObject);
o.transform.localPosition = Vector3.zero;
o.transform.position = h.point;
o.transform.rotation = Quaternion.AngleAxis(90, Vector3.up) * Quaternion.LookRotation(h.normal);
//* Quaternion.LookRotation(h.point - SceneView.lastActiveSceneView.camera.transform.position);
}
}
}
示例8: ViewFromNiceAngle
private void ViewFromNiceAngle(SceneView view, bool forcePerspective)
{
Vector3 vector = view.rotation * Vector3.forward;
vector.y = 0f;
if (vector == Vector3.zero)
{
vector = Vector3.forward;
}
else
{
vector = vector.normalized;
}
vector.y = -0.5f;
bool flag = !forcePerspective && view.orthographic;
view.LookAt(view.pivot, Quaternion.LookRotation(vector), view.size, flag);
this.SwitchDirNameVisible((!flag) ? 7 : 6);
}
示例9: HandleMouseUp
private static void HandleMouseUp(SceneView view, int id, int button, int clickCount)
{
if (GUIUtility.hotControl != id)
return;
SceneViewMotion.ResetDragState();
RaycastHit hit;
if (button == 2 && !SceneViewMotion.s_Dragged && SceneViewMotion.RaycastWorld(Event.current.mousePosition, out hit))
{
Vector3 vector3 = view.pivot - view.rotation * Vector3.forward * view.cameraDistance;
float newSize = view.size;
if (!view.orthographic)
newSize = view.size * Vector3.Dot(hit.point - vector3, view.rotation * Vector3.forward) / view.cameraDistance;
view.LookAt(hit.point, view.rotation, newSize);
}
Event.current.Use();
}
示例10: HandleMouseUp
private static void HandleMouseUp(SceneView view, int id, int button, int clickCount)
{
if (GUIUtility.hotControl == id)
{
RaycastHit hit;
ResetDragState();
if (((button == 2) && !s_Dragged) && RaycastWorld(Event.current.mousePosition, out hit))
{
Vector3 vector = view.pivot - ((Vector3) ((view.rotation * Vector3.forward) * view.cameraDistance));
float size = view.size;
if (!view.orthographic)
{
size = (view.size * Vector3.Dot(hit.point - vector, (Vector3) (view.rotation * Vector3.forward))) / view.cameraDistance;
}
view.LookAt(hit.point, view.rotation, size);
}
Event.current.Use();
}
}
示例11: ViewFromNiceAngle
private void ViewFromNiceAngle(SceneView view, bool forcePerspective)
{
Vector3 forward = (Vector3) (view.rotation * Vector3.forward);
forward.y = 0f;
if (forward == Vector3.zero)
{
forward = Vector3.forward;
}
else
{
forward = forward.normalized;
}
forward.y = -0.5f;
bool ortho = !forcePerspective ? view.orthographic : false;
view.LookAt(view.pivot, Quaternion.LookRotation(forward), view.size, ortho);
this.SwitchDirNameVisible(!ortho ? 7 : 6);
}
示例12: ToggleBetweenViewDirections
static void ToggleBetweenViewDirections(SceneView view, Quaternion primaryDirection, Quaternion alternativeDirection)
{
Vector3 direction = primaryDirection * Vector3.forward;
float dot = Vector3.Dot(view.camera.transform.forward, direction);
if (dot < 1.0f - kCompareEpsilon) { view.LookAt(view.pivot, primaryDirection, view.size, view.orthographic); }
else { view.LookAt(view.pivot, alternativeDirection, view.size, view.orthographic); }
}