Exemplo n.º 1
0
        DrawGridParameters PrepareGridRenderOrthogonalMode(Camera camera, Vector3 pivot, Quaternion rotation,
                                                           float size)
        {
            Vector3 direction = camera.transform.TransformDirection(new Vector3(0, 0, 1));

            DrawGridParameters parameters = default(DrawGridParameters);

            // Don't show orthographic grid at very shallow angles because it looks bad.
            // It's normally already faded out by the managed animated fading values at this angle,
            // but if it's orbited rapidly, it can end up at this angle faster than the fading has kicked in.
            // For these cases hiding it abruptly looks better.
            // The popping isn't noticable because the user is orbiting rapidly to begin with.
            if (xGrid.fade.target && Mathf.Abs(direction.x) >= k_AngleThresholdForOrthographicGrid)
            {
                parameters = xGrid.PrepareGridRender(0, gridOpacity);
            }
            else if (yGrid.fade.target && Mathf.Abs(direction.y) >= k_AngleThresholdForOrthographicGrid)
            {
                parameters = yGrid.PrepareGridRender(1, gridOpacity);
            }
            else if (zGrid.fade.target && Mathf.Abs(direction.z) >= k_AngleThresholdForOrthographicGrid)
            {
                parameters = zGrid.PrepareGridRender(2, gridOpacity);
            }

            return(parameters);
        }
Exemplo n.º 2
0
            internal DrawGridParameters PrepareGridRender(int gridID, float opacity)
            {
                DrawGridParameters parameters = default(DrawGridParameters);

                parameters.gridID  = gridID;
                parameters.pivot   = pivot;
                parameters.color   = color;
                parameters.color.a = fade.faded * opacity;
                parameters.size    = size;

                return(parameters);
            }
Exemplo n.º 3
0
        DrawGridParameters PrepareGridRenderPerspectiveMode(Camera camera, Vector3 pivot, Quaternion rotation,
                                                            float size)
        {
            DrawGridParameters parameters = default(DrawGridParameters);

            switch (gridAxis)
            {
            case GridRenderAxis.X:
                parameters = xGrid.PrepareGridRender(0, gridOpacity);
                break;

            case GridRenderAxis.Y:
                parameters = yGrid.PrepareGridRender(1, gridOpacity);
                break;

            case GridRenderAxis.Z:
                parameters = zGrid.PrepareGridRender(2, gridOpacity);
                break;
            }

            return(parameters);
        }
Exemplo n.º 4
0
		internal static void DrawCameraStep1(Rect position, Camera camera, DrawCameraMode drawMode, DrawGridParameters gridParam)
		{
			Handles.DrawCameraImpl(position, camera, drawMode, true, gridParam, false);
		}
Exemplo n.º 5
0
		internal static void DrawCameraImpl(Rect position, Camera camera, DrawCameraMode drawMode, bool drawGrid, DrawGridParameters gridParam, bool finish)
		{
			Event current = Event.current;
			if (current.type == EventType.Repaint)
			{
				if (camera.targetTexture == null)
				{
					Rect rect = GUIClip.Unclip(position);
					camera.pixelRect = new Rect(rect.xMin, (float)Screen.height - rect.yMax, rect.width, rect.height);
				}
				else
				{
					camera.rect = new Rect(0f, 0f, 1f, 1f);
				}
				if (drawMode == DrawCameraMode.Normal)
				{
					RenderTexture targetTexture = camera.targetTexture;
					camera.targetTexture = RenderTexture.active;
					camera.Render();
					camera.targetTexture = targetTexture;
				}
				else
				{
					if (drawGrid)
					{
						Handles.Internal_DrawCameraWithGrid(camera, (int)drawMode, ref gridParam);
					}
					else
					{
						Handles.Internal_DrawCamera(camera, (int)drawMode);
					}
					if (finish)
					{
						Handles.Internal_FinishDrawingCamera(camera);
					}
				}
			}
			else
			{
				Handles.Internal_SetCurrentCamera(camera);
			}
		}
Exemplo n.º 6
0
		private static extern void Internal_DrawCameraWithGrid(Camera cam, int renderMode, ref DrawGridParameters gridParam);
Exemplo n.º 7
0
 static extern void Internal_DrawCameraWithGrid(Camera cam, DrawCameraMode renderMode, ref DrawGridParameters gridParam);
Exemplo n.º 8
0
 static extern void Internal_DrawCameraWithGrid([NotNull("NullExceptionObject")] Camera cam, DrawCameraMode renderMode, ref DrawGridParameters gridParam, bool drawGizmos, bool drawSelection);
Exemplo n.º 9
0
 internal static void DrawCamera(Rect position, Camera camera, DrawCameraMode drawMode, DrawGridParameters gridParam)
 {
     DrawCameraImpl(position, camera, drawMode, true, gridParam, true);
 }
Exemplo n.º 10
0
 public static void DrawCamera(Rect position, Camera camera, [DefaultValue("DrawCameraMode.Normal")] DrawCameraMode drawMode)
 {
     DrawGridParameters gridParam = new DrawGridParameters();
     DrawCameraImpl(position, camera, drawMode, false, gridParam, true);
 }
Exemplo n.º 11
0
 internal static void DrawCameraImpl(Rect position, Camera camera, DrawCameraMode drawMode, bool drawGrid, DrawGridParameters gridParam, bool finish)
 {
   if (Event.current.type == EventType.Repaint)
   {
     if ((UnityEngine.Object) camera.targetTexture == (UnityEngine.Object) null)
     {
       Rect pixels = EditorGUIUtility.PointsToPixels(GUIClip.Unclip(position));
       camera.pixelRect = new Rect(pixels.xMin, (float) Screen.height - pixels.yMax, pixels.width, pixels.height);
     }
     else
       camera.rect = new Rect(0.0f, 0.0f, 1f, 1f);
     if (drawMode == DrawCameraMode.Normal)
     {
       RenderTexture targetTexture = camera.targetTexture;
       camera.targetTexture = RenderTexture.active;
       camera.Render();
       camera.targetTexture = targetTexture;
     }
     else
     {
       if (drawGrid)
         Handles.Internal_DrawCameraWithGrid(camera, (int) drawMode, ref gridParam);
       else
         Handles.Internal_DrawCamera(camera, (int) drawMode);
       if (!finish)
         return;
       Handles.Internal_FinishDrawingCamera(camera);
     }
   }
   else
     Handles.Internal_SetCurrentCamera(camera);
 }