Bosses for help!
Don't know why you in when the part will be redraw the Preview screen keep out but have no effect about model is code below
The class PreviewEditor: Editor
{
Private PreviewRenderUtility m_PreviewUtility;
Private GameObject m_PreviewInstance;
//preview object bounding box
Private Bounds m_PreviewBounds;
//the preview in the direction of the
Private Vector2 m_PreviewDir=new Vector2 (120 f, 20 f);
Private Vector3 m_ScrollZoom=Vector3. Zero;
Public override bool HasPreviewGUI ()
{
return true;
}
Private void AddSingleGO GameObject (go)
{
# if UNITY_2017_1_OR_NEWER
M_PreviewUtility. AddSingleGO (go);
# endif
}
Camera Camera;
Public override void OnPreviewGUI (the Rect r, GUIStyle background)
{
The Debug Log (r);
//truly idth=1500;
InitPreview ();
//the up and down or so the rotation of the
Vector3 zoom;
M_PreviewDir=Drag2D (m_PreviewDir, r, out zoom);
M_ScrollZoom +=zoom;
M_ScrollZoom. Y=Mathf. Max (- 33 f Mathf. Min (m_ScrollZoom. J y, 44));
If (Event. The current type!=EventType. Repaint)
{
return;
}
M_PreviewUtility. BeginPreview (r, background);
Camera=m_PreviewUtility. Camera;
M_PreviewBounds. Size=new Vector3 (1, 1, 1);
Float num=Mathf. Max (m_PreviewBounds. Extents. Magnitude, 0.0001 f);
Float num2=num * 3.8 f;
Quaternion Quaternion=Quaternion. Euler (- m_PreviewDir. Y, - m_PreviewDir. X, 0 f);
Vector3 position=m_PreviewBounds. Center - quaternion * (Vector3. Forward * num2) * (1 + m_ScrollZoom. Y * 0.02 f);
//Vector3 position=new Vector3 (0.0 f, 0, 0.0 f);
//m_PreviewUtility. CameraFieldOfView=30;
Camera. The transform. The position=position;
Camera. The transform. Rotation=quaternion;
Camera. NearClipPlane=0.1 f;
Camera. FarClipPlane=1000.0 f;
Camera. FieldOfView=80;
Camera. AllowHDR=false;
Camera. AllowMSAA=false;
Camera. ClearFlags=CameraClearFlags. The Depth;
//camera. The rect=new the rect (0, 0, 2, 2);
For (int I=0; I & lt; M_PreviewUtility. Towns. Length; I + +)
{
M_PreviewUtility. Towns [I]=new Light ();
M_PreviewUtility. Towns [I]. Transform. Rotation=quaternion;
}
SetEnabledRecursive (m_PreviewInstance, true);
//Draw the Line
ShowLayerGrid m_PreviewInstance. Transform. (position);
Camera. The Render ();
SetEnabledRecursive (m_PreviewInstance, false);
Var texture=m_PreviewUtility. EndPreview ();
The Debug Log (r);
GUI. DrawTexture (r, texture, ScaleMode ScaleToFit, false);
//GUI. The Box (r, texture);
//m_PreviewUtility. EndAndDrawPreview (r);
}
Public override void DrawPreview (the Rect previewArea)
{
Base. DrawPreview (previewArea);
GUILayout. BeginHorizontal ();
If (GUILayout. Button (" before "))
{
M_PreviewDir=new Vector2 (0, 0);
//the Debug Log (m_PreviewDir + "before");
}
If (GUILayout. Button (" after "))
{
M_PreviewDir=new Vector2 (180, 0).
//the Debug Log (m_PreviewDir + "after");
}
If (GUILayout. Button (" left "))
{
M_PreviewDir=new Vector2 (90, 0).
//the Debug Log (m_PreviewDir + "left");
}
If (GUILayout. Button (" right "))
{
M_PreviewDir=new Vector2 (90, 0);
//the Debug Log (m_PreviewDir + "right");
}
If (GUILayout. Button (" VAT "))
{
M_PreviewDir=new Vector2 (120 f, 20 f);
M_ScrollZoom=Vector3. Zero;
}
GUILayout. EndHorizontal ();
}
Private void InitPreview ()
{
If (m_PreviewUtility==null)
{
//parameter true representative drawing game objects within the scene
M_PreviewUtility=new PreviewRenderUtility (true);
//set some parameters of the camera
M_PreviewUtility. CameraFieldOfView=30;//0.7 f;
//create a preview of the game object
CreatePreviewInstances ();
//SceneView. OnSceneGUIDelegate +=OnSceneGUI;
}
M_PreviewUtility. Camera. CullingMask=1 & lt;
Private void DestroyPreview ()
{
If (m_PreviewUtility!=null)
{
//must be cleaned up, will not remain object generated by the camera, etc.
M_PreviewUtility. The Cleanup ();
M_PreviewUtility=null;
}
}
Private int offsetz;
Private void ShowLayerGrid (Vector3 origin)
{
Vector3 start=Vector3. Zero;
Vector3 end=Vector3. Zero;
int num=10;
Float step=1.0 f;
Float linelength num=step *;
Float sb_x=- num/2.0 f * step;
Float sb_z=- num/2.0 f * step;
For (float x=0; X & lt; Num + 1; X + +)
{
Start. The Set (sb_x + x * step, 0, sb_z);
//start. Set (512, 128, 0).
////the Debug Log (start);
End. Set (start. X, 0, start. Z + linelength);
Var b=camera. WorldToScreenPoint (start);
If (b.z & lt; 0)
continue;
B.z=1.0 f;
Var e=camera. WorldToScreenPoint (end);
If (e.z & lt; 0)
continue;
E.z=1.0 f;
Handles. DrawLine (b, e);
//the Debug Log (camera. WorldToScreenPoint (origin) + "" + camera. WorldToScreenPoint (end));
}
For (float z=0; Z & lt; Num + 1; Z++)
{
nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull