本文整理汇总了C#中SceneView.Repaint方法的典型用法代码示例。如果您正苦于以下问题:C# SceneView.Repaint方法的具体用法?C# SceneView.Repaint怎么用?C# SceneView.Repaint使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SceneView
的用法示例。
在下文中一共展示了SceneView.Repaint方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnSceneGUIDelegate
private static void OnSceneGUIDelegate(SceneView sceneView)
{
switch (Event.current.type)
{
case EventType.DragUpdated:
case EventType.DragPerform:
case EventType.DragExited:
sceneView.Repaint();
break;
}
if (Event.current.type == EventType.repaint)
{
var drawnInstanceIDs = new HashSet<int>();
Color handleColor = Handles.color;
Handles.color = DragColor;
foreach (var objectReference in DragAndDrop.objectReferences)
{
var gameObject = objectReference as GameObject;
if (gameObject && gameObject.activeInHierarchy)
{
DrawObjectBounds(gameObject);
drawnInstanceIDs.Add(gameObject.GetInstanceID());
}
}
Handles.color = HoverColor;
if (_hoveredInstance != 0 && !drawnInstanceIDs.Contains(_hoveredInstance))
{
GameObject sceneGameObject = EditorUtility.InstanceIDToObject(_hoveredInstance) as GameObject;
if (sceneGameObject)
{
DrawObjectBounds(sceneGameObject);
}
}
Handles.color = handleColor;
}
}
示例2: OnSceneGUI
public void OnSceneGUI(SceneView sceneView)
{
if (spriteRenderer == null) return;
Event e = Event.current;
if (e.type == EventType.ValidateCommand && e.commandName == "UndoRedoPerformed") {
UpdateMesh();
sceneView.Repaint();
}
if (points.Length == 0) return;
bool closed = true;
if (points.Length < 3) {
closed = false;
}
Handles.matrix = spriteRenderer.transform.localToWorldMatrix;
Handles.color = polyColor;
// Handles.DrawPolyLine(mesh.vertices);
if (mesh != null) {
int triCount = mesh.triangles.Length / 3;
for (int i = 0; i < triCount; i++) {
Vector3 p1 = mesh.vertices[mesh.triangles[i * 3]];
Vector3 p2 = mesh.vertices[mesh.triangles[(i * 3) + 1]];
Vector3 p3 = mesh.vertices[mesh.triangles[(i * 3) + 2]];
Handles.DrawLine(p1, p2);
Handles.DrawLine(p2, p3);
Handles.DrawLine(p3, p1);
}
}
else {
if (points.Length > 1 && !closed) {
Handles.DrawLine(points[0], points[1]);
}
}
EditorGUI.BeginChangeCheck();
if (e.alt) {
RemovePoint();
}
else {
if (e.shift) {
AddMidPoint();
}
else if (e.control) {
AddPoint(e);
}
if (points.Length > 0) {
for (int i = 0; i < points.Length; i++) {
Vector3 point = new Vector3(points[i].x, points[i].y, 0);
Handles.color = handleColor;
GUI.SetNextControlName("polygon point " + i);
if (i == 0) Handles.color = handleColorFirst;
if (i == (points.Length - 1)) Handles.color = handleColorLast;
float size = GetHandleSize(point, 1);
point = Handles.FreeMoveHandle(
point,
Quaternion.identity,
size,
Vector3.zero,
Handles.CircleCap
);
points[i] = point;
}
}
}
if (EditorGUI.EndChangeCheck()) {
Undo.RecordObject(spriteRenderer, "moved polygon point");
// UpdateMesh();
if (mesh != null) {
Vector3[] vertices = new Vector3[mesh.vertices.Length];
System.Array.Copy(mesh.vertices, vertices, mesh.vertices.Length);
if (points.Length > 0 && vertices.Length > 0 && points.Length == vertices.Length) {
for (int i = 0; i < points.Length; i++) {
Vector3 point = new Vector3(points[i].x, points[i].y, 0);
vertices[i] = point;
}
}
mesh.vertices = vertices;
mesh.RecalculateBounds();
mesh.RecalculateNormals();
}
sceneView.Repaint();
EditorUtility.SetDirty(this);
}
}
示例3: OnSceneGUI
public void OnSceneGUI(SceneView sceneView) {
if (skin != null && isPainting) {
HandleUtility.AddDefaultControl(GUIUtility.GetControlID(FocusType.Passive));
Mesh m = skin.sharedMesh.Clone();
m.colors = CalculateVertexColors(skin.bones, m, skin.bones[bone].GetComponent<Bone>());
List<BoneWeight> weights = m.boneWeights.ToList();
Event current = Event.current;
Graphics.DrawMeshNow(m, skin.transform.position, skin.transform.rotation);
Bone bn = skin.bones[bone].GetComponent<Bone>();
foreach (Bone b in skin.GetComponentsInChildren<Bone>()) {
if (bn == b)
Handles.color = Color.yellow;
else
Handles.color = Color.gray;
Handles.DrawLine(b.transform.position, b.Head);
}
Handles.color = Color.red;
Vector3 mpos = HandleUtility.GUIPointToWorldRay(current.mousePosition).origin;
mpos = new Vector3(mpos.x, mpos.y);
Handles.DrawWireDisc(mpos, Vector3.forward, brushSize);
if (isPainting) {
if (current.type == EventType.scrollWheel && current.modifiers == EventModifiers.Control) {
brushSize = Mathf.Clamp(brushSize + (float)System.Math.Round(current.delta.y / 30, 2), 0, float.MaxValue);
Repaint();
current.Use();
} else if (current.type == EventType.mouseDown && current.button == 0) {
isDrawing = true;
} else if (current.type == EventType.mouseUp && current.button == 0) {
isDrawing = false;
} else if (current.type == EventType.mouseDrag && isDrawing && current.button == 0) {
float w = weight * ((mode == PaintingMode.Subtract) ? -1 : 1);
for (int i = 0; i < m.vertices.Length; i++) {
Vector3 v = m.vertices[i];
float d = (v - skin.gameObject.transform.InverseTransformPoint(mpos)).magnitude;
if (d <= brushSize) {
BoneWeight bw = weights[i];
float vw = bw.GetWeight(bn.index);
vw = Mathf.Clamp(vw + (1 - d / brushSize) * w, 0, 1);
bw = bw.SetWeight(bn.index, vw);
weights[i] = bw.Clone();
}
}
skin.sharedMesh.boneWeights = weights.ToArray();
EditorUtility.SetDirty(skin.gameObject);
if (PrefabUtility.GetPrefabType(skin.gameObject) != PrefabType.None) {
AssetDatabase.SaveAssets();
}
}
}
sceneView.Repaint();
}
}
示例4: OnUpdate
void OnUpdate(SceneView sceneView)
{
Vector2 screenpos = Event.current.mousePosition;
screenpos.y = sceneView.camera.pixelHeight - screenpos.y;
MousePos = sceneView.camera.ScreenPointToRay(screenpos).origin;
bool withinGrid = MousePos.isWithinGrid();
if (withinGrid)
{
if (Event.current.type == EventType.MouseDown && Event.current.button == 2)
{
Active = !Active;
Event.current.Use(); //keeping this line causes one bug, removing it causes another.
}
}
if (Active)
{
UpdateIndicator(withinGrid);
}
if(Active && withinGrid)
{
if (Event.current.type == EventType.layout)
HandleUtility.AddDefaultControl(GUIUtility.GetControlID(GetHashCode(), FocusType.Passive));
Selection.activeObject = null;
RightClick = isRightPressed(RightClick);
LeftClick = isLeftPressed(LeftClick);
Vector2 ScrollVect = getScroll();
int scroll = Math.Sign(ScrollVect.y);
if (scroll != 0)
{
int nextPiece = (int)selectedIndex + scroll;
if (nextPiece >= 0 && nextPiece < PieceTypeList.Count)
{
selectedIndex = nextPiece;
SetIndicator();
}
}
if (selectedPiece == typeof(Wall))
{
Side side;
Orientation or;
Vector2 target = Utils.WorldToWallPos(MousePos, out side, out or);
if (Indicator)
{
Indicator.transform.position = target;
Wall wall = Indicator.GetComponent<Wall>();
wall.orientation = or;
}
if (LeftDown())
{
SpawnWall(target, or, side);
sceneView.Update();
sceneView.Repaint();
}
else if (RightDown())
{
RoomManager.roomManager.RemoveWall(MousePos);
sceneView.Update();
sceneView.Repaint();
}
}
else if (selectedPiece == typeof(Player))
{
Cell target = Cell.GetFromWorldPos(MousePos);
if (target != null)
{
Indicator.transform.position = target.WorldPos();
if (LeftDown())
{
//SpawnPiece(selectedPiece, target);
SpawnPlayer(target);
sceneView.Update();
sceneView.Repaint();
}
else if (RightDown())
{
RoomManager.roomManager.RemoveTopPiece(target);
sceneView.Update();
sceneView.Repaint();
}
}
}
else if (selectedIndex != 0)//spawn any other piece (other than wall)
{
Cell target = Cell.GetFromWorldPos(MousePos);
if (target!=null) {
if (Indicator != null) Indicator.transform.position = target.WorldPos();
if (LeftDown())
{
SpawnPiece(selectedPiece, target);
sceneView.Update();
sceneView.Repaint();
}
else if (RightDown())
{
RoomManager.roomManager.RemoveTopPiece(target);
sceneView.Update();
sceneView.Repaint();
//.........这里部分代码省略.........
示例5: OnSceneGUI2
void OnSceneGUI2(SceneView sceneView)
{
if(Event.current.button == 0 )
if(Event.current.rawType == EventType.used){
for(int i = 0; i<cell.Length; i++){
if(cell[i].Map != null)
cell[i].Map.updateCell(cell[i], Event.current.type == EventType.MouseUp);
}
sceneView.Repaint();
}
}
示例6: OnSceneGUI
//.........这里部分代码省略.........
}
HandleUtility.AddDefaultControl(GUIUtility.GetControlID(FocusType.Passive));
Event curEvent = Event.current;
if(altDown == false)
{
switch(curEvent.type)
{
case EventType.mouseUp:
if(curEvent.button == 0)
{
if(brushMode == BrushMode.On)
{
if(painting == true)
{
EndStroke();
}
if(placing == true)
{
EndPlaceStroke();
}
}
}
break;
case EventType.mouseDown:
if(curEvent.button == 0)
{
if(brushMode == BrushMode.On)
{
if(!shiftDown)
{
BeginStroke();
if(paintable)
{
Paint(mouseRayHit);
Event.current.Use();
}
UnityEditor.Tools.current = UnityEditor.Tool.None;
}
else //shiftDown
{
if(paintable)
{
BeginPlaceStroke();
Event.current.Use();
}
UnityEditor.Tools.current = UnityEditor.Tool.None;
}
}
}
break;
case EventType.mouseDrag:
if(curEvent.button == 0)
{
if(brushMode == BrushMode.On)
{
if(placing == true)
{
//if(paintable)
//{
UpdatePlace(sceneView);
Event.current.Use();
UnityEditor.Tools.current = UnityEditor.Tool.None; //make sure needed?
//}
}
else if(painting == true)
{
if(paintable)
{
Paint(mouseRayHit);
Event.current.Use();
UnityEditor.Tools.current = UnityEditor.Tool.None; //make sure needed?
}
}
}
}
HandleUtility.Repaint();
break;
case EventType.mouseMove:
HandleUtility.Repaint();
break;
}
}
CalculateCursor(mouseRayHit);
//This repaint is important to make lines and indicators not hang around for more frames
sceneView.Repaint();
}
示例7: OnSceneGUI
//.........这里部分代码省略.........
{
brushDirection = !brushDirection;
}
if(altDown == false)
{
switch(Event.current.type)
{
case EventType.mouseUp:
if(Event.current.button == 0)
{
if(brushMode == BrushMode.On)
{
if(painting == true)
{
EndStroke();
}
if(placing == true)
{
EndPlaceStroke();
}
}
}
break;
case EventType.mouseDown:
if(Event.current.button == 0)
{
if(brushMode == BrushMode.On)
{
if(!shiftDown)
{
BeginStroke();
if(paintable)
{
Paint(mouseRayHit);
Event.current.Use();
}
Tools.current = Tool.None;
}
else //shiftDown
{
if(paintable)
{
BeginPlaceStroke();
Event.current.Use();
}
Tools.current = Tool.None;
}
}
}
break;
case EventType.mouseDrag:
if(Event.current.button == 0)
{
if(brushMode == BrushMode.On)
{
if(placing == true)
{
//if(paintable)
//{
UpdatePlace(sceneView);
Event.current.Use();
Tools.current = Tool.None; //make sure needed?
//}
}
else if(painting == true)
{
if(paintable)
{
Paint(mouseRayHit);
Event.current.Use();
Tools.current = Tool.None; //make sure needed?
}
}
}
}
HandleUtility.Repaint();
break;
case EventType.mouseMove:
HandleUtility.Repaint();
break;
}
}
CalculateCursor(mouseRayHit);
//This repaint is important to make lines and indicators not hang around for more frames
sceneView.Repaint();
}
示例8: OnScene
private static void OnScene(SceneView sceneview)
{
if (!isEnabled) return;
UnityEditor.SceneView sceneView;
Vector3 eulerAngles;
Event current;
Quaternion rotHelper;
current = Event.current;
sceneView = SceneView.lastActiveSceneView;
eulerAngles = sceneView.camera.transform.rotation.eulerAngles;
rotHelper = sceneView.camera.transform.rotation;
if (autoRotate)
{
sceneView.LookAtDirect(SceneView.lastActiveSceneView.pivot, Quaternion.Euler(new Vector3(eulerAngles.x, eulerAngles.y + autoRotateSpeed, eulerAngles.z)));
sceneview.Repaint();
}
if (!current.isKey || current.type != EventType.keyDown)
return;
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;
}
}
示例9: 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);
}
示例10: OnSceneGUI
public void OnSceneGUI(SceneView sceneView) {
#if UNITY_EDITOR
Event e = Event.current;
Ray r = HandleUtility.GUIPointToWorldRay(e.mousePosition);
Vector2 mousePos = r.origin; //- spriteRenderer.transform.position;
if (e.type == EventType.ValidateCommand && e.commandName == "UndoRedoPerformed") {
Mesh mesh = GetMesh();
LoadMesh(mesh);
sceneView.Repaint();
}
if(previewMode) {
if(!hideGizmos && e.type != EventType.MouseMove) PreviewMode();
return;
}
if(e.type == EventType.MouseDown) {
meshDirty = true;
EditorUtility.SetDirty(this);
//sceneView.Repaint();
#region Hole operations
if(e.alt && e.type == EventType.MouseDown) {
Undo.RecordObject(this, "Added or Removed hole");
AddOrRemoveHole(mousePos);
e.Use();
EditorUtility.SetDirty(this);
}
#endregion
#region Vertex operations
else if(e.shift && e.type == EventType.MouseDown) {
Undo.RecordObject(this, "Removed Vertex or Segment");
RemoveVertexOrSegment(mousePos);
e.Use();
EditorUtility.SetDirty(this);
}
#endregion
#region Adding vertices
// Adding a point if control is pressed
else if(e.control && e.type == EventType.MouseDown) {
var newVert = new Vertex(mousePos);
Undo.RecordObject(this, "Added Point");
verts.Add(newVert);
e.Use();
EditorUtility.SetDirty(this);
// Remove old segment and add 2 new segments if new point is added near a segment
Undo.RecordObject(this, "Added Segments");
var seg = GetSegmentNearPosition(mousePos);
if(seg != null) {
segments.RemoveAt(seg.index);
seg.deleted = true;
AddSegment(newVert, seg.first);
AddSegment(newVert, seg.second);
}
EditorUtility.SetDirty(this);
}
#endregion
#region Segment Defining
else if(!segmentDefiningDrag && e.button == 1 && e.type == EventType.MouseDown) {
Undo.RecordObject(this, "Defined Segment");
segmentDefiningDrag = true;
var dragStart = GetVertexNearPosition(mousePos);
dragStartIndex = dragStart == null ? -1 : dragStart.index;
if(dragStartIndex >= 0) e.Use(); // To prevent scene drag with right mouse drag
EditorUtility.SetDirty(this);
}
#endregion
}
else if(e.type == EventType.MouseUp) {
if(segmentDefiningDrag && dragStartIndex >= 0) {
Undo.RecordObject(this, "Added Segment");
var endVert = GetVertexNearPosition(mousePos);
if(endVert != null && endVert != verts[dragStartIndex]) {
AddSegment(endVert, verts[dragStartIndex]);
}
EditorUtility.SetDirty(this);
}
segmentDefiningDrag = false;
}
else if(e.type == EventType.MouseMove || e.type == EventType.MouseDrag) {
sceneView.Repaint();
}
if(!hideGizmos) VisualizePolygon(sceneView);
if (GUI.changed) EditorUtility.SetDirty(this);
#endif
}
示例11: 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);
}
示例12: Orbit
static void Orbit(SceneView sceneView)
{
// If no object is selected don't orbit, fly instead.
if (Selection.gameObjects.Length == 0) {
Fly(sceneView);
return;
}
SyncRigWithScene();
// Apply inversion of axes for orbit mode.
Vector3 translation = Vector3.Scale(SpaceNavigator.Translation, OrbitInvertTranslation);
Vector3 rotation = Vector3.Scale(SpaceNavigator.Rotation.eulerAngles, OrbitInvertRotation);
_camera.Translate(translation, Space.Self);
if (LockHorizon) {
_camera.RotateAround(Tools.handlePosition, Vector3.up, rotation.y);
_camera.RotateAround(Tools.handlePosition, _camera.right, rotation.x);
} else {
_camera.RotateAround(Tools.handlePosition, _camera.up, rotation.y);
_camera.RotateAround(Tools.handlePosition, _camera.right, rotation.x);
_camera.RotateAround(Tools.handlePosition, _camera.forward, rotation.z);
}
// Update sceneview pivot and repaint view.
sceneView.pivot = _pivot.position;
sceneView.rotation = _pivot.rotation;
sceneView.Repaint();
}
示例13: Fly
static void Fly(SceneView sceneView, Vector3 translationInversion, Vector3 rotationInversion)
{
SyncRigWithScene();
// Apply inversion of axes for fly/grabmove mode.
Vector3 translation = Vector3.Scale(SpaceNavigator.Translation, translationInversion);
Vector3 rotation = Vector3.Scale(SpaceNavigator.Rotation.eulerAngles, rotationInversion);
_camera.Translate(translation, Space.Self);
if (sceneView.orthographic)
sceneView.size -= translation.z;
else {
if (LockHorizon) {
// Perform azimuth in world coordinates.
_camera.Rotate(Vector3.up, rotation.y, Space.World);
// Perform pitch in local coordinates.
_camera.Rotate(Vector3.right, rotation.x, Space.Self);
} else {
// Default rotation method, applies the whole quaternion to the camera.
_camera.Rotate(rotation);
}
}
// Update sceneview pivot and repaint view.
sceneView.pivot = _pivot.position;
sceneView.rotation = _pivot.rotation;
sceneView.Repaint();
}
示例14: Orbit
private void Orbit(SceneView sceneView)
{
if (Selection.gameObjects.Length == 0) return;
SyncRigWithScene();
// Apply inversion of axes for orbit mode.
Vector3 translation = Vector3.Scale(SpaceNavigator.Translation, _orbitInvertTranslation);
Vector3 rotation = Vector3.Scale(SpaceNavigator.Rotation.eulerAngles, _orbitInvertRotation);
_camera.Translate(new Vector3(0, 0, translation.z), Space.Self);
if (_lockHorizon) {
_camera.RotateAround(Tools.handlePosition, Vector3.up, rotation.y);
_camera.RotateAround(Tools.handlePosition, _camera.right, rotation.x);
} else {
_camera.RotateAround(Tools.handlePosition, _camera.up, rotation.y);
_camera.RotateAround(Tools.handlePosition, _camera.right, rotation.x);
_camera.RotateAround(Tools.handlePosition, _camera.forward, rotation.z);
}
// Update sceneview pivot and repaint view.
sceneView.pivot = _pivot.position;
sceneView.rotation = _pivot.rotation;
sceneView.Repaint();
}