本文整理汇总了C#中UnityEditor.SceneView.Repaint方法的典型用法代码示例。如果您正苦于以下问题:C# SceneView.Repaint方法的具体用法?C# SceneView.Repaint怎么用?C# SceneView.Repaint使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UnityEditor.SceneView
的用法示例。
在下文中一共展示了SceneView.Repaint方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnSceneGUI
static void OnSceneGUI(SceneView sceneview)
{
Event e = Event.current;
if (isPainting) {
switch(e.type){
case EventType.MouseDown:
window.Paint();
e.Use();
break;
case EventType.MouseDrag:
window.Paint();
HandleUtility.Repaint();
e.Use();
break;
case EventType.MouseUp:
window.CreatePoly();
break;
}
}
HandleUtility.AddDefaultControl(GUIUtility.GetControlID (painterHash, FocusType.Passive));
window.DrawHandles();
HandleUtility.Repaint();
sceneview.Repaint();
}
示例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)
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;
}
}
示例3: OnRaycast
/// <summary>
/// Метод обрабатывающий лучи добра, посланные в окно SceveView
/// </summary>
/// <param name="sceneView"></param>
/// <param name="hitInfo">Объект, до которого дотронулись лучи добра</param>
private void OnRaycast(SceneView sceneView, RaycastHit hitInfo)
{
Vector3 cameraPoint = sceneView.camera.transform.position + sceneView.camera.transform.forward + sceneView.camera.transform.right;
Quaternion startRot = Quaternion.LookRotation(hitInfo.normal);
if (windowGUI.consoleMode) {
Handles.color = textColor;
Handles.Label(hitInfo.collider.transform.position, new GUIContent(Utils.ToString(hitInfo.collider.transform.position)));
Handles.Label(hitInfo.point, new GUIContent("\n"+Utils.ToString(hitInfo.normal)+"\n"+Utils.ToString(hitInfo.barycentricCoordinate)));
Handles.Label(hitInfo.point, Utils.ToString(startRot));
}
switch (currentMode) {
case EEditorMode.ModeDelete:
OnCleanGenerateObjects();
Handles.color = designDeleteColor;
Handles.CircleCap(0, hitInfo.point, startRot, windowGUI.brushSize);
Handles.CircleCap(2, hitInfo.point, startRot, windowGUI.brushSize*0.9f);
Handles.CircleCap(3, hitInfo.point, startRot, windowGUI.brushSize*0.8f);
if (deleteModeOn)
foreach (AutoGen obj in UnityEngine.Object.FindObjectsOfType<AutoGen>())
if (Vector3.Distance(obj.transform.position, hitInfo.point) <= windowGUI.brushSize)
DestroyImmediate(obj.gameObject);
break;
case EEditorMode.ModeAdd:
if (windowGUI.PrefabObject!=null) {
if (tmpData.Count != windowGUI.brushSensitivity) {
OnGenerateObjects(hitInfo.point, startRot);
} else {
foreach (TempObject tmp in tmpData)
OnSetupSettings(tmp, hitInfo.point, startRot, false);
}
if (addingModeOn) {
OnAddObjectToTerrainData();
addingModeOn=false;
}
}
if(Event.current.shift)
Handles.color = designPickColor;
else
Handles.color = designAddColor;
break;
case EEditorMode.ModePick:
Handles.color = designPickColor;
Handles.DotCap(0, hitInfo.collider.bounds.center, startRot, 0.2f); // рисуем центр выбранного объекта
if (selectModeOn) { // если надо захватить объект
selection = hitInfo.collider.gameObject;
doPickUpObject();
this.Repaint();
selectModeOn=false;
}
break;
}
Handles.DrawLine(hitInfo.point, cameraPoint);
// рисуем разметку кисточки
Handles.color = designToolsColor;
Handles.DrawLine(hitInfo.point, hitInfo.point + (startRot * new Vector3(-windowGUI.brushSize, 0, 0)));
Handles.DrawLine(hitInfo.point, hitInfo.point + (startRot * new Vector3(windowGUI.brushSize, 0, 0)));
Handles.DrawLine(hitInfo.point, hitInfo.point + (startRot * new Vector3(0, windowGUI.brushSize, 0)));
Handles.DrawLine(hitInfo.point, hitInfo.point + (startRot * new Vector3(0, -windowGUI.brushSize, 0)));
// направление нормали
Handles.DrawLine(hitInfo.point, hitInfo.point + (startRot * new Vector3(0, 0, windowGUI.brushSize*0.2f)));
sceneView.Repaint();
}
示例4: 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();
}
//.........这里部分代码省略.........
示例5: DoViewTool
public static void DoViewTool(SceneView view)
{
Event current = Event.current;
int viewToolId = SceneViewMotion.s_ViewToolID;
EventType typeForControl = current.GetTypeForControl(viewToolId);
if ((bool) ((Object) view) && Tools.s_LockedViewTool == ViewTool.FPS)
view.FixNegativeSize();
switch (typeForControl)
{
case EventType.MouseDown:
SceneViewMotion.HandleMouseDown(view, viewToolId, current.button);
break;
case EventType.MouseUp:
SceneViewMotion.HandleMouseUp(view, viewToolId, current.button, current.clickCount);
break;
case EventType.MouseDrag:
SceneViewMotion.HandleMouseDrag(view, viewToolId);
break;
case EventType.KeyDown:
SceneViewMotion.HandleKeyDown(view);
break;
case EventType.KeyUp:
SceneViewMotion.HandleKeyUp();
break;
case EventType.ScrollWheel:
SceneViewMotion.HandleScrollWheel(view, !current.alt);
break;
case EventType.Layout:
Vector3 movementDirection = SceneViewMotion.GetMovementDirection();
if (GUIUtility.hotControl != viewToolId || (double) movementDirection.sqrMagnitude == 0.0)
break;
view.pivot = view.pivot + view.rotation * movementDirection;
view.Repaint();
break;
}
}
示例6: OnSceneGUI
private void OnSceneGUI(SceneView sceneView)
{
HandleSnapping();
if (repaintScene)
{
sceneView.Repaint();
repaintScene = false;
}
KeyCheck();
//if (snappingOverride)
// sceneView.Focus();
if (!sceneView.camera.isOrthoGraphic)
return;
Vector3 facingDirection = sceneView.camera.transform.forward;
axis = (Mathf.Approximately(Mathf.Abs(facingDirection.x), 1)) ? Axis.X :
(Mathf.Approximately(Mathf.Abs(facingDirection.y), 1)) ? Axis.Y :
(Mathf.Approximately(Mathf.Abs(facingDirection.z), 1)) ? Axis.Z :
Axis.None;
Color majorColour = (axis == Axis.X) ? settings.xColourMajor : (axis == Axis.Y) ? settings.yColourMajor : (axis == Axis.Z) ? settings.zColourMajor : Color.white;
Color minorColour = (axis == Axis.X) ? settings.xColourMinor : (axis == Axis.Y) ? settings.yColourMinor : (axis == Axis.Z) ? settings.zColourMinor : Color.white;
if (settings.DrawGrid && axis != Axis.None)
{
DrawGrid(sceneView.camera, settings.MinorGridSize, minorColour);
if(settings.IsMajorGridEnabled)
DrawGrid(sceneView.camera, Mul(settings.MajorGridSize, settings.MinorGridSize), majorColour, true);
}
}
示例7: DoViewTool
public static void DoViewTool(SceneView view)
{
Event current = Event.current;
int controlID = s_ViewToolID;
EventType typeForControl = current.GetTypeForControl(controlID);
if ((view != null) && (Tools.s_LockedViewTool == ViewTool.FPS))
{
view.FixNegativeSize();
}
switch (typeForControl)
{
case EventType.MouseDown:
HandleMouseDown(view, controlID, current.button);
break;
case EventType.MouseUp:
HandleMouseUp(view, controlID, current.button, current.clickCount);
break;
case EventType.MouseDrag:
HandleMouseDrag(view, controlID);
break;
case EventType.KeyDown:
HandleKeyDown(view);
break;
case EventType.KeyUp:
HandleKeyUp();
break;
case EventType.ScrollWheel:
HandleScrollWheel(view, !current.alt);
break;
case EventType.Layout:
{
Vector3 movementDirection = GetMovementDirection();
if ((GUIUtility.hotControl == controlID) && (movementDirection.sqrMagnitude != 0f))
{
view.pivot += view.rotation * movementDirection;
view.Repaint();
}
break;
}
}
}
示例8: OnSceneGUI
//.........这里部分代码省略.........
brushSize += Event.current.delta.x * (float)deltaTime * 6.0f;
brushFalloff -= Event.current.delta.y * (float)deltaTime * 48.0f;
}
if (Event.current.rawType == EventType.MouseUp)
{
EndStroke();
}
if (Event.current.type == EventType.MouseMove && Event.current.alt)
{
brushSize += Event.current.delta.y * (float)deltaTime;
}
// set brush color
if (tab == Tab.Custom && customBrush != null)
{
Handles.color = customBrush.GetPreviewColor();
}
else if (brushMode == BrushTarget.Color || brushMode == BrushTarget.UV0_AsColor || brushMode == BrushTarget.UV1_AsColor
|| brushMode == BrushTarget.UV2_AsColor || brushMode == BrushTarget.UV3_AsColor)
{
Handles.color = new Color(brushColor.r, brushColor.g, brushColor.b, 0.4f);
}
else if (brushMode == BrushTarget.ValueR || brushMode == BrushTarget.ValueG ||
brushMode == BrushTarget.ValueB || brushMode == BrushTarget.ValueA)
{
float v = (float)brushValue / 255.0f;
Handles.color = new Color(v, v, v, 0.4f);
}
else
{
float v = (floatBrushValue - uvVisualizationRange.x) / Mathf.Max(0.00001f, uvVisualizationRange.y);
Handles.color = new Color(v, v, v, 0.4f);
}
if (brushVisualization == BrushVisualization.Sphere)
{
Handles.SphereCap(0, point, Quaternion.identity, brushSize * 2);
}
else
{
Handles.color = new Color(0.8f, 0, 0, 1.0f);
float r = Mathf.Pow(0.5f, brushFalloff);
Handles.DrawWireDisc(point, normal, brushSize * r);
Handles.color = new Color(0.9f, 0, 0, 0.8f);
Handles.DrawWireDisc(point, normal, brushSize);
}
// eat current event if mouse event and we're painting
if (Event.current.isMouse && painting)
{
Event.current.Use();
}
if (Event.current.type == EventType.Layout)
{
HandleUtility.AddDefaultControl(GUIUtility.GetControlID(GetHashCode(), FocusType.Passive));
}
// only paint once per frame
if (tab != Tab.Flow && Event.current.type != EventType.Repaint)
{
return;
}
if (jobs.Length > 0 && painting)
{
var lerper = GetLerper();
var value = GetBrushValue();
for (int i = 0; i < jobs.Length; ++i)
{
Bounds b = jobs[i].renderer.bounds;
b.Expand(brushSize*2);
if (!b.IntersectRay(ray))
{
continue;
}
if (jobEdits[i] == false)
{
jobEdits[i] = true;
Undo.RegisterCompleteObjectUndo(jobs[i].stream, "Vertex Painter Stroke");
}
PaintMesh(jobs[i], point, lerper, value);
Undo.RecordObject(jobs[i].stream, "Vertex Painter Stroke");
}
}
if (jobs.Length > 0 && showVertexPoints)
{
for (int i = 0; i < jobs.Length; ++i)
{
DrawVertexPoints(jobs[i], point);
}
}
// update views
sceneView.Repaint();
HandleUtility.Repaint();
}
示例9: OnSceneGUI
//.........这里部分代码省略.........
}
}
}
strokeDir = Vector3.zero;
if (tab == Tab.Flow || vertexMode == VertexMode.Smear)
{
if (Event.current.isMouse)
{
strokeDir = (point - oldMousePosition);
strokeDir.x *= Event.current.delta.magnitude;
strokeDir.y *= Event.current.delta.magnitude;
strokeDir.z *= Event.current.delta.magnitude;
oldMousePosition = point;
}
}
else if (vertexMode == VertexMode.Adjust)
{
strokeDir = -sceneView.camera.transform.forward;
}
if (Event.current.type == EventType.MouseDown && Event.current.button == 0 && Event.current.alt == false)
{
painting = true;
for (int i = 0; i < jobs.Length; ++i)
{
Undo.RegisterCompleteObjectUndo(jobs[i].stream, "Vertex Painter Stroke");
}
}
if (Event.current.rawType == EventType.MouseUp)
{
EndStroke();
}
if (Event.current.type == EventType.MouseMove && Event.current.alt)
{
brushSize += Event.current.delta.y * (float)deltaTime;
}
// set brush color
if (brushMode == BrushTarget.Color)
{
Handles.color = new Color(brushColor.r, brushColor.g, brushColor.b, 0.4f);
}
else if (brushMode == BrushTarget.ValueR || brushMode == BrushTarget.ValueG ||
brushMode == BrushTarget.ValueB || brushMode == BrushTarget.ValueA)
{
float v = (float)brushValue / 255.0f;
Handles.color = new Color(v, v, v, 0.4f);
}
else
{
float v = (floatBrushValue - uvVisualizationRange.x) / Mathf.Max(0.00001f, uvVisualizationRange.y);
Handles.color = new Color(v, v, v, 0.4f);
}
if (tab != Tab.Deform)
{
Handles.SphereCap(0, point, Quaternion.identity, brushSize * 2);
}
else
{
Handles.color = new Color(0.8f, 0, 0, 1.0f);
float r = Mathf.Pow(0.5f, brushFalloff);
Handles.DrawWireDisc(point, normal, brushSize * 2 * r);
Handles.color = new Color(0.9f, 0, 0, 0.8f);
Handles.DrawWireDisc(point, normal, brushSize * 2);
}
// eat current event if mouse event and we're painting
if (Event.current.isMouse && painting)
{
Event.current.Use();
}
if (Event.current.type == EventType.Layout)
{
HandleUtility.AddDefaultControl(GUIUtility.GetControlID(GetHashCode(), FocusType.Passive));
}
// only paint once per frame
if (tab != Tab.Flow && Event.current.type != EventType.Repaint)
{
return;
}
if (jobs.Length > 0 && painting)
{
for (int i = 0; i < jobs.Length; ++i)
{
PaintMesh(jobs[i], point);
Undo.RecordObject(jobs[i].stream, "Vertex Painter Stroke");
}
}
// update views
sceneView.Repaint();
HandleUtility.Repaint();
}
示例10: OnSceneGUI
Event currentEvent;// = (Event)0;
void OnSceneGUI(SceneView scnView)
{
currentEvent = Event.current;
if(editLevel == EditLevel.Geometry && currentEvent.Equals(Event.KeyboardEvent("v")))
{
currentEvent.Use();
snapToVertex = true;
}
/**
* Snap stuff
*/
if(currentEvent.type == EventType.KeyUp)
snapToVertex = false;
if(currentEvent.type == EventType.MouseDown && currentEvent.button == 1)
rightMouseDown = true;
if(currentEvent.type == EventType.MouseUp && currentEvent.button == 1 || currentEvent.type == EventType.Ignore)
rightMouseDown = false;
#if !PROTOTYPE
// e.type == EventType.DragUpdated ||
if(currentEvent.type == EventType.DragPerform)
{
GameObject go = HandleUtility.PickGameObject(currentEvent.mousePosition, false);
if(go != null && System.Array.Exists(DragAndDrop.objectReferences, x => x is Texture2D || x is Material))
{
pb_Object pb = go.GetComponent<pb_Object>();
if( pb )
{
Material mat = null;
foreach(Object t in DragAndDrop.objectReferences)
{
if(t is Material)
{
mat = (Material)t;
break;
}
/* This works, but throws some bullshit errors. Not creating a material leaks, so disable this functionality. */
else
if(t is Texture2D)
{
mat = new Material(Shader.Find("Diffuse"));
mat.mainTexture = (Texture2D)t;
string texPath = AssetDatabase.GetAssetPath(mat.mainTexture);
int lastDot = texPath.LastIndexOf(".");
texPath = texPath.Substring(0, texPath.Length - (texPath.Length-lastDot));
texPath = AssetDatabase.GenerateUniqueAssetPath(texPath + ".mat");
AssetDatabase.CreateAsset(mat, texPath);
AssetDatabase.Refresh();
break;
}
}
if(mat != null)
{
if(editLevel == EditLevel.Geometry)
{
pbUndo.RecordObjects(selection, "Set Face Materials");
foreach(pb_Object pbs in selection)
pbs.SetFaceMaterial(pbs.SelectedFaces.Length < 1 ? pbs.faces : pbs.SelectedFaces, mat);
}
else
{
pbUndo.RecordObject(pb, "Set Object Material");
pb.SetFaceMaterial(pb.faces, mat);
}
pb.ToMesh();
pb.Refresh();
pb.Optimize();
currentEvent.Use();
}
}
}
}
#endif
DrawHandleGUI(scnView);
if(editLevelToolbarRect.Contains(currentEvent.mousePosition))
scnView.Repaint();
if(!rightMouseDown && getKeyUp != KeyCode.None)
{
if(ShortcutCheck(currentEvent))
{
currentEvent.Use();
//.........这里部分代码省略.........
示例11: DoViewTool
public static void DoViewTool(Transform cameraTransform, SceneView view)
{
Event current = Event.current;
int num = SceneViewMotion.s_ViewToolID;
EventType typeForControl = current.GetTypeForControl(num);
float d = 0f;
if (view && Tools.s_LockedViewTool == ViewTool.FPS)
{
view.FixNegativeSize();
d = (view.pivot - cameraTransform.position).magnitude;
}
switch (typeForControl)
{
case EventType.MouseDown:
SceneViewMotion.HandleMouseDown(view, num, current.button);
break;
case EventType.MouseUp:
SceneViewMotion.HandleMouseUp(view, num, current.button, current.clickCount);
break;
case EventType.MouseDrag:
SceneViewMotion.HandleMouseDrag(cameraTransform, view, num);
break;
case EventType.KeyDown:
SceneViewMotion.HandleKeyDown(view);
break;
case EventType.KeyUp:
SceneViewMotion.HandleKeyUp();
break;
case EventType.ScrollWheel:
SceneViewMotion.HandleScrollWheel(view, !current.alt);
break;
case EventType.Layout:
{
Vector3 movementDirection = SceneViewMotion.GetMovementDirection();
if (GUIUtility.hotControl == num && movementDirection.sqrMagnitude != 0f)
{
cameraTransform.position += cameraTransform.rotation * movementDirection;
}
break;
}
}
if (view && Tools.s_LockedViewTool == ViewTool.FPS)
{
if (!view.orthographic)
{
view.rotation = cameraTransform.rotation;
}
view.pivot = cameraTransform.position + cameraTransform.forward * d;
view.Repaint();
}
}
示例12: OnSceneGUI
void OnSceneGUI(SceneView sceneView)
{
stroke.Clear();
deltaTime = EditorApplication.timeSinceStartup - lastTime;
lastTime = EditorApplication.timeSinceStartup;
if (jobs.Length == 0 && Selection.activeGameObject != null)
{
InitMeshes();
}
if (!enabled || jobs.Length == 0 || Selection.activeGameObject == null)
return;
RaycastHit hit;
float distance = float.MaxValue;
Vector3 mousePosition = Event.current.mousePosition;
mousePosition.y = sceneView.camera.pixelHeight - mousePosition.y;
Vector3 fakeMP = mousePosition;
fakeMP.z = 20;
Vector3 point = sceneView.camera.ScreenToWorldPoint(fakeMP);
Ray ray = sceneView.camera.ScreenPointToRay(mousePosition);
for (int i = 0; i < jobs.Length; ++i)
{
if (RXLookingGlass.IntersectRayMesh(ray, jobs[i].meshFilter, out hit))
{
stroke.Add(jobs[i]);
if (hit.distance < distance)
{
distance = hit.distance;
point = hit.point;
}
}
}
if (Event.current.type == EventType.MouseDown && Event.current.button == 0 && Event.current.alt == false)
{
painting = true;
}
if (Event.current.type == EventType.MouseUp)
{
Undo.CollapseUndoOperations(Undo.GetCurrentGroup());
painting = false;
}
if (Event.current.type == EventType.MouseMove && Event.current.alt)
{
brushSize += Event.current.delta.y * (float)deltaTime;
}
if (stroke.Count > 0 && painting)
{
for (int i = 0; i < stroke.Count; ++i)
{
Undo.RecordObject(stroke[i].stream, "Vertex Painter Stroke");
PaintMesh(stroke[i], point);
}
}
Handles.color = new Color(0, 0, 1, 0.5f);
Handles.SphereCap(0, point, Quaternion.identity, brushSize*2);
if (Event.current.isMouse && painting)
Event.current.Use ();
if (Event.current.type == EventType.layout)
HandleUtility.AddDefaultControl(GUIUtility.GetControlID(GetHashCode(), FocusType.Passive));
HandleUtility.Repaint();
sceneView.Repaint();
}