private void OnDrawGizmos() { if (_sight != null) { Gizmos.color = Color.red; Matrix4x4 temp = Gizmos.matrix; Gizmos.matrix = Matrix4x4.TRS( _sight.transform.position, _sight.transform.rotation, Vector3.one ); Gizmos.DrawFrustum( _sight.transform.position, _sight.fieldOfView, _sight.farClipPlane, _sight.nearClipPlane, _sight.aspect ); Gizmos.matrix = temp; } }
internal static void DrawCameraFrustumGizmo( CinemachineBrain brain, LensSettings lens, Matrix4x4 transform, Color color) { float aspect = 1; bool ortho = false; if (brain != null) { aspect = brain.OutputCamera.aspect; ortho = brain.OutputCamera.orthographic; } Matrix4x4 originalMatrix = Gizmos.matrix; Color originalGizmoColour = Gizmos.color; Gizmos.color = color; Gizmos.matrix = transform; if (ortho) { Vector3 size = new Vector3( aspect * lens.OrthographicSize * 2, lens.OrthographicSize * 2, lens.NearClipPlane + lens.FarClipPlane); Gizmos.DrawWireCube( new Vector3(0, 0, (size.z / 2) + lens.NearClipPlane), size); } else { Gizmos.DrawFrustum( Vector3.zero, lens.FieldOfView, lens.FarClipPlane, lens.NearClipPlane, aspect); } Gizmos.matrix = originalMatrix; Gizmos.color = originalGizmoColour; }
private void OnDrawGizmos() { Gizmos.DrawFrustum(transform.position, fov, range.x, range.y, aspectRatio); }
private void OnDrawGizmosSelected() { Gizmos.set_matrix(((Component)this).get_transform().get_localToWorldMatrix()); Gizmos.set_color(Color.get_yellow()); Gizmos.DrawFrustum(Vector3.get_zero(), this.withinDegrees, 1f, 0.0f, 1f); }
/// <summary> Draw a camera frustum using the currently set Gizmos.matrix for it's location and rotation. </summary> public static Gizmo DrawFrustum(Vector3 position, float fieldOfView, float nearClipPlane, float farClipPlane, float aspect) => Draw(new Gizmo(() => Gizmos.DrawFrustum(position, fieldOfView, farClipPlane, nearClipPlane, aspect)));
public static void DrawFrustum(Vector3 center, float fov, float maxRange, float minRange, float aspect, Color c) { using (block.Begin(c)) Gizmos.DrawFrustum(center, fov, maxRange, minRange, aspect); }
public static Drawing DrawFrustum(Vector3 center, float fov, float maxRange, float minRange, float aspect) { return(Draw(new Drawing(() => Gizmos.DrawFrustum(center, fov, maxRange, minRange, aspect)))); }
/// <summary> /// Draw a gizmo with the specified settings. /// </summary> public static void Draw(Transform parent, Color color, Types type, float size, bool useWorldScale = true, //line Vector3 lineStart = new Vector3(), Vector3 lineEnd = new Vector3(), //frustum float frustumFOV = 60f, float frustumMaxRange = 1f, float frustumMinRange = .1f, float frustumAspect = 1f, //icon string iconFilename = "", bool iconAllowScaling = true, //texture Rect textureRect = new Rect(), Texture texture = null, Material textureMaterial = null, int textureLeftBorder = 0, int textureRightBorder = 0, int textureTopBorder = 0, int textureBottomBorder = 0, //mesh Mesh mesh = null, Vector3 meshPosition = new Vector3(), Vector3 meshRotation = new Vector3(), Vector3 meshScale = new Vector3()) { Gizmos.matrix = parent.localToWorldMatrix; Gizmos.color = color; float v_size_x = useWorldScale ? (size / parent.lossyScale.x) : size; float v_size_y = useWorldScale ? (size / parent.lossyScale.y) : size; float v_size_z = useWorldScale ? (size / parent.lossyScale.z) : size; float f_size = Mathf.Min(v_size_x, v_size_y, v_size_z); Vector3 v_size = new Vector3(v_size_x, v_size_y, v_size_z); switch (type) { case Types.Sphere: Gizmos.DrawSphere(Vector3.zero, f_size); break; case Types.WireSphere: Gizmos.DrawWireSphere(Vector3.zero, f_size); break; case Types.Cube: Gizmos.DrawCube(Vector3.zero, v_size); break; case Types.WireCube: Gizmos.DrawWireCube(Vector3.zero, v_size); break; case Types.Ray: Gizmos.DrawRay(Vector3.zero, Vector3.forward * f_size); break; case Types.Line: Gizmos.DrawLine(lineStart, lineEnd); break; case Types.Frustum: Gizmos.DrawFrustum(Vector3.zero, frustumFOV, frustumMaxRange, frustumMinRange, frustumAspect); break; case Types.Icon: if (!string.IsNullOrEmpty(iconFilename)) { Gizmos.DrawIcon(Vector3.zero, iconFilename, iconAllowScaling); } break; case Types.Texture: if (texture != null && textureMaterial != null) { Gizmos.DrawGUITexture(textureRect, texture, textureLeftBorder, textureRightBorder, textureTopBorder, textureBottomBorder, textureMaterial); } break; case Types.Mesh: if (mesh != null) { Gizmos.DrawMesh(mesh, meshPosition, Quaternion.Euler(meshRotation), meshScale); } break; case Types.WireMesh: if (mesh != null) { Gizmos.DrawWireMesh(mesh, meshPosition, Quaternion.Euler(meshRotation), meshScale); } break; default: break; } }
public static void DrawFrustum(Vector3 center, float fov, float maxRange, float minRange, float aspect, Color c) { ColorBlock(c, () => Gizmos.DrawFrustum(center, fov, maxRange, minRange, aspect)); }
public void OnDrawGizmos(bool isChallengeSelected) { if (frustumHeightByMonsterId == null) { frustumHeightByMonsterId = new Dictionary <string, float>(); frustumHeightByMonsterId["1100"] = 3; frustumHeightByMonsterId["4003"] = 3; frustumHeightByMonsterId["4004"] = 2; frustumHeightByMonsterId["4005"] = 2; frustumHeightByMonsterId["4006"] = 2; frustumHeightByMonsterId["4007"] = 1; frustumHeightByMonsterId["40010"] = 4; } if (textureByMonsterId == null) { textureByMonsterId = new Dictionary <string, Texture>(); } CharacterId characterId; try { characterId = new CharacterId(monsterId); } catch (Exception e) { DLog.LogError(e); characterId = new CharacterId(1, 1); } Texture icon; bool found = textureByMonsterId.TryGetValue(characterId.ToString(), out icon); if (!found) { string pathToIcon = string.Format(Config.characterIconPathFormat, characterId.GroupId, characterId.SubId); icon = EditorGUIUtility.Load(pathToIcon) as Texture; textureByMonsterId[characterId.StringValue] = icon; } // Gizmos.DrawIcon((Vector3) ShowWorldPosition() + Vector3.up * 3.25f, pathToIcon, true); if (icon) { Gizmos.DrawGUITexture( new Rect(ShowWorldPosition() + new Vector3(-3.25f, 6), new Vector2(6, -6)), icon ); } float height = 4; float newHeight = height; if (frustumHeightByMonsterId.TryGetValue(characterId.GroupId.ToString(), out newHeight)) { height = newHeight; } Gizmos.color = Color.red; Matrix4x4 originalMatrix = Gizmos.matrix; Matrix4x4 rotationMatrix = Matrix4x4.Rotate(Quaternion.LookRotation(Vector3.up, Vector3.up)); Matrix4x4 translationMatrix = Matrix4x4.Translate(ShowWorldPosition() + Vector3.up * height); Gizmos.matrix = Matrix4x4.identity * translationMatrix * rotationMatrix; Gizmos.DrawFrustum(Vector3.zero, 45, 1, 0, 1); Gizmos.matrix = originalMatrix; if (!isChallengeSelected) { return; } Gizmos.color = Color.green; Vector2 rectDimension = new Vector2(xAxisAmplitude, .5f); RectPivotPosition rpp = new RectPivotPosition(RectPivotPosition.PivotType.Center, Vector2.zero, rectDimension); Vector2 offset = rpp.RelativePositionOfPivotAt(RectPivotPosition.PivotType.BottomLeft); Gizmos.DrawCube( ShowWorldPosition() + new Vector3(offset.x * -1, offset.y), rectDimension ); }
private void DrawGizmos() { GizmoSettings.Validate(); float aspect = ( float )Width / Height; if (GizmoSettings.DrawFrustum) { Matrix4x4 originalMatrix = Gizmos.matrix; Gizmos.matrix = Matrix4x4.TRS(transform.position, transform.rotation, transform.localScale); Gizmos.color = Color.gray; if (Camera.orthographic) { float orthoSize = Camera.orthographicSize * 2; Vector3 cubeSize = new Vector3( orthoSize * aspect, orthoSize, Camera.farClipPlane - Camera.nearClipPlane ); Vector3 cubePos = new Vector3( 0, 0, cubeSize.z * 0.5f + Camera.nearClipPlane ); Gizmos.DrawWireCube(cubePos, cubeSize); } else { Gizmos.DrawFrustum(Vector3.zero, Camera.fieldOfView, Camera.farClipPlane, Camera.nearClipPlane, aspect); } Gizmos.matrix = originalMatrix; } if (GizmoSettings.DrawTracePaths) { Camera.aspect = aspect; Awake(); Start(); float halfPixelWidth = 1.0f / GizmoSettings.NumPathsX / 2; float halfPixelHeight = 1.0f / GizmoSettings.NumPathsY / 2; var counters = new RaytraceCounters(); for (int y = 0; y < GizmoSettings.NumPathsY; y++) { for (int x = 0; x < GizmoSettings.NumPathsX; x++) { counters.InitialRays++; Ray ray = Camera.ViewportPointToRay( new Vector3( ( float )x / GizmoSettings.NumPathsX + halfPixelWidth, ( float )y / GizmoSettings.NumPathsY + halfPixelHeight, 0 ) ); TraceData traceData = new TraceData(Camera.backgroundColor, counters, recordHistory: true); raytracer.Trace(ray, traceData); var flatBranches = traceData.FlattenBranches().ToArray(); const float NoHitSegmentLength = 10; // TODO: move it to argument of function that draws segments and/or make it come from setting. #if PERIODIC_UPDATE const float SpiderSpawnRate = 0.5f; // Number of spiders spawning per second. const float SpiderVelocity = 1; // Units per second. const float SpiderLength = 0.1f; float spiderSpawnInterval = 1 / SpiderSpawnRate; #endif foreach (var td in flatBranches) { float segStartDistance = td.StartDistance; foreach (var item in td.History) { Ray itemRay = item.Ray; Color rayColor = GizmoSettings.UseCustomColorForPaths ? GizmoSettings.PathsColor : item.Color; Gizmos.color = rayColor; float segEndDistance; if (item.Hit.HasValue) { RaycastHit hit = item.Hit.Value; Gizmos.DrawLine(itemRay.origin, hit.point); segEndDistance = segStartDistance + hit.distance; } else { Gizmos.DrawLine(itemRay.origin, itemRay.GetPoint(NoHitSegmentLength)); segEndDistance = segStartDistance + NoHitSegmentLength; } #if PERIODIC_UPDATE /* Draw marching ants crawling along the rays */ /* TODO: I couldn't figure out how to make SceneView update periodically * rather than in response to events. I don't know where from I can call * SceneView.RepaintAll () in order to force scene to update itself as well. */ float timeToReachStart = segStartDistance / SpiderVelocity; float timeToReachEnd = segEndDistance / SpiderVelocity; float segTravelTime = timeToReachEnd - timeToReachStart; float t = (( float )EditorApplication.timeSinceStartup + timeToReachStart) % spiderSpawnInterval; for ( ; t < segTravelTime; t += spiderSpawnInterval) { Gizmos.color = new Color(1 - rayColor.r, 1 - rayColor.g, 1 - rayColor.b, 1); Vector3 spiderPos = itemRay.GetPoint(t * SpiderVelocity); Gizmos.DrawLine(spiderPos, spiderPos + itemRay.direction * SpiderLength); } #endif segStartDistance = segEndDistance; } } } } Camera.ResetAspect(); } }
private void OnDrawGizmos() { Gizmos.color = isCurrentlyAlarmed ? Color.red : Color.green; Gizmos.matrix = transform.localToWorldMatrix; Gizmos.DrawFrustum(Vector3.zero, fieldOfView, maxViewDistance, 1, 1); }
private void OnDrawGizmosSelected() { Gizmos.matrix = base.transform.localToWorldMatrix; Gizmos.color = Color.yellow; Gizmos.DrawFrustum(Vector3.zero, this.withinDegrees, 1f, 0f, 1f); }
void OnDrawGizmosSelected() { Gizmos.color = Color.yellow; Gizmos.DrawFrustum(transform.position + eyeLevel, fieldOfView, maxSeeDistance, 0f, 1f); }
[DrawGizmo(GizmoType.NotInSelectionHierarchy)]// | GizmoType.Active)] static void DrawGizmoForMyScript(Camera cam, GizmoType gizmoType) { Gizmos.color = Color.red; Gizmos.DrawFrustum(cam.transform.position, cam.fieldOfView, cam.farClipPlane, cam.nearClipPlane, cam.aspect); }
public static void DrawFrustum(Vector3 center, float fov, float maxRange = 100, float minRange = 0.1f, float aspect = 16 / 9, Color?color = null) { SwapColor(color); Gizmos.DrawFrustum(center, fov, maxRange, minRange, aspect); RestoreColor(); }
// public static void DrawVisor(Vector3 pos, float fov, float maxRnage, float minRange, float spect) { Gizmos.DrawFrustum(pos, fov, maxRnage, minRange, spect); }
/// <summary> /// Draws the gun view cone area /// </summary> private void OnDrawGizmos() { Gizmos.matrix = Matrix4x4.TRS(_rotatingGun.position, _rotatingGun.rotation, Vector3.one); Gizmos.DrawFrustum(Vector3.zero, _gunFieldOfView, 0.1f, _gunFarPlane, 1); }
// Token: 0x060013DD RID: 5085 RVA: 0x00061644 File Offset: 0x0005F844 private void OnDrawGizmos() { Gizmos.color = Color.yellow; Gizmos.matrix = Matrix4x4.TRS(base.transform.position, base.transform.rotation, Vector3.one); Gizmos.DrawFrustum(Vector3.zero, this.placementSpreadMax * 0.5f, this.placementMaxDistance, 0f, 1f); }
private void OnDrawGizmos() { Gizmos.matrix = Matrix4x4.TRS(transform.position, transform.rotation, transform.lossyScale); Gizmos.DrawFrustum(Vector3.zero, 84.1f, 6, .5f, 1.563f); }
void OnDrawGizmos() { if (!active) { return; } Gizmos.color = color; switch (type) { case "Cube": if (!positionIsCenterCube) { Gizmos.DrawCube(cubeCenter, cubeSize); } else { Gizmos.DrawCube(this.transform.position, cubeSize); } break; case "Frustum": if (!positionIsCenterFrustum) { Gizmos.DrawFrustum(frustumCenter, fov, maxRange, minRange, aspect); } else { Gizmos.DrawFrustum(this.transform.position, fov, maxRange, minRange, aspect); } break; case "GUITexture": if (texture != null) { Gizmos.DrawGUITexture(screenRect, texture, mat); } break; case "Icon": if (!positionIsCenterIcon) { Gizmos.DrawIcon(iconCenter, iconName); } else { Gizmos.DrawIcon(this.transform.position, iconName); } break; case "Line": if (!useTwoTransforms) { Gizmos.DrawLine(fromV, toV); } else if (fromTr != null && toTr != null) { Gizmos.DrawLine(fromTr.position, toTr.position); } break; case "Mesh": if (!transformIsMeshTransform) { Gizmos.DrawMesh(mesh, subMeshIndex, meshPosition, Quaternion.Euler(meshRotation), meshScale); } else { Gizmos.DrawMesh(mesh, subMeshIndex, this.transform.position, this.transform.rotation, this.transform.localScale); } break; case "Ray": Gizmos.DrawRay(fromR, directionR); break; case "Sphere": if (positionIsCenterSphere) { Gizmos.DrawSphere(this.transform.position, radiusS); } else { Gizmos.DrawSphere(sphereCenter, radiusS); } break; case "WireCube": if (!positionIsCenterWireCube) { Gizmos.DrawWireCube(wireCubeCenter, wireCubeSize); } else { Gizmos.DrawWireCube(this.transform.position, wireCubeSize); } break; case "WireMesh": if (!transformIsWireMeshTransform) { Gizmos.DrawWireMesh(wireMesh, subWireMeshIndex, wireMeshPosition, Quaternion.Euler(wireMeshRotation), wireMeshScale); } else { Gizmos.DrawWireMesh(wireMesh, subWireMeshIndex, this.transform.position, this.transform.rotation, this.transform.localScale); } break; case "WireSphere": if (positionIsCenterWireSphere) { Gizmos.DrawWireSphere(this.transform.position, radiusWS); } else { Gizmos.DrawWireSphere(wireSphereCenter, radiusWS); } break; case "CameraOrthographic": FastGizmosExtra.DrawCameraOrthographic(cam, color, drawVertex); break; case "LineExtended": if (!useTwoTransformsLE) { FastGizmosExtra.DrawLineExtended(startPointLE, endPointLE, thickness); } else if (fromTrLE != null && toTrLE != null) { FastGizmosExtra.DrawLineExtended(fromTrLE.position, toTrLE.position, thickness); } break; case "CubeExtended": FastGizmosExtra.DrawCubeExtended(positionCE, Quaternion.Euler(rotationCE.x, rotationCE.y, rotationCE.z), scaleCE); break; case "WireCubeExtended": FastGizmosExtra.DrawWireCubeExtended(positionWCE, Quaternion.Euler(rotationWCE.x, rotationWCE.y, rotationWCE.z), scaleWCE); break; } Gizmos.color = Color.white; }
private void OnDrawGizmosSelected() { Gizmos.matrix = ReferencePoint.localToWorldMatrix; Gizmos.DrawFrustum(Vector3.zero, InteractionAngle, 0.1f, 2.0f, 1.0f); }
private void OnDrawGizmosSelected() { Gizmos.color = Color.gray; Gizmos.matrix = transform.localToWorldMatrix; Gizmos.DrawFrustum(transform.position, transform.parent.GetComponent <Camera>().fieldOfView, transform.parent.GetComponent <Camera>().nearClipPlane, transform.parent.GetComponent <Camera>().farClipPlane, transform.parent.GetComponent <Camera>().aspect); }
private void OnDrawGizmos() { Gizmos.color = Color; Gizmos.matrix = transform.localToWorldMatrix; Gizmos.DrawFrustum(Vector3.zero, 30, 1, 0.1f, 1); }
void OnDrawGizmosSelected() { Gizmos.color = Color.yellow; Gizmos.matrix = transform.localToWorldMatrix; Gizmos.DrawFrustum(Vector3.zero, cam.fieldOfView, farClip, nearClip, cam.aspect); }
//Handles drawing gizmos/path/etc in the editor void OnDrawGizmos() { SetCameraPointReferences(); //Only draw gizmos if we want to if (showPathType == PathType.PathOnly || showPathType == PathType.PathAndFrustum) { Gizmos.color = Color.green; //Draw for each mid point, and draw a path for (int i = 0; i < cutsceneCameraPoints.Length - 2; i++) { Gizmos.color = Color.yellow; if (curveChoice[i] == true) { if (curveChoice[i] == true && cutsceneCameraSpeedOptions[i] == CameraSpeedOptions.MobileCurve)//Only draw this if it is a bezier curve point { SetPathFromIndex(true, i); Vector3 lastVec = cutsceneCameraPoints[i + 1].position; foreach (Vector3 nextVec in currentDebugnodes) { Gizmos.DrawLine(lastVec, nextVec); lastVec = nextVec; } } } } //And draw for each cubic mid point, and a path for (int i = 0; i < cutsceneCameraPoints.Length - 2; i++) { Gizmos.color = Color.magenta; if (curveChoice[i] == true && cutsceneCameraSpeedOptions[i] == CameraSpeedOptions.Curve)//Only draw this midpoint if it is a cubic curve { SetPathFromIndex(false, i); Vector3 lastVec = cutsceneCameraPoints[i + 1].position; foreach (Vector3 nextVec in currentDebugnodes) { Gizmos.DrawLine(lastVec, nextVec); lastVec = nextVec; } } Gizmos.color = Color.green; if (curveChoice[i] == false) { Gizmos.DrawLine(cutsceneCameraPoints[i + 1].position, cutsceneCameraPoints[i + 2].position); } } //Draw frustrums for (int i = 0; i < cutsceneCameraPoints.Length - 1; i++) { //Set fov if it is custom float fov = initialZoom; if (i > 0 && i < cutsceneEventZoom.Length) { if (cutsceneEventZoom[i - 1]) { fov = cutsceneEventZoomAmount[i - 1]; } } if (showPathType == PathType.PathAndFrustum) { float max = 3f; float min = 0.1f; Matrix4x4 temp = Gizmos.matrix; Gizmos.matrix = Matrix4x4.TRS(cutsceneCameraPoints[i + 1].position, cutsceneCameraPoints[i + 1].rotation, Vector3.one); Gizmos.DrawFrustum(Vector3.zero, fov, max, min, 1); Gizmos.matrix = temp; } } } }
public static void DrawFrustum(Vector3 center, float fov, float maxRange, float minRange, float aspect) { Gizmos.DrawFrustum(center, fov, maxRange, minRange, aspect); }
// private void RotationUpdate() // { // transform.rotation = Quaternion.identity; // transform.Rotate(transform.up,horizontal,Space.World); // transform.Rotate(transform.right,vertical,Space.World); // } private void OnDrawGizmos() { Gizmos.matrix = transform.localToWorldMatrix; Gizmos.DrawFrustum(transform.position, 60, 100, 0, 2f); }
public void DrawFrustrum(Matrix4x4 gizmoMatrix) { //Gizmos.matrix = gizmoMatrix; Gizmos.DrawFrustum(Vector3.zero, fieldOfView, farPlane, nearPlane, 1); }
protected void OnDrawGizmos() { Gizmos.matrix = transform.localToWorldMatrix; Gizmos.DrawFrustum(Vector3.zero, fieldOfView, far, near, aspect); }